From 05bf24212fa709c519e1bc95e9cdec91c06a1fee Mon Sep 17 00:00:00 2001 From: Chengguang Xu Date: Thu, 12 Jul 2018 16:35:32 +0800 Subject: [PATCH] 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" --- fs/ceph/mds_client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); -- 2.47.3