@@ -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);
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> --- fs/ceph/mds_client.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)