[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090112110322.GA2001@elf.ucw.cz>
Date: Mon, 12 Jan 2009 12:04:00 +0100
From: Pavel Machek <pavel@...e.cz>
To: kernel list <linux-kernel@...r.kernel.org>,
Paul.Clements@...eleye.com, Andrew Morton <akpm@...l.org>
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@...e.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists