From: Benny Halevy <benny@tonian.com>
To: Jim Rees <rees@umich.edu>, Peng Tao <bergwolf@gmail.com>
Cc: linux-nfs@vger.kernel.org, Benny Halevy <bhalevy@tonian.com>
Subject: [PATCH 1/2] SQUASHME: pnfs: simplify and clean up pnfsiod workqueue
Date: Sun, 11 Sep 2011 08:31:40 -0700 [thread overview]
Message-ID: <1315755100-31204-1-git-send-email-benny@tonian.com> (raw)
In-Reply-To: <4E6CD076.6050607@tonian.com>
From: Benny Halevy <bhalevy@tonian.com>
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..0bed5fc 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.6
next prev parent reply other threads:[~2011-09-11 15:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-10 17:41 [PATCH 0/3] pnfs private workqueue, and two cleanups Jim Rees
2011-09-10 17:41 ` [PATCH 1/3] SUNRPC/NFS: make rpc pipe upcall generic Jim Rees
2011-09-10 17:41 ` [PATCH 2/3] pNFS: introduce pnfs private workqueue Jim Rees
2011-09-11 14:51 ` Benny Halevy
2011-09-11 15:15 ` Benny Halevy
2011-09-11 15:31 ` Benny Halevy [this message]
2011-09-11 17:17 ` [PATCH 1/2] SQUASHME: pnfs: simplify and clean up pnfsiod workqueue Jim Rees
2011-09-12 13:31 ` Benny Halevy
2011-09-11 15:31 ` [PATCH 2/2] SQUASHME: pnfs: do pnfsiod_start before registering layout drivers Benny Halevy
2011-09-10 17:41 ` [PATCH 3/3] pNFS: make _set_lo_fail generic Jim Rees
2011-09-11 16:01 ` [PATCH 0/3] pnfs private workqueue, and two cleanups Benny Halevy
2011-09-11 16:04 ` Benny Halevy
2011-09-11 17:21 ` 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=1315755100-31204-1-git-send-email-benny@tonian.com \
--to=benny@tonian.com \
--cc=bergwolf@gmail.com \
--cc=bhalevy@tonian.com \
--cc=linux-nfs@vger.kernel.org \
--cc=rees@umich.edu \
/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).