kernel_optimize_test/fs/ceph
Jeff Layton 0463b49e02 netfs: fix test for whether we can skip read when writing beyond EOF
commit 827a746f405d25f79560c7868474aec5aee174e1 upstream.

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.
]

[ Note: this fix is commit 827a746f405d in mainline kernels. The
	original bug was in ceph, but got lifted into the fs/netfs
	library for v5.13. This backport should apply to stable
	kernels v5.10 though v5.12. ]

Fixes: e1b1240c1ff5f ("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/ # v1
Link: https://lore.kernel.org/r/162391826758.1173366.11794946719301590013.stgit@warthog.procyon.org.uk/ # v2
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-06-30 08:47:29 -04:00
..
acl.c ceph: add caps perf metric for each superblock 2020-06-01 13:22:51 +02:00
addr.c netfs: fix test for whether we can skip read when writing beyond EOF 2021-06-30 08:47:29 -04:00
cache.c
cache.h
caps.c ceph: fix fscache invalidation 2021-05-22 11:40:53 +02:00
ceph_frag.c
debugfs.c ceph: metrics for opened files, pinned caps and opened inodes 2020-10-12 15:29:26 +02:00
dir.c ceph: add ceph_sb_to_mdsc helper support to parse the mdsc 2020-10-12 15:29:26 +02:00
export.c ceph: don't allow access to MDS-private inodes 2021-05-22 11:40:54 +02:00
file.c ceph: must hold snap_rwsem when filling inode for async create 2021-06-30 08:47:25 -04:00
inode.c ceph: must hold snap_rwsem when filling inode for async create 2021-06-30 08:47:25 -04:00
io.c
io.h
ioctl.c ceph: consider inode's last read/write when calculating wanted caps 2020-03-30 12:42:42 +02:00
ioctl.h
Kconfig libceph: replace HTTP links with HTTPS ones 2020-08-03 11:05:26 +02:00
locks.c ceph: add ceph_sb_to_mdsc helper support to parse the mdsc 2020-10-12 15:29:26 +02:00
Makefile ceph: add dentry lease metric support 2020-06-01 13:22:51 +02:00
mds_client.c ceph: don't allow access to MDS-private inodes 2021-05-22 11:40:54 +02:00
mds_client.h ceph: check session state after bumping session->s_seq 2020-11-04 20:55:49 +01:00
mdsmap.c ceph: downgrade warning from mdsmap decode to debug 2021-02-26 10:13:00 +01:00
metric.c ceph: metrics for opened files, pinned caps and opened inodes 2020-10-12 15:29:26 +02:00
metric.h ceph: metrics for opened files, pinned caps and opened inodes 2020-10-12 15:29:26 +02:00
quota.c ceph: check session state after bumping session->s_seq 2020-11-04 20:55:49 +01:00
snap.c ceph: check session state after bumping session->s_seq 2020-11-04 20:55:49 +01:00
strings.c
super.c Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-10-24 12:26:05 -07:00
super.h ceph: don't allow access to MDS-private inodes 2021-05-22 11:40:54 +02:00
util.c
xattr.c ceph: mark ceph_fmt_xattr() as printf-like for better type checking 2020-10-12 15:29:27 +02:00