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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 net/ceph/osd_client.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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);
-- 
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



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux