Package: nbd-server
Version: 1:2.9.11-2
Severity: normal
Steps to reproduce:
0) make sure /dev/md0 has size of 3000614518784 bytes
1) nbd-server 2000 /dev/md0
2) nc localhost 2000 | hexdump -C
Expected results:
2) netcat shows the NBD init packet, second row starts with
0x000002baa2900000 as this is the size of the device in hex.
Actual results:
2) netcat shows the NBD init packet, second row starts with
0x000000baa2900000 which is NOT the size of the block device.
00000000 4e 42 44 4d 41 47 49 43 00 00 42 02 81 86 12 53 |NBDMAGIC..B....S|
00000010 00 00 00 ba a2 90 00 00 00 00 00 01 00 00 00 00 |................|
It seems that nbd-server is for some reason zeroing the upper three
bytes of the size field and preventing the use of such large devices.
More info:
1) nbd-server logs
Jan 30 11:36:09 nbd_server[6740]: Size of exported file/device is 801591263232
which is 0x000000baa2900000 in hex and incorrect.
2) It seems that the kernel API returns 'unsigned long' count of
512-byte sectors. On this 32-bit system 'unsigned long' is 4 bytes so
this interface is not sufficient to support 3TB:
off_t size_autodetect(int fhandle) {
off_t es;
unsigned long sectors;
struct stat stat_buf;
int error;
#ifdef HAVE_SYS_MOUNT_H
#ifdef HAVE_SYS_IOCTL_H
#ifdef BLKGETSIZE
DEBUG("looking for export size with ioctl BLKGETSIZE\n");
if (!ioctl(fhandle, BLKGETSIZE, §ors) && sectors) {
es = (off_t)sectors * (off_t)512;
3) In addition, off_t is also only 4 bytes so even if I manually
specify the right size of the block device I still get wrong size back:
$ nbd-server 2000 /dev/md0 3000614518784
$ nc localhost 2000|hexdump -C
00000000 4e 42 44 4d 41 47 49 43 00 00 42 02 81 86 12 53 |NBDMAGIC..B....S|
00000010 00 00 00 ba a2 90 00 00 00 00 00 01 00 00 00 00 |................|
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]