iomap: Use kzalloc to allocate iomap_page
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 21 Sep 2020 15:58:39 +0000 (08:58 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Mon, 21 Sep 2020 15:59:26 +0000 (08:59 -0700)
We can skip most of the initialisation, although spinlocks still
need explicit initialisation as architectures may use a non-zero
value to indicate unlocked.  The comment is no longer useful as
attach_page_private() handles the refcount now.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/iomap/buffered-io.c

index dd0739606dced72390ee99da36d8d6560a685018..d1caea4c5fba53ec1fc3b26c88d02485760980a5 100644 (file)
@@ -49,16 +49,8 @@ iomap_page_create(struct inode *inode, struct page *page)
        if (iop || i_blocks_per_page(inode, page) <= 1)
                return iop;
 
-       iop = kmalloc(sizeof(*iop), GFP_NOFS | __GFP_NOFAIL);
-       atomic_set(&iop->read_count, 0);
-       atomic_set(&iop->write_count, 0);
+       iop = kzalloc(sizeof(*iop), GFP_NOFS | __GFP_NOFAIL);
        spin_lock_init(&iop->uptodate_lock);
-       bitmap_zero(iop->uptodate, PAGE_SIZE / SECTOR_SIZE);
-
-       /*
-        * migrate_page_move_mapping() assumes that pages with private data have
-        * their count elevated by 1.
-        */
        attach_page_private(page, iop);
        return iop;
 }