]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
ceph: introudce a variable to avoid calling refcount_read() twice
authorChengguang Xu <cgxu519@gmx.com>
Thu, 12 Jul 2018 08:35:32 +0000 (16:35 +0800)
committerJeff Layton <jlayton@kernel.org>
Mon, 23 Sep 2019 13:27:21 +0000 (09:27 -0400)
Calling refcount_read() twice may return different value each time,
so introduce a variable to avoid it.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
fs/ceph/mds_client.c

index 03697aefa27342b0d3fc43166cda18115a9e7d86..0d7afabb1f49bb705f17abaa840a0faa28906b82 100644 (file)
@@ -539,8 +539,8 @@ const char *ceph_session_state_name(int s)
 static struct ceph_mds_session *get_session(struct ceph_mds_session *s)
 {
        if (refcount_inc_not_zero(&s->s_ref)) {
-               dout("mdsc get_session %p %d -> %d\n", s,
-                    refcount_read(&s->s_ref)-1, refcount_read(&s->s_ref));
+               unsigned int refcnt = refcount_read(&s->s_ref);
+               dout("mdsc get_session %p %d -> %d\n", s, refcnt - 1, refcnt);
                return s;
        } else {
                dout("mdsc get_session %p 0 -- FAIL\n", s);
@@ -550,8 +550,8 @@ static struct ceph_mds_session *get_session(struct ceph_mds_session *s)
 
 void ceph_put_mds_session(struct ceph_mds_session *s)
 {
-       dout("mdsc put_session %p %d -> %d\n", s,
-            refcount_read(&s->s_ref), refcount_read(&s->s_ref)-1);
+       unsigned int refcnt = refcount_read(&s->s_ref);
+       dout("mdsc put_session %p %d -> %d\n", s, refcnt, refcnt - 1);
        if (refcount_dec_and_test(&s->s_ref)) {
                if (s->s_auth.authorizer)
                        ceph_auth_destroy_authorizer(s->s_auth.authorizer);