[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Nbd] NBD blksize = 1024



Hi,

Way back in the mists of time
(http://repo.or.cz/davej-history.git?a=blame_incremental;hb=c5a4ebcd4431e607667b63c173d5918b518fe3b2;f=drivers%2Fblock%2Fnbd.c#l39
) the first two NBD devices were set to have a blksize of 1024 by
default.

This has slowly carried forward
(http://repo.or.cz/davej-history.git?a=blame_incremental;hb=2e59abdfb0c73ae04a9af8498935e37d064ab534;f=drivers%2Fblock%2Fnbd.c#l480
, https://github.com/torvalds/linux/blob/v4.3/drivers/block/nbd.c#L1086
,
https://github.com/torvalds/linux/blob/v4.7/drivers/block/nbd.c#L670) to
today. Negotiation
(https://github.com/yoe/nbd/blob/extension-info/doc/proto.md#block-size-constraints
) means this size can be changed but if the server doesn't say anything
that is presumably the block size that will end up being used.

However, while nbd_dev's blksize is set to 1024 the bdev's own block
size will presumably start out at something different (512?) and if the
server doesn't choose to negotiate a different size it will remain at
that size. Does anyone know why blksize was made to default to 1024 and
is that just for things like size calculations or does it impact the
minimum block size too?

The above questions came up because I was looking at the default discard
amount over in https://sourceforge.net/p/nbd/mailman/message/34730802/ .
According to
https://github.com/torvalds/linux/blob/v4.7/drivers/block/nbd.c#L1057
the discard granularity is always 512 whereas it might make more sense
for it be the minimum block size. Further, as an NBD block length can
never be more than 32 bits this means the maximum expressible discarded
amount is 2^32 bytes. Linux expresses the maximum discard length in
sectors so the previous number should be divided by the block size (but
which one?) to be a useful limit.

-- 
Sitsofe | http://sucs.org/~sits/



Reply to: