All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ceph: no need to wait for transition RDCACHE|RD -> RD
@ 2022-08-11  9:12 xiubli
  0 siblings, 0 replies; only message in thread
From: xiubli @ 2022-08-11  9:12 UTC (permalink / raw
  To: ceph-devel; +Cc: Xiubo Li

From: Xiubo Li <xiubli@redhat.com>

For write when trying to get the Fwb caps we need to keep waiting
on transition from WRBUFFER|WR -> WR to avoid a new WR sync write
from going before a prior buffered writeback happens.

Whild for read there is not need to wait on transition from
RDCACHE|RD -> RD, and we can just exclude the revoking caps and
force to sync read.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/caps.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 139d21b8fb49..d5fc9b1be7c3 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2811,13 +2811,17 @@ static int try_get_cap_refs(struct inode *inode, int need, int want,
 		 * on transition from wanted -> needed caps.  This is needed
 		 * for WRBUFFER|WR -> WR to avoid a new WR sync write from
 		 * going before a prior buffered writeback happens.
+		 *
+		 * For RDCACHE|RD -> RD, there is not need to wait and we can
+		 * just exclude the revoking caps and force to sync read.
 		 */
 		int not = want & ~(have & need);
 		int revoking = implemented & ~have;
+		int exclude = revoking & not;
 		dout("get_cap_refs %p have %s but not %s (revoking %s)\n",
 		     inode, ceph_cap_string(have), ceph_cap_string(not),
 		     ceph_cap_string(revoking));
-		if ((revoking & not) == 0) {
+		if (!exclude || !(exclude & CEPH_CAP_FILE_BUFFER)) {
 			if (!snap_rwsem_locked &&
 			    !ci->i_head_snapc &&
 			    (need & CEPH_CAP_FILE_WR)) {
@@ -2839,7 +2843,7 @@ static int try_get_cap_refs(struct inode *inode, int need, int want,
 				snap_rwsem_locked = true;
 			}
 			if ((have & want) == want)
-				*got = need | want;
+				*got = need | (want & ~exclude);
 			else
 				*got = need;
 			ceph_take_cap_refs(ci, *got, true);
-- 
2.36.0.rc1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-11  9:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-11  9:12 [PATCH] ceph: no need to wait for transition RDCACHE|RD -> RD xiubli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.