From: Ed Cashin <ecashin@coraid.com>
To: akpm@linux-foundation.org
Cc: ecashin@coraid.com, linux-kernel@vger.kernel.org
Subject: [PATCH 4/9] aoe: support the forgetting (flushing) of a user-specified AoE target
Date: Wed, 17 Oct 2012 18:49:31 -0700 [thread overview]
Message-ID: <aa84749e245856ccac41c5ddea5db52fc6ac6ea1.1350524227.git.ecashin@coraid.com> (raw)
In-Reply-To: <cover.1350524227.git.ecashin@coraid.com>
Users sometimes want to cause the aoe driver to forget a
particular previously discovered device when it is no longer
online. The aoetools provide an "aoe-flush" command that users
run to perform this administrative task. The changes below
provide the support needed in the driver.
Signed-off-by: Ed Cashin <ecashin@coraid.com>
---
drivers/block/aoe/aoedev.c | 44 ++++++++++++++++++++++++++++++++++++++------
1 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 90e5b53..63b2660 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -241,6 +241,30 @@ aoedev_freedev(struct aoedev *d)
kfree(d);
}
+/* return whether the user asked for this particular
+ * device to be flushed
+ */
+static int
+user_req(char *s, size_t slen, struct aoedev *d)
+{
+ char *p;
+ size_t lim;
+
+ if (!d->gd)
+ return 0;
+ p = strrchr(d->gd->disk_name, '/');
+ if (!p)
+ p = d->gd->disk_name;
+ else
+ p += 1;
+ lim = sizeof(d->gd->disk_name);
+ lim -= p - d->gd->disk_name;
+ if (slen < lim)
+ lim = slen;
+
+ return !strncmp(s, p, lim);
+}
+
int
aoedev_flush(const char __user *str, size_t cnt)
{
@@ -249,6 +273,7 @@ aoedev_flush(const char __user *str, size_t cnt)
struct aoedev *rmd = NULL;
char buf[16];
int all = 0;
+ int specified = 0; /* flush a specific device */
if (cnt >= 3) {
if (cnt > sizeof buf)
@@ -256,26 +281,33 @@ aoedev_flush(const char __user *str, size_t cnt)
if (copy_from_user(buf, str, cnt))
return -EFAULT;
all = !strncmp(buf, "all", 3);
+ if (!all)
+ specified = 1;
}
spin_lock_irqsave(&devlist_lock, flags);
dd = &devlist;
while ((d = *dd)) {
spin_lock(&d->lock);
- if ((!all && (d->flags & DEVFL_UP))
+ if (specified) {
+ if (!user_req(buf, cnt, d))
+ goto skip;
+ } else if ((!all && (d->flags & DEVFL_UP))
|| (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE))
|| d->nopen
- || d->ref) {
- spin_unlock(&d->lock);
- dd = &d->next;
- continue;
- }
+ || d->ref)
+ goto skip;
+
*dd = d->next;
aoedev_downdev(d);
d->flags |= DEVFL_TKILL;
spin_unlock(&d->lock);
d->next = rmd;
rmd = d;
+ continue;
+skip:
+ spin_unlock(&d->lock);
+ dd = &d->next;
}
spin_unlock_irqrestore(&devlist_lock, flags);
while ((d = rmd)) {
--
1.7.1
next prev parent reply other threads:[~2012-10-18 1:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 1:43 [PATCH 0/9] aoe: various enhancements and cleanup from v50 to v60 Ed Cashin
2012-10-18 1:43 ` [PATCH 1/9] aoe: describe the behavior of the "err" character device Ed Cashin
2012-10-18 1:45 ` [PATCH 2/9] aoe: print warning regarding a common reason for dropped transmits Ed Cashin
2012-10-18 1:47 ` [PATCH 3/9] aoe: update cap on outstanding commands based on config query response Ed Cashin
2012-10-18 1:49 ` Ed Cashin [this message]
2012-10-18 1:51 ` [PATCH 5/9] aoe: support larger I/O requests via aoe_maxsectors module param Ed Cashin
2012-10-18 1:53 ` [PATCH 6/9] aoe: "payload" sysfs file exports per-AoE-command data transfer size Ed Cashin
2012-10-18 1:55 ` [PATCH 7/9] aoe: cleanup: remove unused ata_scnt function Ed Cashin
2012-10-18 1:57 ` [PATCH 8/9] aoe: whitespace cleanup Ed Cashin
2012-10-18 1:59 ` [PATCH 9/9] aoe: update driver-internal version number to 60 Ed Cashin
-- strict thread matches above, loose matches on Subject: below --
2012-10-16 1:40 [PATCH 0/9] aoe: various enhancements and cleanup from v50 to v60 Ed Cashin
2012-10-16 1:46 ` [PATCH 4/9] aoe: support the forgetting (flushing) of a user-specified AoE target Ed Cashin
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=aa84749e245856ccac41c5ddea5db52fc6ac6ea1.1350524227.git.ecashin@coraid.com \
--to=ecashin@coraid.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®