diff mbox series

[RFC,4/6] ceph: don't take s_mutex in try_flush_caps

Message ID 20210615145730.21952-5-jlayton@kernel.org (mailing list archive)
State New, archived
Headers show
Series ceph: remove excess mutex locking from cap/snap flushing codepaths | expand

Commit Message

Jeff Layton June 15, 2021, 2:57 p.m. UTC
The s_mutex doesn't protect anything in this codepath.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/caps.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

Comments

Luis Henriques June 16, 2021, 3:25 p.m. UTC | #1
On Tue, Jun 15, 2021 at 10:57:28AM -0400, Jeff Layton wrote:
> The s_mutex doesn't protect anything in this codepath.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/ceph/caps.c | 16 ++--------------
>  1 file changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index 825b1e463ad3..d21b1fa36875 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -2149,26 +2149,17 @@ static int try_flush_caps(struct inode *inode, u64 *ptid)
>  {
>  	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
>  	struct ceph_inode_info *ci = ceph_inode(inode);
> -	struct ceph_mds_session *session = NULL;
>  	int flushing = 0;
>  	u64 flush_tid = 0, oldest_flush_tid = 0;
>  
> -retry:
>  	spin_lock(&ci->i_ceph_lock);
>  retry_locked:
>  	if (ci->i_dirty_caps && ci->i_auth_cap) {
>  		struct ceph_cap *cap = ci->i_auth_cap;
>  		struct cap_msg_args arg;
> +		struct ceph_mds_session *session = cap->session;
>  
> -		if (session != cap->session) {
> -			spin_unlock(&ci->i_ceph_lock);
> -			if (session)
> -				mutex_unlock(&session->s_mutex);
> -			session = cap->session;
> -			mutex_lock(&session->s_mutex);
> -			goto retry;
> -		}
> -		if (cap->session->s_state < CEPH_MDS_SESSION_OPEN) {
> +		if (session->s_state < CEPH_MDS_SESSION_OPEN) {
>  			spin_unlock(&ci->i_ceph_lock);
>  			goto out;
>  		}
> @@ -2205,9 +2196,6 @@ static int try_flush_caps(struct inode *inode, u64 *ptid)
>  		spin_unlock(&ci->i_ceph_lock);
>  	}
>  out:
> -	if (session)
> -		mutex_unlock(&session->s_mutex);
> -
>  	*ptid = flush_tid;
>  	return flushing;
>  }
> -- 
> 2.31.1
> 

Reviewed-by: Luis Henriques <lhenriques@suse.de>

Cheers,
--
Luís
diff mbox series

Patch

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 825b1e463ad3..d21b1fa36875 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2149,26 +2149,17 @@  static int try_flush_caps(struct inode *inode, u64 *ptid)
 {
 	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
 	struct ceph_inode_info *ci = ceph_inode(inode);
-	struct ceph_mds_session *session = NULL;
 	int flushing = 0;
 	u64 flush_tid = 0, oldest_flush_tid = 0;
 
-retry:
 	spin_lock(&ci->i_ceph_lock);
 retry_locked:
 	if (ci->i_dirty_caps && ci->i_auth_cap) {
 		struct ceph_cap *cap = ci->i_auth_cap;
 		struct cap_msg_args arg;
+		struct ceph_mds_session *session = cap->session;
 
-		if (session != cap->session) {
-			spin_unlock(&ci->i_ceph_lock);
-			if (session)
-				mutex_unlock(&session->s_mutex);
-			session = cap->session;
-			mutex_lock(&session->s_mutex);
-			goto retry;
-		}
-		if (cap->session->s_state < CEPH_MDS_SESSION_OPEN) {
+		if (session->s_state < CEPH_MDS_SESSION_OPEN) {
 			spin_unlock(&ci->i_ceph_lock);
 			goto out;
 		}
@@ -2205,9 +2196,6 @@  static int try_flush_caps(struct inode *inode, u64 *ptid)
 		spin_unlock(&ci->i_ceph_lock);
 	}
 out:
-	if (session)
-		mutex_unlock(&session->s_mutex);
-
 	*ptid = flush_tid;
 	return flushing;
 }