scsi: return blk_status_t from device handler ->prep_fn
authorChristoph Hellwig <hch@lst.de>
Fri, 9 Nov 2018 13:42:40 +0000 (14:42 +0100)
committerJens Axboe <axboe@kernel.dk>
Sat, 10 Nov 2018 02:17:14 +0000 (19:17 -0700)
Remove the last use of the old BLKPREP_* values, which get converted
to BLK_STS_* later anyway.

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/scsi/device_handler/scsi_dh_alua.c
drivers/scsi/device_handler/scsi_dh_emc.c
drivers/scsi/device_handler/scsi_dh_hp_sw.c
drivers/scsi/device_handler/scsi_dh_rdac.c
drivers/scsi/scsi_lib.c
include/scsi/scsi_dh.h

index 12dc7100bb4c240e1161e60043413d64611a3bd3..d7ac498ba35aec018039b7ea98ec397cb299bc18 100644 (file)
@@ -1071,28 +1071,29 @@ static void alua_check(struct scsi_device *sdev, bool force)
  * Fail I/O to all paths not in state
  * active/optimized or active/non-optimized.
  */
-static int alua_prep_fn(struct scsi_device *sdev, struct request *req)
+static blk_status_t alua_prep_fn(struct scsi_device *sdev, struct request *req)
 {
        struct alua_dh_data *h = sdev->handler_data;
        struct alua_port_group *pg;
        unsigned char state = SCSI_ACCESS_STATE_OPTIMAL;
-       int ret = BLKPREP_OK;
 
        rcu_read_lock();
        pg = rcu_dereference(h->pg);
        if (pg)
                state = pg->state;
        rcu_read_unlock();
-       if (state == SCSI_ACCESS_STATE_TRANSITIONING)
-               ret = BLKPREP_DEFER;
-       else if (state != SCSI_ACCESS_STATE_OPTIMAL &&
-                state != SCSI_ACCESS_STATE_ACTIVE &&
-                state != SCSI_ACCESS_STATE_LBA) {
-               ret = BLKPREP_KILL;
+
+       switch (state) {
+       case SCSI_ACCESS_STATE_OPTIMAL:
+       case SCSI_ACCESS_STATE_ACTIVE:
+       case SCSI_ACCESS_STATE_LBA:
+               return BLK_STS_OK;
+       case SCSI_ACCESS_STATE_TRANSITIONING:
+               return BLK_STS_RESOURCE;
+       default:
                req->rq_flags |= RQF_QUIET;
+               return BLK_STS_IOERR;
        }
-       return ret;
-
 }
 
 static void alua_rescan(struct scsi_device *sdev)
index 95c47909a58f33409822b66da4b097700736526a..bea8e13febb665deafb797a060eb03d87ac197e8 100644 (file)
@@ -341,17 +341,17 @@ static int clariion_check_sense(struct scsi_device *sdev,
        return SCSI_RETURN_NOT_HANDLED;
 }
 
-static int clariion_prep_fn(struct scsi_device *sdev, struct request *req)
+static blk_status_t clariion_prep_fn(struct scsi_device *sdev,
+               struct request *req)
 {
        struct clariion_dh_data *h = sdev->handler_data;
-       int ret = BLKPREP_OK;
 
        if (h->lun_state != CLARIION_LUN_OWNED) {
-               ret = BLKPREP_KILL;
                req->rq_flags |= RQF_QUIET;
+               return BLK_STS_IOERR;
        }
-       return ret;
 
+       return BLK_STS_OK;
 }
 
 static int clariion_std_inquiry(struct scsi_device *sdev,
index e65a0ebb4b5419c25e96aff01d028fd532adb170..80129b033855f55b96e04e71dc427ebf98fc423b 100644 (file)
@@ -172,17 +172,16 @@ retry:
        return rc;
 }
 
-static int hp_sw_prep_fn(struct scsi_device *sdev, struct request *req)
+static blk_status_t hp_sw_prep_fn(struct scsi_device *sdev, struct request *req)
 {
        struct hp_sw_dh_data *h = sdev->handler_data;
-       int ret = BLKPREP_OK;
 
        if (h->path_state != HP_SW_PATH_ACTIVE) {
-               ret = BLKPREP_KILL;
                req->rq_flags |= RQF_QUIET;
+               return BLK_STS_IOERR;
        }
-       return ret;
 
+       return BLK_STS_OK;
 }
 
 /*
index d27fabae8ddd9c2e045203ada3d3673799441ce8..65f1fe343c647164e9e0d3f9f37de96220c0b2c5 100644 (file)
@@ -642,17 +642,16 @@ done:
        return 0;
 }
 
-static int rdac_prep_fn(struct scsi_device *sdev, struct request *req)
+static blk_status_t rdac_prep_fn(struct scsi_device *sdev, struct request *req)
 {
        struct rdac_dh_data *h = sdev->handler_data;
-       int ret = BLKPREP_OK;
 
        if (h->state != RDAC_STATE_ACTIVE) {
-               ret = BLKPREP_KILL;
                req->rq_flags |= RQF_QUIET;
+               return BLK_STS_IOERR;
        }
-       return ret;
 
+       return BLK_STS_OK;
 }
 
 static int rdac_check_sense(struct scsi_device *sdev,
index 3e3bdeee8f14347a73d0f409d7cad9a859a059e6..5d83a162d03b8ed3dff87d51aaf0c22565f9db6a 100644 (file)
@@ -1177,18 +1177,6 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
        scsi_add_cmd_to_list(cmd);
 }
 
-static inline blk_status_t prep_to_mq(int ret)
-{
-       switch (ret) {
-       case BLKPREP_OK:
-               return BLK_STS_OK;
-       case BLKPREP_DEFER:
-               return BLK_STS_RESOURCE;
-       default:
-               return BLK_STS_IOERR;
-       }
-}
-
 static blk_status_t scsi_setup_scsi_cmnd(struct scsi_device *sdev,
                struct request *req)
 {
@@ -1227,9 +1215,9 @@ static blk_status_t scsi_setup_fs_cmnd(struct scsi_device *sdev,
        struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
 
        if (unlikely(sdev->handler && sdev->handler->prep_fn)) {
-               int ret = sdev->handler->prep_fn(sdev, req);
-               if (ret != BLKPREP_OK)
-                       return prep_to_mq(ret);
+               blk_status_t ret = sdev->handler->prep_fn(sdev, req);
+               if (ret != BLK_STS_OK)
+                       return ret;
        }
 
        cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
index c7bba2b248498cbd8acb11b4b35bb2f0e5fc4ed7..a862dc23c68d4239701815cb8ad3a7540eb86b2d 100644 (file)
@@ -69,7 +69,7 @@ struct scsi_device_handler {
        int (*attach)(struct scsi_device *);
        void (*detach)(struct scsi_device *);
        int (*activate)(struct scsi_device *, activate_complete, void *);
-       int (*prep_fn)(struct scsi_device *, struct request *);
+       blk_status_t (*prep_fn)(struct scsi_device *, struct request *);
        int (*set_params)(struct scsi_device *, const char *);
        void (*rescan)(struct scsi_device *);
 };