diff options
| author | Peter Zijlstra <peterz@infradead.org> | 2016-11-14 11:29:48 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2017-01-14 05:37:18 -0500 |
| commit | 2c935bc57221cc2edc787c72ea0e2d30cdcd3d5e (patch) | |
| tree | 4ccb975ac9142887b4e7e7bf1c0cca5c53d4cf99 /drivers/block/rbd.c | |
| parent | 1e24edca0557dba6486d39d3c24c288475432bcf (diff) | |
locking/atomic, kref: Add kref_read()
Since we need to change the implementation, stop exposing internals.
Provide kref_read() to read the current reference count; typically
used for debug messages.
Kills two anti-patterns:
atomic_read(&kref->refcount)
kref->refcount.counter
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/block/rbd.c')
| -rw-r--r-- | drivers/block/rbd.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 36d2b9f4e836..436baa66f701 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
| @@ -1535,7 +1535,7 @@ static bool obj_request_overlaps_parent(struct rbd_obj_request *obj_request) | |||
| 1535 | static void rbd_obj_request_get(struct rbd_obj_request *obj_request) | 1535 | static void rbd_obj_request_get(struct rbd_obj_request *obj_request) |
| 1536 | { | 1536 | { |
| 1537 | dout("%s: obj %p (was %d)\n", __func__, obj_request, | 1537 | dout("%s: obj %p (was %d)\n", __func__, obj_request, |
| 1538 | atomic_read(&obj_request->kref.refcount)); | 1538 | kref_read(&obj_request->kref)); |
| 1539 | kref_get(&obj_request->kref); | 1539 | kref_get(&obj_request->kref); |
| 1540 | } | 1540 | } |
| 1541 | 1541 | ||
| @@ -1544,14 +1544,14 @@ static void rbd_obj_request_put(struct rbd_obj_request *obj_request) | |||
| 1544 | { | 1544 | { |
| 1545 | rbd_assert(obj_request != NULL); | 1545 | rbd_assert(obj_request != NULL); |
| 1546 | dout("%s: obj %p (was %d)\n", __func__, obj_request, | 1546 | dout("%s: obj %p (was %d)\n", __func__, obj_request, |
| 1547 | atomic_read(&obj_request->kref.refcount)); | 1547 | kref_read(&obj_request->kref)); |
| 1548 | kref_put(&obj_request->kref, rbd_obj_request_destroy); | 1548 | kref_put(&obj_request->kref, rbd_obj_request_destroy); |
| 1549 | } | 1549 | } |
| 1550 | 1550 | ||
| 1551 | static void rbd_img_request_get(struct rbd_img_request *img_request) | 1551 | static void rbd_img_request_get(struct rbd_img_request *img_request) |
| 1552 | { | 1552 | { |
| 1553 | dout("%s: img %p (was %d)\n", __func__, img_request, | 1553 | dout("%s: img %p (was %d)\n", __func__, img_request, |
| 1554 | atomic_read(&img_request->kref.refcount)); | 1554 | kref_read(&img_request->kref)); |
| 1555 | kref_get(&img_request->kref); | 1555 | kref_get(&img_request->kref); |
| 1556 | } | 1556 | } |
| 1557 | 1557 | ||
| @@ -1562,7 +1562,7 @@ static void rbd_img_request_put(struct rbd_img_request *img_request) | |||
| 1562 | { | 1562 | { |
| 1563 | rbd_assert(img_request != NULL); | 1563 | rbd_assert(img_request != NULL); |
| 1564 | dout("%s: img %p (was %d)\n", __func__, img_request, | 1564 | dout("%s: img %p (was %d)\n", __func__, img_request, |
| 1565 | atomic_read(&img_request->kref.refcount)); | 1565 | kref_read(&img_request->kref)); |
| 1566 | if (img_request_child_test(img_request)) | 1566 | if (img_request_child_test(img_request)) |
| 1567 | kref_put(&img_request->kref, rbd_parent_request_destroy); | 1567 | kref_put(&img_request->kref, rbd_parent_request_destroy); |
| 1568 | else | 1568 | else |
