linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] afs: Fix afs_write_end() when called with copied == 0
@ 2020-11-14 17:15 David Howells
  2020-11-14 17:26 ` David Howells
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2020-11-14 17:15 UTC (permalink / raw)
  To: torvalds; +Cc: dhowells, linux-afs, linux-fsdevel, linux-kernel

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: 65dd2d6072d3 ("afs: Alter dirty range encoding in page->private")
Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/afs/write.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/afs/write.c b/fs/afs/write.c
index 50371207f327..f34d13d294fa 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -174,6 +174,9 @@ int afs_write_end(struct file *file, struct address_space *mapping,
 	_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);



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] afs: Fix afs_write_end() when called with copied == 0
  2020-11-14 17:15 [PATCH] afs: Fix afs_write_end() when called with copied == 0 David Howells
@ 2020-11-14 17:26 ` David Howells
  0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2020-11-14 17:26 UTC (permalink / raw)
  To: torvalds; +Cc: dhowells, linux-afs, linux-fsdevel, linux-kernel

Oops.  I forgot to compile it after picking it from a patch series.  There's
an uninitialised warning in it.

David


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-14 17:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-14 17:15 [PATCH] afs: Fix afs_write_end() when called with copied == 0 David Howells
2020-11-14 17:26 ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).