Skip to contentSkip to conversation

fs/ceph:fix double unlock in handle_cap_export()

PATCH In review Wu Bo 3 participants 3 messages Apr 30, 2020 Ceph client

lore
Share & tools
lore

Wu Bo

author
#0 lore raw

PATCH v3 1/1 fs/ceph:fix double unlock in handle_cap_export()

If the ceph_mdsc_open_export_target_session() return fails, we should add mutex_lock(&session->s_mutex) on IS_ERR(tsession) block to avoid twice unlocking. because the session->s_mutex will be unlock at the out_unlock lable.

--
v2 -> v3:
- Rewrite solution, adding a mutex_lock(&session->s_mutex) to the IS_ERR(tsession) block.
- Modify the comment more clearly.
v1 -> v2:
- add spin_lock(&ci->i_ceph_lock) before goto out_unlock lable

---
 fs/ceph/caps.c | 1 +
 1 file changed, 1 insertion(+)
fs/ceph/caps.c +1 -0
index 185db76..d27d778 100644
@@ -3746,6 +3746,7 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
 		WARN_ON(1);
 		tsession = NULL;
 		target = -1;
+		mutex_lock(&session->s_mutex);
 	}
 	goto retry;
 
Signature · 1 line
1.8.3.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 33 lines · Wu Bo

If the ceph_mdsc_open_export_target_session() return fails, we should add mutex_lock(&session->s_mutex) on IS_ERR(tsession) block to avoid twice unlocking. because the session->s_mutex will be unlock at the out_unlock lable.

--
v2 -> v3:
- Rewrite solution, adding a mutex_lock(&session->s_mutex) to the IS_ERR(tsession) block.
- Modify the comment more clearly.
v1 -> v2:
- add spin_lock(&ci->i_ceph_lock) before goto out_unlock lable

---
 fs/ceph/caps.c | 1 +
 1 file changed, 1 insertion(+)
fs/ceph/caps.c +1 -1
index 185db76..d27d778 100644
@@ -3746,6 +3746,7 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
                WARN_ON(1);
                tsession = NULL;
                target = -1;
+               mutex_lock(&session->s_mutex);
        }
        goto retry;
 
--
Quoted 2 lines

1.8.3.1

#2 lore raw
In reply to Wu Bo
Quoted 5 lines · Wu Bo

If the ceph_mdsc_open_export_target_session() return fails, we should add mutex_lock(&session->s_mutex) on IS_ERR(tsession) block to avoid twice unlocking. because the session->s_mutex will be unlock at the out_unlock lable.

Quoted 8 lines

--
v2 -> v3:
- Rewrite solution, adding a mutex_lock(&session->s_mutex) to the IS_ERR(tsession) block.
- Modify the comment more clearly.
v1 -> v2:
- add spin_lock(&ci->i_ceph_lock) before goto out_unlock lable

For future reference, notes like this should go a little lower...

Quoted 7 lines
---
 fs/ceph/caps.c | 1 +
 1 file changed, 1 insertion(+)

If you put the patch version notes here, they'll be stripped out when we go to merge the patch with git-am.

fs/ceph/caps.c static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex, · line 3752

Quoted 12 lines
fs/ceph/caps.c +1 -0
index 185db76..d27d778 100644
@@ -3746,6 +3746,7 @@ static void handle_cap_export(struct inode *inode, struct ceph_mds_caps *ex,
 		WARN_ON(1);
 		tsession = NULL;
 		target = -1;
+		mutex_lock(&session->s_mutex);
 	}
 	goto retry;
 

Looks good. Merged, but I did clean up the verbiage in the changelog a bit.

Thanks!

Signature · 1 line
Jeff Layton <[email protected]>