Skip to content

Commit 39c910a

Browse files
Christoph Hellwigamschuma-ntap
authored andcommitted
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: b73fe2d ("nfs: add support for large folios") Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Benjamin Coddington <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 3921ae0 commit 39c910a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/nfs/write.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,8 +1351,12 @@ int nfs_update_folio(struct file *file, struct folio *folio,
13511351
goto out;
13521352

13531353
if (nfs_can_extend_write(file, folio, pagelen)) {
1354-
count = max(count + offset, pagelen);
1355-
offset = 0;
1354+
unsigned int end = count + offset;
1355+
1356+
offset = round_down(offset, PAGE_SIZE);
1357+
if (end < pagelen)
1358+
end = min(round_up(end, PAGE_SIZE), pagelen);
1359+
count = end - offset;
13561360
}
13571361

13581362
status = nfs_writepage_setup(ctx, folio, offset, count);

0 commit comments

Comments
 (0)