Revert "scsi: core: Introduce enum scsi_disposition"

This reverts commit 7efadce40a which is
commit b8e162f9e7e2da6e823a4984d6aa0523e278babf upstream.

It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.

Bug: 161946584
Change-Id: I4d61091819d54c290cfe08152daab17cfb7a3fa5
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2024-04-16 09:43:42 +00:00
parent 7c333b5976
commit c5fa21f10b
10 changed files with 51 additions and 57 deletions

View File

@@ -1607,7 +1607,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
} }
if (qc->flags & ATA_QCFLAG_SENSE_VALID) { if (qc->flags & ATA_QCFLAG_SENSE_VALID) {
enum scsi_disposition ret = scsi_check_sense(qc->scsicmd); int ret = scsi_check_sense(qc->scsicmd);
/* /*
* SUCCESS here means that the sense code could be * SUCCESS here means that the sense code could be
* evaluated and should be passed to the upper layers * evaluated and should be passed to the upper layers

View File

@@ -405,7 +405,7 @@ static char print_alua_state(unsigned char state)
} }
} }
static enum scsi_disposition alua_check_sense(struct scsi_device *sdev, static int alua_check_sense(struct scsi_device *sdev,
struct scsi_sense_hdr *sense_hdr) struct scsi_sense_hdr *sense_hdr)
{ {
switch (sense_hdr->sense_key) { switch (sense_hdr->sense_key) {

View File

@@ -280,7 +280,7 @@ static int send_trespass_cmd(struct scsi_device *sdev,
return res; return res;
} }
static enum scsi_disposition clariion_check_sense(struct scsi_device *sdev, static int clariion_check_sense(struct scsi_device *sdev,
struct scsi_sense_hdr *sense_hdr) struct scsi_sense_hdr *sense_hdr)
{ {
switch (sense_hdr->sense_key) { switch (sense_hdr->sense_key) {

View File

@@ -656,7 +656,7 @@ static blk_status_t rdac_prep_fn(struct scsi_device *sdev, struct request *req)
return BLK_STS_OK; return BLK_STS_OK;
} }
static enum scsi_disposition rdac_check_sense(struct scsi_device *sdev, static int rdac_check_sense(struct scsi_device *sdev,
struct scsi_sense_hdr *sense_hdr) struct scsi_sense_hdr *sense_hdr)
{ {
struct rdac_dh_data *h = sdev->handler_data; struct rdac_dh_data *h = sdev->handler_data;

View File

@@ -60,7 +60,7 @@ static void scsi_eh_done(struct scsi_cmnd *scmd);
#define HOST_RESET_SETTLE_TIME (10) #define HOST_RESET_SETTLE_TIME (10)
static int scsi_eh_try_stu(struct scsi_cmnd *scmd); static int scsi_eh_try_stu(struct scsi_cmnd *scmd);
static enum scsi_disposition scsi_try_to_abort_cmd(struct scsi_host_template *, static int scsi_try_to_abort_cmd(struct scsi_host_template *,
struct scsi_cmnd *); struct scsi_cmnd *);
void scsi_eh_wakeup(struct Scsi_Host *shost) void scsi_eh_wakeup(struct Scsi_Host *shost)
@@ -140,7 +140,7 @@ scmd_eh_abort_handler(struct work_struct *work)
struct scsi_cmnd *scmd = struct scsi_cmnd *scmd =
container_of(work, struct scsi_cmnd, abort_work.work); container_of(work, struct scsi_cmnd, abort_work.work);
struct scsi_device *sdev = scmd->device; struct scsi_device *sdev = scmd->device;
enum scsi_disposition rtn; int rtn;
if (scsi_host_eh_past_deadline(sdev->host)) { if (scsi_host_eh_past_deadline(sdev->host)) {
SCSI_LOG_ERROR_RECOVERY(3, SCSI_LOG_ERROR_RECOVERY(3,
@@ -478,7 +478,7 @@ static void scsi_report_sense(struct scsi_device *sdev,
* When a deferred error is detected the current command has * When a deferred error is detected the current command has
* not been executed and needs retrying. * not been executed and needs retrying.
*/ */
enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd) int scsi_check_sense(struct scsi_cmnd *scmd)
{ {
struct scsi_device *sdev = scmd->device; struct scsi_device *sdev = scmd->device;
struct scsi_sense_hdr sshdr; struct scsi_sense_hdr sshdr;
@@ -492,7 +492,7 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)
return NEEDS_RETRY; return NEEDS_RETRY;
if (sdev->handler && sdev->handler->check_sense) { if (sdev->handler && sdev->handler->check_sense) {
enum scsi_disposition rc; int rc;
rc = sdev->handler->check_sense(sdev, &sshdr); rc = sdev->handler->check_sense(sdev, &sshdr);
if (rc != SCSI_RETURN_NOT_HANDLED) if (rc != SCSI_RETURN_NOT_HANDLED)
@@ -703,7 +703,7 @@ static void scsi_handle_queue_full(struct scsi_device *sdev)
* don't allow for the possibility of retries here, and we are a lot * don't allow for the possibility of retries here, and we are a lot
* more restrictive about what we consider acceptable. * more restrictive about what we consider acceptable.
*/ */
static enum scsi_disposition scsi_eh_completed_normally(struct scsi_cmnd *scmd) static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
{ {
/* /*
* first check the host byte, to see if there is anything in there * first check the host byte, to see if there is anything in there
@@ -784,10 +784,10 @@ static void scsi_eh_done(struct scsi_cmnd *scmd)
* scsi_try_host_reset - ask host adapter to reset itself * scsi_try_host_reset - ask host adapter to reset itself
* @scmd: SCSI cmd to send host reset. * @scmd: SCSI cmd to send host reset.
*/ */
static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd) static int scsi_try_host_reset(struct scsi_cmnd *scmd)
{ {
unsigned long flags; unsigned long flags;
enum scsi_disposition rtn; int rtn;
struct Scsi_Host *host = scmd->device->host; struct Scsi_Host *host = scmd->device->host;
struct scsi_host_template *hostt = host->hostt; struct scsi_host_template *hostt = host->hostt;
@@ -814,10 +814,10 @@ static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd)
* scsi_try_bus_reset - ask host to perform a bus reset * scsi_try_bus_reset - ask host to perform a bus reset
* @scmd: SCSI cmd to send bus reset. * @scmd: SCSI cmd to send bus reset.
*/ */
static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd) static int scsi_try_bus_reset(struct scsi_cmnd *scmd)
{ {
unsigned long flags; unsigned long flags;
enum scsi_disposition rtn; int rtn;
struct Scsi_Host *host = scmd->device->host; struct Scsi_Host *host = scmd->device->host;
struct scsi_host_template *hostt = host->hostt; struct scsi_host_template *hostt = host->hostt;
@@ -856,10 +856,10 @@ static void __scsi_report_device_reset(struct scsi_device *sdev, void *data)
* timer on it, and set the host back to a consistent state prior to * timer on it, and set the host back to a consistent state prior to
* returning. * returning.
*/ */
static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd) static int scsi_try_target_reset(struct scsi_cmnd *scmd)
{ {
unsigned long flags; unsigned long flags;
enum scsi_disposition rtn; int rtn;
struct Scsi_Host *host = scmd->device->host; struct Scsi_Host *host = scmd->device->host;
struct scsi_host_template *hostt = host->hostt; struct scsi_host_template *hostt = host->hostt;
@@ -887,9 +887,9 @@ static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd)
* timer on it, and set the host back to a consistent state prior to * timer on it, and set the host back to a consistent state prior to
* returning. * returning.
*/ */
static enum scsi_disposition scsi_try_bus_device_reset(struct scsi_cmnd *scmd) static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd)
{ {
enum scsi_disposition rtn; int rtn;
struct scsi_host_template *hostt = scmd->device->host->hostt; struct scsi_host_template *hostt = scmd->device->host->hostt;
if (!hostt->eh_device_reset_handler) if (!hostt->eh_device_reset_handler)
@@ -918,8 +918,8 @@ static enum scsi_disposition scsi_try_bus_device_reset(struct scsi_cmnd *scmd)
* if the device is temporarily unavailable (eg due to a * if the device is temporarily unavailable (eg due to a
* link down on FibreChannel) * link down on FibreChannel)
*/ */
static enum scsi_disposition static int scsi_try_to_abort_cmd(struct scsi_host_template *hostt,
scsi_try_to_abort_cmd(struct scsi_host_template *hostt, struct scsi_cmnd *scmd) struct scsi_cmnd *scmd)
{ {
if (!hostt->eh_abort_handler) if (!hostt->eh_abort_handler)
return FAILED; return FAILED;
@@ -1052,8 +1052,8 @@ EXPORT_SYMBOL(scsi_eh_restore_cmnd);
* Return value: * Return value:
* SUCCESS or FAILED or NEEDS_RETRY * SUCCESS or FAILED or NEEDS_RETRY
*/ */
static enum scsi_disposition scsi_send_eh_cmnd(struct scsi_cmnd *scmd, static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
unsigned char *cmnd, int cmnd_size, int timeout, unsigned sense_bytes) int cmnd_size, int timeout, unsigned sense_bytes)
{ {
struct scsi_device *sdev = scmd->device; struct scsi_device *sdev = scmd->device;
struct Scsi_Host *shost = sdev->host; struct Scsi_Host *shost = sdev->host;
@@ -1161,13 +1161,12 @@ retry:
* that we obtain it on our own. This function will *not* return until * that we obtain it on our own. This function will *not* return until
* the command either times out, or it completes. * the command either times out, or it completes.
*/ */
static enum scsi_disposition scsi_request_sense(struct scsi_cmnd *scmd) static int scsi_request_sense(struct scsi_cmnd *scmd)
{ {
return scsi_send_eh_cmnd(scmd, NULL, 0, scmd->device->eh_timeout, ~0); return scsi_send_eh_cmnd(scmd, NULL, 0, scmd->device->eh_timeout, ~0);
} }
static enum scsi_disposition static int scsi_eh_action(struct scsi_cmnd *scmd, int rtn)
scsi_eh_action(struct scsi_cmnd *scmd, enum scsi_disposition rtn)
{ {
if (!blk_rq_is_passthrough(scmd->request)) { if (!blk_rq_is_passthrough(scmd->request)) {
struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd); struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd);
@@ -1220,7 +1219,7 @@ int scsi_eh_get_sense(struct list_head *work_q,
{ {
struct scsi_cmnd *scmd, *next; struct scsi_cmnd *scmd, *next;
struct Scsi_Host *shost; struct Scsi_Host *shost;
enum scsi_disposition rtn; int rtn;
/* /*
* If SCSI_EH_ABORT_SCHEDULED has been set, it is timeout IO, * If SCSI_EH_ABORT_SCHEDULED has been set, it is timeout IO,
@@ -1298,8 +1297,7 @@ EXPORT_SYMBOL_GPL(scsi_eh_get_sense);
static int scsi_eh_tur(struct scsi_cmnd *scmd) static int scsi_eh_tur(struct scsi_cmnd *scmd)
{ {
static unsigned char tur_command[6] = {TEST_UNIT_READY, 0, 0, 0, 0, 0}; static unsigned char tur_command[6] = {TEST_UNIT_READY, 0, 0, 0, 0, 0};
int retry_cnt = 1; int retry_cnt = 1, rtn;
enum scsi_disposition rtn;
retry_tur: retry_tur:
rtn = scsi_send_eh_cmnd(scmd, tur_command, 6, rtn = scsi_send_eh_cmnd(scmd, tur_command, 6,
@@ -1387,8 +1385,7 @@ static int scsi_eh_try_stu(struct scsi_cmnd *scmd)
static unsigned char stu_command[6] = {START_STOP, 0, 0, 0, 1, 0}; static unsigned char stu_command[6] = {START_STOP, 0, 0, 0, 1, 0};
if (scmd->device->allow_restart) { if (scmd->device->allow_restart) {
int i; int i, rtn = NEEDS_RETRY;
enum scsi_disposition rtn = NEEDS_RETRY;
for (i = 0; rtn == NEEDS_RETRY && i < 2; i++) for (i = 0; rtn == NEEDS_RETRY && i < 2; i++)
rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, scmd->device->request_queue->rq_timeout, 0); rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, scmd->device->request_queue->rq_timeout, 0);
@@ -1482,7 +1479,7 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
{ {
struct scsi_cmnd *scmd, *bdr_scmd, *next; struct scsi_cmnd *scmd, *bdr_scmd, *next;
struct scsi_device *sdev; struct scsi_device *sdev;
enum scsi_disposition rtn; int rtn;
shost_for_each_device(sdev, shost) { shost_for_each_device(sdev, shost) {
if (scsi_host_eh_past_deadline(shost)) { if (scsi_host_eh_past_deadline(shost)) {
@@ -1549,7 +1546,7 @@ static int scsi_eh_target_reset(struct Scsi_Host *shost,
while (!list_empty(&tmp_list)) { while (!list_empty(&tmp_list)) {
struct scsi_cmnd *next, *scmd; struct scsi_cmnd *next, *scmd;
enum scsi_disposition rtn; int rtn;
unsigned int id; unsigned int id;
if (scsi_host_eh_past_deadline(shost)) { if (scsi_host_eh_past_deadline(shost)) {
@@ -1607,7 +1604,7 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
struct scsi_cmnd *scmd, *chan_scmd, *next; struct scsi_cmnd *scmd, *chan_scmd, *next;
LIST_HEAD(check_list); LIST_HEAD(check_list);
unsigned int channel; unsigned int channel;
enum scsi_disposition rtn; int rtn;
/* /*
* we really want to loop over the various channels, and do this on * we really want to loop over the various channels, and do this on
@@ -1678,7 +1675,7 @@ static int scsi_eh_host_reset(struct Scsi_Host *shost,
{ {
struct scsi_cmnd *scmd, *next; struct scsi_cmnd *scmd, *next;
LIST_HEAD(check_list); LIST_HEAD(check_list);
enum scsi_disposition rtn; int rtn;
if (!list_empty(work_q)) { if (!list_empty(work_q)) {
scmd = list_entry(work_q->next, scmd = list_entry(work_q->next,
@@ -1784,9 +1781,9 @@ check_type:
* doesn't require the error handler read (i.e. we don't need to * doesn't require the error handler read (i.e. we don't need to
* abort/reset), this function should return SUCCESS. * abort/reset), this function should return SUCCESS.
*/ */
enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *scmd) int scsi_decide_disposition(struct scsi_cmnd *scmd)
{ {
enum scsi_disposition rtn; int rtn;
/* /*
* if the device is offline, then we clearly just pass the result back * if the device is offline, then we clearly just pass the result back
@@ -2342,8 +2339,7 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)
struct Scsi_Host *shost = dev->host; struct Scsi_Host *shost = dev->host;
struct request *rq; struct request *rq;
unsigned long flags; unsigned long flags;
int error = 0, val; int error = 0, rtn, val;
enum scsi_disposition rtn;
if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
return -EACCES; return -EACCES;

View File

@@ -1426,7 +1426,7 @@ static bool scsi_mq_lld_busy(struct request_queue *q)
static void scsi_softirq_done(struct request *rq) static void scsi_softirq_done(struct request *rq)
{ {
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
enum scsi_disposition disposition; int disposition;
INIT_LIST_HEAD(&cmd->eh_entry); INIT_LIST_HEAD(&cmd->eh_entry);

View File

@@ -73,7 +73,7 @@ extern void scsi_exit_devinfo(void);
extern void scmd_eh_abort_handler(struct work_struct *work); extern void scmd_eh_abort_handler(struct work_struct *work);
extern enum blk_eh_timer_return scsi_times_out(struct request *req); extern enum blk_eh_timer_return scsi_times_out(struct request *req);
extern int scsi_error_handler(void *host); extern int scsi_error_handler(void *host);
extern enum scsi_disposition scsi_decide_disposition(struct scsi_cmnd *cmd); extern int scsi_decide_disposition(struct scsi_cmnd *cmd);
extern void scsi_eh_wakeup(struct Scsi_Host *shost); extern void scsi_eh_wakeup(struct Scsi_Host *shost);
extern void scsi_eh_scmd_add(struct scsi_cmnd *); extern void scsi_eh_scmd_add(struct scsi_cmnd *);
void scsi_eh_ready_devs(struct Scsi_Host *shost, void scsi_eh_ready_devs(struct Scsi_Host *shost,

View File

@@ -193,17 +193,16 @@ static inline int scsi_status_is_check_condition(int status)
/* /*
* Internal return values. * Internal return values.
*/ */
enum scsi_disposition {
NEEDS_RETRY = 0x2001, #define NEEDS_RETRY 0x2001
SUCCESS = 0x2002, #define SUCCESS 0x2002
FAILED = 0x2003, #define FAILED 0x2003
QUEUED = 0x2004, #define QUEUED 0x2004
SOFT_ERROR = 0x2005, #define SOFT_ERROR 0x2005
ADD_TO_MLQUEUE = 0x2006, #define ADD_TO_MLQUEUE 0x2006
TIMEOUT_ERROR = 0x2007, #define TIMEOUT_ERROR 0x2007
SCSI_RETURN_NOT_HANDLED = 0x2008, #define SCSI_RETURN_NOT_HANDLED 0x2008
FAST_IO_FAIL = 0x2009, #define FAST_IO_FAIL 0x2009
};
/* /*
* Midlevel queue return values. * Midlevel queue return values.

View File

@@ -52,8 +52,7 @@ struct scsi_device_handler {
/* Filled by the hardware handler */ /* Filled by the hardware handler */
struct module *module; struct module *module;
const char *name; const char *name;
enum scsi_disposition (*check_sense)(struct scsi_device *, int (*check_sense)(struct scsi_device *, struct scsi_sense_hdr *);
struct scsi_sense_hdr *);
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 *);

View File

@@ -17,7 +17,7 @@ extern void scsi_report_device_reset(struct Scsi_Host *, int, int);
extern int scsi_block_when_processing_errors(struct scsi_device *); extern int scsi_block_when_processing_errors(struct scsi_device *);
extern bool scsi_command_normalize_sense(const struct scsi_cmnd *cmd, extern bool scsi_command_normalize_sense(const struct scsi_cmnd *cmd,
struct scsi_sense_hdr *sshdr); struct scsi_sense_hdr *sshdr);
extern enum scsi_disposition scsi_check_sense(struct scsi_cmnd *); extern int scsi_check_sense(struct scsi_cmnd *);
static inline bool scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr) static inline bool scsi_sense_is_deferred(const struct scsi_sense_hdr *sshdr)
{ {