Skip to content

Commit

Permalink
netfs: Allocate multipage folios in the writepath
Browse files Browse the repository at this point in the history
Allocate a multipage folio when copying data into the pagecache if possible
if there's sufficient data to warrant it.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
  • Loading branch information
David Howells committed Dec 28, 2023
1 parent 7f84a7b commit e2e2e83
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fs/netfs/buffered_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,19 @@ static enum netfs_how_to_modify netfs_how_to_modify(struct netfs_inode *ctx,
}

/*
* Grab a folio for writing and lock it.
* Grab a folio for writing and lock it. Attempt to allocate as large a folio
* as possible to hold as much of the remaining length as possible in one go.
*/
static struct folio *netfs_grab_folio_for_write(struct address_space *mapping,
loff_t pos, size_t part)
{
pgoff_t index = pos / PAGE_SIZE;
fgf_t fgp_flags = FGP_WRITEBEGIN;

return __filemap_get_folio(mapping, index, FGP_WRITEBEGIN,
if (mapping_large_folio_support(mapping))
fgp_flags |= fgf_set_order(pos % PAGE_SIZE + part);

return __filemap_get_folio(mapping, index, fgp_flags,
mapping_gfp_mask(mapping));
}

Expand Down

0 comments on commit e2e2e83

Please sign in to comment.