From: Pavel Machek <pavel@suse.cz>
To: Paul Clements <paul.clements@steeleye.com>
Cc: kernel list <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>
Subject: Re: do not allow two nbd-clients at same time
Date: Tue, 13 Jan 2009 09:27:45 +0100 [thread overview]
Message-ID: <20090113082745.GA2098@elf.ucw.cz> (raw)
In-Reply-To: <496B4BBE.5040701@steeleye.com>
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@suse.cz>
Acked-by: Paul Clements <paul.clements@steeleye.com>
---
commit 831d1b7c7c5b16b1115d7e08ddf9038704653a03
tree 1ae30466acfb40b88cb7c20613f327c3871274ee
parent 66d8f12491f52e259e42148af099a3fc83425a7b
author Pavel <pavel@amd.ucw.cz> Tue, 13 Jan 2009 09:26:22 +0100
committer Pavel <pavel@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
prev parent reply other threads:[~2009-01-13 8:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-08 21:35 warn-on from nbd in 2.6.28-rc7 from sysfs_add_one() Pavel Machek
2008-12-08 22:58 ` Pavel Machek
2009-01-12 11:04 ` do not allow two nbd-clients at same time Pavel Machek
2009-01-12 13:55 ` Paul Clements
2009-01-13 8:27 ` Pavel Machek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090113082745.GA2098@elf.ucw.cz \
--to=pavel@suse.cz \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul.clements@steeleye.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox