[PATCH v2 1/2] ceph: introudce a variable to avoid calling atomic_read() twice

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

 



Calling atomic_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>
---
v1->v2:
- Keep atomic_t type as it is and only fix the problem of calling
atomic_read() twice in a debug message.

 fs/ceph/snap.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index 01b0144c0b73..4f8228e58d73 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -63,8 +63,8 @@
 void ceph_get_snap_realm(struct ceph_mds_client *mdsc,
 			 struct ceph_snap_realm *realm)
 {
-	dout("get_realm %p %d -> %d\n", realm,
-	     atomic_read(&realm->nref), atomic_read(&realm->nref)+1);
+	int nref = atomic_read(&realm->nref);
+	dout("get_realm %p %d -> %d\n", realm, nref, nref + 1);
 	/*
 	 * since we _only_ increment realm refs or empty the empty
 	 * list with snap_rwsem held, adjusting the empty list here is
@@ -193,8 +193,9 @@ static void __destroy_snap_realm(struct ceph_mds_client *mdsc,
 static void __put_snap_realm(struct ceph_mds_client *mdsc,
 			     struct ceph_snap_realm *realm)
 {
+	int nref = atomic_read(&realm->nref);
 	dout("__put_snap_realm %llx %p %d -> %d\n", realm->ino, realm,
-	     atomic_read(&realm->nref), atomic_read(&realm->nref)-1);
+		nref, nref - 1);
 	if (atomic_dec_and_test(&realm->nref))
 		__destroy_snap_realm(mdsc, realm);
 }
@@ -205,8 +206,9 @@ static void __put_snap_realm(struct ceph_mds_client *mdsc,
 void ceph_put_snap_realm(struct ceph_mds_client *mdsc,
 			 struct ceph_snap_realm *realm)
 {
+	int nref = atomic_read(&realm->nref);
 	dout("put_snap_realm %llx %p %d -> %d\n", realm->ino, realm,
-	     atomic_read(&realm->nref), atomic_read(&realm->nref)-1);
+		nref, nref - 1);
 	if (!atomic_dec_and_test(&realm->nref))
 		return;
 
-- 
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