Skip to contentSkip to conversation

ocfs2: kill EBUSY from dlmfs_evict_inode

PATCH Superseded Junxiao Bi via Ocfs2-devel 1 participant 12 messages Jun 3, 2022 – Jun 7, 2022 OCFS2

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocfs2: kill EBUSY from dlmfs_evict_inode

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

---
 fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +11 -3
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
 {
 	int status;
 	struct dlmfs_inode_private *ip;
+	struct user_lock_res *lockres;
+	int destroyed;
 
 	clear_inode(inode);
 
 	mlog(0, "inode %lu\n", inode->i_ino);
 
 	ip = DLMFS_I(inode);
+	lockres = &ip->ip_lockres;
 
 	if (S_ISREG(inode->i_mode)) {
-		status = user_dlm_destroy_lock(&ip->ip_lockres);
-		if (status < 0)
-			mlog_errno(status);
+		spin_lock(&lockres->l_lock);
+		destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+		spin_unlock(&lockres->l_lock);
+		if (!destroyed) {
+			status = user_dlm_destroy_lock(lockres);
+			if (status < 0)
+				mlog_errno(status);
+		}
 		iput(ip->ip_parent);
 		goto clear_fields;
 	}
Signature · 7 lines
2.24.3 (Apple Git-128)


_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
#1 lore raw

Hello Junxiao,

Quoted 26 lines · On 6/4/22 06:31, Junxiao Bi via Ocfs2-devel wrote:

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

---
  fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +2 -0
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
  {
  	int status;
  	struct dlmfs_inode_private *ip;
+	struct user_lock_res *lockres;
+	int destroyed;
 
  	clear_inode(inode);
 
  	mlog(0, "inode %lu\n", inode->i_ino);
 

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 312

Quoted 10 lines
fs/ocfs2/dlmfs/dlmfs.c +4 -3
  	ip = DLMFS_I(inode);
+	lockres = &ip->ip_lockres;
 
  	if (S_ISREG(inode->i_mode)) {
-		status = user_dlm_destroy_lock(&ip->ip_lockres);
-		if (status < 0)
-			mlog_errno(status);
+		spin_lock(&lockres->l_lock);
+		destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+		spin_unlock(&lockres->l_lock);

This area code does the same work in user_dlm_destroy_lock(). Why not to give another errno (e.g -EAGAIN) for user_dlm_destroy_lock when l_flags contains USER_LOCK_IN_TEARDOWN. then change 'if (status < 0)' to 'if (status < 0 && status != -EAGAIN)'

Thanks,
Heming

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 320

Quoted 8 lines
fs/ocfs2/dlmfs/dlmfs.c +5 -0
+		if (!destroyed) {
+			status = user_dlm_destroy_lock(lockres);
+			if (status < 0)
+				mlog_errno(status);
+		}
  		iput(ip->ip_parent);
  		goto clear_fields;
  	}

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

#2 lore raw
Quoted 31 lines · On 6/4/22 3:10 AM, [email protected] wrote:

Hello Junxiao,

Quoted 28 lines · On 6/4/22 06:31, Junxiao Bi via Ocfs2-devel wrote:

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

---
  fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---

  1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +3 -2
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
   {
       int status;
       struct dlmfs_inode_private *ip;
+    struct user_lock_res *lockres;
+    int destroyed;
         clear_inode(inode);
         mlog(0, "inode %lu\n", inode->i_ino);
         ip = DLMFS_I(inode);
+    lockres = &ip->ip_lockres;
         if (S_ISREG(inode->i_mode)) {
-        status = user_dlm_destroy_lock(&ip->ip_lockres);
-        if (status < 0)
Quoted 8 lines

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 312

Quoted 4 lines
fs/ocfs2/dlmfs/dlmfs.c +3 -1
-            mlog_errno(status);
+        spin_lock(&lockres->l_lock);
+        destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+        spin_unlock(&lockres->l_lock);

This area code does the same work in user_dlm_destroy_lock(). Why not to give another errno (e.g -EAGAIN) for user_dlm_destroy_lock when l_flags contains USER_LOCK_IN_TEARDOWN. then change 'if (status < 0)' to 'if (status < 0 && status != -EAGAIN)'

I don't think we should do that. It's reasonable for user_dlm_destroy_lock() to return EBUSY in that case. EAGAIN is for the case, you invoke it second time you may succeed. That's not the case here.

Thanks,

Junxiao.

Quoted 13 lines

Thanks,
Heming

Quoted 8 lines
fs/ocfs2/dlmfs/dlmfs.c +5 -0
+        if (!destroyed) {
+            status = user_dlm_destroy_lock(lockres);
+            if (status < 0)
+                mlog_errno(status);
+        }
           iput(ip->ip_parent);
           goto clear_fields;
       }

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

#3 lore raw
Quoted 42 lines · Junxiao Bi
Quoted 31 lines · On 6/4/22 3:10 AM, [email protected] wrote:

Hello Junxiao,

Quoted 28 lines · On 6/4/22 06:31, Junxiao Bi via Ocfs2-devel wrote:

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

---
  fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---

  1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +3 -2
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
   {
       int status;
       struct dlmfs_inode_private *ip;
+    struct user_lock_res *lockres;
+    int destroyed;
         clear_inode(inode);
         mlog(0, "inode %lu\n", inode->i_ino);
         ip = DLMFS_I(inode);
+    lockres = &ip->ip_lockres;
         if (S_ISREG(inode->i_mode)) {
-        status = user_dlm_destroy_lock(&ip->ip_lockres);
-        if (status < 0)
Quoted 8 lines

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 312

Quoted 4 lines
fs/ocfs2/dlmfs/dlmfs.c +3 -1
-            mlog_errno(status);
+        spin_lock(&lockres->l_lock);
+        destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+        spin_unlock(&lockres->l_lock);

This area code does the same work in user_dlm_destroy_lock(). Why not to give another errno (e.g -EAGAIN) for user_dlm_destroy_lock when l_flags contains USER_LOCK_IN_TEARDOWN. then change 'if (status < 0)' to 'if (status < 0 && status != -EAGAIN)'

Quoted 2 lines

I don't think we should do that. It's reasonable for user_dlm_destroy_lock() to return EBUSY in that case. EAGAIN is for the case, you invoke it second time you may succeed. That's not the case here.

I agree the EAGAIN is not good, but do you think the errno idea is reasonable? user_dlm_destroy_lock only has two callers: dlmfs_evict_inode & dlmfs_unlink. the code logic is clear, we can choose another errno, or even create a new one. it costs too much to use spin_lock to avoid print an error log.

Thanks,
Heming

Quoted 10 lines
Quoted 10 lines

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 320

Quoted 9 lines
fs/ocfs2/dlmfs/dlmfs.c +5 -0
+        if (!destroyed) {
+            status = user_dlm_destroy_lock(lockres);
+            if (status < 0)
+                mlog_errno(status);
+        }
           iput(ip->ip_parent);
           goto clear_fields;
       }

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

#4 lore raw
Quoted 45 lines · 在 2022年6月4日,下午4:17,[email protected] 写道:
Quoted 40 lines · Junxiao Bi
Quoted 40 lines · On 6/4/22 3:10 AM, [email protected] wrote:

Hello Junxiao,

Quoted 22 lines · On 6/4/22 06:31, Junxiao Bi via Ocfs2-devel wrote:

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

---
  fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +2 -0
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
  {
      int status;
      struct dlmfs_inode_private *ip;
+    struct user_lock_res *lockres;
+    int destroyed;
        clear_inode(inode);

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 308

Quoted 10 lines
fs/ocfs2/dlmfs/dlmfs.c +4 -3
        mlog(0, "inode %lu\n", inode->i_ino);
        ip = DLMFS_I(inode);
+    lockres = &ip->ip_lockres;
        if (S_ISREG(inode->i_mode)) {
-        status = user_dlm_destroy_lock(&ip->ip_lockres);
-        if (status < 0)
-            mlog_errno(status);
+        spin_lock(&lockres->l_lock);
+        destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+        spin_unlock(&lockres->l_lock);

This area code does the same work in user_dlm_destroy_lock(). Why not to give another errno (e.g -EAGAIN) for user_dlm_destroy_lock when l_flags contains USER_LOCK_IN_TEARDOWN. then change 'if (status < 0)' to 'if (status < 0 && status != -EAGAIN)'

Quoted 6 lines
Quoted 1 line

I don't think we should do that. It's reasonable for user_dlm_destroy_lock() to return EBUSY in that case. EAGAIN is for the case, you invoke it second time you may succeed. That's not the case here.

I agree the EAGAIN is not good, but do you think the errno idea is reasonable? user_dlm_destroy_lock only has two callers: dlmfs_evict_inode & dlmfs_unlink. the code logic is clear, we can choose another errno, or even create a new one. it costs too much to use spin_lock to avoid print an error log.

Regarding cost, the suggested way has even higher cost, the spin lock can’t be avoided unless you don’t access the lockres and an extra function call was also added. Actually that function shouldn’t be invoked because it was already invoked once in this flow. I don’t think we should change return value of that function, EBUSY looks most reasonable return value for me.

Thanks,
Junxiao

Quoted 15 lines

Thanks,
Heming

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
fs/ocfs2/dlmfs/dlmfs.c +5 -0
+        if (!destroyed) {
+            status = user_dlm_destroy_lock(lockres);
+            if (status < 0)
+                mlog_errno(status);
+        }
          iput(ip->ip_parent);
          goto clear_fields;
      }

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

#5 lore raw
Quoted 45 lines · Junxiao Bi
Quoted 45 lines · 在 2022年6月4日,下午4:17,[email protected] 写道:
Quoted 40 lines · Junxiao Bi
Quoted 40 lines · On 6/4/22 3:10 AM, [email protected] wrote:

Hello Junxiao,

Quoted 22 lines · On 6/4/22 06:31, Junxiao Bi via Ocfs2-devel wrote:

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

---
   fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---
   1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +2 -0
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
   {
       int status;
       struct dlmfs_inode_private *ip;
+    struct user_lock_res *lockres;
+    int destroyed;
         clear_inode(inode);

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 308

Quoted 10 lines
fs/ocfs2/dlmfs/dlmfs.c +4 -3
         mlog(0, "inode %lu\n", inode->i_ino);
         ip = DLMFS_I(inode);
+    lockres = &ip->ip_lockres;
         if (S_ISREG(inode->i_mode)) {
-        status = user_dlm_destroy_lock(&ip->ip_lockres);
-        if (status < 0)
-            mlog_errno(status);
+        spin_lock(&lockres->l_lock);
+        destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+        spin_unlock(&lockres->l_lock);

This area code does the same work in user_dlm_destroy_lock(). Why not to give another errno (e.g -EAGAIN) for user_dlm_destroy_lock when l_flags contains USER_LOCK_IN_TEARDOWN. then change 'if (status < 0)' to 'if (status < 0 && status != -EAGAIN)'

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I don't think we should do that. It's reasonable for user_dlm_destroy_lock() to return EBUSY in that case. EAGAIN is for the case, you invoke it second time you may succeed. That's not the case here.

I agree the EAGAIN is not good, but do you think the errno idea is reasonable? user_dlm_destroy_lock only has two callers: dlmfs_evict_inode & dlmfs_unlink. the code logic is clear, we can choose another errno, or even create a new one. it costs too much to use spin_lock to avoid print an error log.

Regarding cost, the suggested way has even higher cost, the spin lock can’t be avoided unless you don’t access the lockres and an extra function call was also added. Actually that function shouldn’t be invoked because it was already invoked once in this flow. I don’t think we should change return value of that function, EBUSY looks most reasonable return value for me.

I can't see why my idea cost more. the patch ('NEW_ERRNO' should be changed) with my idea:

fs/ocfs2/dlmfs/dlmfs.c +0 -0

index e360543ad7e7..dd47556b07fa 100644

--- a/fs/ocfs2/dlmfs/dlmfs.c

+++ b/fs/ocfs2/dlmfs/dlmfs.c

@@ -305,7 +305,7 @@ static void dlmfs_evict_inode(struct inode *inode)

     if (S_ISREG(inode->i_mode)) {

         status = user_dlm_destroy_lock(&ip->ip_lockres);

- if (status < 0)

+ if (status < 0 && status != NEW_ERRNO)

             mlog_errno(status);

         iput(ip->ip_parent);

         goto clear_fields;
fs/ocfs2/dlmfs/userdlm.c +0 -0

index 617c92e7b925..93b8d7bad96e 100644

--- a/fs/ocfs2/dlmfs/userdlm.c

+++ b/fs/ocfs2/dlmfs/userdlm.c

@@ -600,6 +600,7 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)

     spin_lock(&lockres->l_lock);

     if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {

         spin_unlock(&lockres->l_lock);

+ status = -NEW_ERRNO;

         goto bail;

     }

your patch added many codes and add another 'if' branch.
- the many codes: cpu will spend more time to complete the same work.
- the new added 'if' branch will breaks cpu pipeline.

my patch only changes 2 lines, maybe add 2 lines cpu instruct without adding new breaking cpu pipeline case.

/Heming

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 316

Quoted 10 lines
fs/ocfs2/dlmfs/dlmfs.c +5 -0
+        if (!destroyed) {
+            status = user_dlm_destroy_lock(lockres);
+            if (status < 0)
+                mlog_errno(status);
+        }
           iput(ip->ip_parent);
           goto clear_fields;
       }

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

#6 lore raw
In reply to Junxiao Bi via Ocfs2-devel

sorry for my last reply. thunderbird messed up format. I resend my reply with neomutt, please check it.
(no new change between the last messed-up mail and this mail.)

Quoted 45 lines · Junxiao Bi
Quoted 45 lines · 在 2022年6月4日,下午4:17,[email protected] 写道:
Quoted 40 lines · Junxiao Bi
Quoted 40 lines · On 6/4/22 3:10 AM, [email protected] wrote:

Hello Junxiao,

Quoted 22 lines · On 6/4/22 06:31, Junxiao Bi via Ocfs2-devel wrote:

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

---
  fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +2 -0
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
  {
      int status;
      struct dlmfs_inode_private *ip;
+    struct user_lock_res *lockres;
+    int destroyed;
        clear_inode(inode);

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 308

Quoted 10 lines
fs/ocfs2/dlmfs/dlmfs.c +4 -3
        mlog(0, "inode %lu\n", inode->i_ino);
        ip = DLMFS_I(inode);
+    lockres = &ip->ip_lockres;
        if (S_ISREG(inode->i_mode)) {
-        status = user_dlm_destroy_lock(&ip->ip_lockres);
-        if (status < 0)
-            mlog_errno(status);
+        spin_lock(&lockres->l_lock);
+        destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+        spin_unlock(&lockres->l_lock);

This area code does the same work in user_dlm_destroy_lock(). Why not to give another errno (e.g -EAGAIN) for user_dlm_destroy_lock when l_flags contains USER_LOCK_IN_TEARDOWN. then change 'if (status < 0)' to 'if (status < 0 && status != -EAGAIN)'

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I don't think we should do that. It's reasonable for user_dlm_destroy_lock() to return EBUSY in that case. EAGAIN is for the case, you invoke it second time you may succeed. That's not the case here.

I agree the EAGAIN is not good, but do you think the errno idea is reasonable? user_dlm_destroy_lock only has two callers: dlmfs_evict_inode & dlmfs_unlink. the code logic is clear, we can choose another errno, or even create a new one. it costs too much to use spin_lock to avoid print an error log.

Regarding cost, the suggested way has even higher cost, the spin lock can’t be avoided unless you don’t access the lockres and an extra function call was also added. Actually that function shouldn’t be invoked because it was already invoked once in this flow. I don’t think we should change return value of that function, EBUSY looks most reasonable return value for me.

I can't see why my idea cost more.
The patch ('NEW_ERRNO' should be changed) with my idea:

fs/ocfs2/dlmfs/dlmfs.c +1 -1
index e360543ad7e7..dd47556b07fa 100644
@@ -305,7 +305,7 @@ static void dlmfs_evict_inode(struct inode *inode)
 
     if (S_ISREG(inode->i_mode)) {
         status = user_dlm_destroy_lock(&ip->ip_lockres);
-        if (status < 0)
+        if (status < 0 && status != -NEW_ERRNO)
             mlog_errno(status);
         iput(ip->ip_parent);
         goto clear_fields;
fs/ocfs2/dlmfs/userdlm.c +0 -0
index 617c92e7b925..93b8d7bad96e 100644
@@ -600,6 +600,7 @@ int user_dlm_destroy_lock(struct user_lock_res

*lockres)

     spin_lock(&lockres->l_lock);
     if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
         spin_unlock(&lockres->l_lock);
+        status = -NEW_ERRNO;
         goto bail;
     } 

your patch added many codes and add another 'if' branch.
- the many codes: cpu will spend more time to complete the same work.
- the new added 'if' branch will breaks cpu pipeline.

my patch only changes 2 lines, maybe add 2 lines cpu instruct without adding new breaking cpu pipeline case.

/Heming

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 316

Quoted 9 lines
fs/ocfs2/dlmfs/dlmfs.c +5 -0
+        if (!destroyed) {
+            status = user_dlm_destroy_lock(lockres);
+            if (status < 0)
+                mlog_errno(status);
+        }
          iput(ip->ip_parent);
          goto clear_fields;
      }

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

#7 lore raw
Quoted 91 lines · 在 2022年6月4日,下午6:48,Heming Zhao <[email protected]> 写道:

sorry for my last reply. thunderbird messed up format. I resend my reply with neomutt, please check it.
(no new change between the last messed-up mail and this mail.)

Quoted 46 lines · Junxiao Bi
Quoted 45 lines
Quoted 3 lines · 在 2022年6月4日,下午4:17,[email protected] 写道:
Quoted 40 lines · Junxiao Bi
Quoted 40 lines · On 6/4/22 3:10 AM, [email protected] wrote:

Hello Junxiao,

Quoted 22 lines · On 6/4/22 06:31, Junxiao Bi via Ocfs2-devel wrote:

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

---
 fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +2 -0
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
 {
     int status;
     struct dlmfs_inode_private *ip;
+    struct user_lock_res *lockres;
+    int destroyed;
       clear_inode(inode);

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 308

Quoted 10 lines
fs/ocfs2/dlmfs/dlmfs.c +4 -3
       mlog(0, "inode %lu\n", inode->i_ino);
       ip = DLMFS_I(inode);
+    lockres = &ip->ip_lockres;
       if (S_ISREG(inode->i_mode)) {
-        status = user_dlm_destroy_lock(&ip->ip_lockres);
-        if (status < 0)
-            mlog_errno(status);
+        spin_lock(&lockres->l_lock);
+        destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+        spin_unlock(&lockres->l_lock);

This area code does the same work in user_dlm_destroy_lock(). Why not to give another errno (e.g -EAGAIN) for user_dlm_destroy_lock when l_flags contains USER_LOCK_IN_TEARDOWN. then change 'if (status < 0)' to 'if (status < 0 && status != -EAGAIN)'

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I don't think we should do that. It's reasonable for user_dlm_destroy_lock() to return EBUSY in that case. EAGAIN is for the case, you invoke it second time you may succeed. That's not the case here.

I agree the EAGAIN is not good, but do you think the errno idea is reasonable? user_dlm_destroy_lock only has two callers: dlmfs_evict_inode & dlmfs_unlink. the code logic is clear, we can choose another errno, or even create a new one. it costs too much to use spin_lock to avoid print an error log.

Regarding cost, the suggested way has even higher cost, the spin lock can’t be avoided unless you don’t access the lockres and an extra function call was also added. Actually that function shouldn’t be invoked because it was already invoked once in this flow. I don’t think we should change return value of that function, EBUSY looks most reasonable return value for me.

I can't see why my idea cost more.
The patch ('NEW_ERRNO' should be changed) with my idea:

fs/ocfs2/dlmfs/dlmfs.c +1 -1
index e360543ad7e7..dd47556b07fa 100644
@@ -305,7 +305,7 @@ static void dlmfs_evict_inode(struct inode *inode)
 
    if (S_ISREG(inode->i_mode)) {
        status = user_dlm_destroy_lock(&ip->ip_lockres);
-        if (status < 0)
+        if (status < 0 && status != -NEW_ERRNO)
            mlog_errno(status);
        iput(ip->ip_parent);
        goto clear_fields;
fs/ocfs2/dlmfs/userdlm.c +1 -0
index 617c92e7b925..93b8d7bad96e 100644
@@ -600,6 +600,7 @@ int user_dlm_destroy_lock(struct user_lock_res
 *lockres)
    spin_lock(&lockres->l_lock);
    if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
        spin_unlock(&lockres->l_lock);
+        status = -NEW_ERRNO;
        goto bail;
    } 
Quoted 6 lines

your patch added many codes and add another 'if' branch.
- the many codes: cpu will spend more time to complete the same work.
- the new added 'if' branch will breaks cpu pipeline.

my patch only changes 2 lines, maybe add 2 lines cpu instruct without adding new breaking cpu pipeline case.

Your patch invoked user_dlm_destroy_lock, that will execute also the if and spin lock. Plus function call, that’s not higher cost?

Quoted 15 lines

/Heming

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
fs/ocfs2/dlmfs/dlmfs.c +5 -0
+        if (!destroyed) {
+            status = user_dlm_destroy_lock(lockres);
+            if (status < 0)
+                mlog_errno(status);
+        }
         iput(ip->ip_parent);
         goto clear_fields;
     }

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

#8 lore raw
Quoted 91 lines · Junxiao Bi
Quoted 91 lines · 在 2022年6月4日,下午6:48,Heming Zhao <[email protected]> 写道:

sorry for my last reply. thunderbird messed up format. I resend my reply with neomutt, please check it.
(no new change between the last messed-up mail and this mail.)

Quoted 46 lines · Junxiao Bi
Quoted 45 lines
Quoted 3 lines · 在 2022年6月4日,下午4:17,[email protected] 写道:
Quoted 40 lines · Junxiao Bi
Quoted 40 lines · On 6/4/22 3:10 AM, [email protected] wrote:

Hello Junxiao,

Quoted 22 lines · On 6/4/22 06:31, Junxiao Bi via Ocfs2-devel wrote:

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

---
  fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +2 -0
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
  {
      int status;
      struct dlmfs_inode_private *ip;
+    struct user_lock_res *lockres;
+    int destroyed;
        clear_inode(inode);

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 308

Quoted 10 lines
fs/ocfs2/dlmfs/dlmfs.c +4 -3
        mlog(0, "inode %lu\n", inode->i_ino);
        ip = DLMFS_I(inode);
+    lockres = &ip->ip_lockres;
        if (S_ISREG(inode->i_mode)) {
-        status = user_dlm_destroy_lock(&ip->ip_lockres);
-        if (status < 0)
-            mlog_errno(status);
+        spin_lock(&lockres->l_lock);
+        destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+        spin_unlock(&lockres->l_lock);

This area code does the same work in user_dlm_destroy_lock(). Why not to give another errno (e.g -EAGAIN) for user_dlm_destroy_lock when l_flags contains USER_LOCK_IN_TEARDOWN. then change 'if (status < 0)' to 'if (status < 0 && status != -EAGAIN)'

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I don't think we should do that. It's reasonable for user_dlm_destroy_lock() to return EBUSY in that case. EAGAIN is for the case, you invoke it second time you may succeed. That's not the case here.

I agree the EAGAIN is not good, but do you think the errno idea is reasonable? user_dlm_destroy_lock only has two callers: dlmfs_evict_inode & dlmfs_unlink. the code logic is clear, we can choose another errno, or even create a new one. it costs too much to use spin_lock to avoid print an error log.

Regarding cost, the suggested way has even higher cost, the spin lock can’t be avoided unless you don’t access the lockres and an extra function call was also added. Actually that function shouldn’t be invoked because it was already invoked once in this flow. I don’t think we should change return value of that function, EBUSY looks most reasonable return value for me.

I can't see why my idea cost more.
The patch ('NEW_ERRNO' should be changed) with my idea:

fs/ocfs2/dlmfs/dlmfs.c +1 -1
index e360543ad7e7..dd47556b07fa 100644
@@ -305,7 +305,7 @@ static void dlmfs_evict_inode(struct inode *inode)
 
     if (S_ISREG(inode->i_mode)) {
         status = user_dlm_destroy_lock(&ip->ip_lockres);
-        if (status < 0)
+        if (status < 0 && status != -NEW_ERRNO)
             mlog_errno(status);
         iput(ip->ip_parent);
         goto clear_fields;
fs/ocfs2/dlmfs/userdlm.c +1 -0
index 617c92e7b925..93b8d7bad96e 100644
@@ -600,6 +600,7 @@ int user_dlm_destroy_lock(struct user_lock_res
 *lockres)
     spin_lock(&lockres->l_lock);
     if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
         spin_unlock(&lockres->l_lock);
+        status = -NEW_ERRNO;
         goto bail;
     }
Quoted 7 lines
Quoted 6 lines

your patch added many codes and add another 'if' branch.
- the many codes: cpu will spend more time to complete the same work.
- the new added 'if' branch will breaks cpu pipeline.

my patch only changes 2 lines, maybe add 2 lines cpu instruct without adding new breaking cpu pipeline case.

Your patch invoked user_dlm_destroy_lock, that will execute also the if and spin lock. Plus function call, that’s not higher cost?

Thank you for your explanation, I got your patch meaning. Yes, my idea cost more. Let's wait for maintainer comment.

/Heming

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 316

Quoted 10 lines
fs/ocfs2/dlmfs/dlmfs.c +5 -0
+        if (!destroyed) {
+            status = user_dlm_destroy_lock(lockres);
+            if (status < 0)
+                mlog_errno(status);
+        }
          iput(ip->ip_parent);
          goto clear_fields;
      }

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

#9 lore raw
In reply to Junxiao Bi via Ocfs2-devel
Quoted 5 lines · Junxiao Bi

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

s/anonying/annoying

Quoted 29 lines
---
 fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +4 -3
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
 {
 	int status;
 	struct dlmfs_inode_private *ip;
+	struct user_lock_res *lockres;
+	int destroyed;
 
 	clear_inode(inode);
 
 	mlog(0, "inode %lu\n", inode->i_ino);
 
 	ip = DLMFS_I(inode);
+	lockres = &ip->ip_lockres;
 
 	if (S_ISREG(inode->i_mode)) {
-		status = user_dlm_destroy_lock(&ip->ip_lockres);
-		if (status < 0)
-			mlog_errno(status);
+		spin_lock(&lockres->l_lock);

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 320

Quoted 10 lines
fs/ocfs2/dlmfs/dlmfs.c +7 -0
+		destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+		spin_unlock(&lockres->l_lock);
+		if (!destroyed) {
+			status = user_dlm_destroy_lock(lockres);
+			if (status < 0)
+				mlog_errno(status);
+		}
 		iput(ip->ip_parent);
 		goto clear_fields;
 	}

As you describes, it firstly invokes unlink and then evict, but strictly speaking, flag USER_LOCK_IN_TEARDOWN doesn't mean 'destroyed', it could be destroying, destroyed, or even unattached.

So how about just checking the flag like other places? Something like:

	/* Don't destroy lockres twice */
	spin_lock(&lockres->l_lock);
	(lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
		spin_unlock(&lockres->l_lock);
		goto skip;
	}
	spin_unlock(&lockres->l_lock);
	status = user_dlm_destroy_lock(lockres);
	...
skip:
	iput(ip->ip_parent);
	...

Thanks,
Joseph

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

#10 lore raw
Quoted 53 lines · Joseph Qi
Quoted 5 lines · Junxiao Bi

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

s/anonying/annoying

Quoted 28 lines
---
  fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +4 -3
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
  {
  	int status;
  	struct dlmfs_inode_private *ip;
+	struct user_lock_res *lockres;
+	int destroyed;
 
  	clear_inode(inode);
 
  	mlog(0, "inode %lu\n", inode->i_ino);
 
  	ip = DLMFS_I(inode);
+	lockres = &ip->ip_lockres;
 
  	if (S_ISREG(inode->i_mode)) {
-		status = user_dlm_destroy_lock(&ip->ip_lockres);
-		if (status < 0)
-			mlog_errno(status);
+		spin_lock(&lockres->l_lock);

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 320

Quoted 10 lines
fs/ocfs2/dlmfs/dlmfs.c +7 -0
+		destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+		spin_unlock(&lockres->l_lock);
+		if (!destroyed) {
+			status = user_dlm_destroy_lock(lockres);
+			if (status < 0)
+				mlog_errno(status);
+		}
  		iput(ip->ip_parent);
  		goto clear_fields;
  	}

As you describes, it firstly invokes unlink and then evict, but strictly speaking, flag USER_LOCK_IN_TEARDOWN doesn't mean 'destroyed', it could be destroying, destroyed, or even unattached.

So how about just checking the flag like other places? Something like:

Quoted 12 lines
	/* Don't destroy lockres twice */
	spin_lock(&lockres->l_lock);
	(lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
		spin_unlock(&lockres->l_lock);
		goto skip;
	}
	spin_unlock(&lockres->l_lock);
	status = user_dlm_destroy_lock(lockres);
	...
skip:
	iput(ip->ip_parent);
	...

Sound like the concern is about the variable name, how about s/destroyed/tearingdown ?

Thanks,

Junxiao.

Quoted 2 lines

Thanks,
Joseph

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

#11 lore raw
Quoted 64 lines · Junxiao Bi
Quoted 49 lines · Joseph Qi
Quoted 5 lines · Junxiao Bi

When unlink a dlmfs, first it will invoke dlmfs_unlink(), and then invoke dlmfs_evict_inode(), user_dlm_destroy_lock() is invoked in both places, the second one from dlmfs_evict_inode() will get EBUSY error because USER_LOCK_IN_TEARDOWN is already set in lockres. This doesn't affect any function, just the error log is anonying.

s/anonying/annoying

Quoted 24 lines

---
  fs/ocfs2/dlmfs/dlmfs.c | 14 +++++++++++---

  1 file changed, 11 insertions(+), 3 deletions(-)
fs/ocfs2/dlmfs/dlmfs.c +4 -3
index e360543ad7e7..a120610dff7e 100644
@@ -296,17 +296,25 @@ static void dlmfs_evict_inode(struct inode *inode)
   {
       int status;
       struct dlmfs_inode_private *ip;
+    struct user_lock_res *lockres;
+    int destroyed;
         clear_inode(inode);
         mlog(0, "inode %lu\n", inode->i_ino);
         ip = DLMFS_I(inode);
+    lockres = &ip->ip_lockres;
         if (S_ISREG(inode->i_mode)) {
-        status = user_dlm_destroy_lock(&ip->ip_lockres);
-        if (status < 0)
-            mlog_errno(status);
+        spin_lock(&lockres->l_lock);

fs/ocfs2/dlmfs/dlmfs.c static void dlmfs_evict_inode(struct inode *inode) · line 316

Quoted 10 lines
fs/ocfs2/dlmfs/dlmfs.c +7 -0
+        destroyed = !!(lockres->l_flags & USER_LOCK_IN_TEARDOWN);
+        spin_unlock(&lockres->l_lock);
+        if (!destroyed) {
+            status = user_dlm_destroy_lock(lockres);
+            if (status < 0)
+                mlog_errno(status);
+        }
           iput(ip->ip_parent);
           goto clear_fields;
       }

As you describes, it firstly invokes unlink and then evict, but strictly speaking, flag USER_LOCK_IN_TEARDOWN doesn't mean 'destroyed', it could be destroying, destroyed, or even unattached.

So how about just checking the flag like other places? Something like:

Quoted 12 lines

    /* Don't destroy lockres twice */
    spin_lock(&lockres->l_lock);
    (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
        spin_unlock(&lockres->l_lock);
        goto skip;
    }
    spin_unlock(&lockres->l_lock);
    status = user_dlm_destroy_lock(lockres);
    ...
skip:
    iput(ip->ip_parent);
    ...

Quoted 2 lines

Sound like the concern is about the variable name, how about s/destroyed/tearingdown ?

Yes, teardown would be better.

Thanks,
Joseph

_______________________________________________
Ocfs2-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/ocfs2-devel