Skip to content

Commit 262bf54

Browse files
ecashinLinus Torvalds
authored andcommitted
aoe: user can ask driver to forget previously detected devices
When an AoE device is detected, the kernel is informed, and a new block device is created. If the device is unused, the block device corresponding to remote device that is no longer available may be removed from the system by telling the aoe driver to "flush" its list of devices. Without this patch, software like GPFS and LVM may attempt to read from AoE devices that were discovered earlier but are no longer present, blocking until the I/O attempt times out. Signed-off-by: Ed L. Cashin <ecashin@coraid.com> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent cf446f0 commit 262bf54

5 files changed

Lines changed: 77 additions & 19 deletions

File tree

‎Documentation/aoe/mkdevs.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ rm -f $dir/interfaces
2929
mknod -m 0200 $dir/interfaces c $MAJOR 4
3030
rm -f $dir/revalidate
3131
mknod -m 0200 $dir/revalidate c $MAJOR 5
32+
rm -f $dir/flush
33+
mknod -m 0200 $dir/flush c $MAJOR 6
3234

3335
export n_partitions
3436
mkshelf=`echo $0 | sed 's!mkdevs!mkshelf!'`

‎Documentation/aoe/udev.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ SUBSYSTEM=="aoe", KERNEL=="discover", NAME="etherd/%k", GROUP="disk", MODE="0220
2020
SUBSYSTEM=="aoe", KERNEL=="err", NAME="etherd/%k", GROUP="disk", MODE="0440"
2121
SUBSYSTEM=="aoe", KERNEL=="interfaces", NAME="etherd/%k", GROUP="disk", MODE="0220"
2222
SUBSYSTEM=="aoe", KERNEL=="revalidate", NAME="etherd/%k", GROUP="disk", MODE="0220"
23+
SUBSYSTEM=="aoe", KERNEL=="flush", NAME="etherd/%k", GROUP="disk", MODE="0220"
2324

2425
# aoe block devices
2526
KERNEL=="etherd*", NAME="%k", GROUP="disk"

‎drivers/block/aoe/aoe.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ struct aoedev *aoedev_by_aoeaddr(int maj, int min);
191191
struct aoedev *aoedev_by_sysminor_m(ulong sysminor);
192192
void aoedev_downdev(struct aoedev *d);
193193
int aoedev_isbusy(struct aoedev *d);
194+
int aoedev_flush(const char __user *str, size_t size);
194195

195196
int aoenet_init(void);
196197
void aoenet_exit(void);

‎drivers/block/aoe/aoechr.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ enum {
1515
MINOR_DISCOVER,
1616
MINOR_INTERFACES,
1717
MINOR_REVALIDATE,
18+
MINOR_FLUSH,
1819
MSGSZ = 2048,
1920
NMSG = 100, /* message backlog to retain */
2021
};
@@ -43,6 +44,7 @@ static struct aoe_chardev chardevs[] = {
4344
{ MINOR_DISCOVER, "discover" },
4445
{ MINOR_INTERFACES, "interfaces" },
4546
{ MINOR_REVALIDATE, "revalidate" },
47+
{ MINOR_FLUSH, "flush" },
4648
};
4749

4850
static int
@@ -158,6 +160,9 @@ aoechr_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offp
158160
break;
159161
case MINOR_REVALIDATE:
160162
ret = revalidate(buf, cnt);
163+
break;
164+
case MINOR_FLUSH:
165+
ret = aoedev_flush(buf, cnt);
161166
}
162167
if (ret == 0)
163168
ret = cnt;

‎drivers/block/aoe/aoedev.c‎

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include <linux/netdevice.h>
1010
#include "aoe.h"
1111

12+
static void dummy_timer(ulong);
13+
static void aoedev_freedev(struct aoedev *);
14+
static void freetgt(struct aoetgt *t);
15+
1216
static struct aoedev *devlist;
1317
static spinlock_t devlist_lock;
1418

@@ -108,6 +112,70 @@ aoedev_downdev(struct aoedev *d)
108112
d->flags &= ~DEVFL_UP;
109113
}
110114

115+
static void
116+
aoedev_freedev(struct aoedev *d)
117+
{
118+
struct aoetgt **t, **e;
119+
120+
if (d->gd) {
121+
aoedisk_rm_sysfs(d);
122+
del_gendisk(d->gd);
123+
put_disk(d->gd);
124+
}
125+
t = d->targets;
126+
e = t + NTARGETS;
127+
for (; t < e && *t; t++)
128+
freetgt(*t);
129+
if (d->bufpool)
130+
mempool_destroy(d->bufpool);
131+
kfree(d);
132+
}
133+
134+
int
135+
aoedev_flush(const char __user *str, size_t cnt)
136+
{
137+
ulong flags;
138+
struct aoedev *d, **dd;
139+
struct aoedev *rmd = NULL;
140+
char buf[16];
141+
int all = 0;
142+
143+
if (cnt >= 3) {
144+
if (cnt > sizeof buf)
145+
cnt = sizeof buf;
146+
if (copy_from_user(buf, str, cnt))
147+
return -EFAULT;
148+
all = !strncmp(buf, "all", 3);
149+
}
150+
151+
flush_scheduled_work();
152+
spin_lock_irqsave(&devlist_lock, flags);
153+
dd = &devlist;
154+
while ((d = *dd)) {
155+
spin_lock(&d->lock);
156+
if ((!all && (d->flags & DEVFL_UP))
157+
|| (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE))
158+
|| d->nopen) {
159+
spin_unlock(&d->lock);
160+
dd = &d->next;
161+
continue;
162+
}
163+
*dd = d->next;
164+
aoedev_downdev(d);
165+
d->flags |= DEVFL_TKILL;
166+
spin_unlock(&d->lock);
167+
d->next = rmd;
168+
rmd = d;
169+
}
170+
spin_unlock_irqrestore(&devlist_lock, flags);
171+
while ((d = rmd)) {
172+
rmd = d->next;
173+
del_timer_sync(&d->timer);
174+
aoedev_freedev(d); /* must be able to sleep */
175+
}
176+
return 0;
177+
}
178+
111179
/* find it or malloc it */
112180
struct aoedev *
113181
aoedev_by_sysminor_m(ulong sysminor)
@@ -161,25 +229,6 @@ freetgt(struct aoetgt *t)
161229
kfree(t);
162230
}
163231

164-
static void
165-
aoedev_freedev(struct aoedev *d)
166-
{
167-
struct aoetgt **t, **e;
168-
169-
if (d->gd) {
170-
aoedisk_rm_sysfs(d);
171-
del_gendisk(d->gd);
172-
put_disk(d->gd);
173-
}
174-
t = d->targets;
175-
e = t + NTARGETS;
176-
for (; t < e && *t; t++)
177-
freetgt(*t);
178-
if (d->bufpool)
179-
mempool_destroy(d->bufpool);
180-
kfree(d);
181-
}
182-
183232
void
184233
aoedev_exit(void)
185234
{

0 commit comments

Comments
 (0)