Skip to content

Commit 3ad216e

Browse files
dhowellstorvalds
authored andcommitted
afs: Fix afs_write_end() when called with copied == 0 [ver GalliumOS#3]
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 <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent f01c30d commit 3ad216e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/afs/write.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,14 @@ int afs_write_end(struct file *file, struct address_space *mapping,
169169
unsigned int f, from = pos & (PAGE_SIZE - 1);
170170
unsigned int t, to = from + copied;
171171
loff_t i_size, maybe_i_size;
172-
int ret;
172+
int ret = 0;
173173

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

177+
if (copied == 0)
178+
goto out;
179+
177180
maybe_i_size = pos + copied;
178181

179182
i_size = i_size_read(&vnode->vfs_inode);

0 commit comments

Comments
 (0)