gfs2: Minor gfs2_write_jdata_batch PAGE_SIZE cleanup
authorAndreas Gruenbacher <agruenba@redhat.com>
Tue, 18 Jul 2023 13:49:08 +0000 (15:49 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Mon, 6 Nov 2023 00:51:25 +0000 (01:51 +0100)
In gfs2_write_jdata_batch(), to compute the number of blocks, compute
the total size of the folio batch instead of the number of pages it
contains.  Not a functional change.

Note that we don't currently allow mounting filesystems with a block
size bigger than the page size.  We could change that after converting
the page cache to folios.  The page cache would then only contain
block-size or bigger folios, so rounding wouldn't become an issue here.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/aops.c

index 52fad5bcb0472e5a92e9c69993981c9097427f81..494484427ee303ec94737770f16d01c532d3d295 100644 (file)
@@ -214,12 +214,12 @@ static int gfs2_write_jdata_batch(struct address_space *mapping,
        unsigned nrblocks;
        int i;
        int ret;
-       int nr_pages = 0;
+       size_t size = 0;
        int nr_folios = folio_batch_count(fbatch);
 
        for (i = 0; i < nr_folios; i++)
-               nr_pages += folio_nr_pages(fbatch->folios[i]);
-       nrblocks = nr_pages * (PAGE_SIZE >> inode->i_blkbits);
+               size += folio_size(fbatch->folios[i]);
+       nrblocks = size >> inode->i_blkbits;
 
        ret = gfs2_trans_begin(sdp, nrblocks, nrblocks);
        if (ret < 0)