Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 346468
b: refs/heads/master
c: 4ba9aa7
h: refs/heads/master
v: v3
  • Loading branch information
Ed Cashin authored and Linus Torvalds committed Dec 18, 2012
1 parent c2ce69d commit f0179c8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1b8a1636ceea573b1d452a1cccf01c990d8d628a
refs/heads/master: 4ba9aa7f9819bafb304f09dee90bb1fa40627358
44 changes: 38 additions & 6 deletions trunk/drivers/block/aoe/aoedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -249,33 +273,41 @@ 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)
cnt = sizeof buf;
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)) {
Expand Down

0 comments on commit f0179c8

Please sign in to comment.