Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christoph Hellwig and committed by
Jens Axboe
4c1cb67c 159b2cbf

+26 -39
+12 -11
drivers/scsi/device_handler/scsi_dh_alua.c
··· 1071 1071 * Fail I/O to all paths not in state 1072 1072 * active/optimized or active/non-optimized. 1073 1073 */ 1074 - static int alua_prep_fn(struct scsi_device *sdev, struct request *req) 1074 + static blk_status_t alua_prep_fn(struct scsi_device *sdev, struct request *req) 1075 1075 { 1076 1076 struct alua_dh_data *h = sdev->handler_data; 1077 1077 struct alua_port_group *pg; 1078 1078 unsigned char state = SCSI_ACCESS_STATE_OPTIMAL; 1079 - int ret = BLKPREP_OK; 1080 1079 1081 1080 rcu_read_lock(); 1082 1081 pg = rcu_dereference(h->pg); 1083 1082 if (pg) 1084 1083 state = pg->state; 1085 1084 rcu_read_unlock(); 1086 - if (state == SCSI_ACCESS_STATE_TRANSITIONING) 1087 - ret = BLKPREP_DEFER; 1088 - else if (state != SCSI_ACCESS_STATE_OPTIMAL && 1089 - state != SCSI_ACCESS_STATE_ACTIVE && 1090 - state != SCSI_ACCESS_STATE_LBA) { 1091 - ret = BLKPREP_KILL; 1092 - req->rq_flags |= RQF_QUIET; 1093 - } 1094 - return ret; 1095 1085 1086 + switch (state) { 1087 + case SCSI_ACCESS_STATE_OPTIMAL: 1088 + case SCSI_ACCESS_STATE_ACTIVE: 1089 + case SCSI_ACCESS_STATE_LBA: 1090 + return BLK_STS_OK; 1091 + case SCSI_ACCESS_STATE_TRANSITIONING: 1092 + return BLK_STS_RESOURCE; 1093 + default: 1094 + req->rq_flags |= RQF_QUIET; 1095 + return BLK_STS_IOERR; 1096 + } 1096 1097 } 1097 1098 1098 1099 static void alua_rescan(struct scsi_device *sdev)
+4 -4
drivers/scsi/device_handler/scsi_dh_emc.c
··· 341 341 return SCSI_RETURN_NOT_HANDLED; 342 342 } 343 343 344 - static int clariion_prep_fn(struct scsi_device *sdev, struct request *req) 344 + static blk_status_t clariion_prep_fn(struct scsi_device *sdev, 345 + struct request *req) 345 346 { 346 347 struct clariion_dh_data *h = sdev->handler_data; 347 - int ret = BLKPREP_OK; 348 348 349 349 if (h->lun_state != CLARIION_LUN_OWNED) { 350 - ret = BLKPREP_KILL; 351 350 req->rq_flags |= RQF_QUIET; 351 + return BLK_STS_IOERR; 352 352 } 353 - return ret; 354 353 354 + return BLK_STS_OK; 355 355 } 356 356 357 357 static int clariion_std_inquiry(struct scsi_device *sdev,
+3 -4
drivers/scsi/device_handler/scsi_dh_hp_sw.c
··· 172 172 return rc; 173 173 } 174 174 175 - static int hp_sw_prep_fn(struct scsi_device *sdev, struct request *req) 175 + static blk_status_t hp_sw_prep_fn(struct scsi_device *sdev, struct request *req) 176 176 { 177 177 struct hp_sw_dh_data *h = sdev->handler_data; 178 - int ret = BLKPREP_OK; 179 178 180 179 if (h->path_state != HP_SW_PATH_ACTIVE) { 181 - ret = BLKPREP_KILL; 182 180 req->rq_flags |= RQF_QUIET; 181 + return BLK_STS_IOERR; 183 182 } 184 - return ret; 185 183 184 + return BLK_STS_OK; 186 185 } 187 186 188 187 /*
+3 -4
drivers/scsi/device_handler/scsi_dh_rdac.c
··· 642 642 return 0; 643 643 } 644 644 645 - static int rdac_prep_fn(struct scsi_device *sdev, struct request *req) 645 + static blk_status_t rdac_prep_fn(struct scsi_device *sdev, struct request *req) 646 646 { 647 647 struct rdac_dh_data *h = sdev->handler_data; 648 - int ret = BLKPREP_OK; 649 648 650 649 if (h->state != RDAC_STATE_ACTIVE) { 651 - ret = BLKPREP_KILL; 652 650 req->rq_flags |= RQF_QUIET; 651 + return BLK_STS_IOERR; 653 652 } 654 - return ret; 655 653 654 + return BLK_STS_OK; 656 655 } 657 656 658 657 static int rdac_check_sense(struct scsi_device *sdev,
+3 -15
drivers/scsi/scsi_lib.c
··· 1177 1177 scsi_add_cmd_to_list(cmd); 1178 1178 } 1179 1179 1180 - static inline blk_status_t prep_to_mq(int ret) 1181 - { 1182 - switch (ret) { 1183 - case BLKPREP_OK: 1184 - return BLK_STS_OK; 1185 - case BLKPREP_DEFER: 1186 - return BLK_STS_RESOURCE; 1187 - default: 1188 - return BLK_STS_IOERR; 1189 - } 1190 - } 1191 - 1192 1180 static blk_status_t scsi_setup_scsi_cmnd(struct scsi_device *sdev, 1193 1181 struct request *req) 1194 1182 { ··· 1215 1227 struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); 1216 1228 1217 1229 if (unlikely(sdev->handler && sdev->handler->prep_fn)) { 1218 - int ret = sdev->handler->prep_fn(sdev, req); 1219 - if (ret != BLKPREP_OK) 1220 - return prep_to_mq(ret); 1230 + blk_status_t ret = sdev->handler->prep_fn(sdev, req); 1231 + if (ret != BLK_STS_OK) 1232 + return ret; 1221 1233 } 1222 1234 1223 1235 cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
+1 -1
include/scsi/scsi_dh.h
··· 69 69 int (*attach)(struct scsi_device *); 70 70 void (*detach)(struct scsi_device *); 71 71 int (*activate)(struct scsi_device *, activate_complete, void *); 72 - int (*prep_fn)(struct scsi_device *, struct request *); 72 + blk_status_t (*prep_fn)(struct scsi_device *, struct request *); 73 73 int (*set_params)(struct scsi_device *, const char *); 74 74 void (*rescan)(struct scsi_device *); 75 75 };