diff options
Diffstat (limited to 'drivers/xen/xen-scsiback.c')
-rw-r--r-- | drivers/xen/xen-scsiback.c | 191 |
1 files changed, 19 insertions, 172 deletions
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 39223c3e99ad..9eeefd7cad41 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c | |||
@@ -53,7 +53,6 @@ | |||
53 | 53 | ||
54 | #include <target/target_core_base.h> | 54 | #include <target/target_core_base.h> |
55 | #include <target/target_core_fabric.h> | 55 | #include <target/target_core_fabric.h> |
56 | #include <target/target_core_configfs.h> | ||
57 | #include <target/target_core_fabric_configfs.h> | 56 | #include <target/target_core_fabric_configfs.h> |
58 | 57 | ||
59 | #include <asm/hypervisor.h> | 58 | #include <asm/hypervisor.h> |
@@ -201,8 +200,6 @@ static LIST_HEAD(scsiback_free_pages); | |||
201 | static DEFINE_MUTEX(scsiback_mutex); | 200 | static DEFINE_MUTEX(scsiback_mutex); |
202 | static LIST_HEAD(scsiback_list); | 201 | static LIST_HEAD(scsiback_list); |
203 | 202 | ||
204 | static const struct target_core_fabric_ops scsiback_ops; | ||
205 | |||
206 | static void scsiback_get(struct vscsibk_info *info) | 203 | static void scsiback_get(struct vscsibk_info *info) |
207 | { | 204 | { |
208 | atomic_inc(&info->nr_unreplied_reqs); | 205 | atomic_inc(&info->nr_unreplied_reqs); |
@@ -397,6 +394,7 @@ static void scsiback_cmd_exec(struct vscsibk_pend *pending_req) | |||
397 | memset(se_cmd, 0, sizeof(*se_cmd)); | 394 | memset(se_cmd, 0, sizeof(*se_cmd)); |
398 | 395 | ||
399 | scsiback_get(pending_req->info); | 396 | scsiback_get(pending_req->info); |
397 | se_cmd->tag = pending_req->rqid; | ||
400 | rc = target_submit_cmd_map_sgls(se_cmd, sess, pending_req->cmnd, | 398 | rc = target_submit_cmd_map_sgls(se_cmd, sess, pending_req->cmnd, |
401 | pending_req->sense_buffer, pending_req->v2p->lun, | 399 | pending_req->sense_buffer, pending_req->v2p->lun, |
402 | pending_req->data_len, 0, | 400 | pending_req->data_len, 0, |
@@ -863,7 +861,8 @@ static int scsiback_add_translation_entry(struct vscsibk_info *info, | |||
863 | struct list_head *head = &(info->v2p_entry_lists); | 861 | struct list_head *head = &(info->v2p_entry_lists); |
864 | unsigned long flags; | 862 | unsigned long flags; |
865 | char *lunp; | 863 | char *lunp; |
866 | unsigned int lun; | 864 | unsigned long long unpacked_lun; |
865 | struct se_lun *se_lun; | ||
867 | struct scsiback_tpg *tpg_entry, *tpg = NULL; | 866 | struct scsiback_tpg *tpg_entry, *tpg = NULL; |
868 | char *error = "doesn't exist"; | 867 | char *error = "doesn't exist"; |
869 | 868 | ||
@@ -874,24 +873,27 @@ static int scsiback_add_translation_entry(struct vscsibk_info *info, | |||
874 | } | 873 | } |
875 | *lunp = 0; | 874 | *lunp = 0; |
876 | lunp++; | 875 | lunp++; |
877 | if (kstrtouint(lunp, 10, &lun) || lun >= TRANSPORT_MAX_LUNS_PER_TPG) { | 876 | err = kstrtoull(lunp, 10, &unpacked_lun); |
877 | if (err < 0) { | ||
878 | pr_err("lun number not valid: %s\n", lunp); | 878 | pr_err("lun number not valid: %s\n", lunp); |
879 | return -EINVAL; | 879 | return err; |
880 | } | 880 | } |
881 | 881 | ||
882 | mutex_lock(&scsiback_mutex); | 882 | mutex_lock(&scsiback_mutex); |
883 | list_for_each_entry(tpg_entry, &scsiback_list, tv_tpg_list) { | 883 | list_for_each_entry(tpg_entry, &scsiback_list, tv_tpg_list) { |
884 | if (!strcmp(phy, tpg_entry->tport->tport_name) || | 884 | if (!strcmp(phy, tpg_entry->tport->tport_name) || |
885 | !strcmp(phy, tpg_entry->param_alias)) { | 885 | !strcmp(phy, tpg_entry->param_alias)) { |
886 | spin_lock(&tpg_entry->se_tpg.tpg_lun_lock); | 886 | mutex_lock(&tpg_entry->se_tpg.tpg_lun_mutex); |
887 | if (tpg_entry->se_tpg.tpg_lun_list[lun]->lun_status == | 887 | hlist_for_each_entry(se_lun, &tpg_entry->se_tpg.tpg_lun_hlist, link) { |
888 | TRANSPORT_LUN_STATUS_ACTIVE) { | 888 | if (se_lun->unpacked_lun == unpacked_lun) { |
889 | if (!tpg_entry->tpg_nexus) | 889 | if (!tpg_entry->tpg_nexus) |
890 | error = "nexus undefined"; | 890 | error = "nexus undefined"; |
891 | else | 891 | else |
892 | tpg = tpg_entry; | 892 | tpg = tpg_entry; |
893 | break; | ||
894 | } | ||
893 | } | 895 | } |
894 | spin_unlock(&tpg_entry->se_tpg.tpg_lun_lock); | 896 | mutex_unlock(&tpg_entry->se_tpg.tpg_lun_mutex); |
895 | break; | 897 | break; |
896 | } | 898 | } |
897 | } | 899 | } |
@@ -903,7 +905,7 @@ static int scsiback_add_translation_entry(struct vscsibk_info *info, | |||
903 | mutex_unlock(&scsiback_mutex); | 905 | mutex_unlock(&scsiback_mutex); |
904 | 906 | ||
905 | if (!tpg) { | 907 | if (!tpg) { |
906 | pr_err("%s:%d %s\n", phy, lun, error); | 908 | pr_err("%s:%llu %s\n", phy, unpacked_lun, error); |
907 | return -ENODEV; | 909 | return -ENODEV; |
908 | } | 910 | } |
909 | 911 | ||
@@ -931,7 +933,7 @@ static int scsiback_add_translation_entry(struct vscsibk_info *info, | |||
931 | kref_init(&new->kref); | 933 | kref_init(&new->kref); |
932 | new->v = *v; | 934 | new->v = *v; |
933 | new->tpg = tpg; | 935 | new->tpg = tpg; |
934 | new->lun = lun; | 936 | new->lun = unpacked_lun; |
935 | list_add_tail(&new->l, head); | 937 | list_add_tail(&new->l, head); |
936 | 938 | ||
937 | out: | 939 | out: |
@@ -1251,28 +1253,6 @@ static char *scsiback_dump_proto_id(struct scsiback_tport *tport) | |||
1251 | return "Unknown"; | 1253 | return "Unknown"; |
1252 | } | 1254 | } |
1253 | 1255 | ||
1254 | static u8 scsiback_get_fabric_proto_ident(struct se_portal_group *se_tpg) | ||
1255 | { | ||
1256 | struct scsiback_tpg *tpg = container_of(se_tpg, | ||
1257 | struct scsiback_tpg, se_tpg); | ||
1258 | struct scsiback_tport *tport = tpg->tport; | ||
1259 | |||
1260 | switch (tport->tport_proto_id) { | ||
1261 | case SCSI_PROTOCOL_SAS: | ||
1262 | return sas_get_fabric_proto_ident(se_tpg); | ||
1263 | case SCSI_PROTOCOL_FCP: | ||
1264 | return fc_get_fabric_proto_ident(se_tpg); | ||
1265 | case SCSI_PROTOCOL_ISCSI: | ||
1266 | return iscsi_get_fabric_proto_ident(se_tpg); | ||
1267 | default: | ||
1268 | pr_err("Unknown tport_proto_id: 0x%02x, using SAS emulation\n", | ||
1269 | tport->tport_proto_id); | ||
1270 | break; | ||
1271 | } | ||
1272 | |||
1273 | return sas_get_fabric_proto_ident(se_tpg); | ||
1274 | } | ||
1275 | |||
1276 | static char *scsiback_get_fabric_wwn(struct se_portal_group *se_tpg) | 1256 | static char *scsiback_get_fabric_wwn(struct se_portal_group *se_tpg) |
1277 | { | 1257 | { |
1278 | struct scsiback_tpg *tpg = container_of(se_tpg, | 1258 | struct scsiback_tpg *tpg = container_of(se_tpg, |
@@ -1289,102 +1269,6 @@ static u16 scsiback_get_tag(struct se_portal_group *se_tpg) | |||
1289 | return tpg->tport_tpgt; | 1269 | return tpg->tport_tpgt; |
1290 | } | 1270 | } |
1291 | 1271 | ||
1292 | static u32 scsiback_get_default_depth(struct se_portal_group *se_tpg) | ||
1293 | { | ||
1294 | return 1; | ||
1295 | } | ||
1296 | |||
1297 | static u32 | ||
1298 | scsiback_get_pr_transport_id(struct se_portal_group *se_tpg, | ||
1299 | struct se_node_acl *se_nacl, | ||
1300 | struct t10_pr_registration *pr_reg, | ||
1301 | int *format_code, | ||
1302 | unsigned char *buf) | ||
1303 | { | ||
1304 | struct scsiback_tpg *tpg = container_of(se_tpg, | ||
1305 | struct scsiback_tpg, se_tpg); | ||
1306 | struct scsiback_tport *tport = tpg->tport; | ||
1307 | |||
1308 | switch (tport->tport_proto_id) { | ||
1309 | case SCSI_PROTOCOL_SAS: | ||
1310 | return sas_get_pr_transport_id(se_tpg, se_nacl, pr_reg, | ||
1311 | format_code, buf); | ||
1312 | case SCSI_PROTOCOL_FCP: | ||
1313 | return fc_get_pr_transport_id(se_tpg, se_nacl, pr_reg, | ||
1314 | format_code, buf); | ||
1315 | case SCSI_PROTOCOL_ISCSI: | ||
1316 | return iscsi_get_pr_transport_id(se_tpg, se_nacl, pr_reg, | ||
1317 | format_code, buf); | ||
1318 | default: | ||
1319 | pr_err("Unknown tport_proto_id: 0x%02x, using SAS emulation\n", | ||
1320 | tport->tport_proto_id); | ||
1321 | break; | ||
1322 | } | ||
1323 | |||
1324 | return sas_get_pr_transport_id(se_tpg, se_nacl, pr_reg, | ||
1325 | format_code, buf); | ||
1326 | } | ||
1327 | |||
1328 | static u32 | ||
1329 | scsiback_get_pr_transport_id_len(struct se_portal_group *se_tpg, | ||
1330 | struct se_node_acl *se_nacl, | ||
1331 | struct t10_pr_registration *pr_reg, | ||
1332 | int *format_code) | ||
1333 | { | ||
1334 | struct scsiback_tpg *tpg = container_of(se_tpg, | ||
1335 | struct scsiback_tpg, se_tpg); | ||
1336 | struct scsiback_tport *tport = tpg->tport; | ||
1337 | |||
1338 | switch (tport->tport_proto_id) { | ||
1339 | case SCSI_PROTOCOL_SAS: | ||
1340 | return sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg, | ||
1341 | format_code); | ||
1342 | case SCSI_PROTOCOL_FCP: | ||
1343 | return fc_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg, | ||
1344 | format_code); | ||
1345 | case SCSI_PROTOCOL_ISCSI: | ||
1346 | return iscsi_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg, | ||
1347 | format_code); | ||
1348 | default: | ||
1349 | pr_err("Unknown tport_proto_id: 0x%02x, using SAS emulation\n", | ||
1350 | tport->tport_proto_id); | ||
1351 | break; | ||
1352 | } | ||
1353 | |||
1354 | return sas_get_pr_transport_id_len(se_tpg, se_nacl, pr_reg, | ||
1355 | format_code); | ||
1356 | } | ||
1357 | |||
1358 | static char * | ||
1359 | scsiback_parse_pr_out_transport_id(struct se_portal_group *se_tpg, | ||
1360 | const char *buf, | ||
1361 | u32 *out_tid_len, | ||
1362 | char **port_nexus_ptr) | ||
1363 | { | ||
1364 | struct scsiback_tpg *tpg = container_of(se_tpg, | ||
1365 | struct scsiback_tpg, se_tpg); | ||
1366 | struct scsiback_tport *tport = tpg->tport; | ||
1367 | |||
1368 | switch (tport->tport_proto_id) { | ||
1369 | case SCSI_PROTOCOL_SAS: | ||
1370 | return sas_parse_pr_out_transport_id(se_tpg, buf, out_tid_len, | ||
1371 | port_nexus_ptr); | ||
1372 | case SCSI_PROTOCOL_FCP: | ||
1373 | return fc_parse_pr_out_transport_id(se_tpg, buf, out_tid_len, | ||
1374 | port_nexus_ptr); | ||
1375 | case SCSI_PROTOCOL_ISCSI: | ||
1376 | return iscsi_parse_pr_out_transport_id(se_tpg, buf, out_tid_len, | ||
1377 | port_nexus_ptr); | ||
1378 | default: | ||
1379 | pr_err("Unknown tport_proto_id: 0x%02x, using SAS emulation\n", | ||
1380 | tport->tport_proto_id); | ||
1381 | break; | ||
1382 | } | ||
1383 | |||
1384 | return sas_parse_pr_out_transport_id(se_tpg, buf, out_tid_len, | ||
1385 | port_nexus_ptr); | ||
1386 | } | ||
1387 | |||
1388 | static struct se_wwn * | 1272 | static struct se_wwn * |
1389 | scsiback_make_tport(struct target_fabric_configfs *tf, | 1273 | scsiback_make_tport(struct target_fabric_configfs *tf, |
1390 | struct config_group *group, | 1274 | struct config_group *group, |
@@ -1451,19 +1335,6 @@ static void scsiback_drop_tport(struct se_wwn *wwn) | |||
1451 | kfree(tport); | 1335 | kfree(tport); |
1452 | } | 1336 | } |
1453 | 1337 | ||
1454 | static struct se_node_acl * | ||
1455 | scsiback_alloc_fabric_acl(struct se_portal_group *se_tpg) | ||
1456 | { | ||
1457 | return kzalloc(sizeof(struct se_node_acl), GFP_KERNEL); | ||
1458 | } | ||
1459 | |||
1460 | static void | ||
1461 | scsiback_release_fabric_acl(struct se_portal_group *se_tpg, | ||
1462 | struct se_node_acl *se_nacl) | ||
1463 | { | ||
1464 | kfree(se_nacl); | ||
1465 | } | ||
1466 | |||
1467 | static u32 scsiback_tpg_get_inst_index(struct se_portal_group *se_tpg) | 1338 | static u32 scsiback_tpg_get_inst_index(struct se_portal_group *se_tpg) |
1468 | { | 1339 | { |
1469 | return 1; | 1340 | return 1; |
@@ -1522,14 +1393,6 @@ static void scsiback_set_default_node_attrs(struct se_node_acl *nacl) | |||
1522 | { | 1393 | { |
1523 | } | 1394 | } |
1524 | 1395 | ||
1525 | static u32 scsiback_get_task_tag(struct se_cmd *se_cmd) | ||
1526 | { | ||
1527 | struct vscsibk_pend *pending_req = container_of(se_cmd, | ||
1528 | struct vscsibk_pend, se_cmd); | ||
1529 | |||
1530 | return pending_req->rqid; | ||
1531 | } | ||
1532 | |||
1533 | static int scsiback_get_cmd_state(struct se_cmd *se_cmd) | 1396 | static int scsiback_get_cmd_state(struct se_cmd *se_cmd) |
1534 | { | 1397 | { |
1535 | return 0; | 1398 | return 0; |
@@ -1898,8 +1761,7 @@ scsiback_make_tpg(struct se_wwn *wwn, | |||
1898 | tpg->tport = tport; | 1761 | tpg->tport = tport; |
1899 | tpg->tport_tpgt = tpgt; | 1762 | tpg->tport_tpgt = tpgt; |
1900 | 1763 | ||
1901 | ret = core_tpg_register(&scsiback_ops, wwn, | 1764 | ret = core_tpg_register(wwn, &tpg->se_tpg, tport->tport_proto_id); |
1902 | &tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL); | ||
1903 | if (ret < 0) { | 1765 | if (ret < 0) { |
1904 | kfree(tpg); | 1766 | kfree(tpg); |
1905 | return NULL; | 1767 | return NULL; |
@@ -1944,23 +1806,15 @@ static const struct target_core_fabric_ops scsiback_ops = { | |||
1944 | .module = THIS_MODULE, | 1806 | .module = THIS_MODULE, |
1945 | .name = "xen-pvscsi", | 1807 | .name = "xen-pvscsi", |
1946 | .get_fabric_name = scsiback_get_fabric_name, | 1808 | .get_fabric_name = scsiback_get_fabric_name, |
1947 | .get_fabric_proto_ident = scsiback_get_fabric_proto_ident, | ||
1948 | .tpg_get_wwn = scsiback_get_fabric_wwn, | 1809 | .tpg_get_wwn = scsiback_get_fabric_wwn, |
1949 | .tpg_get_tag = scsiback_get_tag, | 1810 | .tpg_get_tag = scsiback_get_tag, |
1950 | .tpg_get_default_depth = scsiback_get_default_depth, | ||
1951 | .tpg_get_pr_transport_id = scsiback_get_pr_transport_id, | ||
1952 | .tpg_get_pr_transport_id_len = scsiback_get_pr_transport_id_len, | ||
1953 | .tpg_parse_pr_out_transport_id = scsiback_parse_pr_out_transport_id, | ||
1954 | .tpg_check_demo_mode = scsiback_check_true, | 1811 | .tpg_check_demo_mode = scsiback_check_true, |
1955 | .tpg_check_demo_mode_cache = scsiback_check_true, | 1812 | .tpg_check_demo_mode_cache = scsiback_check_true, |
1956 | .tpg_check_demo_mode_write_protect = scsiback_check_false, | 1813 | .tpg_check_demo_mode_write_protect = scsiback_check_false, |
1957 | .tpg_check_prod_mode_write_protect = scsiback_check_false, | 1814 | .tpg_check_prod_mode_write_protect = scsiback_check_false, |
1958 | .tpg_alloc_fabric_acl = scsiback_alloc_fabric_acl, | ||
1959 | .tpg_release_fabric_acl = scsiback_release_fabric_acl, | ||
1960 | .tpg_get_inst_index = scsiback_tpg_get_inst_index, | 1815 | .tpg_get_inst_index = scsiback_tpg_get_inst_index, |
1961 | .check_stop_free = scsiback_check_stop_free, | 1816 | .check_stop_free = scsiback_check_stop_free, |
1962 | .release_cmd = scsiback_release_cmd, | 1817 | .release_cmd = scsiback_release_cmd, |
1963 | .put_session = NULL, | ||
1964 | .shutdown_session = scsiback_shutdown_session, | 1818 | .shutdown_session = scsiback_shutdown_session, |
1965 | .close_session = scsiback_close_session, | 1819 | .close_session = scsiback_close_session, |
1966 | .sess_get_index = scsiback_sess_get_index, | 1820 | .sess_get_index = scsiback_sess_get_index, |
@@ -1968,7 +1822,6 @@ static const struct target_core_fabric_ops scsiback_ops = { | |||
1968 | .write_pending = scsiback_write_pending, | 1822 | .write_pending = scsiback_write_pending, |
1969 | .write_pending_status = scsiback_write_pending_status, | 1823 | .write_pending_status = scsiback_write_pending_status, |
1970 | .set_default_node_attributes = scsiback_set_default_node_attrs, | 1824 | .set_default_node_attributes = scsiback_set_default_node_attrs, |
1971 | .get_task_tag = scsiback_get_task_tag, | ||
1972 | .get_cmd_state = scsiback_get_cmd_state, | 1825 | .get_cmd_state = scsiback_get_cmd_state, |
1973 | .queue_data_in = scsiback_queue_data_in, | 1826 | .queue_data_in = scsiback_queue_data_in, |
1974 | .queue_status = scsiback_queue_status, | 1827 | .queue_status = scsiback_queue_status, |
@@ -1983,12 +1836,6 @@ static const struct target_core_fabric_ops scsiback_ops = { | |||
1983 | .fabric_drop_tpg = scsiback_drop_tpg, | 1836 | .fabric_drop_tpg = scsiback_drop_tpg, |
1984 | .fabric_post_link = scsiback_port_link, | 1837 | .fabric_post_link = scsiback_port_link, |
1985 | .fabric_pre_unlink = scsiback_port_unlink, | 1838 | .fabric_pre_unlink = scsiback_port_unlink, |
1986 | .fabric_make_np = NULL, | ||
1987 | .fabric_drop_np = NULL, | ||
1988 | #if 0 | ||
1989 | .fabric_make_nodeacl = scsiback_make_nodeacl, | ||
1990 | .fabric_drop_nodeacl = scsiback_drop_nodeacl, | ||
1991 | #endif | ||
1992 | 1839 | ||
1993 | .tfc_wwn_attrs = scsiback_wwn_attrs, | 1840 | .tfc_wwn_attrs = scsiback_wwn_attrs, |
1994 | .tfc_tpg_base_attrs = scsiback_tpg_attrs, | 1841 | .tfc_tpg_base_attrs = scsiback_tpg_attrs, |