scsi: return blk_status_t from device handler ->prep_fn
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>
This commit is contained in:
parent
159b2cbf59
commit
4c1cb67c03
|
@ -1071,28 +1071,29 @@ static void alua_check(struct scsi_device *sdev, bool force)
|
||||||
* Fail I/O to all paths not in state
|
* Fail I/O to all paths not in state
|
||||||
* active/optimized or active/non-optimized.
|
* 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_dh_data *h = sdev->handler_data;
|
||||||
struct alua_port_group *pg;
|
struct alua_port_group *pg;
|
||||||
unsigned char state = SCSI_ACCESS_STATE_OPTIMAL;
|
unsigned char state = SCSI_ACCESS_STATE_OPTIMAL;
|
||||||
int ret = BLKPREP_OK;
|
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
pg = rcu_dereference(h->pg);
|
pg = rcu_dereference(h->pg);
|
||||||
if (pg)
|
if (pg)
|
||||||
state = pg->state;
|
state = pg->state;
|
||||||
rcu_read_unlock();
|
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;
|
|
||||||
req->rq_flags |= RQF_QUIET;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void alua_rescan(struct scsi_device *sdev)
|
static void alua_rescan(struct scsi_device *sdev)
|
||||||
|
|
|
@ -341,17 +341,17 @@ static int clariion_check_sense(struct scsi_device *sdev,
|
||||||
return SCSI_RETURN_NOT_HANDLED;
|
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;
|
struct clariion_dh_data *h = sdev->handler_data;
|
||||||
int ret = BLKPREP_OK;
|
|
||||||
|
|
||||||
if (h->lun_state != CLARIION_LUN_OWNED) {
|
if (h->lun_state != CLARIION_LUN_OWNED) {
|
||||||
ret = BLKPREP_KILL;
|
|
||||||
req->rq_flags |= RQF_QUIET;
|
req->rq_flags |= RQF_QUIET;
|
||||||
|
return BLK_STS_IOERR;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
|
|
||||||
|
return BLK_STS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clariion_std_inquiry(struct scsi_device *sdev,
|
static int clariion_std_inquiry(struct scsi_device *sdev,
|
||||||
|
|
|
@ -172,17 +172,16 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h)
|
||||||
return rc;
|
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;
|
struct hp_sw_dh_data *h = sdev->handler_data;
|
||||||
int ret = BLKPREP_OK;
|
|
||||||
|
|
||||||
if (h->path_state != HP_SW_PATH_ACTIVE) {
|
if (h->path_state != HP_SW_PATH_ACTIVE) {
|
||||||
ret = BLKPREP_KILL;
|
|
||||||
req->rq_flags |= RQF_QUIET;
|
req->rq_flags |= RQF_QUIET;
|
||||||
|
return BLK_STS_IOERR;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
|
|
||||||
|
return BLK_STS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -642,17 +642,16 @@ static int rdac_activate(struct scsi_device *sdev,
|
||||||
return 0;
|
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;
|
struct rdac_dh_data *h = sdev->handler_data;
|
||||||
int ret = BLKPREP_OK;
|
|
||||||
|
|
||||||
if (h->state != RDAC_STATE_ACTIVE) {
|
if (h->state != RDAC_STATE_ACTIVE) {
|
||||||
ret = BLKPREP_KILL;
|
|
||||||
req->rq_flags |= RQF_QUIET;
|
req->rq_flags |= RQF_QUIET;
|
||||||
|
return BLK_STS_IOERR;
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
|
|
||||||
|
return BLK_STS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rdac_check_sense(struct scsi_device *sdev,
|
static int rdac_check_sense(struct scsi_device *sdev,
|
||||||
|
|
|
@ -1177,18 +1177,6 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
|
||||||
scsi_add_cmd_to_list(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,
|
static blk_status_t scsi_setup_scsi_cmnd(struct scsi_device *sdev,
|
||||||
struct request *req)
|
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);
|
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
|
||||||
|
|
||||||
if (unlikely(sdev->handler && sdev->handler->prep_fn)) {
|
if (unlikely(sdev->handler && sdev->handler->prep_fn)) {
|
||||||
int ret = sdev->handler->prep_fn(sdev, req);
|
blk_status_t ret = sdev->handler->prep_fn(sdev, req);
|
||||||
if (ret != BLKPREP_OK)
|
if (ret != BLK_STS_OK)
|
||||||
return prep_to_mq(ret);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
|
cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
|
||||||
|
|
|
@ -69,7 +69,7 @@ struct scsi_device_handler {
|
||||||
int (*attach)(struct scsi_device *);
|
int (*attach)(struct scsi_device *);
|
||||||
void (*detach)(struct scsi_device *);
|
void (*detach)(struct scsi_device *);
|
||||||
int (*activate)(struct scsi_device *, activate_complete, void *);
|
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 *);
|
int (*set_params)(struct scsi_device *, const char *);
|
||||||
void (*rescan)(struct scsi_device *);
|
void (*rescan)(struct scsi_device *);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue