Skip to contentSkip to conversation

ocfs2: move the mlog from the spinlock to outside

PATCH New Shuning Zhang 3 participants 6 messages Sep 30, 2019 – Oct 9, 2019 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocfs2: move the mlog from the spinlock to outside

There is a potential task of deadlock. Because the mask is 0, the deadlock does not occur now. But There is a potential task. If someone change the mask of mlog, but forget to modify the order of the mlog and spin_unlock, There will be a potential deadlock.So I move the mlog from the spinlock to outsize.

---
 fs/ocfs2/dlmglue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/dlmglue.c +1 -1
index 1420723..9960e61 100644
@@ -2315,10 +2315,10 @@ static int ocfs2_inode_lock_update(struct inode *inode,
 
 	spin_lock(&oi->ip_lock);
 	if (oi->ip_flags & OCFS2_INODE_DELETED) {
+		spin_unlock(&oi->ip_lock);
 		mlog(0, "Orphaned inode %llu was deleted while we "
 		     "were waiting on a lock. ip_flags = 0x%x\n",
 		     (unsigned long long)oi->ip_blkno, oi->ip_flags);
-		spin_unlock(&oi->ip_lock);
 		status = -ENOENT;
 		goto bail;
 	}
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 ocfs2: move the mlog from the spinlock to outside

Quoted 13 lines · On Mon, 30 Sep 2019 11:17:39 +0800 Shuning Zhang <[email protected]>…

There is a potential task of deadlock. Because the mask is 0, the deadlock does not occur now. But There is a potential task. If someone change the mask of mlog, but forget to modify the order of the mlog and spin_unlock, There will be a potential deadlock.So I move the mlog from the spinlock to outsize.

...

fs/ocfs2/dlmglue.c +0 -0
@@ -2315,10 +2315,10 @@ static int ocfs2_inode_lock_update(struct inode *inode,
 

fs/ocfs2/dlmglue.c static int ocfs2_inode_lock_update(struct inode *inode, · line 2324

Quoted 10 lines
fs/ocfs2/dlmglue.c +1 -1
 	spin_lock(&oi->ip_lock);
 	if (oi->ip_flags & OCFS2_INODE_DELETED) {
+		spin_unlock(&oi->ip_lock);
 		mlog(0, "Orphaned inode %llu was deleted while we "
 		     "were waiting on a lock. ip_flags = 0x%x\n",
 		     (unsigned long long)oi->ip_blkno, oi->ip_flags);
-		spin_unlock(&oi->ip_lock);
 		status = -ENOENT;
 		goto bail;
 	}

The patch is obviously OK but I don't see any deadlock. mlog() doesn't take any locks?

maintainer
#2 lore raw

PATCH 1/1 ocfs2: move the mlog from the spinlock to outside

Quoted 15 lines · Andrew Morton
Quoted 13 lines · On Mon, 30 Sep 2019 11:17:39 +0800 Shuning Zhang <[email protected]>…

There is a potential task of deadlock. Because the mask is 0, the deadlock does not occur now. But There is a potential task. If someone change the mask of mlog, but forget to modify the order of the mlog and spin_unlock, There will be a potential deadlock.So I move the mlog from the spinlock to outsize.

...

fs/ocfs2/dlmglue.c +0 -0
@@ -2315,10 +2315,10 @@ static int ocfs2_inode_lock_update(struct inode *inode,
 
Quoted 14 lines

fs/ocfs2/dlmglue.c static int ocfs2_inode_lock_update(struct inode *inode, · line 2324

Quoted 10 lines
fs/ocfs2/dlmglue.c +1 -1
 	spin_lock(&oi->ip_lock);
 	if (oi->ip_flags & OCFS2_INODE_DELETED) {
+		spin_unlock(&oi->ip_lock);
 		mlog(0, "Orphaned inode %llu was deleted while we "
 		     "were waiting on a lock. ip_flags = 0x%x\n",
 		     (unsigned long long)oi->ip_blkno, oi->ip_flags);
-		spin_unlock(&oi->ip_lock);
 		status = -ENOENT;
 		goto bail;
 	}

The patch is obviously OK but I don't see any deadlock. mlog() doesn't take any locks?

I guess Shuning refers the calling of printk with spin lock.

Quoted 6 lines

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

author
#3 lore raw

PATCH 1/1 ocfs2: move the mlog from the spinlock to outside

? 2019/10/8 ??9:14, Joseph Qi ??:

Quoted 30 lines · Andrew Morton
Quoted 15 lines · On Mon, 30 Sep 2019 11:17:39 +0800 Shuning Zhang <[email protected]>…
Quoted 14 lines

There is a potential task of deadlock. Because the mask is 0, the deadlock does not occur now. But There is a potential task. If someone change the mask of mlog, but forget to modify the order of the mlog and spin_unlock, There will be a potential deadlock.So I move the mlog from the spinlock to outsize.

...

fs/ocfs2/dlmglue.c +0 -0
@@ -2315,10 +2315,10 @@ static int ocfs2_inode_lock_update(struct inode *inode,
 
Quoted 13 lines

fs/ocfs2/dlmglue.c static int ocfs2_inode_lock_update(struct inode *inode, · line 2324

Quoted 10 lines
fs/ocfs2/dlmglue.c +1 -1
  	spin_lock(&oi->ip_lock);
  	if (oi->ip_flags & OCFS2_INODE_DELETED) {
+		spin_unlock(&oi->ip_lock);
  		mlog(0, "Orphaned inode %llu was deleted while we "
  		     "were waiting on a lock. ip_flags = 0x%x\n",
  		     (unsigned long long)oi->ip_blkno, oi->ip_flags);
-		spin_unlock(&oi->ip_lock);
  		status = -ENOENT;
  		goto bail;
  	}

The patch is obviously OK but I don't see any deadlock. mlog() doesn't take any locks?

Quoted 1 line

I guess Shuning refers the calling of printk with spin lock.

Yes, It is the calling of printk.

Sorry for the description is not clear enough. :)

Quoted 5 lines
Quoted 5 lines

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel

maintainer
#4 lore raw

PATCH 1/1 ocfs2: move the mlog from the spinlock to outside

Quoted 31 lines · sunnyZhang

? 2019/10/8 ??9:14, Joseph Qi ??:

Quoted 29 lines · Andrew Morton
Quoted 27 lines · On Mon, 30 Sep 2019 11:17:39 +0800 Shuning Zhang <[email protected]>…
Quoted 16 lines

There is a potential task of deadlock. Because the mask is 0, the deadlock does not occur now. But There is a potential task. If someone change the mask of mlog, but forget to modify the order of the mlog and spin_unlock, There will be a potential deadlock.So I move the mlog from the spinlock to outsize.

...

fs/ocfs2/dlmglue.c +1 -0
@@ -2315,10 +2315,10 @@ static int ocfs2_inode_lock_update(struct inode *inode,
 ? ????? spin_lock(&oi->ip_lock);
 ????? if (oi->ip_flags & OCFS2_INODE_DELETED) {
+??????? spin_unlock(&oi->ip_lock);
Quoted 7 lines

????????? mlog(0, "Orphaned inode %llu was deleted while we " ?????????????? "were waiting on a lock. ip_flags = 0x%x\n", ?????????????? (unsigned long long)oi->ip_blkno, oi->ip_flags); -??????? spin_unlock(&oi->ip_lock);
????????? status = -ENOENT;
????????? goto bail;
????? }

The patch is obviously OK but I don't see any deadlock.? mlog() doesn't take any locks?

Quoted 6 lines
Quoted 1 line

I guess Shuning refers the calling of printk with spin lock.

Yes, It is the calling of printk.

Sorry for the description is not clear enough. :)

IIUC, we can call printk with spinlock, no deadlock will happen. So I have the same question, where is the "potential deadlock"?

Thanks,
Joseph

author
#5 lore raw

PATCH 1/1 ocfs2: move the mlog from the spinlock to outside

? 2019/10/8 ??5:51, Joseph Qi ??:

Quoted 31 lines · sunnyZhang
Quoted 29 lines

? 2019/10/8 ??9:14, Joseph Qi ??:

Quoted 28 lines · Andrew Morton
Quoted 27 lines · On Mon, 30 Sep 2019 11:17:39 +0800 Shuning Zhang <[email protected]>…
Quoted 13 lines

There is a potential task of deadlock. Because the mask is 0, the deadlock does not occur now. But There is a potential task. If someone change the mask of mlog, but forget to modify the order of the mlog and spin_unlock, There will be a potential deadlock.So I move the mlog from the spinlock to outsize.

...

fs/ocfs2/dlmglue.c static int ocfs2_inode_lock_update(struct inode *inode, · line 2323

Quoted 10 lines
fs/ocfs2/dlmglue.c +1 -1
@@ -2315,10 +2315,10 @@ static int ocfs2_inode_lock_update(struct inode *inode,
 ? ????? spin_lock(&oi->ip_lock);
 ????? if (oi->ip_flags & OCFS2_INODE_DELETED) {
+??????? spin_unlock(&oi->ip_lock);
 ????????? mlog(0, "Orphaned inode %llu was deleted while we "
 ?????????????? "were waiting on a lock. ip_flags = 0x%x\n",
 ?????????????? (unsigned long long)oi->ip_blkno, oi->ip_flags);
-??????? spin_unlock(&oi->ip_lock);
 ????????? status = -ENOENT;
 ????????? goto bail;
 ????? }

The patch is obviously OK but I don't see any deadlock.? mlog() doesn't take any locks?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I guess Shuning refers the calling of printk with spin lock.

Yes, It is the calling of printk.

Sorry for the description is not clear enough. :)

IIUC, we can call printk with spinlock, no deadlock will happen. So I have the same question, where is the "potential deadlock"?

I apology for my stupidity.

I have always had a wrong memory, I think printk() can sleep.

@Andrew Please can you help me to withdraw this patch?

Thanks

Quoted 3 lines

Thanks,
Joseph