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

Re: [Nbd] /sys/block/nbd*/queue/max_hw_sectors_kb low value



On Sun, Mar 03, 2013 at 04:14:26PM +0100, Michal Belczyk wrote:
> Hi there,
> 
> using vanilla nbd-kmod makes it currently impossible to raise
> max_sectors_kb for nbd devices as max_hw_sectors_kb is hardcoded to 127.
> The following change to nbd.c makes it possible to increase the value up
> to 32767, but also changes the default of max_sectors_kb to 512, which
> is the default for most of other block queues.
> Not only this helps to run fair performance comparisions agains raw disk
> devices, but make the default 4K aligned, which is a good thing IMHO...
> 
> @@ -856,6 +860,7 @@
>                 disk->queue->limits.discard_granularity = 512;
>                 disk->queue->limits.max_discard_sectors = UINT_MAX;
>                 disk->queue->limits.discard_zeroes_data = 0;
> +               blk_queue_max_hw_sectors(disk->queue, 65535);
>         }
>  
>         if (register_blkdev(NBD_MAJOR, "nbd")) {
> 
> Perhaps raising the max_hw_sectors_kb to this high value but setting the
> default for max_sectors_kb to 128 would be even better...

An updated version of the above patch follows:

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 7fecc78..5997a19 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -853,6 +853,8 @@ static int __init nbd_init(void)
                 * Tell the block layer that we are not a rotational device
                 */
                queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue);
+               blk_queue_max_hw_sectors(disk->queue, 65536);
+               disk->queue->limits.max_sectors = 256;
                disk->queue->limits.discard_granularity = 512;
                disk->queue->limits.max_discard_sectors = UINT_MAX;
                disk->queue->limits.discard_zeroes_data = 0;

This is much safer version -- it changes the default value of
/sys/block/nbd*/queue/max_sectors_kb from 127 to 128 KB making the
default maximum request size sent over the wire 4KB aligned and only
slightly larger which should not impact any existing NBD installation.
The previous version of this patch would drastically increase the total
queue length (default /sys/block/nbd*/queue/nr_requests is 128 times 2
[for both read and write requests] times 512KB which is a lot of
memory).  Still, with the above patch is now possible to adjust
max_sectors_kb to a larger value which is quite useful if one wants to
run fair benchmark against a physical disk which has a different block
queue characteristic.

Please do consider pushing this change upstream.
Thanks!

-- 
Michal Belczyk Sr.



Reply to: