diff options
author | Keith Busch <keith.busch@intel.com> | 2014-10-06 21:23:06 (GMT) |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-11-04 20:18:37 (GMT) |
commit | 9dbbfab7d54109626031bf3bc476fb1804113970 (patch) | |
tree | 49d5e8d5357dc0e77625f0632a91078e4ab67904 /drivers/block | |
parent | 9e60352cf83faaba57f99f6960b545687b8bbb20 (diff) | |
download | linux-9dbbfab7d54109626031bf3bc476fb1804113970.tar.xz |
NVMe: Do not over allocate for discard requests
Discard requests are often for very large ranges. The discard size is not
representative of the data transfer size so we don't need to allocate
for such a large prp list. This patch requests allocating only enough
for the memory needed for the data transfer and saves a little over 8k
of memory per max discard request.
Signed-off-by: Keith Busch <keith.busch@intel.com>
Reported-by: Paul Grabinar <paul.grabinar@ranbarg.com>
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/nvme-core.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index fb21d36..c70eff3 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c @@ -763,11 +763,13 @@ static int nvme_submit_bio_queue(struct nvme_queue *nvmeq, struct nvme_ns *ns, struct nvme_iod *iod; int psegs = bio_phys_segments(ns->queue, bio); int result; + unsigned size = !(bio->bi_rw & REQ_DISCARD) ? bio->bi_iter.bi_size : + sizeof(struct nvme_dsm_range); if ((bio->bi_rw & REQ_FLUSH) && psegs) return nvme_split_flush_data(nvmeq, bio); - iod = nvme_alloc_iod(psegs, bio->bi_iter.bi_size, ns->dev, GFP_ATOMIC); + iod = nvme_alloc_iod(psegs, size, ns->dev, GFP_ATOMIC); if (!iod) return -ENOMEM; |