All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 21/21] lustre: make exp_refcount in obd_export a refcount_t
Date: Thu, 07 Feb 2019 11:03:33 +1100	[thread overview]
Message-ID: <154949781349.10620.3269248433038576631.stgit@noble.brown> (raw)
In-Reply-To: <154949776249.10620.1215070753973826063.stgit@noble.brown>

As this is used as a refcount, it should be declared
as one.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lustre/include/lustre_export.h  |    2 +-
 drivers/staging/lustre/lustre/ldlm/ldlm_lock.c     |   10 +++++-----
 drivers/staging/lustre/lustre/obdclass/genops.c    |   15 ++++++++-------
 .../staging/lustre/lustre/obdecho/echo_client.c    |    2 +-
 drivers/staging/lustre/lustre/ptlrpc/service.c     |    4 ++--
 5 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h
index 63fa656eb7ba..fb34e0b7de35 100644
--- a/drivers/staging/lustre/lustre/include/lustre_export.h
+++ b/drivers/staging/lustre/lustre/include/lustre_export.h
@@ -67,7 +67,7 @@ struct obd_export {
 	 * what export they are talking to.
 	 */
 	struct portals_handle		exp_handle;
-	atomic_t			exp_refcount;
+	refcount_t			exp_refcount;
 	/**
 	 * Set of counters below is to track where export references are
 	 * kept. The exp_rpc_count is used for reconnect handling also,
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index cea0e22d064b..f2433dc0e558 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -1998,7 +1998,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				   ldlm_lockname[lock->l_req_mode],
 				   lock->l_flags, nid,
 				   lock->l_remote_handle.cookie,
-				   exp ? atomic_read(&exp->exp_refcount) : -99,
+				   exp ? refcount_read(&exp->exp_refcount) : -99,
 				   lock->l_pid, lock->l_callback_timeout,
 				   lock->l_lvb_type);
 		va_end(args);
@@ -2024,7 +2024,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				   lock->l_req_extent.end,
 				   lock->l_flags, nid,
 				   lock->l_remote_handle.cookie,
-				   exp ? atomic_read(&exp->exp_refcount) : -99,
+				   exp ? refcount_read(&exp->exp_refcount) : -99,
 				   lock->l_pid, lock->l_callback_timeout,
 				   lock->l_lvb_type);
 		break;
@@ -2046,7 +2046,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				   lock->l_policy_data.l_flock.end,
 				   lock->l_flags, nid,
 				   lock->l_remote_handle.cookie,
-				   exp ? atomic_read(&exp->exp_refcount) : -99,
+				   exp ? refcount_read(&exp->exp_refcount) : -99,
 				   lock->l_pid, lock->l_callback_timeout);
 		break;
 
@@ -2065,7 +2065,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				   ldlm_typename[resource->lr_type],
 				   lock->l_flags, nid,
 				   lock->l_remote_handle.cookie,
-				   exp ? atomic_read(&exp->exp_refcount) : -99,
+				   exp ? refcount_read(&exp->exp_refcount) : -99,
 				   lock->l_pid, lock->l_callback_timeout,
 				   lock->l_lvb_type);
 		break;
@@ -2084,7 +2084,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock,
 				   ldlm_typename[resource->lr_type],
 				   lock->l_flags, nid,
 				   lock->l_remote_handle.cookie,
-				   exp ? atomic_read(&exp->exp_refcount) : -99,
+				   exp ? refcount_read(&exp->exp_refcount) : -99,
 				   lock->l_pid, lock->l_callback_timeout,
 				   lock->l_lvb_type);
 		break;
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index dad21d9fa328..39919f1c5b71 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -757,7 +757,7 @@ static void class_export_destroy(struct obd_export *exp)
 {
 	struct obd_device *obd = exp->exp_obd;
 
-	LASSERT_ATOMIC_ZERO(&exp->exp_refcount);
+	LASSERT(refcount_read(&exp->exp_refcount) == 0);
 	LASSERT(obd);
 
 	CDEBUG(D_IOCTL, "destroying export %p/%s for %s\n", exp,
@@ -793,20 +793,21 @@ static struct portals_handle_ops export_handle_ops = {
 
 struct obd_export *class_export_get(struct obd_export *exp)
 {
-	atomic_inc(&exp->exp_refcount);
+	refcount_inc(&exp->exp_refcount);
 	CDEBUG(D_INFO, "GETting export %p : new refcount %d\n", exp,
-	       atomic_read(&exp->exp_refcount));
+	       refcount_read(&exp->exp_refcount));
 	return exp;
 }
 EXPORT_SYMBOL(class_export_get);
 
 void class_export_put(struct obd_export *exp)
 {
-	LASSERT_ATOMIC_GT_LT(&exp->exp_refcount, 0, LI_POISON);
+	LASSERT(refcount_read(&exp->exp_refcount) >  0);
+	LASSERT(refcount_read(&exp->exp_refcount) < LI_POISON);
 	CDEBUG(D_INFO, "PUTting export %p : new refcount %d\n", exp,
-	       atomic_read(&exp->exp_refcount) - 1);
+	       refcount_read(&exp->exp_refcount) - 1);
 
-	if (atomic_dec_and_test(&exp->exp_refcount)) {
+	if (refcount_dec_and_test(&exp->exp_refcount)) {
 		struct obd_device *obd = exp->exp_obd;
 
 		CDEBUG(D_IOCTL, "final put %p/%s\n",
@@ -856,7 +857,7 @@ static struct obd_export *__class_new_export(struct obd_device *obd,
 
 	export->exp_conn_cnt = 0;
 	/* 2 = class_handle_hash + last */
-	atomic_set(&export->exp_refcount, 2);
+	refcount_set(&export->exp_refcount, 2);
 	atomic_set(&export->exp_rpc_count, 0);
 	atomic_set(&export->exp_cb_count, 0);
 	atomic_set(&export->exp_locks_count, 0);
diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index 1b7d98c649b6..317123fd27cb 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -1638,7 +1638,7 @@ static int echo_client_cleanup(struct obd_device *obddev)
 		return -EBUSY;
 	}
 
-	LASSERT(atomic_read(&ec->ec_exp->exp_refcount) > 0);
+	LASSERT(refcount_read(&ec->ec_exp->exp_refcount) > 0);
 	rc = obd_disconnect(ec->ec_exp);
 	if (rc != 0)
 		CERROR("fail to disconnect device: %d\n", rc);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index 35a59e5a5e9d..b7d44fc21d73 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -1697,7 +1697,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt,
 	       (request->rq_export ?
 		(char *)request->rq_export->exp_client_uuid.uuid : "0"),
 	       (request->rq_export ?
-		atomic_read(&request->rq_export->exp_refcount) : -99),
+		refcount_read(&request->rq_export->exp_refcount) : -99),
 	       lustre_msg_get_status(request->rq_reqmsg), request->rq_xid,
 	       libcfs_id2str(request->rq_peer),
 	       lustre_msg_get_opc(request->rq_reqmsg));
@@ -1741,7 +1741,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt,
 	       (request->rq_export ?
 		(char *)request->rq_export->exp_client_uuid.uuid : "0"),
 	       (request->rq_export ?
-		atomic_read(&request->rq_export->exp_refcount) : -99),
+		refcount_read(&request->rq_export->exp_refcount) : -99),
 	       lustre_msg_get_status(request->rq_reqmsg),
 	       request->rq_xid,
 	       libcfs_id2str(request->rq_peer),

  parent reply	other threads:[~2019-02-07  0:03 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-07  0:03 [lustre-devel] [PATCH 00/21] lustre: Assorted cleanups for obdclass NeilBrown
2019-02-07  0:03 ` [lustre-devel] [PATCH 02/21] lustre: obd_class: remove csi_barrier from struct cl_sync_io NeilBrown
2019-02-08  0:09   ` Andreas Dilger
2019-02-11  0:24     ` NeilBrown
2019-02-11  0:34   ` James Simmons
2019-02-11  1:09     ` NeilBrown
2019-02-07  0:03 ` [lustre-devel] [PATCH 05/21] lustre: use list_first_entry() in lustre subdirectory NeilBrown
2019-02-08  0:31   ` Andreas Dilger
2019-02-11  0:13     ` NeilBrown
2019-02-11  1:45   ` James Simmons
2019-02-11  3:08     ` NeilBrown
2019-02-07  0:03 ` [lustre-devel] [PATCH 03/21] lustre: obdclass: use list_sort() to sort a list NeilBrown
2019-02-08  0:13   ` Andreas Dilger
2019-02-11  0:39   ` James Simmons
2019-02-11  1:05     ` NeilBrown
2019-02-07  0:03 ` [lustre-devel] [PATCH 06/21] lustre: use list_first_entry() in lnet/lnet subdirectory NeilBrown
2019-02-08  0:44   ` Andreas Dilger
2019-02-11  1:46   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 01/21] lustre: obdclass: discard csi_end_io NeilBrown
2019-02-07  0:20   ` Andreas Dilger
2019-02-11  0:19   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 04/21] lustre: use list*entry macros in place of container_of() NeilBrown
2019-02-08  0:25   ` Andreas Dilger
2019-02-11  1:32   ` James Simmons
2019-02-11  3:14     ` NeilBrown
2019-02-07  0:03 ` [lustre-devel] [PATCH 13/21] lustre: make cp_ref in cl_page a refcount_t NeilBrown
2019-02-08  5:45   ` Andreas Dilger
2019-02-11  4:00   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 14/21] lustre: make ccc_users in cl_client_cache " NeilBrown
2019-02-08  5:46   ` Andreas Dilger
2019-02-11  4:01   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 08/21] lustre: use list_first_entry() throughout NeilBrown
2019-02-08  1:06   ` Andreas Dilger
2019-02-11  1:48   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 20/21] lustre: obdclass: fix module load locking NeilBrown
2019-02-13  1:53   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 17/21] lustre: obdclass: result of try_module_get() should not be ignored NeilBrown
2019-02-08  5:58   ` Andreas Dilger
2019-02-11  4:22   ` James Simmons
2019-02-11  5:01     ` NeilBrown
2019-02-11  5:09       ` [lustre-devel] [PATCH] lustre: don't manage module refs in obd_class_open/close NeilBrown
2019-02-12  4:17         ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 19/21] lustre: obdclass: avoid races in class_register_type() NeilBrown
2019-02-08  6:41   ` Andreas Dilger
2019-02-11  0:58     ` NeilBrown
2019-02-12  5:03   ` James Simmons
2019-02-14  3:43     ` NeilBrown
2019-02-07  0:03 ` [lustre-devel] [PATCH 11/21] lustre: cl_object: remove vestigial debugging NeilBrown
2019-02-08  1:31   ` Andreas Dilger
2019-02-11  0:48     ` NeilBrown
2019-02-11  2:04   ` James Simmons
2019-02-11  3:25     ` NeilBrown
2019-02-12  5:19       ` James Simmons
2019-02-12 13:56         ` Patrick Farrell
2019-02-12 22:12         ` NeilBrown
2019-02-13  0:19           ` James Simmons
2019-02-13  0:29             ` NeilBrown
2019-02-07  0:03 ` NeilBrown [this message]
2019-02-08  7:07   ` [lustre-devel] [PATCH 21/21] lustre: make exp_refcount in obd_export a refcount_t Andreas Dilger
2019-02-11  4:18   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 10/21] lustre: obdclass: use cl_object_for_each where appropriate NeilBrown
2019-02-08  1:10   ` Andreas Dilger
2019-02-11  0:42     ` NeilBrown
2019-02-11  4:19       ` James Simmons
2019-02-15 18:15       ` Andreas Dilger
2019-02-11  1:57   ` James Simmons
2019-02-11  3:19     ` NeilBrown
2019-02-07  0:03 ` [lustre-devel] [PATCH 18/21] lustre: move debug.c from obdclass to obdecho NeilBrown
2019-02-08  6:02   ` Andreas Dilger
2019-02-11  4:17   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 09/21] lustre: use list_last_entry() throughout NeilBrown
2019-02-08  1:07   ` Andreas Dilger
2019-02-11  1:48   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 07/21] lustre: use list_first_entry() in lnet/klnds subdirectory NeilBrown
2019-02-08  0:59   ` Andreas Dilger
2019-02-11  0:34     ` NeilBrown
2019-02-11  1:47   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 16/21] lustre: obdclass: normalize a switch statement NeilBrown
2019-02-08  5:57   ` Andreas Dilger
2019-02-11  4:03   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 12/21] lustre: cl_page.c: remove PINVRNT() NeilBrown
2019-02-08  5:43   ` Andreas Dilger
2019-02-11  4:01   ` James Simmons
2019-02-07  0:03 ` [lustre-devel] [PATCH 15/21] lustre: obdclass: char obd_ioctl_getdata type NeilBrown
2019-02-08  5:56   ` Andreas Dilger
2019-02-11  0:52     ` NeilBrown
2019-02-11  4:03   ` James Simmons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=154949781349.10620.3269248433038576631.stgit@noble.brown \
    --to=neilb@suse.com \
    --cc=lustre-devel@lists.lustre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.