forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/target/target_core_alua.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*******************************************************************************
23 * Filename: target_core_alua.c
34 *
....@@ -6,20 +7,6 @@
67 * (c) Copyright 2009-2013 Datera, Inc.
78 *
89 * Nicholas A. Bellinger <nab@kernel.org>
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with this program; if not, write to the Free Software
22
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2310 *
2411 ******************************************************************************/
2512
....@@ -268,7 +255,7 @@
268255 }
269256 transport_kunmap_data_sg(cmd);
270257
271
- target_complete_cmd(cmd, GOOD);
258
+ target_complete_cmd_with_length(cmd, GOOD, rd_len + 4);
272259 return 0;
273260 }
274261
....@@ -451,7 +438,7 @@
451438 pr_debug("[%s]: ALUA TG Port not available, "
452439 "SenseKey: NOT_READY, ASC/ASCQ: "
453440 "0x04/0x%02x\n",
454
- cmd->se_tfo->get_fabric_name(), alua_ascq);
441
+ cmd->se_tfo->fabric_name, alua_ascq);
455442
456443 cmd->scsi_asc = 0x04;
457444 cmd->scsi_ascq = alua_ascq;
....@@ -690,7 +677,7 @@
690677
691678 if (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)
692679 return 0;
693
- if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA)
680
+ if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA)
694681 return 0;
695682
696683 /*
....@@ -910,9 +897,6 @@
910897 return (ret < 0) ? -EIO : 0;
911898 }
912899
913
-/*
914
- * Called with tg_pt_gp->tg_pt_gp_transition_mutex held
915
- */
916900 static int core_alua_update_tpg_primary_metadata(
917901 struct t10_alua_tg_pt_gp *tg_pt_gp)
918902 {
....@@ -920,6 +904,8 @@
920904 struct t10_wwn *wwn = &tg_pt_gp->tg_pt_gp_dev->t10_wwn;
921905 char *path;
922906 int len, rc;
907
+
908
+ lockdep_assert_held(&tg_pt_gp->tg_pt_gp_transition_mutex);
923909
924910 md_buf = kzalloc(ALUA_MD_BUF_LEN, GFP_KERNEL);
925911 if (!md_buf) {
....@@ -1104,7 +1090,7 @@
11041090 struct t10_alua_tg_pt_gp *tg_pt_gp;
11051091 int primary, valid_states, rc = 0;
11061092
1107
- if (l_dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA)
1093
+ if (l_dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA)
11081094 return -ENODEV;
11091095
11101096 valid_states = l_tg_pt_gp->tg_pt_gp_alua_supported_states;
....@@ -1229,13 +1215,13 @@
12291215
12301216 if (se_tpg->se_tpg_tfo->tpg_get_tag != NULL) {
12311217 path = kasprintf(GFP_KERNEL, "%s/alua/%s/%s+%hu/lun_%llu",
1232
- db_root, se_tpg->se_tpg_tfo->get_fabric_name(),
1218
+ db_root, se_tpg->se_tpg_tfo->fabric_name,
12331219 se_tpg->se_tpg_tfo->tpg_get_wwn(se_tpg),
12341220 se_tpg->se_tpg_tfo->tpg_get_tag(se_tpg),
12351221 lun->unpacked_lun);
12361222 } else {
12371223 path = kasprintf(GFP_KERNEL, "%s/alua/%s/%s/lun_%llu",
1238
- db_root, se_tpg->se_tpg_tfo->get_fabric_name(),
1224
+ db_root, se_tpg->se_tpg_tfo->fabric_name,
12391225 se_tpg->se_tpg_tfo->tpg_get_wwn(se_tpg),
12401226 lun->unpacked_lun);
12411227 }
....@@ -1760,8 +1746,10 @@
17601746 * can be made while we are releasing struct t10_alua_tg_pt_gp.
17611747 */
17621748 spin_lock(&dev->t10_alua.tg_pt_gps_lock);
1763
- list_del(&tg_pt_gp->tg_pt_gp_list);
1764
- dev->t10_alua.alua_tg_pt_gps_counter--;
1749
+ if (tg_pt_gp->tg_pt_gp_valid_id) {
1750
+ list_del(&tg_pt_gp->tg_pt_gp_list);
1751
+ dev->t10_alua.alua_tg_pt_gps_count--;
1752
+ }
17651753 spin_unlock(&dev->t10_alua.tg_pt_gps_lock);
17661754
17671755 /*
....@@ -1931,7 +1919,7 @@
19311919 unsigned char buf[TG_PT_GROUP_NAME_BUF];
19321920 int move = 0;
19331921
1934
- if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA ||
1922
+ if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA ||
19351923 (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE))
19361924 return -ENODEV;
19371925
....@@ -2188,7 +2176,7 @@
21882176 unsigned long tmp;
21892177 int ret;
21902178
2191
- if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA ||
2179
+ if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA ||
21922180 (dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE))
21932181 return -ENODEV;
21942182
....@@ -2274,7 +2262,7 @@
22742262
22752263 int core_setup_alua(struct se_device *dev)
22762264 {
2277
- if (!(dev->transport->transport_flags &
2265
+ if (!(dev->transport_flags &
22782266 TRANSPORT_FLAG_PASSTHROUGH_ALUA) &&
22792267 !(dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE)) {
22802268 struct t10_alua_lu_gp_member *lu_gp_mem;