From: Keith Busch Date: Wed, 12 Aug 2015 22:17:54 +0000 (-0600) Subject: NVMe: Set queue max segments X-Git-Tag: v4.1.12-92~126^2~244 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0981d848c3ca7969c2bd7cd39a0cf015d754247a;p=users%2Fjedix%2Flinux-maple.git NVMe: Set queue max segments This sets the queue's max segment size to match the device's capabilities. The default of 128 is usable until a device's transfer capability exceeds 512k, assuming a device page size of 4k. Many nvme devices exceed that transfer limit, so this lets the block layer know what kind of commands it to allow to form rather than unnecessarily split them. One additional segment is added to account for a transfer that may start in the middle of a page. Signed-off-by: Keith Busch Reviewed-by: Christoph Hellwig Signed-off-by: Jens Axboe (cherry picked from commit e824410ffcf4b245296b56c6fdf7b9797fce8c3e) Orabug: 22620486 Signed-off-by: Jason Luo --- diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index 2e3595ef22a85..64c6784f84ab9 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c @@ -2135,8 +2135,11 @@ static void nvme_alloc_ns(struct nvme_dev *dev, unsigned nsid) list_add_tail(&ns->list, &dev->namespaces); blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift); - if (dev->max_hw_sectors) + if (dev->max_hw_sectors) { blk_queue_max_hw_sectors(ns->queue, dev->max_hw_sectors); + blk_queue_max_segments(ns->queue, + ((dev->max_hw_sectors << 9) / dev->page_size) + 1); + } if (dev->stripe_size) blk_queue_chunk_sectors(ns->queue, dev->stripe_size >> 9); if (dev->vwc & NVME_CTRL_VWC_PRESENT)