forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/scsi/device_handler/scsi_dh_alua.c
....@@ -1,23 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Generic SCSI-3 ALUA SCSI Device Handler
34 *
45 * Copyright (C) 2007-2010 Hannes Reinecke, SUSE Linux Products GmbH.
56 * All rights reserved.
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; if not, write to the Free Software
19
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
- *
217 */
228 #include <linux/slab.h>
239 #include <linux/delay.h>
....@@ -1090,28 +1076,29 @@
10901076 * Fail I/O to all paths not in state
10911077 * active/optimized or active/non-optimized.
10921078 */
1093
-static int alua_prep_fn(struct scsi_device *sdev, struct request *req)
1079
+static blk_status_t alua_prep_fn(struct scsi_device *sdev, struct request *req)
10941080 {
10951081 struct alua_dh_data *h = sdev->handler_data;
10961082 struct alua_port_group *pg;
10971083 unsigned char state = SCSI_ACCESS_STATE_OPTIMAL;
1098
- int ret = BLKPREP_OK;
10991084
11001085 rcu_read_lock();
11011086 pg = rcu_dereference(h->pg);
11021087 if (pg)
11031088 state = pg->state;
11041089 rcu_read_unlock();
1105
- if (state == SCSI_ACCESS_STATE_TRANSITIONING)
1106
- ret = BLKPREP_DEFER;
1107
- else if (state != SCSI_ACCESS_STATE_OPTIMAL &&
1108
- state != SCSI_ACCESS_STATE_ACTIVE &&
1109
- state != SCSI_ACCESS_STATE_LBA) {
1110
- ret = BLKPREP_KILL;
1111
- req->rq_flags |= RQF_QUIET;
1112
- }
1113
- return ret;
11141090
1091
+ switch (state) {
1092
+ case SCSI_ACCESS_STATE_OPTIMAL:
1093
+ case SCSI_ACCESS_STATE_ACTIVE:
1094
+ case SCSI_ACCESS_STATE_LBA:
1095
+ return BLK_STS_OK;
1096
+ case SCSI_ACCESS_STATE_TRANSITIONING:
1097
+ return BLK_STS_RESOURCE;
1098
+ default:
1099
+ req->rq_flags |= RQF_QUIET;
1100
+ return BLK_STS_IOERR;
1101
+ }
11151102 }
11161103
11171104 static void alua_rescan(struct scsi_device *sdev)