Skip to contentSkip to conversation

nvmet: Finish the blk plug when integrity allocation fails

PATCH Applied Guixin Liu 5 participants 5 messages Oct 28

Subsystems (2)
lore
Share & tools
lore

Guixin Liu

author
#0 lore raw

PATCH 1/1 nvmet: Finish the blk plug when integrity allocation fails

nvmet_bdev_execute_rw() starts a plug before building the bios, but the two error exits taken when nvmet_bdev_alloc_bip() fails return without calling blk_finish_plug(). current->plug is left pointing at the stack frame of the returned function, so the next blk_flush_plug() walks a stale list.

Route both failures through a common exit that finishes the plug.

Fixes c6e3f13398123 ("nvmet: add metadata support for block devices")
---
 drivers/nvme/target/io-cmd-bdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/target/io-cmd-bdev.c +3 -2
index f2d9e8901df4e..4b7483bc9cc31 100644
@@ -316,7 +316,7 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
 							  &prot_miter);
 				if (unlikely(rc)) {
 					bio_io_error(bio);
-					return;
+					goto out_plug;
 				}
 			}
 
@@ -336,11 +336,12 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
 		rc = nvmet_bdev_alloc_bip(req, bio, &prot_miter);
 		if (unlikely(rc)) {
 			bio_io_error(bio);
-			return;
+			goto out_plug;
 		}
 	}
 
 	submit_bio(bio);
+out_plug:
 	blk_finish_plug(&plug);
 }
 
Signature · 1 line
2.43.7
Reviewed-by on v1 1/1
#1 lore raw
Quoted 32 lines · Guixin Liu

nvmet_bdev_execute_rw() starts a plug before building the bios, but the two error exits taken when nvmet_bdev_alloc_bip() fails return without calling blk_finish_plug(). current->plug is left pointing at the stack frame of the returned function, so the next blk_flush_plug() walks a stale list.

Route both failures through a common exit that finishes the plug.

Fixes c6e3f13398123 ("nvmet: add metadata support for block devices")
---
  drivers/nvme/target/io-cmd-bdev.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvme/target/io-cmd-bdev.c +1 -1
index f2d9e8901df4e..4b7483bc9cc31 100644
@@ -316,7 +316,7 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
  							  &prot_miter);
  				if (unlikely(rc)) {
  					bio_io_error(bio);
-					return;
+					goto out_plug;
  				}
  			}
 
@@ -336,11 +336,12 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
  		rc = nvmet_bdev_alloc_bip(req, bio, &prot_miter);
  		if (unlikely(rc)) {
  			bio_io_error(bio);

drivers/nvme/target/io-cmd-bdev.c static void nvmet_bdev_execute_rw(struct nvmet_req *req) · line 347

Quoted 10 lines
drivers/nvme/target/io-cmd-bdev.c +2 -1
-			return;
+			goto out_plug;
  		}
  	}
 
  	submit_bio(bio);
+out_plug:
  	blk_finish_plug(&plug);
  }
 

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Reviewed-by on v1 1/1
#3 lore raw
In reply to Guixin Liu
Quoted 11 lines · Guixin Liu

nvmet_bdev_execute_rw() starts a plug before building the bios, but the two error exits taken when nvmet_bdev_alloc_bip() fails return without calling blk_finish_plug(). current->plug is left pointing at the stack frame of the returned function, so the next blk_flush_plug() walks a stale list.

Route both failures through a common exit that finishes the plug.

Fixes c6e3f13398123 ("nvmet: add metadata support for block devices")

Looks good to me:

maintainer Applied
#4 lore raw
In reply to Guixin Liu
Quoted 7 lines · Guixin Liu

nvmet_bdev_execute_rw() starts a plug before building the bios, but the two error exits taken when nvmet_bdev_alloc_bip() fails return without calling blk_finish_plug(). current->plug is left pointing at the stack frame of the returned function, so the next blk_flush_plug() walks a stale list.

Route both failures through a common exit that finishes the plug.

Thanks, applied to nvme-7.4.