Skip to content

Commit

Permalink
afs: Fix partial writeback of large files on fsync and close
Browse files Browse the repository at this point in the history
In commit e87b03f ("afs: Prepare for use of THPs"), the return
value for afs_write_back_from_locked_page was changed from a number
of pages to a length in bytes.  The loop in afs_writepages_region uses
the return value to compute the index that will be used to find dirty
pages in the next iteration, but treats it as a number of pages and
wrongly multiplies it by PAGE_SIZE.  This gives a very large index value,
potentially skipping any dirty data that was not covered in the first
pass, which is limited to 256M.

This causes fsync(), and indirectly close(), to only do a partial
writeback of a large file's dirty data.  The rest is eventually written
back by background threads after dirty_expire_centisecs.

Fixes: e87b03f ("afs: Prepare for use of THPs")
Signed-off-by: Marc Dionne <[email protected]>
Signed-off-by: David Howells <[email protected]>
Reviewed-by: Jeffrey Altman <[email protected]>
cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]/
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Marc Dionne authored and torvalds committed Jun 7, 2021
1 parent 614124b commit dc25573
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/afs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ static int afs_writepages_region(struct address_space *mapping,
return ret;
}

start += ret * PAGE_SIZE;
start += ret;

cond_resched();
} while (wbc->nr_to_write > 0);
Expand Down

0 comments on commit dc25573

Please sign in to comment.