hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/target/target_core_configfs.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*******************************************************************************
23 * Filename: target_core_configfs.c
34 *
....@@ -9,15 +10,6 @@
910 *
1011 * based on configfs Copyright (C) 2005 Oracle. All rights reserved.
1112 *
12
- * This program is free software; you can redistribute it and/or modify
13
- * it under the terms of the GNU General Public License as published by
14
- * the Free Software Foundation; either version 2 of the License, or
15
- * (at your option) any later version.
16
- *
17
- * This program is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- * GNU General Public License for more details.
2113 ****************************************************************************/
2214
2315 #include <linux/module.h>
....@@ -172,7 +164,10 @@
172164
173165 mutex_lock(&g_tf_lock);
174166 list_for_each_entry(tf, &g_tf_list, tf_list) {
175
- if (!strcmp(tf->tf_ops->name, name)) {
167
+ const char *cmp_name = tf->tf_ops->fabric_alias;
168
+ if (!cmp_name)
169
+ cmp_name = tf->tf_ops->fabric_name;
170
+ if (!strcmp(cmp_name, name)) {
176171 atomic_inc(&tf->tf_access_cnt);
177172 mutex_unlock(&g_tf_lock);
178173 return tf;
....@@ -249,7 +244,7 @@
249244 return ERR_PTR(-EINVAL);
250245 }
251246 pr_debug("Target_Core_ConfigFS: REGISTER -> Located fabric:"
252
- " %s\n", tf->tf_ops->name);
247
+ " %s\n", tf->tf_ops->fabric_name);
253248 /*
254249 * On a successful target_core_get_fabric() look, the returned
255250 * struct target_fabric_configfs *tf will contain a usage reference.
....@@ -282,7 +277,7 @@
282277 " tf list\n", config_item_name(item));
283278
284279 pr_debug("Target_Core_ConfigFS: DEREGISTER -> located fabric:"
285
- " %s\n", tf->tf_ops->name);
280
+ " %s\n", tf->tf_ops->fabric_name);
286281 atomic_dec(&tf->tf_access_cnt);
287282
288283 pr_debug("Target_Core_ConfigFS: DEREGISTER -> Releasing ci"
....@@ -342,17 +337,20 @@
342337
343338 static int target_fabric_tf_ops_check(const struct target_core_fabric_ops *tfo)
344339 {
345
- if (!tfo->name) {
346
- pr_err("Missing tfo->name\n");
340
+ if (tfo->fabric_alias) {
341
+ if (strlen(tfo->fabric_alias) >= TARGET_FABRIC_NAME_SIZE) {
342
+ pr_err("Passed alias: %s exceeds "
343
+ "TARGET_FABRIC_NAME_SIZE\n", tfo->fabric_alias);
344
+ return -EINVAL;
345
+ }
346
+ }
347
+ if (!tfo->fabric_name) {
348
+ pr_err("Missing tfo->fabric_name\n");
347349 return -EINVAL;
348350 }
349
- if (strlen(tfo->name) >= TARGET_FABRIC_NAME_SIZE) {
350
- pr_err("Passed name: %s exceeds TARGET_FABRIC"
351
- "_NAME_SIZE\n", tfo->name);
352
- return -EINVAL;
353
- }
354
- if (!tfo->get_fabric_name) {
355
- pr_err("Missing tfo->get_fabric_name()\n");
351
+ if (strlen(tfo->fabric_name) >= TARGET_FABRIC_NAME_SIZE) {
352
+ pr_err("Passed name: %s exceeds "
353
+ "TARGET_FABRIC_NAME_SIZE\n", tfo->fabric_name);
356354 return -EINVAL;
357355 }
358356 if (!tfo->tpg_get_wwn) {
....@@ -393,10 +391,6 @@
393391 }
394392 if (!tfo->write_pending) {
395393 pr_err("Missing tfo->write_pending()\n");
396
- return -EINVAL;
397
- }
398
- if (!tfo->write_pending_status) {
399
- pr_err("Missing tfo->write_pending_status()\n");
400394 return -EINVAL;
401395 }
402396 if (!tfo->set_default_node_attributes) {
....@@ -486,7 +480,7 @@
486480
487481 mutex_lock(&g_tf_lock);
488482 list_for_each_entry(t, &g_tf_list, tf_list) {
489
- if (!strcmp(t->tf_ops->name, fo->name)) {
483
+ if (!strcmp(t->tf_ops->fabric_name, fo->fabric_name)) {
490484 BUG_ON(atomic_read(&t->tf_access_cnt));
491485 list_del(&t->tf_list);
492486 mutex_unlock(&g_tf_lock);
....@@ -532,9 +526,9 @@
532526 DEF_CONFIGFS_ATTRIB_SHOW(emulate_tpws);
533527 DEF_CONFIGFS_ATTRIB_SHOW(emulate_caw);
534528 DEF_CONFIGFS_ATTRIB_SHOW(emulate_3pc);
529
+DEF_CONFIGFS_ATTRIB_SHOW(emulate_pr);
535530 DEF_CONFIGFS_ATTRIB_SHOW(pi_prot_type);
536531 DEF_CONFIGFS_ATTRIB_SHOW(hw_pi_prot_type);
537
-DEF_CONFIGFS_ATTRIB_SHOW(pi_prot_format);
538532 DEF_CONFIGFS_ATTRIB_SHOW(pi_prot_verify);
539533 DEF_CONFIGFS_ATTRIB_SHOW(enforce_pr_isids);
540534 DEF_CONFIGFS_ATTRIB_SHOW(is_nonrot);
....@@ -592,6 +586,7 @@
592586 DEF_CONFIGFS_ATTRIB_STORE_BOOL(emulate_fua_write);
593587 DEF_CONFIGFS_ATTRIB_STORE_BOOL(emulate_caw);
594588 DEF_CONFIGFS_ATTRIB_STORE_BOOL(emulate_3pc);
589
+DEF_CONFIGFS_ATTRIB_STORE_BOOL(emulate_pr);
595590 DEF_CONFIGFS_ATTRIB_STORE_BOOL(enforce_pr_isids);
596591 DEF_CONFIGFS_ATTRIB_STORE_BOOL(is_nonrot);
597592
....@@ -613,12 +608,17 @@
613608 const char *configname;
614609
615610 configname = config_item_name(&dev->dev_group.cg_item);
616
- if (strlen(configname) >= 16) {
611
+ if (strlen(configname) >= INQUIRY_MODEL_LEN) {
617612 pr_warn("dev[%p]: Backstore name '%s' is too long for "
618
- "INQUIRY_MODEL, truncating to 16 bytes\n", dev,
613
+ "INQUIRY_MODEL, truncating to 15 characters\n", dev,
619614 configname);
620615 }
621
- snprintf(&dev->t10_wwn.model[0], 16, "%s", configname);
616
+ /*
617
+ * XXX We can't use sizeof(dev->t10_wwn.model) (INQUIRY_MODEL_LEN + 1)
618
+ * here without potentially breaking existing setups, so continue to
619
+ * truncate one byte shorter than what can be carried in INQUIRY.
620
+ */
621
+ strlcpy(dev->t10_wwn.model, configname, INQUIRY_MODEL_LEN);
622622 }
623623
624624 static ssize_t emulate_model_alias_store(struct config_item *item,
....@@ -640,11 +640,12 @@
640640 if (ret < 0)
641641 return ret;
642642
643
+ BUILD_BUG_ON(sizeof(dev->t10_wwn.model) != INQUIRY_MODEL_LEN + 1);
643644 if (flag) {
644645 dev_set_t10_wwn_model_alias(dev);
645646 } else {
646
- strncpy(&dev->t10_wwn.model[0],
647
- dev->transport->inquiry_prod, 16);
647
+ strlcpy(dev->t10_wwn.model, dev->transport->inquiry_prod,
648
+ sizeof(dev->t10_wwn.model));
648649 }
649650 da->emulate_model_alias = flag;
650651 return count;
....@@ -683,7 +684,9 @@
683684 if (ret < 0)
684685 return ret;
685686
686
- if (val != 0 && val != 1 && val != 2) {
687
+ if (val != TARGET_UA_INTLCK_CTRL_CLEAR
688
+ && val != TARGET_UA_INTLCK_CTRL_NO_CLEAR
689
+ && val != TARGET_UA_INTLCK_CTRL_ESTABLISH_UA) {
687690 pr_err("Illegal value %d\n", val);
688691 return -EINVAL;
689692 }
....@@ -837,6 +840,12 @@
837840 da->pi_prot_verify = (bool) da->pi_prot_type;
838841 pr_debug("dev[%p]: SE Device Protection Type: %d\n", dev, flag);
839842 return count;
843
+}
844
+
845
+/* always zero, but attr needs to remain RW to avoid userspace breakage */
846
+static ssize_t pi_prot_format_show(struct config_item *item, char *page)
847
+{
848
+ return snprintf(page, PAGE_SIZE, "0\n");
840849 }
841850
842851 static ssize_t pi_prot_format_store(struct config_item *item,
....@@ -1090,19 +1099,79 @@
10901099 static ssize_t alua_support_show(struct config_item *item, char *page)
10911100 {
10921101 struct se_dev_attrib *da = to_attrib(item);
1093
- u8 flags = da->da_dev->transport->transport_flags;
1102
+ u8 flags = da->da_dev->transport_flags;
10941103
10951104 return snprintf(page, PAGE_SIZE, "%d\n",
10961105 flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA ? 0 : 1);
10971106 }
10981107
1108
+static ssize_t alua_support_store(struct config_item *item,
1109
+ const char *page, size_t count)
1110
+{
1111
+ struct se_dev_attrib *da = to_attrib(item);
1112
+ struct se_device *dev = da->da_dev;
1113
+ bool flag, oldflag;
1114
+ int ret;
1115
+
1116
+ ret = strtobool(page, &flag);
1117
+ if (ret < 0)
1118
+ return ret;
1119
+
1120
+ oldflag = !(dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_ALUA);
1121
+ if (flag == oldflag)
1122
+ return count;
1123
+
1124
+ if (!(dev->transport->transport_flags_changeable &
1125
+ TRANSPORT_FLAG_PASSTHROUGH_ALUA)) {
1126
+ pr_err("dev[%p]: Unable to change SE Device alua_support:"
1127
+ " alua_support has fixed value\n", dev);
1128
+ return -ENOSYS;
1129
+ }
1130
+
1131
+ if (flag)
1132
+ dev->transport_flags &= ~TRANSPORT_FLAG_PASSTHROUGH_ALUA;
1133
+ else
1134
+ dev->transport_flags |= TRANSPORT_FLAG_PASSTHROUGH_ALUA;
1135
+ return count;
1136
+}
1137
+
10991138 static ssize_t pgr_support_show(struct config_item *item, char *page)
11001139 {
11011140 struct se_dev_attrib *da = to_attrib(item);
1102
- u8 flags = da->da_dev->transport->transport_flags;
1141
+ u8 flags = da->da_dev->transport_flags;
11031142
11041143 return snprintf(page, PAGE_SIZE, "%d\n",
11051144 flags & TRANSPORT_FLAG_PASSTHROUGH_PGR ? 0 : 1);
1145
+}
1146
+
1147
+static ssize_t pgr_support_store(struct config_item *item,
1148
+ const char *page, size_t count)
1149
+{
1150
+ struct se_dev_attrib *da = to_attrib(item);
1151
+ struct se_device *dev = da->da_dev;
1152
+ bool flag, oldflag;
1153
+ int ret;
1154
+
1155
+ ret = strtobool(page, &flag);
1156
+ if (ret < 0)
1157
+ return ret;
1158
+
1159
+ oldflag = !(dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR);
1160
+ if (flag == oldflag)
1161
+ return count;
1162
+
1163
+ if (!(dev->transport->transport_flags_changeable &
1164
+ TRANSPORT_FLAG_PASSTHROUGH_PGR)) {
1165
+ pr_err("dev[%p]: Unable to change SE Device pgr_support:"
1166
+ " pgr_support has fixed value\n", dev);
1167
+ return -ENOSYS;
1168
+ }
1169
+
1170
+ if (flag)
1171
+ dev->transport_flags &= ~TRANSPORT_FLAG_PASSTHROUGH_PGR;
1172
+ else
1173
+ dev->transport_flags |= TRANSPORT_FLAG_PASSTHROUGH_PGR;
1174
+ return count;
11061175 }
11071176
11081177 CONFIGFS_ATTR(, emulate_model_alias);
....@@ -1116,6 +1185,7 @@
11161185 CONFIGFS_ATTR(, emulate_tpws);
11171186 CONFIGFS_ATTR(, emulate_caw);
11181187 CONFIGFS_ATTR(, emulate_3pc);
1188
+CONFIGFS_ATTR(, emulate_pr);
11191189 CONFIGFS_ATTR(, pi_prot_type);
11201190 CONFIGFS_ATTR_RO(, hw_pi_prot_type);
11211191 CONFIGFS_ATTR(, pi_prot_format);
....@@ -1136,8 +1206,8 @@
11361206 CONFIGFS_ATTR(, unmap_granularity_alignment);
11371207 CONFIGFS_ATTR(, unmap_zeroes_data);
11381208 CONFIGFS_ATTR(, max_write_same_len);
1139
-CONFIGFS_ATTR_RO(, alua_support);
1140
-CONFIGFS_ATTR_RO(, pgr_support);
1209
+CONFIGFS_ATTR(, alua_support);
1210
+CONFIGFS_ATTR(, pgr_support);
11411211
11421212 /*
11431213 * dev_attrib attributes for devices using the target core SBC/SPC
....@@ -1156,6 +1226,7 @@
11561226 &attr_emulate_tpws,
11571227 &attr_emulate_caw,
11581228 &attr_emulate_3pc,
1229
+ &attr_emulate_pr,
11591230 &attr_pi_prot_type,
11601231 &attr_hw_pi_prot_type,
11611232 &attr_pi_prot_format,
....@@ -1192,11 +1263,23 @@
11921263 &attr_hw_block_size,
11931264 &attr_hw_max_sectors,
11941265 &attr_hw_queue_depth,
1266
+ &attr_emulate_pr,
11951267 &attr_alua_support,
11961268 &attr_pgr_support,
11971269 NULL,
11981270 };
11991271 EXPORT_SYMBOL(passthrough_attrib_attrs);
1272
+
1273
+/*
1274
+ * pr related dev_attrib attributes for devices passing through CDBs,
1275
+ * but allowing in core pr emulation.
1276
+ */
1277
+struct configfs_attribute *passthrough_pr_attrib_attrs[] = {
1278
+ &attr_enforce_pr_isids,
1279
+ &attr_force_pr_aptpl,
1280
+ NULL,
1281
+};
1282
+EXPORT_SYMBOL(passthrough_pr_attrib_attrs);
12001283
12011284 TB_CIT_SETUP_DRV(dev_attrib, NULL, NULL);
12021285 TB_CIT_SETUP_DRV(dev_action, NULL, NULL);
....@@ -1208,6 +1291,200 @@
12081291 static struct t10_wwn *to_t10_wwn(struct config_item *item)
12091292 {
12101293 return container_of(to_config_group(item), struct t10_wwn, t10_wwn_group);
1294
+}
1295
+
1296
+static ssize_t target_check_inquiry_data(char *buf)
1297
+{
1298
+ size_t len;
1299
+ int i;
1300
+
1301
+ len = strlen(buf);
1302
+
1303
+ /*
1304
+ * SPC 4.3.1:
1305
+ * ASCII data fields shall contain only ASCII printable characters
1306
+ * (i.e., code values 20h to 7Eh) and may be terminated with one or
1307
+ * more ASCII null (00h) characters.
1308
+ */
1309
+ for (i = 0; i < len; i++) {
1310
+ if (buf[i] < 0x20 || buf[i] > 0x7E) {
1311
+ pr_err("Emulated T10 Inquiry Data contains non-ASCII-printable characters\n");
1312
+ return -EINVAL;
1313
+ }
1314
+ }
1315
+
1316
+ return len;
1317
+}
1318
+
1319
+/*
1320
+ * STANDARD and VPD page 0x83 T10 Vendor Identification
1321
+ */
1322
+static ssize_t target_wwn_vendor_id_show(struct config_item *item,
1323
+ char *page)
1324
+{
1325
+ return sprintf(page, "%s\n", &to_t10_wwn(item)->vendor[0]);
1326
+}
1327
+
1328
+static ssize_t target_wwn_vendor_id_store(struct config_item *item,
1329
+ const char *page, size_t count)
1330
+{
1331
+ struct t10_wwn *t10_wwn = to_t10_wwn(item);
1332
+ struct se_device *dev = t10_wwn->t10_dev;
1333
+ /* +2 to allow for a trailing (stripped) '\n' and null-terminator */
1334
+ unsigned char buf[INQUIRY_VENDOR_LEN + 2];
1335
+ char *stripped = NULL;
1336
+ size_t len;
1337
+ ssize_t ret;
1338
+
1339
+ len = strlcpy(buf, page, sizeof(buf));
1340
+ if (len < sizeof(buf)) {
1341
+ /* Strip any newline added from userspace. */
1342
+ stripped = strstrip(buf);
1343
+ len = strlen(stripped);
1344
+ }
1345
+ if (len > INQUIRY_VENDOR_LEN) {
1346
+ pr_err("Emulated T10 Vendor Identification exceeds"
1347
+ " INQUIRY_VENDOR_LEN: " __stringify(INQUIRY_VENDOR_LEN)
1348
+ "\n");
1349
+ return -EOVERFLOW;
1350
+ }
1351
+
1352
+ ret = target_check_inquiry_data(stripped);
1353
+
1354
+ if (ret < 0)
1355
+ return ret;
1356
+
1357
+ /*
1358
+ * Check to see if any active exports exist. If they do exist, fail
1359
+ * here as changing this information on the fly (underneath the
1360
+ * initiator side OS dependent multipath code) could cause negative
1361
+ * effects.
1362
+ */
1363
+ if (dev->export_count) {
1364
+ pr_err("Unable to set T10 Vendor Identification while"
1365
+ " active %d exports exist\n", dev->export_count);
1366
+ return -EINVAL;
1367
+ }
1368
+
1369
+ BUILD_BUG_ON(sizeof(dev->t10_wwn.vendor) != INQUIRY_VENDOR_LEN + 1);
1370
+ strlcpy(dev->t10_wwn.vendor, stripped, sizeof(dev->t10_wwn.vendor));
1371
+
1372
+ pr_debug("Target_Core_ConfigFS: Set emulated T10 Vendor Identification:"
1373
+ " %s\n", dev->t10_wwn.vendor);
1374
+
1375
+ return count;
1376
+}
1377
+
1378
+static ssize_t target_wwn_product_id_show(struct config_item *item,
1379
+ char *page)
1380
+{
1381
+ return sprintf(page, "%s\n", &to_t10_wwn(item)->model[0]);
1382
+}
1383
+
1384
+static ssize_t target_wwn_product_id_store(struct config_item *item,
1385
+ const char *page, size_t count)
1386
+{
1387
+ struct t10_wwn *t10_wwn = to_t10_wwn(item);
1388
+ struct se_device *dev = t10_wwn->t10_dev;
1389
+ /* +2 to allow for a trailing (stripped) '\n' and null-terminator */
1390
+ unsigned char buf[INQUIRY_MODEL_LEN + 2];
1391
+ char *stripped = NULL;
1392
+ size_t len;
1393
+ ssize_t ret;
1394
+
1395
+ len = strlcpy(buf, page, sizeof(buf));
1396
+ if (len < sizeof(buf)) {
1397
+ /* Strip any newline added from userspace. */
1398
+ stripped = strstrip(buf);
1399
+ len = strlen(stripped);
1400
+ }
1401
+ if (len > INQUIRY_MODEL_LEN) {
1402
+ pr_err("Emulated T10 Vendor exceeds INQUIRY_MODEL_LEN: "
1403
+ __stringify(INQUIRY_MODEL_LEN)
1404
+ "\n");
1405
+ return -EOVERFLOW;
1406
+ }
1407
+
1408
+ ret = target_check_inquiry_data(stripped);
1409
+
1410
+ if (ret < 0)
1411
+ return ret;
1412
+
1413
+ /*
1414
+ * Check to see if any active exports exist. If they do exist, fail
1415
+ * here as changing this information on the fly (underneath the
1416
+ * initiator side OS dependent multipath code) could cause negative
1417
+ * effects.
1418
+ */
1419
+ if (dev->export_count) {
1420
+ pr_err("Unable to set T10 Model while active %d exports exist\n",
1421
+ dev->export_count);
1422
+ return -EINVAL;
1423
+ }
1424
+
1425
+ BUILD_BUG_ON(sizeof(dev->t10_wwn.model) != INQUIRY_MODEL_LEN + 1);
1426
+ strlcpy(dev->t10_wwn.model, stripped, sizeof(dev->t10_wwn.model));
1427
+
1428
+ pr_debug("Target_Core_ConfigFS: Set emulated T10 Model Identification: %s\n",
1429
+ dev->t10_wwn.model);
1430
+
1431
+ return count;
1432
+}
1433
+
1434
+static ssize_t target_wwn_revision_show(struct config_item *item,
1435
+ char *page)
1436
+{
1437
+ return sprintf(page, "%s\n", &to_t10_wwn(item)->revision[0]);
1438
+}
1439
+
1440
+static ssize_t target_wwn_revision_store(struct config_item *item,
1441
+ const char *page, size_t count)
1442
+{
1443
+ struct t10_wwn *t10_wwn = to_t10_wwn(item);
1444
+ struct se_device *dev = t10_wwn->t10_dev;
1445
+ /* +2 to allow for a trailing (stripped) '\n' and null-terminator */
1446
+ unsigned char buf[INQUIRY_REVISION_LEN + 2];
1447
+ char *stripped = NULL;
1448
+ size_t len;
1449
+ ssize_t ret;
1450
+
1451
+ len = strlcpy(buf, page, sizeof(buf));
1452
+ if (len < sizeof(buf)) {
1453
+ /* Strip any newline added from userspace. */
1454
+ stripped = strstrip(buf);
1455
+ len = strlen(stripped);
1456
+ }
1457
+ if (len > INQUIRY_REVISION_LEN) {
1458
+ pr_err("Emulated T10 Revision exceeds INQUIRY_REVISION_LEN: "
1459
+ __stringify(INQUIRY_REVISION_LEN)
1460
+ "\n");
1461
+ return -EOVERFLOW;
1462
+ }
1463
+
1464
+ ret = target_check_inquiry_data(stripped);
1465
+
1466
+ if (ret < 0)
1467
+ return ret;
1468
+
1469
+ /*
1470
+ * Check to see if any active exports exist. If they do exist, fail
1471
+ * here as changing this information on the fly (underneath the
1472
+ * initiator side OS dependent multipath code) could cause negative
1473
+ * effects.
1474
+ */
1475
+ if (dev->export_count) {
1476
+ pr_err("Unable to set T10 Revision while active %d exports exist\n",
1477
+ dev->export_count);
1478
+ return -EINVAL;
1479
+ }
1480
+
1481
+ BUILD_BUG_ON(sizeof(dev->t10_wwn.revision) != INQUIRY_REVISION_LEN + 1);
1482
+ strlcpy(dev->t10_wwn.revision, stripped, sizeof(dev->t10_wwn.revision));
1483
+
1484
+ pr_debug("Target_Core_ConfigFS: Set emulated T10 Revision: %s\n",
1485
+ dev->t10_wwn.revision);
1486
+
1487
+ return count;
12111488 }
12121489
12131490 /*
....@@ -1356,6 +1633,9 @@
13561633 /* VPD page 0x83 Association: SCSI Target Device */
13571634 DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_scsi_target_device, 0x20);
13581635
1636
+CONFIGFS_ATTR(target_wwn_, vendor_id);
1637
+CONFIGFS_ATTR(target_wwn_, product_id);
1638
+CONFIGFS_ATTR(target_wwn_, revision);
13591639 CONFIGFS_ATTR(target_wwn_, vpd_unit_serial);
13601640 CONFIGFS_ATTR_RO(target_wwn_, vpd_protocol_identifier);
13611641 CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_logical_unit);
....@@ -1363,6 +1643,9 @@
13631643 CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_scsi_target_device);
13641644
13651645 static struct configfs_attribute *target_core_dev_wwn_attrs[] = {
1646
+ &target_wwn_attr_vendor_id,
1647
+ &target_wwn_attr_product_id,
1648
+ &target_wwn_attr_revision,
13661649 &target_wwn_attr_vpd_unit_serial,
13671650 &target_wwn_attr_vpd_protocol_identifier,
13681651 &target_wwn_attr_vpd_assoc_logical_unit,
....@@ -1400,21 +1683,22 @@
14001683 core_pr_dump_initiator_port(pr_reg, i_buf, PR_REG_ISID_ID_LEN);
14011684
14021685 return sprintf(page, "SPC-3 Reservation: %s Initiator: %s%s\n",
1403
- se_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
1686
+ se_nacl->se_tpg->se_tpg_tfo->fabric_name,
14041687 se_nacl->initiatorname, i_buf);
14051688 }
14061689
14071690 static ssize_t target_core_dev_pr_show_spc2_res(struct se_device *dev,
14081691 char *page)
14091692 {
1693
+ struct se_session *sess = dev->reservation_holder;
14101694 struct se_node_acl *se_nacl;
14111695 ssize_t len;
14121696
1413
- se_nacl = dev->dev_reserved_node_acl;
1414
- if (se_nacl) {
1697
+ if (sess) {
1698
+ se_nacl = sess->se_node_acl;
14151699 len = sprintf(page,
14161700 "SPC-2 Reservation: %s Initiator: %s\n",
1417
- se_nacl->se_tpg->se_tpg_tfo->get_fabric_name(),
1701
+ se_nacl->se_tpg->se_tpg_tfo->fabric_name,
14181702 se_nacl->initiatorname);
14191703 } else {
14201704 len = sprintf(page, "No SPC-2 Reservation holder\n");
....@@ -1427,7 +1711,10 @@
14271711 struct se_device *dev = pr_to_dev(item);
14281712 int ret;
14291713
1430
- if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)
1714
+ if (!dev->dev_attrib.emulate_pr)
1715
+ return sprintf(page, "SPC_RESERVATIONS_DISABLED\n");
1716
+
1717
+ if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)
14311718 return sprintf(page, "Passthrough\n");
14321719
14331720 spin_lock(&dev->dev_reservation_lock);
....@@ -1489,13 +1776,13 @@
14891776 tfo = se_tpg->se_tpg_tfo;
14901777
14911778 len += sprintf(page+len, "SPC-3 Reservation: %s"
1492
- " Target Node Endpoint: %s\n", tfo->get_fabric_name(),
1779
+ " Target Node Endpoint: %s\n", tfo->fabric_name,
14931780 tfo->tpg_get_wwn(se_tpg));
14941781 len += sprintf(page+len, "SPC-3 Reservation: Relative Port"
14951782 " Identifier Tag: %hu %s Portal Group Tag: %hu"
14961783 " %s Logical Unit: %llu\n", pr_reg->tg_pt_sep_rtpi,
1497
- tfo->get_fabric_name(), tfo->tpg_get_tag(se_tpg),
1498
- tfo->get_fabric_name(), pr_reg->pr_aptpl_target_lun);
1784
+ tfo->fabric_name, tfo->tpg_get_tag(se_tpg),
1785
+ tfo->fabric_name, pr_reg->pr_aptpl_target_lun);
14991786
15001787 out_unlock:
15011788 spin_unlock(&dev->dev_reservation_lock);
....@@ -1526,7 +1813,7 @@
15261813 core_pr_dump_initiator_port(pr_reg, i_buf,
15271814 PR_REG_ISID_ID_LEN);
15281815 sprintf(buf, "%s Node: %s%s Key: 0x%016Lx PRgen: 0x%08x\n",
1529
- tfo->get_fabric_name(),
1816
+ tfo->fabric_name,
15301817 pr_reg->pr_reg_nacl->initiatorname, i_buf, pr_reg->pr_res_key,
15311818 pr_reg->pr_res_generation);
15321819
....@@ -1567,12 +1854,14 @@
15671854 {
15681855 struct se_device *dev = pr_to_dev(item);
15691856
1570
- if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)
1857
+ if (!dev->dev_attrib.emulate_pr)
1858
+ return sprintf(page, "SPC_RESERVATIONS_DISABLED\n");
1859
+ if (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)
15711860 return sprintf(page, "SPC_PASSTHROUGH\n");
1572
- else if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS)
1861
+ if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS)
15731862 return sprintf(page, "SPC2_RESERVATIONS\n");
1574
- else
1575
- return sprintf(page, "SPC3_PERSISTENT_RESERVATIONS\n");
1863
+
1864
+ return sprintf(page, "SPC3_PERSISTENT_RESERVATIONS\n");
15761865 }
15771866
15781867 static ssize_t target_pr_res_aptpl_active_show(struct config_item *item,
....@@ -1580,7 +1869,8 @@
15801869 {
15811870 struct se_device *dev = pr_to_dev(item);
15821871
1583
- if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)
1872
+ if (!dev->dev_attrib.emulate_pr ||
1873
+ (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR))
15841874 return 0;
15851875
15861876 return sprintf(page, "APTPL Bit Status: %s\n",
....@@ -1592,7 +1882,8 @@
15921882 {
15931883 struct se_device *dev = pr_to_dev(item);
15941884
1595
- if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)
1885
+ if (!dev->dev_attrib.emulate_pr ||
1886
+ (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR))
15961887 return 0;
15971888
15981889 return sprintf(page, "Ready to process PR APTPL metadata..\n");
....@@ -1638,7 +1929,8 @@
16381929 u16 tpgt = 0;
16391930 u8 type = 0;
16401931
1641
- if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR)
1932
+ if (!dev->dev_attrib.emulate_pr ||
1933
+ (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR))
16421934 return count;
16431935 if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS)
16441936 return count;
....@@ -2746,7 +3038,7 @@
27463038 struct se_portal_group *tpg = lun->lun_tpg;
27473039
27483040 cur_len = snprintf(buf, TG_PT_GROUP_NAME_BUF, "%s/%s/tpgt_%hu"
2749
- "/%s\n", tpg->se_tpg_tfo->get_fabric_name(),
3041
+ "/%s\n", tpg->se_tpg_tfo->fabric_name,
27503042 tpg->se_tpg_tfo->tpg_get_wwn(tpg),
27513043 tpg->se_tpg_tfo->tpg_get_tag(tpg),
27523044 config_item_name(&lun->lun_group.cg_item));
....@@ -3360,6 +3652,7 @@
33603652 MODULE_DESCRIPTION("Target_Core_Mod/ConfigFS");
33613653 MODULE_AUTHOR("nab@Linux-iSCSI.org");
33623654 MODULE_LICENSE("GPL");
3655
+MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
33633656
33643657 module_init(target_core_init_configfs);
33653658 module_exit(target_core_exit_configfs);