From: Chengguang Xu Date: Thu, 12 Jul 2018 08:35:32 +0000 (+0800) Subject: ceph: introudce a variable to avoid calling refcount_read() twice X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=05bf24212fa709c519e1bc95e9cdec91c06a1fee;p=ceph-client.git ceph: introudce a variable to avoid calling refcount_read() twice Calling refcount_read() twice may return different value each time, so introduce a variable to avoid it. Signed-off-by: Chengguang Xu Reviewed-by: "Yan, Zheng" --- diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 03697aefa273..0d7afabb1f49 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -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);