diff mbox series

[v2,2/2] libceph: introudce a variable to avoid calling refcount_read() twice

Message ID 20180802133222.3692-2-cgxu519@gmx.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/2] ceph: introudce a variable to avoid calling atomic_read() twice | expand

Commit Message

Chengguang Xu Aug. 2, 2018, 1:32 p.m. UTC
Calling refcount_read() twice in a debug message may return different
value each time, so introduce a variable to avoid it.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 net/ceph/osd_client.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 8002b8e9ce24..ee8eb99a06ae 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1155,8 +1155,8 @@  static struct ceph_osd *create_osd(struct ceph_osd_client *osdc, int onum)
 static struct ceph_osd *get_osd(struct ceph_osd *osd)
 {
 	if (refcount_inc_not_zero(&osd->o_ref)) {
-		dout("get_osd %p %d -> %d\n", osd, refcount_read(&osd->o_ref)-1,
-		     refcount_read(&osd->o_ref));
+		unsigned int refcnt = refcount_read(&osd->o_ref);
+		dout("get_osd %p %d -> %d\n", osd, refcnt - 1, refcnt);
 		return osd;
 	} else {
 		dout("get_osd %p FAIL\n", osd);
@@ -1166,8 +1166,8 @@  static struct ceph_osd *get_osd(struct ceph_osd *osd)
 
 static void put_osd(struct ceph_osd *osd)
 {
-	dout("put_osd %p %d -> %d\n", osd, refcount_read(&osd->o_ref),
-	     refcount_read(&osd->o_ref) - 1);
+	unsigned int refcnt = refcount_read(&osd->o_ref);
+	dout("put_osd %p %d -> %d\n", osd, refcnt, refcnt - 1);
 	if (refcount_dec_and_test(&osd->o_ref)) {
 		osd_cleanup(osd);
 		kfree(osd);