]> git.baikalelectronics.ru Git - kernel.git/commitdiff
nvmet: avoid unnecessary flush bio
authorGuixin Liu <kanie@linux.alibaba.com>
Fri, 29 Jul 2022 03:53:05 +0000 (11:53 +0800)
committerChristoph Hellwig <hch@lst.de>
Mon, 19 Sep 2022 09:33:54 +0000 (11:33 +0200)
For no volatile write cache block device backend, sending flush bio is
unnecessary, avoid to do that.

Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/io-cmd-bdev.c

index 2dc1c1035626b2330b799106527a3c323e7956f1..8d527a8c0f5428c5694ab644fa8a8f9a57319328 100644 (file)
@@ -334,6 +334,11 @@ static void nvmet_bdev_execute_flush(struct nvmet_req *req)
 {
        struct bio *bio = &req->b.inline_bio;
 
+       if (!bdev_write_cache(req->ns->bdev)) {
+               nvmet_req_complete(req, NVME_SC_SUCCESS);
+               return;
+       }
+
        if (!nvmet_check_transfer_len(req, 0))
                return;
 
@@ -347,6 +352,9 @@ static void nvmet_bdev_execute_flush(struct nvmet_req *req)
 
 u16 nvmet_bdev_flush(struct nvmet_req *req)
 {
+       if (!bdev_write_cache(req->ns->bdev))
+               return 0;
+
        if (blkdev_issue_flush(req->ns->bdev))
                return NVME_SC_INTERNAL | NVME_SC_DNR;
        return 0;