Messages in this thread Patch in this message | | | Date | Mon, 12 Jan 2009 12:04:00 +0100 | From | Pavel Machek <> | Subject | do not allow two nbd-clients at same time |
| |
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@suse.cz>
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 78e22d7..0da741e 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -413,6 +410,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; } @@ -627,5 +626,7 @@ static int nbd_ioctl(struct block_device 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
| |