Skip to content

Commit

Permalink
afs: Fix afs_write_end() when called with copied == 0 [ver #3]
Browse files Browse the repository at this point in the history
[ Upstream commit 3ad216e ]

When afs_write_end() is called with copied == 0, it tries to set the
dirty region, but there's no way to actually encode a 0-length region in
the encoding in page->private.

"0,0", for example, indicates a 1-byte region at offset 0.  The maths
miscalculates this and sets it incorrectly.

Fix it to just do nothing but unlock and put the page in this case.  We
don't actually need to mark the page dirty as nothing presumably
changed.

Fixes: 65dd2d6 ("afs: Alter dirty range encoding in page->private")
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
dhowells authored and gregkh committed Nov 18, 2020
1 parent 9e22b87 commit 2ee7230
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/afs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,14 @@ int afs_write_end(struct file *file, struct address_space *mapping,
unsigned int f, from = pos & (PAGE_SIZE - 1);
unsigned int t, to = from + copied;
loff_t i_size, maybe_i_size;
int ret;
int ret = 0;

_enter("{%llx:%llu},{%lx}",
vnode->fid.vid, vnode->fid.vnode, page->index);

if (copied == 0)
goto out;

maybe_i_size = pos + copied;

i_size = i_size_read(&vnode->vfs_inode);
Expand Down

0 comments on commit 2ee7230

Please sign in to comment.