nvmet: cleanup nvmet_passthru_map_sg()
authorLogan Gunthorpe <logang@deltatee.com>
Fri, 16 Oct 2020 22:19:05 +0000 (16:19 -0600)
committerChristoph Hellwig <hch@lst.de>
Thu, 22 Oct 2020 13:28:02 +0000 (15:28 +0200)
commit5e063101ffacf7c14797f5185c58a967ca83c79f
tree9dd5d8300c7ec5af92fe15492027363d6ed7f370
parentdf06047d54276f73782c9d97882b305fca745d3f
nvmet: cleanup nvmet_passthru_map_sg()

Clean up some confusing elements of nvmet_passthru_map_sg() by returning
early if the request is greater than the maximum bio size. This allows
us to drop the sg_cnt variable.

This should not result in any functional change but makes the code
clearer and more understandable. The original code allocated a truncated
bio then would return EINVAL when bio_add_pc_page() filled that bio. The
new code just returns EINVAL early if this would happen.

Fixes: c1fef73f793b ("nvmet: add passthru code to process commands")
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Suggested-by: Douglas Gilbert <dgilbert@interlog.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/passthru.c