ceph-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: xiubli@redhat.com
Cc: idryomov@gmail.com, pdonnell@redhat.com, ceph-devel@vger.kernel.org
Subject: Re: [PATCH 2/5] ceph: export iterate_sessions
Date: Tue, 29 Jun 2021 11:39:56 -0400	[thread overview]
Message-ID: <0d114802ce33ec63fa4ef09053e31d410de194d4.camel@kernel.org> (raw)
In-Reply-To: <20210629044241.30359-3-xiubli@redhat.com>

On Tue, 2021-06-29 at 12:42 +0800, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
> 
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
>  fs/ceph/caps.c       | 26 +-----------------------
>  fs/ceph/mds_client.c | 47 +++++++++++++++++++++++++++++---------------
>  fs/ceph/mds_client.h |  3 +++
>  3 files changed, 35 insertions(+), 41 deletions(-)
> 
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index e712826ea3f1..c6a3352a4d52 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -4280,33 +4280,9 @@ static void flush_dirty_session_caps(struct ceph_mds_session *s)
>  	dout("flush_dirty_caps done\n");
>  }
>  
> -static void iterate_sessions(struct ceph_mds_client *mdsc,
> -			     void (*cb)(struct ceph_mds_session *))
> -{
> -	int mds;
> -
> -	mutex_lock(&mdsc->mutex);
> -	for (mds = 0; mds < mdsc->max_sessions; ++mds) {
> -		struct ceph_mds_session *s;
> -
> -		if (!mdsc->sessions[mds])
> -			continue;
> -
> -		s = ceph_get_mds_session(mdsc->sessions[mds]);
> -		if (!s)
> -			continue;
> -
> -		mutex_unlock(&mdsc->mutex);
> -		cb(s);
> -		ceph_put_mds_session(s);
> -		mutex_lock(&mdsc->mutex);
> -	}
> -	mutex_unlock(&mdsc->mutex);
> -}
> -
>  void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc)
>  {
> -	iterate_sessions(mdsc, flush_dirty_session_caps);
> +	ceph_mdsc_iterate_sessions(mdsc, flush_dirty_session_caps, true);
>  }
>  
>  void __ceph_touch_fmode(struct ceph_inode_info *ci,
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index e49d3e230712..96bef289f58f 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -802,6 +802,33 @@ static void put_request_session(struct ceph_mds_request *req)
>  	}
>  }
>  
> +void ceph_mdsc_iterate_sessions(struct ceph_mds_client *mdsc,
> +			       void (*cb)(struct ceph_mds_session *),
> +			       bool check_state)
> +{
> +	int mds;
> +
> +	mutex_lock(&mdsc->mutex);
> +	for (mds = 0; mds < mdsc->max_sessions; ++mds) {
> +		struct ceph_mds_session *s;
> +
> +		s = __ceph_lookup_mds_session(mdsc, mds);
> +		if (!s)
> +			continue;
> +
> +		if (check_state && !check_session_state(s)) {
> +			ceph_put_mds_session(s);
> +			continue;
> +		}
> +
> +		mutex_unlock(&mdsc->mutex);
> +		cb(s);
> +		ceph_put_mds_session(s);
> +		mutex_lock(&mdsc->mutex);
> +	}
> +	mutex_unlock(&mdsc->mutex);
> +}
> +
>  void ceph_mdsc_release_request(struct kref *kref)
>  {
>  	struct ceph_mds_request *req = container_of(kref,
> @@ -4416,22 +4443,10 @@ void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
>  /*
>   * lock unlock sessions, to wait ongoing session activities
>   */
> -static void lock_unlock_sessions(struct ceph_mds_client *mdsc)
> +static void lock_unlock_session(struct ceph_mds_session *s)
>  {
> -	int i;
> -
> -	mutex_lock(&mdsc->mutex);
> -	for (i = 0; i < mdsc->max_sessions; i++) {
> -		struct ceph_mds_session *s = __ceph_lookup_mds_session(mdsc, i);
> -		if (!s)
> -			continue;
> -		mutex_unlock(&mdsc->mutex);
> -		mutex_lock(&s->s_mutex);
> -		mutex_unlock(&s->s_mutex);
> -		ceph_put_mds_session(s);
> -		mutex_lock(&mdsc->mutex);
> -	}
> -	mutex_unlock(&mdsc->mutex);
> +	mutex_lock(&s->s_mutex);
> +	mutex_unlock(&s->s_mutex);
>  }
>  

Your patch doesn't materially change this, but it sure would be nice to
know what purpose this lock/unlock garbage serves. Barf.

>  static void maybe_recover_session(struct ceph_mds_client *mdsc)
> @@ -4683,7 +4698,7 @@ void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc)
>  	dout("pre_umount\n");
>  	mdsc->stopping = 1;
>  
> -	lock_unlock_sessions(mdsc);
> +	ceph_mdsc_iterate_sessions(mdsc, lock_unlock_session, false);
>  	ceph_flush_dirty_caps(mdsc);
>  	wait_requests(mdsc);
>  
> diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
> index bf2683f0ba43..fca2cf427eaf 100644
> --- a/fs/ceph/mds_client.h
> +++ b/fs/ceph/mds_client.h
> @@ -523,6 +523,9 @@ static inline void ceph_mdsc_put_request(struct ceph_mds_request *req)
>  	kref_put(&req->r_kref, ceph_mdsc_release_request);
>  }
>  
> +extern void ceph_mdsc_iterate_sessions(struct ceph_mds_client *mdsc,
> +				       void (*cb)(struct ceph_mds_session *),
> +				       bool check_state);
>  extern struct ceph_msg *ceph_create_session_msg(u32 op, u64 seq);
>  extern void __ceph_queue_cap_release(struct ceph_mds_session *session,
>  				    struct ceph_cap *cap);

Again, not really exporting this function, so maybe reword the subject
line?

Thanks,
-- 
Jeff Layton <jlayton@kernel.org>


  reply	other threads:[~2021-06-29 15:40 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-29  4:42 [PATCH 0/5] flush the mdlog before waiting on unsafe reqs xiubli
2021-06-29  4:42 ` [PATCH 1/5] ceph: export ceph_create_session_msg xiubli
2021-06-29 13:12   ` Jeff Layton
2021-06-29 13:27     ` Xiubo Li
2021-06-30 12:17       ` Ilya Dryomov
2021-07-01  1:50         ` Xiubo Li
2021-06-29  4:42 ` [PATCH 2/5] ceph: export iterate_sessions xiubli
2021-06-29 15:39   ` Jeff Layton [this message]
2021-06-30  0:55     ` Xiubo Li
2021-06-29  4:42 ` [PATCH 3/5] ceph: flush mdlog before umounting xiubli
2021-06-29 15:34   ` Jeff Layton
2021-06-30  0:36     ` Xiubo Li
2021-06-30 12:39   ` Ilya Dryomov
2021-07-01  1:18     ` Xiubo Li
2021-06-29  4:42 ` [PATCH 4/5] ceph: flush the mdlog before waiting on unsafe reqs xiubli
2021-06-29 13:25   ` Jeff Layton
2021-06-30  1:26     ` Xiubo Li
2021-06-30 12:13       ` Jeff Layton
2021-07-01  1:16         ` Xiubo Li
2021-07-01  3:27           ` Patrick Donnelly
     [not found]             ` <e917a3e1-2902-604b-5154-98086c95357f@redhat.com>
2021-07-01 23:46               ` Patrick Donnelly
2021-07-02  0:01                 ` Xiubo Li
2021-07-02 13:17                 ` Xiubo Li
2021-07-02 18:14                   ` Patrick Donnelly
2021-07-03  1:33                     ` Xiubo Li
2021-06-29  4:42 ` [PATCH 5/5] ceph: fix ceph feature bits xiubli
2021-06-29 15:38   ` Jeff Layton
2021-06-30  0:52     ` Xiubo Li
2021-06-30 12:05       ` Jeff Layton
2021-06-30 12:52         ` Ilya Dryomov
2021-07-01  1:07           ` Xiubo Li
2021-07-01  1:08           ` Xiubo Li
2021-07-01  3:35           ` Xiubo Li
2021-06-29 15:27 ` [PATCH 0/5] flush the mdlog before waiting on unsafe reqs Jeff Layton
2021-06-30  0:35   ` Xiubo Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0d114802ce33ec63fa4ef09053e31d410de194d4.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=pdonnell@redhat.com \
    --cc=xiubli@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).