
pavel at suse
Jan 13, 2009, 12:27 AM
Post #3 of 3
(129 views)
Permalink
|
|
Re: do not allow two nbd-clients at same time
[In reply to]
|
|
On Mon 2009-01-12 08:55:10, Paul Clements wrote: > Pavel Machek wrote: >> Two nbd-clients at same time are bad idea, and cause WARN_ON from nbd >> in 2.6.28-rc7 from sysfs_add_one. This simply prevents that from >> happening. > > Thanks for this. But I think we also need the following: > > --- drivers/block/nbd.c 2008-12-24 18:26:37.000000000 -0500 > +++ drivers/block/nbd.c 2009-01-12 08:50:17.000000000 -0500 > @@ -406,6 +406,7 @@ static int nbd_do_it(struct nbd_device * > ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, > &pid_attr.attr); > if (ret) { > printk(KERN_ERR "nbd: sysfs_create_file failed!"); > + lo->pid = 0; > return ret; > } > > Yep, thanks. > To zero out pid in the error case. Otherwise, it looks good. Ok, new patch below. Pavel --- Two nbd-clients at same time are bad idea, and cause WARN_ON from nbd in 2.6.28-rc7 from sysfs_add_one. This simply prevents that from happening. To reproduce: cat /dev/zero | head -c 10000000 > /tmp/delme.fstest.fs nbd-server 9100 -l /anyone.can.connect > /tmp/delme.fstest.fs & sleep 1 nbd-client localhost 9100 /dev/nd0 & nbd-client localhost 9100 /dev/nd0 & Signed-off-by: Pavel Machek <pavel[at]suse.cz> Acked-by: Paul Clements <paul.clements[at]steeleye.com> --- commit 831d1b7c7c5b16b1115d7e08ddf9038704653a03 tree 1ae30466acfb40b88cb7c20613f327c3871274ee parent 66d8f12491f52e259e42148af099a3fc83425a7b author Pavel <pavel[at]amd.ucw.cz> Tue, 13 Jan 2009 09:26:22 +0100 committer Pavel <pavel[at]amd.ucw.cz> Tue, 13 Jan 2009 09:26:22 +0100 drivers/block/nbd.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 670e89d..caf6458 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -406,6 +406,7 @@ static int nbd_do_it(struct nbd_device * ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr); if (ret) { printk(KERN_ERR "nbd: sysfs_create_file failed!"); + lo->pid = 0; return ret; } @@ -413,6 +414,7 @@ static int nbd_do_it(struct nbd_device * nbd_end_request(req); sysfs_remove_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr); + lo->pid = 0; return 0; } @@ -646,6 +648,8 @@ static int nbd_ioctl(struct block_device set_capacity(lo->disk, lo->bytesize >> 9); return 0; case NBD_DO_IT: + if (lo->pid) + return -EBUSY; if (!lo->file) return -EINVAL; thread = kthread_create(nbd_thread, lo, lo->disk->disk_name); -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo[at]vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|