Linux kernel NBD sector size (1K) has peculiar effects
Let's say you have an NBD exported disk which contains an MBR
partition:
# nbd-client localhost /dev/nbd0
Warning: the oldstyle protocol is no longer supported.
This method now uses the newstyle protocol with a default export
Negotiation: ..size = 10240MB
Connected /dev/nbd0
On creating /dev/nbd0 the kernel complains:
[ 3083.308232] nbd0: p1 size 41938944 extends beyond EOD, truncated
and fdisk shows:
# fdisk -l /dev/nbd0
Disk /dev/nbd0: 10 GiB, 10737418240 bytes, 10485760 sectors
Units: sectors of 1 * 1024 = 1024 bytes
Sector size (logical/physical): 1024 bytes / 1024 bytes
I/O size (minimum/optimal): 1024 bytes / 1024 bytes
Disklabel type: dos
Disk identifier: 0x000127ae
Device Boot Start End Sectors Size Id Type
/dev/nbd0p1 2048 20971519 20969472 20G 83 Linux
I think what's happening here is that because the Linux kernel NBD
driver uses the odd 1K sector size, and because MBR partitions use
sector numbers throughout, everything is getting doubled.
Suggested (and completely *untested*) fix would be:
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 3fb95c8d9fd8..cf5b37b7cdd6 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1317,7 +1317,7 @@ static struct nbd_config *nbd_alloc_config(void)
atomic_set(&config->recv_threads, 0);
init_waitqueue_head(&config->recv_wq);
init_waitqueue_head(&config->conn_wait);
- config->blksize = 1024;
+ config->blksize = 512;
atomic_set(&config->live_connections, 0);
try_module_get(THIS_MODULE);
return config;
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
Reply to: