diff options
author | Christoph Hellwig <hch@lst.de> | 2024-07-05 07:42:51 +0200 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2024-07-12 11:36:08 -0400 |
commit | 39c910a430370fd25d5b5e4b2f4b24581a705499 (patch) | |
tree | b2c7a09c25c02d7c4e6796daed57b719051afbf0 | |
parent | 3921ae0850a31f06791e3c5d8f628864b5ae088a (diff) |
nfs: do not extend writes to the entire folio
nfs_update_folio has code to extend a write to the entire page under
certain conditions. With the support for large folios this now
suddenly extents to the variable sized and potentially much larger folio.
Add code to limit the extension to the page boundaries of the start and
end of the write, which matches the historic expecation and the code
comments.
Fixes: b73fe2dd6cd5 ("nfs: add support for large folios")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r-- | fs/nfs/write.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index f0a124b45291..acf2d942d78f 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1351,8 +1351,12 @@ int nfs_update_folio(struct file *file, struct folio *folio, goto out; if (nfs_can_extend_write(file, folio, pagelen)) { - count = max(count + offset, pagelen); - offset = 0; + unsigned int end = count + offset; + + offset = round_down(offset, PAGE_SIZE); + if (end < pagelen) + end = min(round_up(end, PAGE_SIZE), pagelen); + count = end - offset; } status = nfs_writepage_setup(ctx, folio, offset, count); |