]> git.baikalelectronics.ru Git - kernel.git/commit
netfs: fix test for whether we can skip read when writing beyond EOF
authorJeff Layton <jlayton@kernel.org>
Sun, 13 Jun 2021 23:33:45 +0000 (19:33 -0400)
committerDavid Howells <dhowells@redhat.com>
Mon, 21 Jun 2021 20:24:07 +0000 (21:24 +0100)
commitcdb75dac820e39e3366da91555fef78ccfda4fea
tree020798c6aa0d9eee41ce18b91e8f2b4f93ae0c7f
parentf90e6b440e4c19c27abc9a006d0565a2dec5ff7a
netfs: fix test for whether we can skip read when writing beyond EOF

It's not sufficient to skip reading when the pos is beyond the EOF.
There may be data at the head of the page that we need to fill in
before the write.

Add a new helper function that corrects and clarifies the logic of
when we can skip reads, and have it only zero out the part of the page
that won't have data copied in for the write.

Finally, don't set the page Uptodate after zeroing. It's not up to date
since the write data won't have been copied in yet.

[DH made the following changes:

 - Prefixed the new function with "netfs_".

 - Don't call zero_user_segments() for a full-page write.

 - Altered the beyond-last-page check to avoid a DIV instruction and got
   rid of then-redundant zero-length file check.
]

Fixes: b771fce8d94d2 ("netfs: Add write_begin helper")
Reported-by: Andrew W Elble <aweits@rit.edu>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
cc: ceph-devel@vger.kernel.org
Link: https://lore.kernel.org/r/20210613233345.113565-1-jlayton@kernel.org/
Link: https://lore.kernel.org/r/162367683365.460125.4467036947364047314.stgit@warthog.procyon.org.uk/
Link: https://lore.kernel.org/r/162391826758.1173366.11794946719301590013.stgit@warthog.procyon.org.uk/
fs/netfs/read_helper.c