Skip to contentSkip to conversation

ceph: don't retain the caps if they're being revoked and not used

PATCH Superseded Xiubo Li 3 participants 10 messages Apr 28, 2022 – May 5, 2022 Ceph client

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Xiubo Li

author
#0 lore raw

PATCH 1/1 ceph: don't retain the caps if they're being revoked and not used

For example if the Frwcb caps are being revoked, but only the Fr caps is still being used then the kclient will skip releasing them all. But in next turn if the Fr caps is ready to be released the Fw caps maybe just being used again. So in corner case, such as heavy load IOs, the revocation maybe stuck for a long time.

---
 fs/ceph/caps.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ceph/caps.c +7 -0
index 0c0c8f5ae3b3..7eb5238941fc 100644
@@ -1947,6 +1947,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
 
 	/* The ones we currently want to retain (may be adjusted below) */
 	retain = file_wanted | used | CEPH_CAP_PIN;
+
+	/*
+	 * Do not retain the capabilities if they are under revoking
+	 * but not used, this could help speed up the revoking.
+	 */
+	retain &= ~((revoking & retain) & ~used);
+
 	if (!mdsc->stopping && inode->i_nlink > 0) {
 		if (file_wanted) {
 			retain |= CEPH_CAP_ANY;       /* be greedy */
Signature · 1 line
2.36.0.rc1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Xiubo Li

For example if the Frwcb caps are being revoked, but only the Fr caps is still being used then the kclient will skip releasing them all. But in next turn if the Fr caps is ready to be released the Fw caps maybe just being used again. So in corner case, such as heavy load IOs, the revocation maybe stuck for a long time.

---
 fs/ceph/caps.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ceph/caps.c +0 -0
index 0c0c8f5ae3b3..7eb5238941fc 100644
@@ -1947,6 +1947,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
 
 	/* The ones we currently want to retain (may be adjusted below) */
 	retain = file_wanted | used | CEPH_CAP_PIN;

fs/ceph/caps.c void ceph_check_caps(struct ceph_inode_info *ci, int flags, · line 1959

Quoted 10 lines
fs/ceph/caps.c +7 -0
+
+	/*
+	 * Do not retain the capabilities if they are under revoking
+	 * but not used, this could help speed up the revoking.
+	 */
+	retain &= ~((revoking & retain) & ~used);
+
 	if (!mdsc->stopping && inode->i_nlink > 0) {
 		if (file_wanted) {
 			retain |= CEPH_CAP_ANY;       /* be greedy */

Oh wow, I thought this was being done already! Curse the complex logic in this function.

#2 lore raw
In reply to Xiubo Li
Quoted 19 lines · Xiubo Li

For example if the Frwcb caps are being revoked, but only the Fr caps is still being used then the kclient will skip releasing them all. But in next turn if the Fr caps is ready to be released the Fw caps maybe just being used again. So in corner case, such as heavy load IOs, the revocation maybe stuck for a long time.

---
 fs/ceph/caps.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ceph/caps.c +0 -0
index 0c0c8f5ae3b3..7eb5238941fc 100644
@@ -1947,6 +1947,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
 
 	/* The ones we currently want to retain (may be adjusted below) */
 	retain = file_wanted | used | CEPH_CAP_PIN;

fs/ceph/caps.c void ceph_check_caps(struct ceph_inode_info *ci, int flags, · line 1959

Quoted 10 lines
fs/ceph/caps.c +7 -0
+
+	/*
+	 * Do not retain the capabilities if they are under revoking
+	 * but not used, this could help speed up the revoking.
+	 */
+	retain &= ~((revoking & retain) & ~used);
+
 	if (!mdsc->stopping && inode->i_nlink > 0) {
 		if (file_wanted) {
 			retain |= CEPH_CAP_ANY;       /* be greedy */

Actually maybe something like this would be simpler to understand?

/* Retain any caps that are actively in use */
retain = used | CEPH_CAP_PIN;

/* Also retain caps wanted by open files, if they aren't being revoked */ retain |= (file_wanted & ~revoking);

Signature · 1 line
Jeff Layton <[email protected]>
author
#3 lore raw
Quoted 32 lines · Jeff Layton
Quoted 19 lines · Xiubo Li

For example if the Frwcb caps are being revoked, but only the Fr caps is still being used then the kclient will skip releasing them all. But in next turn if the Fr caps is ready to be released the Fw caps maybe just being used again. So in corner case, such as heavy load IOs, the revocation maybe stuck for a long time.

---
  fs/ceph/caps.c | 7 +++++++
  1 file changed, 7 insertions(+)
fs/ceph/caps.c +0 -0
index 0c0c8f5ae3b3..7eb5238941fc 100644
@@ -1947,6 +1947,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
 
  	/* The ones we currently want to retain (may be adjusted below) */
  	retain = file_wanted | used | CEPH_CAP_PIN;

fs/ceph/caps.c void ceph_check_caps(struct ceph_inode_info *ci, int flags, · line 1959

Quoted 10 lines
fs/ceph/caps.c +7 -0
+
+	/*
+	 * Do not retain the capabilities if they are under revoking
+	 * but not used, this could help speed up the revoking.
+	 */
+	retain &= ~((revoking & retain) & ~used);
+
  	if (!mdsc->stopping && inode->i_nlink > 0) {
  		if (file_wanted) {
  			retain |= CEPH_CAP_ANY;       /* be greedy */

Actually maybe something like this would be simpler to understand?

Quoted 5 lines

/* Retain any caps that are actively in use */
retain = used | CEPH_CAP_PIN;

/* Also retain caps wanted by open files, if they aren't being revoked */ retain |= (file_wanted & ~revoking);

Yeah, sounds good, let me try to simplify it to make it more readable.

THanks.

author
#4 lore raw
In reply to Jeff Layton
Quoted 32 lines · Jeff Layton
Quoted 19 lines · Xiubo Li

For example if the Frwcb caps are being revoked, but only the Fr caps is still being used then the kclient will skip releasing them all. But in next turn if the Fr caps is ready to be released the Fw caps maybe just being used again. So in corner case, such as heavy load IOs, the revocation maybe stuck for a long time.

---
  fs/ceph/caps.c | 7 +++++++
  1 file changed, 7 insertions(+)
fs/ceph/caps.c +0 -0
index 0c0c8f5ae3b3..7eb5238941fc 100644
@@ -1947,6 +1947,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
 
  	/* The ones we currently want to retain (may be adjusted below) */
  	retain = file_wanted | used | CEPH_CAP_PIN;

fs/ceph/caps.c void ceph_check_caps(struct ceph_inode_info *ci, int flags, · line 1959

Quoted 10 lines
fs/ceph/caps.c +7 -0
+
+	/*
+	 * Do not retain the capabilities if they are under revoking
+	 * but not used, this could help speed up the revoking.
+	 */
+	retain &= ~((revoking & retain) & ~used);
+
  	if (!mdsc->stopping && inode->i_nlink > 0) {
  		if (file_wanted) {
  			retain |= CEPH_CAP_ANY;       /* be greedy */

Actually maybe something like this would be simpler to understand?

Quoted 5 lines

/* Retain any caps that are actively in use */
retain = used | CEPH_CAP_PIN;

/* Also retain caps wanted by open files, if they aren't being revoked */ retain |= (file_wanted & ~revoking);

This won't work, because the caps maybe '|' back again in the following code:

1950         if (!mdsc->stopping && inode->i_nlink > 0) {
1951                 if (file_wanted) {
1952                         retain |= CEPH_CAP_ANY;       /* be greedy */
                 ...

1979        }

I have adjust the code and simplified it in V2.

-- Xiubo

Quoted 1 line
#5 lore raw
In reply to Xiubo Li
Quoted 7 lines · Xiubo Li

For example if the Frwcb caps are being revoked, but only the Fr caps is still being used then the kclient will skip releasing them all. But in next turn if the Fr caps is ready to be released the Fw caps maybe just being used again. So in corner case, such as heavy load IOs, the revocation maybe stuck for a long time.

This does not make sense. If Frwcb are being revoked, writer can't get Fw again. Second, Frwcb are managed by single lock at mds side. Partial releasing caps does make lock state transition possible.

Quoted 26 lines
---
 fs/ceph/caps.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ceph/caps.c +7 -1
index 0c0c8f5ae3b3..7eb5238941fc 100644
@@ -1947,6 +1947,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
 
        /* The ones we currently want to retain (may be adjusted below) */
        retain = file_wanted | used | CEPH_CAP_PIN;
+
+       /*
+        * Do not retain the capabilities if they are under revoking
+        * but not used, this could help speed up the revoking.
+        */
+       retain &= ~((revoking & retain) & ~used);
+
        if (!mdsc->stopping && inode->i_nlink > 0) {
                if (file_wanted) {
                        retain |= CEPH_CAP_ANY;       /* be greedy */
--

2.36.0.rc1

#6 lore raw
Quoted 9 lines · Zheng
Quoted 7 lines · Xiubo Li

For example if the Frwcb caps are being revoked, but only the Fr caps is still being used then the kclient will skip releasing them all. But in next turn if the Fr caps is ready to be released the Fw caps maybe just being used again. So in corner case, such as heavy load IOs, the revocation maybe stuck for a long time.

Quoted 4 lines

This does not make sense. If Frwcb are being revoked, writer can't get Fw again. Second, Frwcb are managed by single lock at mds side. Partial releasing caps does make lock state transition possible.

I mean, does not make lock state transition possible.

Quoted 27 lines
Quoted 27 lines
---
 fs/ceph/caps.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ceph/caps.c +7 -1
index 0c0c8f5ae3b3..7eb5238941fc 100644
@@ -1947,6 +1947,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
 
        /* The ones we currently want to retain (may be adjusted below) */
        retain = file_wanted | used | CEPH_CAP_PIN;
+
+       /*
+        * Do not retain the capabilities if they are under revoking
+        * but not used, this could help speed up the revoking.
+        */
+       retain &= ~((revoking & retain) & ~used);
+
        if (!mdsc->stopping && inode->i_nlink > 0) {
                if (file_wanted) {
                        retain |= CEPH_CAP_ANY;       /* be greedy */
--

2.36.0.rc1

author
#7 lore raw
In reply to Yan, Zheng
Quoted 11 lines · Zheng
Quoted 6 lines · Xiubo Li

For example if the Frwcb caps are being revoked, but only the Fr caps is still being used then the kclient will skip releasing them all. But in next turn if the Fr caps is ready to be released the Fw caps maybe just being used again. So in corner case, such as heavy load IOs, the revocation maybe stuck for a long time.

This does not make sense. If Frwcb are being revoked, writer can't get Fw again. Second, Frwcb are managed by single lock at mds side. Partial releasing caps does make lock state transition possible.

Yeah, you are right. Checked the __ceph_caps_issued() it really has removed the caps being revoked already.

Thanks Zheng.

Quoted 26 lines
Quoted 26 lines
---
  fs/ceph/caps.c | 7 +++++++
  1 file changed, 7 insertions(+)
fs/ceph/caps.c +7 -1
index 0c0c8f5ae3b3..7eb5238941fc 100644
@@ -1947,6 +1947,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
 
         /* The ones we currently want to retain (may be adjusted below) */
         retain = file_wanted | used | CEPH_CAP_PIN;
+
+       /*
+        * Do not retain the capabilities if they are under revoking
+        * but not used, this could help speed up the revoking.
+        */
+       retain &= ~((revoking & retain) & ~used);
+
         if (!mdsc->stopping && inode->i_nlink > 0) {
                 if (file_wanted) {
                         retain |= CEPH_CAP_ANY;       /* be greedy */
--

2.36.0.rc1

#8 lore raw
Quoted 8 lines · Xiubo Li
Quoted 7 lines · Zheng
Quoted 6 lines · Xiubo Li

For example if the Frwcb caps are being revoked, but only the Fr caps is still being used then the kclient will skip releasing them all. But in next turn if the Fr caps is ready to be released the Fw caps maybe just being used again. So in corner case, such as heavy load IOs, the revocation maybe stuck for a long time.

Quoted 9 lines
Quoted 4 lines

This does not make sense. If Frwcb are being revoked, writer can't get Fw again. Second, Frwcb are managed by single lock at mds side. Partial releasing caps does make lock state transition possible.

Yeah, you are right. Checked the __ceph_caps_issued() it really has removed the caps being revoked already.

Thanks Zheng.

Based on this discussion, I'm going to drop this patch from the testing branch.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
---
  fs/ceph/caps.c | 7 +++++++
  1 file changed, 7 insertions(+)
fs/ceph/caps.c +0 -0
index 0c0c8f5ae3b3..7eb5238941fc 100644
@@ -1947,6 +1947,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
 
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
fs/ceph/caps.c +5 -0
         /* The ones we currently want to retain (may be adjusted below) */
         retain = file_wanted | used | CEPH_CAP_PIN;
+
+       /*
+        * Do not retain the capabilities if they are under revoking
+        * but not used, this could help speed up the revoking.
+        */
Quoted 8 lines
Quoted 8 lines
fs/ceph/caps.c +2 -1
+       retain &= ~((revoking & retain) & ~used);
+
         if (!mdsc->stopping && inode->i_nlink > 0) {
                 if (file_wanted) {
                         retain |= CEPH_CAP_ANY;       /* be greedy */
--

2.36.0.rc1

Thanks,

Signature · 1 line
Jeff Layton <[email protected]>
author
#9 lore raw
Quoted 13 lines · Jeff Layton
Quoted 12 lines · Xiubo Li
Quoted 11 lines · Zheng
Quoted 6 lines · Xiubo Li

For example if the Frwcb caps are being revoked, but only the Fr caps is still being used then the kclient will skip releasing them all. But in next turn if the Fr caps is ready to be released the Fw caps maybe just being used again. So in corner case, such as heavy load IOs, the revocation maybe stuck for a long time.

This does not make sense. If Frwcb are being revoked, writer can't get Fw again. Second, Frwcb are managed by single lock at mds side. Partial releasing caps does make lock state transition possible.

Quoted 7 lines
Quoted 5 lines

Yeah, you are right. Checked the __ceph_caps_issued() it really has removed the caps being revoked already.

Thanks Zheng.

Based on this discussion, I'm going to drop this patch from the testing branch.

Sure, thanks Jeff.

Planed to drop it today.

-- Xiubo

Quoted 27 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
---
   fs/ceph/caps.c | 7 +++++++
   1 file changed, 7 insertions(+)
fs/ceph/caps.c +0 -0
index 0c0c8f5ae3b3..7eb5238941fc 100644
@@ -1947,6 +1947,13 @@ void ceph_check_caps(struct ceph_inode_info *ci, int flags,
 
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
fs/ceph/caps.c +5 -0
          /* The ones we currently want to retain (may be adjusted below) */
          retain = file_wanted | used | CEPH_CAP_PIN;
+
+       /*
+        * Do not retain the capabilities if they are under revoking
+        * but not used, this could help speed up the revoking.
+        */
Quoted 8 lines
Quoted 8 lines
fs/ceph/caps.c +2 -1
+       retain &= ~((revoking & retain) & ~used);
+
          if (!mdsc->stopping && inode->i_nlink > 0) {
                  if (file_wanted) {
                          retain |= CEPH_CAP_ANY;       /* be greedy */
--

2.36.0.rc1

Thanks,