On Thu, Dec 16, 2021 at 11:36:14AM -0800, Darrick J. Wong wrote: > > > > + /* gfs2 does not support large folios yet */ > > + if (len > PAGE_SIZE) > > + len = PAGE_SIZE; > > This is awkward -- gfs2 doesn't set the mapping flag to indicate that it > supports large folios, so it should never be asked to deal with more > than a page at a time. Shouldn't iomap_write_begin clamp its len > argument to PAGE_SIZE at the start if the mapping doesn't have the large > folios flag set? You're right, this is awkward. And it's a bit of a beartrap for another filesystem that wants to implement ->prepare_page in the future. diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 9270db17c435..d67108489148 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -968,9 +968,6 @@ static int gfs2_iomap_page_prepare(struct inode *inode, loff_t pos, struct gfs2_sbd *sdp = GFS2_SB(inode); unsigned int blocks; - /* gfs2 does not support large folios yet */ - if (len > PAGE_SIZE) - len = PAGE_SIZE; blocks = ((pos & blockmask) + len + blockmask) >> inode->i_blkbits; return gfs2_trans_begin(sdp, RES_DINODE + blocks, 0); } diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 1a9e897ee25a..b1ded5204d1c 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -619,6 +619,9 @@ static int iomap_write_begin(const struct iomap_iter *iter, loff_t pos, if (fatal_signal_pending(current)) return -EINTR; + if (!mapping_large_folio_support(iter->inode->i_mapping)) + len = min_t(size_t, len, PAGE_SIZE - offset_in_page(pos)); + if (page_ops && page_ops->page_prepare) { status = page_ops->page_prepare(iter->inode, pos, len); if (status)