Bug #19871
closedrbd-nbd: kernel reported invalid device size (0, expected 1073741824)
0%
Description
before NBD_DO_IT, /sys/block/nbdX/size reports 0
so the check_device_size failed.
log:
rbd-nbd: kernel reported invalid device size (0, expected 1073741824)
rbd-nbd: failed to map, status: (22) Invalid argument
This failure depends on the kernel version. On kernel 4.4, it's ok. But on 4.9, which is the lts version and will shipped in next debian stable, /sys/block/nbdX/size will report 0 before you call NBD_DO_IT.
I haven't dig into kernel source. But after a quick search of the nbd module,
this line may be the reason:
http://elixir.free-electrons.com/linux/v4.9.18/source/drivers/block/nbd.c#L120
After look at the rbd-nbd.cc, I think there's no need to do the check, since
ioctl(nbd, NBD_SET_BLKSIZE, RBD_NBD_BLKSIZE) and ioctl(nbd, NBD_SET_SIZE, size)
all return ok.
But http://tracker.ceph.com/issues/18335 says the check is needed. So how can we handle it more correctly?