From: Pankaj Gupta <pankaj.gu...@ionos.com>

Return from "pmem_submit_bio" when asynchronous flush is in
process in other context.

Signed-off-by: Pankaj Gupta <pankaj.gu...@ionos.com>
---
 drivers/nvdimm/pmem.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 1e0615b8565e..3ca1fa88a5e7 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -201,8 +201,13 @@ static blk_qc_t pmem_submit_bio(struct bio *bio)
        struct pmem_device *pmem = bio->bi_bdev->bd_disk->private_data;
        struct nd_region *nd_region = to_region(pmem);
 
-       if (bio->bi_opf & REQ_PREFLUSH)
-               ret = nvdimm_flush(nd_region, bio);
+       if ((bio->bi_opf & REQ_PREFLUSH) &&
+               nvdimm_flush(nd_region, bio)) {
+
+               /* asynchronous flush completes in other context */
+               if (nd_region->flush)
+                       return BLK_QC_T_NONE;
+       }
 
        do_acct = blk_queue_io_stat(bio->bi_bdev->bd_disk->queue);
        if (do_acct)
@@ -222,11 +227,13 @@ static blk_qc_t pmem_submit_bio(struct bio *bio)
        if (do_acct)
                bio_end_io_acct(bio, start);
 
-       if (bio->bi_opf & REQ_FUA)
+       if (bio->bi_opf & REQ_FUA)  {
                ret = nvdimm_flush(nd_region, bio);
 
-       if (ret)
-               bio->bi_status = errno_to_blk_status(ret);
+               /* asynchronous flush completes in other context */
+               if (nd_region->flush)
+                       return BLK_QC_T_NONE;
+       }
 
        bio_endio(bio);
        return BLK_QC_T_NONE;
-- 
2.25.1


Reply via email to