Calling refcount_read() twice may return different value each time, so introduce a variable to avoid it. Signed-off-by: Chengguang Xu <cgxu519@xxxxxxx> --- Sorry, I just wrote wrong email address in previous sending, so resend it. If you have received previous email please ignore it, thanks. fs/ceph/mds_client.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index df0a3bb0f6a5..2a8d4cc69eb6 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -399,9 +399,10 @@ const char *ceph_session_state_name(int s) static struct ceph_mds_session *get_session(struct ceph_mds_session *s) { + unsigned int refcnt = refcount_read(&s->s_ref); + 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)); + dout("mdsc get_session %p %d -> %d\n", s, refcnt - 1, refcnt); return s; } else { dout("mdsc get_session %p 0 -- FAIL\n", s); @@ -411,8 +412,9 @@ 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.17.1 -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html