nvme: fix handling single range discard request
authorMing Lei <ming.lei@redhat.com>
Fri, 3 Mar 2023 23:13:45 +0000 (07:13 +0800)
committerChristoph Hellwig <hch@lst.de>
Wed, 15 Mar 2023 13:58:51 +0000 (14:58 +0100)
commit37f0dc2ec78af0c3f35dd05578763de059f6fe77
tree62824802413e8c4bf0ac1330995636c2603c9e49
parent54686b611eb054a5c84976e6f6e03788fa8e6a38
nvme: fix handling single range discard request

When investigating one customer report on warning in nvme_setup_discard,
we observed the controller(nvme/tcp) actually exposes
queue_max_discard_segments(req->q) == 1.

Obviously the current code can't handle this situation, since contiguity
merge like normal RW request is taken.

Fix the issue by building range from request sector/nr_sectors directly.

Fixes: b35ba01ea697 ("nvme: support ranged discard requests")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/core.c