linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jim Rees <rees@umich.edu>
To: Benny Halevy <bhalevy@tonian.com>
Cc: linux-nfs@vger.kernel.org, peter honeyman <honey@citi.umich.edu>
Subject: [PATCH 3/3] SQUASHME: pnfs: simplify and clean up pnfsiod workqueue
Date: Mon, 19 Sep 2011 23:18:48 -0400	[thread overview]
Message-ID: <1316488728-24912-4-git-send-email-rees@umich.edu> (raw)
In-Reply-To: <1316488728-24912-1-git-send-email-rees@umich.edu>

From: Benny Halevy <bhalevy@tonian.com>

[whitespace]
Signed-off-by: Jim Rees <rees@umich.edu>
Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 fs/nfs/pnfs.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 5ac7a78..e38b91a 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -38,7 +38,7 @@
 /* Locking:
  *
  * pnfs_spinlock:
- *      protects pnfs_modules_tbl, pnfsiod_workqueue and pnfsiod_users.
+ *      protects pnfs_modules_tbl, pnfsiod_workqueue.
  */
 static DEFINE_SPINLOCK(pnfs_spinlock);
 
@@ -48,7 +48,7 @@ static DEFINE_SPINLOCK(pnfs_spinlock);
 static LIST_HEAD(pnfs_modules_tbl);
 
 static struct workqueue_struct *pnfsiod_workqueue;
-static int pnfsiod_users = 0;
+static atomic_t pnfsiod_users;
 
 /* Return the registered pnfs layout driver module matching given id */
 static struct pnfs_layoutdriver_type *
@@ -1488,18 +1488,22 @@ out:
 int pnfsiod_start(void)
 {
 	struct workqueue_struct *wq;
-	dprintk("RPC:       creating workqueue pnfsiod\n");
-	wq = alloc_workqueue("pnfsiod", WQ_MEM_RECLAIM, 0);
-	if (wq == NULL)
-		return -ENOMEM;
-	spin_lock(&pnfs_spinlock);
-	pnfsiod_users++;
+
+	dprintk("NFS:       creating workqueue pnfsiod\n");
+	atomic_inc(&pnfsiod_users);
 	if (pnfsiod_workqueue == NULL) {
-		pnfsiod_workqueue = wq;
-	} else {
-		destroy_workqueue(wq);
+		wq = alloc_workqueue("pnfsiod", WQ_MEM_RECLAIM, 0);
+		if (wq == NULL) {
+			pnfsiod_stop();
+			return -ENOMEM;
+		}
+		spin_lock(&pnfs_spinlock);
+		if (pnfsiod_workqueue == NULL)
+			pnfsiod_workqueue = wq;
+		else
+			destroy_workqueue(wq);
+		spin_unlock(&pnfs_spinlock);
 	}
-	spin_unlock(&pnfs_spinlock);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(pnfsiod_start);
@@ -1511,13 +1515,11 @@ void pnfsiod_stop(void)
 {
 	struct workqueue_struct *wq = NULL;
 
-	spin_lock(&pnfs_spinlock);
-	pnfsiod_users--;
-	if (pnfsiod_users == 0) {
+	if (atomic_dec_and_lock(&pnfsiod_users, &pnfs_spinlock)) {
 		wq = pnfsiod_workqueue;
 		pnfsiod_workqueue = NULL;
+		spin_unlock(&pnfs_spinlock);
 	}
-	spin_unlock(&pnfs_spinlock);
 	if (wq)
 		destroy_workqueue(wq);
 }
-- 
1.7.4.1


  parent reply	other threads:[~2011-09-20  3:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-20  3:18 [PATCH 0/3] replacement for "introduce pnfs private workqueue" Jim Rees
2011-09-20  3:18 ` [PATCH 1/3] pnfsblock: add missing rpc_put_mount and path_put Jim Rees
2011-09-20  3:18 ` [PATCH 2/3] pnfs: introduce pnfs private workqueue Jim Rees
2011-09-20 22:41   ` Trond Myklebust
2011-09-21  0:29     ` Jim Rees
2011-09-21  2:44       ` tao.peng
2011-09-21  4:20         ` Myklebust, Trond
2011-09-21  5:16           ` tao.peng
2011-09-21  7:04             ` Benny Halevy
2011-09-21 10:23               ` tao.peng
2011-09-21 10:38                 ` Boaz Harrosh
2011-09-21 11:04                   ` tao.peng
2011-09-21 10:56                 ` Benny Halevy
2011-09-21 11:10                   ` tao.peng
2011-09-21 11:27                     ` Benny Halevy
2011-09-21 11:42                       ` Boaz Harrosh
2011-09-21 11:50                         ` Benny Halevy
2011-09-21 13:56                           ` Boaz Harrosh
2011-09-21 15:45                             ` Peng Tao
2011-09-21 16:03                               ` Trond Myklebust
2011-09-22  3:30                                 ` tao.peng
2011-09-22  7:17                                 ` Boaz Harrosh
2011-09-21  4:22       ` Myklebust, Trond
2011-09-20  3:18 ` Jim Rees [this message]
2011-09-21 11:52 ` [PATCH 0/3] replacement for "introduce pnfs private workqueue" Benny Halevy
2011-09-21 12:32   ` Jim Rees

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=1316488728-24912-4-git-send-email-rees@umich.edu \
    --to=rees@umich.edu \
    --cc=bhalevy@tonian.com \
    --cc=honey@citi.umich.edu \
    --cc=linux-nfs@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).