diff mbox

[5/6] block: Introduce BLKPREP_DONE

Message ID 1468934439-93579-6-git-send-email-hare@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Hannes Reinecke July 19, 2016, 1:20 p.m. UTC
Add a new blkprep return code BLKPREP_DONE to signal completion
without I/O error.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 block/blk-core.c        | 6 +++++-
 drivers/scsi/scsi_lib.c | 1 +
 include/linux/blkdev.h  | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

Comments

Damien Le Moal July 20, 2016, 1:10 a.m. UTC | #1
On 7/19/16 22:20, Hannes Reinecke wrote:
> Add a new blkprep return code BLKPREP_DONE to signal completion
> without I/O error.
>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
>  block/blk-core.c        | 6 +++++-
>  drivers/scsi/scsi_lib.c | 1 +
>  include/linux/blkdev.h  | 1 +
>  3 files changed, 7 insertions(+), 1 deletion(-)

Reviewed-by: Damien Le Moal <damien.lemoal@hgst.com>
Tested-by: Damien Le Moal <damien.lemoal@hgst.com>
Christoph Hellwig July 21, 2016, 5:58 a.m. UTC | #2
> +++ b/block/blk-core.c
> @@ -2462,9 +2462,13 @@ struct request *blk_peek_request(struct request_queue *q)
>  
>  			rq = NULL;
>  			break;
> -		} else if (ret == BLKPREP_KILL || ret == BLKPREP_INVALID) {
> +		} else if (ret == BLKPREP_KILL || ret == BLKPREP_INVALID ||
> +			   ret == BLKPREP_DONE) {
>  			int err = (ret == BLKPREP_INVALID) ? -EREMOTEIO : -EIO;
>  
> +			if (ret == BLKPREP_DONE)
> +				err = 0;
> +

Please just use a proper switch statement for the return values.

static void blk_prep_end_request(struct request *req, int error)
{
	rq->cmd_flags |= REQ_QUIET;
	blk_start_request(rq);
	__blk_end_request_all(rq, error);
}

struct request *blk_peek_request(struct request_queue *q)
{

	...


	switch (ret) {
	...
	case BLKPREP_KILL:
		blk_prep_end_request(rq, -EIO);
		break;
	case BLKPREP_INVALID:
		blk_prep_end_request(rq, -EREMOTEIO);
		break;
	case BLKPREP_DONE:
		blk_prep_end_request(rq, 0);
		break;
	...
}
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hannes Reinecke July 21, 2016, 6:01 a.m. UTC | #3
On 07/21/2016 07:58 AM, Christoph Hellwig wrote:
>> +++ b/block/blk-core.c
>> @@ -2462,9 +2462,13 @@ struct request *blk_peek_request(struct request_queue *q)
>>  
>>  			rq = NULL;
>>  			break;
>> -		} else if (ret == BLKPREP_KILL || ret == BLKPREP_INVALID) {
>> +		} else if (ret == BLKPREP_KILL || ret == BLKPREP_INVALID ||
>> +			   ret == BLKPREP_DONE) {
>>  			int err = (ret == BLKPREP_INVALID) ? -EREMOTEIO : -EIO;
>>  
>> +			if (ret == BLKPREP_DONE)
>> +				err = 0;
>> +
> 
> Please just use a proper switch statement for the return values.
> 
Ok.

Cheers,

Hannes
diff mbox

Patch

diff --git a/block/blk-core.c b/block/blk-core.c
index e273194..4bcf30a 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2462,9 +2462,13 @@  struct request *blk_peek_request(struct request_queue *q)
 
 			rq = NULL;
 			break;
-		} else if (ret == BLKPREP_KILL || ret == BLKPREP_INVALID) {
+		} else if (ret == BLKPREP_KILL || ret == BLKPREP_INVALID ||
+			   ret == BLKPREP_DONE) {
 			int err = (ret == BLKPREP_INVALID) ? -EREMOTEIO : -EIO;
 
+			if (ret == BLKPREP_DONE)
+				err = 0;
+
 			rq->cmd_flags |= REQ_QUIET;
 			/*
 			 * Mark this request as started so we don't trigger
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index b2e332a..f112926 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1257,6 +1257,7 @@  scsi_prep_return(struct request_queue *q, struct request *req, int ret)
 	case BLKPREP_KILL:
 	case BLKPREP_INVALID:
 		req->errors = DID_NO_CONNECT << 16;
+	case BLKPREP_DONE:
 		/* release the command and kill it */
 		if (req->special) {
 			struct scsi_cmnd *cmd = req->special;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index d5e3d8b..c351444 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -736,6 +736,7 @@  enum {
 	BLKPREP_KILL,		/* fatal error, kill, return -EIO */
 	BLKPREP_DEFER,		/* leave on queue */
 	BLKPREP_INVALID,	/* invalid command, kill, return -EREMOTEIO */
+	BLKPREP_DONE,		/* complete w/o error */
 };
 
 extern unsigned long blk_max_low_pfn, blk_max_pfn;