From: Petr Vandrovec <vandrove@vc.cvut.cz>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org, pavel@atrey.karlin.mff.cuni.cz
Subject: [PATCH] nbd in 2.5.3 does not work, and can cause severe damage when read-write
Date: Thu, 31 Jan 2002 14:24:46 +0100 [thread overview]
Message-ID: <20020131132446.GA23990@vana.vc.cvut.cz> (raw)
Hi Linus,
I've got strange idea and tried to build diskless machine around
2.5.3... Besides problem with segfaulting crc32 (it is initialized after
net/ipv4/ipconfig.c due to lib/lib.a being a library... I had to hardcode
lib/crc32.o before --start-group in main Makefile, but it is another
story) there is bad problem with NBD caused by BIO changes:
(1) request flags were immediately put into on-wire request format.
In the past, we had 0=READ, !0=WRITE. Now only REQ_RW bit determines
direction. As nbd-server from nbd distribution package treats any
non-zero value as write, it performs writes instead of read. Fortunately
it will die due to other consistency checks on incoming request, but...
(2) nbd servers handle only up to 10240 byte requests. So setting max_sectors
to 20 is needed, as otherwise nbd server commits suicide. Maximum request size
should be handshaked during nbd initialization, but currently just use
hardwired 20 sectors, so it will behave like it did in the past.
Thanks,
Petr Vandrovec
vandrove@vc.cvut.cz
diff -urdN linux/drivers/block/nbd.c linux/drivers/block/nbd.c
--- linux/drivers/block/nbd.c Thu Jan 10 18:15:38 2002
+++ linux/drivers/block/nbd.c Thu Jan 31 00:24:50 2002
@@ -155,14 +155,15 @@
unsigned long size = req->nr_sectors << 9;
DEBUG("NBD: sending control, ");
+
+ rw = rq_data_dir(req);
+
request.magic = htonl(NBD_REQUEST_MAGIC);
- request.type = htonl(req->flags);
+ request.type = htonl((rw & WRITE) ? 1 : 0);
request.from = cpu_to_be64( (u64) req->sector << 9);
request.len = htonl(size);
memcpy(request.handle, &req, sizeof(req));
- rw = rq_data_dir(req);
-
result = nbd_xmit(1, sock, (char *) &request, sizeof(request), rw & WRITE ? MSG_MORE : 0);
if (result <= 0)
FAIL("Sendmsg failed for control.");
@@ -517,6 +518,7 @@
blksize_size[MAJOR_NR] = nbd_blksizes;
blk_size[MAJOR_NR] = nbd_sizes;
blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), do_nbd_request, &nbd_lock);
+ blk_queue_max_sectors(BLK_DEFAULT_QUEUE(MAJOR_NR), 20);
for (i = 0; i < MAX_NBD; i++) {
nbd_dev[i].refcnt = 0;
nbd_dev[i].file = NULL;
next reply other threads:[~2002-01-31 13:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-31 13:24 Petr Vandrovec [this message]
2002-01-31 18:47 ` crc32 and lib.a (was Re: [PATCH] nbd in 2.5.3 does not work, and can cause severe damage when read-write) Jeff Garzik
2002-01-31 21:21 ` [PATCH] nbd in 2.5.3 does not work, and can cause severe damage when read-write Pavel Machek
2002-02-01 14:40 ` Petr Vandrovec
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=20020131132446.GA23990@vana.vc.cvut.cz \
--to=vandrove@vc.cvut.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@atrey.karlin.mff.cuni.cz \
--cc=torvalds@transmeta.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
all inboxes | Powered by JetHome®