diff options
author | Christoph Hellwig <hch@infradead.org> | 2012-10-08 00:03:19 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-11-06 23:55:43 -0500 |
commit | 0fd97ccf45be26fb01b3a412f1f6c6b5044b2f16 (patch) | |
tree | c642e3da11e534a311a1e998ef740a3d44b9187b /drivers/target/target_core_pr.c | |
parent | 3d70f8c617a436c7146ecb81df2265b4626dfe89 (diff) |
target: kill struct se_subsystem_dev
Simplify the code a lot by killing the superflous struct se_subsystem_dev.
Instead se_device is allocated early on by the backend driver, which allocates
it as part of its own per-device structure, borrowing the scheme that is for
example used for inode allocation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_pr.c')
-rw-r--r-- | drivers/target/target_core_pr.c | 148 |
1 files changed, 67 insertions, 81 deletions
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 8c323a98c4a0..2b289891672f 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c | |||
@@ -103,7 +103,7 @@ static int core_scsi2_reservation_check(struct se_cmd *cmd, u32 *pr_reg_type) | |||
103 | spin_unlock(&dev->dev_reservation_lock); | 103 | spin_unlock(&dev->dev_reservation_lock); |
104 | return -EINVAL; | 104 | return -EINVAL; |
105 | } | 105 | } |
106 | if (!(dev->dev_flags & DF_SPC2_RESERVATIONS_WITH_ISID)) { | 106 | if (!(dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS_WITH_ISID)) { |
107 | spin_unlock(&dev->dev_reservation_lock); | 107 | spin_unlock(&dev->dev_reservation_lock); |
108 | return 0; | 108 | return 0; |
109 | } | 109 | } |
@@ -120,10 +120,10 @@ static void core_scsi3_put_pr_reg(struct t10_pr_registration *); | |||
120 | static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd) | 120 | static int target_check_scsi2_reservation_conflict(struct se_cmd *cmd) |
121 | { | 121 | { |
122 | struct se_session *se_sess = cmd->se_sess; | 122 | struct se_session *se_sess = cmd->se_sess; |
123 | struct se_subsystem_dev *su_dev = cmd->se_dev->se_sub_dev; | 123 | struct se_device *dev = cmd->se_dev; |
124 | struct t10_pr_registration *pr_reg; | 124 | struct t10_pr_registration *pr_reg; |
125 | struct t10_reservation *pr_tmpl = &su_dev->t10_pr; | 125 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
126 | int crh = (su_dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS); | 126 | int crh = (dev->t10_pr.res_type == SPC3_PERSISTENT_RESERVATIONS); |
127 | int conflict = 0; | 127 | int conflict = 0; |
128 | 128 | ||
129 | if (!crh) | 129 | if (!crh) |
@@ -223,10 +223,10 @@ int target_scsi2_reservation_release(struct se_cmd *cmd) | |||
223 | goto out_unlock; | 223 | goto out_unlock; |
224 | 224 | ||
225 | dev->dev_reserved_node_acl = NULL; | 225 | dev->dev_reserved_node_acl = NULL; |
226 | dev->dev_flags &= ~DF_SPC2_RESERVATIONS; | 226 | dev->dev_reservation_flags &= ~DRF_SPC2_RESERVATIONS; |
227 | if (dev->dev_flags & DF_SPC2_RESERVATIONS_WITH_ISID) { | 227 | if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS_WITH_ISID) { |
228 | dev->dev_res_bin_isid = 0; | 228 | dev->dev_res_bin_isid = 0; |
229 | dev->dev_flags &= ~DF_SPC2_RESERVATIONS_WITH_ISID; | 229 | dev->dev_reservation_flags &= ~DRF_SPC2_RESERVATIONS_WITH_ISID; |
230 | } | 230 | } |
231 | tpg = sess->se_tpg; | 231 | tpg = sess->se_tpg; |
232 | pr_debug("SCSI-2 Released reservation for %s LUN: %u ->" | 232 | pr_debug("SCSI-2 Released reservation for %s LUN: %u ->" |
@@ -292,10 +292,10 @@ int target_scsi2_reservation_reserve(struct se_cmd *cmd) | |||
292 | } | 292 | } |
293 | 293 | ||
294 | dev->dev_reserved_node_acl = sess->se_node_acl; | 294 | dev->dev_reserved_node_acl = sess->se_node_acl; |
295 | dev->dev_flags |= DF_SPC2_RESERVATIONS; | 295 | dev->dev_reservation_flags |= DRF_SPC2_RESERVATIONS; |
296 | if (sess->sess_bin_isid != 0) { | 296 | if (sess->sess_bin_isid != 0) { |
297 | dev->dev_res_bin_isid = sess->sess_bin_isid; | 297 | dev->dev_res_bin_isid = sess->sess_bin_isid; |
298 | dev->dev_flags |= DF_SPC2_RESERVATIONS_WITH_ISID; | 298 | dev->dev_reservation_flags |= DRF_SPC2_RESERVATIONS_WITH_ISID; |
299 | } | 299 | } |
300 | pr_debug("SCSI-2 Reserved %s LUN: %u -> MAPPED LUN: %u" | 300 | pr_debug("SCSI-2 Reserved %s LUN: %u -> MAPPED LUN: %u" |
301 | " for %s\n", tpg->se_tpg_tfo->get_fabric_name(), | 301 | " for %s\n", tpg->se_tpg_tfo->get_fabric_name(), |
@@ -333,7 +333,7 @@ static int core_scsi3_pr_seq_non_holder( | |||
333 | /* | 333 | /* |
334 | * A legacy SPC-2 reservation is being held. | 334 | * A legacy SPC-2 reservation is being held. |
335 | */ | 335 | */ |
336 | if (cmd->se_dev->dev_flags & DF_SPC2_RESERVATIONS) | 336 | if (cmd->se_dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) |
337 | return core_scsi2_reservation_seq_non_holder(cmd, | 337 | return core_scsi2_reservation_seq_non_holder(cmd, |
338 | cdb, pr_reg_type); | 338 | cdb, pr_reg_type); |
339 | 339 | ||
@@ -565,8 +565,8 @@ static int core_scsi3_pr_seq_non_holder( | |||
565 | 565 | ||
566 | static u32 core_scsi3_pr_generation(struct se_device *dev) | 566 | static u32 core_scsi3_pr_generation(struct se_device *dev) |
567 | { | 567 | { |
568 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; | ||
569 | u32 prg; | 568 | u32 prg; |
569 | |||
570 | /* | 570 | /* |
571 | * PRGeneration field shall contain the value of a 32-bit wrapping | 571 | * PRGeneration field shall contain the value of a 32-bit wrapping |
572 | * counter mainted by the device server. | 572 | * counter mainted by the device server. |
@@ -577,7 +577,7 @@ static u32 core_scsi3_pr_generation(struct se_device *dev) | |||
577 | * See spc4r17 section 6.3.12 READ_KEYS service action | 577 | * See spc4r17 section 6.3.12 READ_KEYS service action |
578 | */ | 578 | */ |
579 | spin_lock(&dev->dev_reservation_lock); | 579 | spin_lock(&dev->dev_reservation_lock); |
580 | prg = su_dev->t10_pr.pr_generation++; | 580 | prg = dev->t10_pr.pr_generation++; |
581 | spin_unlock(&dev->dev_reservation_lock); | 581 | spin_unlock(&dev->dev_reservation_lock); |
582 | 582 | ||
583 | return prg; | 583 | return prg; |
@@ -596,7 +596,7 @@ static int core_scsi3_pr_reservation_check( | |||
596 | /* | 596 | /* |
597 | * A legacy SPC-2 reservation is being held. | 597 | * A legacy SPC-2 reservation is being held. |
598 | */ | 598 | */ |
599 | if (dev->dev_flags & DF_SPC2_RESERVATIONS) | 599 | if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) |
600 | return core_scsi2_reservation_check(cmd, pr_reg_type); | 600 | return core_scsi2_reservation_check(cmd, pr_reg_type); |
601 | 601 | ||
602 | spin_lock(&dev->dev_reservation_lock); | 602 | spin_lock(&dev->dev_reservation_lock); |
@@ -636,7 +636,6 @@ static struct t10_pr_registration *__core_scsi3_do_alloc_registration( | |||
636 | int all_tg_pt, | 636 | int all_tg_pt, |
637 | int aptpl) | 637 | int aptpl) |
638 | { | 638 | { |
639 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; | ||
640 | struct t10_pr_registration *pr_reg; | 639 | struct t10_pr_registration *pr_reg; |
641 | 640 | ||
642 | pr_reg = kmem_cache_zalloc(t10_pr_reg_cache, GFP_ATOMIC); | 641 | pr_reg = kmem_cache_zalloc(t10_pr_reg_cache, GFP_ATOMIC); |
@@ -645,7 +644,7 @@ static struct t10_pr_registration *__core_scsi3_do_alloc_registration( | |||
645 | return NULL; | 644 | return NULL; |
646 | } | 645 | } |
647 | 646 | ||
648 | pr_reg->pr_aptpl_buf = kzalloc(su_dev->t10_pr.pr_aptpl_buf_len, | 647 | pr_reg->pr_aptpl_buf = kzalloc(dev->t10_pr.pr_aptpl_buf_len, |
649 | GFP_ATOMIC); | 648 | GFP_ATOMIC); |
650 | if (!pr_reg->pr_aptpl_buf) { | 649 | if (!pr_reg->pr_aptpl_buf) { |
651 | pr_err("Unable to allocate pr_reg->pr_aptpl_buf\n"); | 650 | pr_err("Unable to allocate pr_reg->pr_aptpl_buf\n"); |
@@ -929,7 +928,7 @@ static int __core_scsi3_check_aptpl_registration( | |||
929 | struct se_dev_entry *deve) | 928 | struct se_dev_entry *deve) |
930 | { | 929 | { |
931 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; | 930 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; |
932 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 931 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
933 | unsigned char i_port[PR_APTPL_MAX_IPORT_LEN]; | 932 | unsigned char i_port[PR_APTPL_MAX_IPORT_LEN]; |
934 | unsigned char t_port[PR_APTPL_MAX_TPORT_LEN]; | 933 | unsigned char t_port[PR_APTPL_MAX_TPORT_LEN]; |
935 | u16 tpgt; | 934 | u16 tpgt; |
@@ -996,11 +995,10 @@ int core_scsi3_check_aptpl_registration( | |||
996 | struct se_lun *lun, | 995 | struct se_lun *lun, |
997 | struct se_lun_acl *lun_acl) | 996 | struct se_lun_acl *lun_acl) |
998 | { | 997 | { |
999 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; | ||
1000 | struct se_node_acl *nacl = lun_acl->se_lun_nacl; | 998 | struct se_node_acl *nacl = lun_acl->se_lun_nacl; |
1001 | struct se_dev_entry *deve = nacl->device_list[lun_acl->mapped_lun]; | 999 | struct se_dev_entry *deve = nacl->device_list[lun_acl->mapped_lun]; |
1002 | 1000 | ||
1003 | if (su_dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) | 1001 | if (dev->t10_pr.res_type != SPC3_PERSISTENT_RESERVATIONS) |
1004 | return 0; | 1002 | return 0; |
1005 | 1003 | ||
1006 | return __core_scsi3_check_aptpl_registration(dev, tpg, lun, | 1004 | return __core_scsi3_check_aptpl_registration(dev, tpg, lun, |
@@ -1051,10 +1049,9 @@ static void __core_scsi3_add_registration( | |||
1051 | int register_type, | 1049 | int register_type, |
1052 | int register_move) | 1050 | int register_move) |
1053 | { | 1051 | { |
1054 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; | ||
1055 | struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo; | 1052 | struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo; |
1056 | struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe; | 1053 | struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe; |
1057 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 1054 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
1058 | 1055 | ||
1059 | /* | 1056 | /* |
1060 | * Increment PRgeneration counter for struct se_device upon a successful | 1057 | * Increment PRgeneration counter for struct se_device upon a successful |
@@ -1066,7 +1063,7 @@ static void __core_scsi3_add_registration( | |||
1066 | * for the REGISTER. | 1063 | * for the REGISTER. |
1067 | */ | 1064 | */ |
1068 | pr_reg->pr_res_generation = (register_move) ? | 1065 | pr_reg->pr_res_generation = (register_move) ? |
1069 | su_dev->t10_pr.pr_generation++ : | 1066 | dev->t10_pr.pr_generation++ : |
1070 | core_scsi3_pr_generation(dev); | 1067 | core_scsi3_pr_generation(dev); |
1071 | 1068 | ||
1072 | spin_lock(&pr_tmpl->registration_lock); | 1069 | spin_lock(&pr_tmpl->registration_lock); |
@@ -1135,7 +1132,7 @@ static struct t10_pr_registration *__core_scsi3_locate_pr_reg( | |||
1135 | struct se_node_acl *nacl, | 1132 | struct se_node_acl *nacl, |
1136 | unsigned char *isid) | 1133 | unsigned char *isid) |
1137 | { | 1134 | { |
1138 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 1135 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
1139 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; | 1136 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; |
1140 | struct se_portal_group *tpg; | 1137 | struct se_portal_group *tpg; |
1141 | 1138 | ||
@@ -1160,7 +1157,7 @@ static struct t10_pr_registration *__core_scsi3_locate_pr_reg( | |||
1160 | * for fabric modules (iSCSI) requiring them. | 1157 | * for fabric modules (iSCSI) requiring them. |
1161 | */ | 1158 | */ |
1162 | if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) { | 1159 | if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL) { |
1163 | if (dev->se_sub_dev->se_dev_attrib.enforce_pr_isids) | 1160 | if (dev->dev_attrib.enforce_pr_isids) |
1164 | continue; | 1161 | continue; |
1165 | } | 1162 | } |
1166 | atomic_inc(&pr_reg->pr_res_holders); | 1163 | atomic_inc(&pr_reg->pr_res_holders); |
@@ -1274,7 +1271,7 @@ static void __core_scsi3_free_registration( | |||
1274 | { | 1271 | { |
1275 | struct target_core_fabric_ops *tfo = | 1272 | struct target_core_fabric_ops *tfo = |
1276 | pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo; | 1273 | pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo; |
1277 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 1274 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
1278 | char i_buf[PR_REG_ISID_ID_LEN]; | 1275 | char i_buf[PR_REG_ISID_ID_LEN]; |
1279 | int prf_isid; | 1276 | int prf_isid; |
1280 | 1277 | ||
@@ -1335,7 +1332,7 @@ void core_scsi3_free_pr_reg_from_nacl( | |||
1335 | struct se_device *dev, | 1332 | struct se_device *dev, |
1336 | struct se_node_acl *nacl) | 1333 | struct se_node_acl *nacl) |
1337 | { | 1334 | { |
1338 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 1335 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
1339 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder; | 1336 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder; |
1340 | /* | 1337 | /* |
1341 | * If the passed se_node_acl matches the reservation holder, | 1338 | * If the passed se_node_acl matches the reservation holder, |
@@ -1365,7 +1362,7 @@ void core_scsi3_free_pr_reg_from_nacl( | |||
1365 | void core_scsi3_free_all_registrations( | 1362 | void core_scsi3_free_all_registrations( |
1366 | struct se_device *dev) | 1363 | struct se_device *dev) |
1367 | { | 1364 | { |
1368 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 1365 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
1369 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder; | 1366 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_res_holder; |
1370 | 1367 | ||
1371 | spin_lock(&dev->dev_reservation_lock); | 1368 | spin_lock(&dev->dev_reservation_lock); |
@@ -1899,7 +1896,6 @@ static int __core_scsi3_update_aptpl_buf( | |||
1899 | { | 1896 | { |
1900 | struct se_lun *lun; | 1897 | struct se_lun *lun; |
1901 | struct se_portal_group *tpg; | 1898 | struct se_portal_group *tpg; |
1902 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; | ||
1903 | struct t10_pr_registration *pr_reg; | 1899 | struct t10_pr_registration *pr_reg; |
1904 | unsigned char tmp[512], isid_buf[32]; | 1900 | unsigned char tmp[512], isid_buf[32]; |
1905 | ssize_t len = 0; | 1901 | ssize_t len = 0; |
@@ -1917,8 +1913,8 @@ static int __core_scsi3_update_aptpl_buf( | |||
1917 | /* | 1913 | /* |
1918 | * Walk the registration list.. | 1914 | * Walk the registration list.. |
1919 | */ | 1915 | */ |
1920 | spin_lock(&su_dev->t10_pr.registration_lock); | 1916 | spin_lock(&dev->t10_pr.registration_lock); |
1921 | list_for_each_entry(pr_reg, &su_dev->t10_pr.registration_list, | 1917 | list_for_each_entry(pr_reg, &dev->t10_pr.registration_list, |
1922 | pr_reg_list) { | 1918 | pr_reg_list) { |
1923 | 1919 | ||
1924 | tmp[0] = '\0'; | 1920 | tmp[0] = '\0'; |
@@ -1963,7 +1959,7 @@ static int __core_scsi3_update_aptpl_buf( | |||
1963 | if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { | 1959 | if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { |
1964 | pr_err("Unable to update renaming" | 1960 | pr_err("Unable to update renaming" |
1965 | " APTPL metadata\n"); | 1961 | " APTPL metadata\n"); |
1966 | spin_unlock(&su_dev->t10_pr.registration_lock); | 1962 | spin_unlock(&dev->t10_pr.registration_lock); |
1967 | return -EMSGSIZE; | 1963 | return -EMSGSIZE; |
1968 | } | 1964 | } |
1969 | len += sprintf(buf+len, "%s", tmp); | 1965 | len += sprintf(buf+len, "%s", tmp); |
@@ -1981,13 +1977,13 @@ static int __core_scsi3_update_aptpl_buf( | |||
1981 | if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { | 1977 | if ((len + strlen(tmp) >= pr_aptpl_buf_len)) { |
1982 | pr_err("Unable to update renaming" | 1978 | pr_err("Unable to update renaming" |
1983 | " APTPL metadata\n"); | 1979 | " APTPL metadata\n"); |
1984 | spin_unlock(&su_dev->t10_pr.registration_lock); | 1980 | spin_unlock(&dev->t10_pr.registration_lock); |
1985 | return -EMSGSIZE; | 1981 | return -EMSGSIZE; |
1986 | } | 1982 | } |
1987 | len += sprintf(buf+len, "%s", tmp); | 1983 | len += sprintf(buf+len, "%s", tmp); |
1988 | reg_count++; | 1984 | reg_count++; |
1989 | } | 1985 | } |
1990 | spin_unlock(&su_dev->t10_pr.registration_lock); | 1986 | spin_unlock(&dev->t10_pr.registration_lock); |
1991 | 1987 | ||
1992 | if (!reg_count) | 1988 | if (!reg_count) |
1993 | len += sprintf(buf+len, "No Registrations or Reservations"); | 1989 | len += sprintf(buf+len, "No Registrations or Reservations"); |
@@ -2019,7 +2015,7 @@ static int __core_scsi3_write_aptpl_to_file( | |||
2019 | unsigned char *buf, | 2015 | unsigned char *buf, |
2020 | u32 pr_aptpl_buf_len) | 2016 | u32 pr_aptpl_buf_len) |
2021 | { | 2017 | { |
2022 | struct t10_wwn *wwn = &dev->se_sub_dev->t10_wwn; | 2018 | struct t10_wwn *wwn = &dev->t10_wwn; |
2023 | struct file *file; | 2019 | struct file *file; |
2024 | struct iovec iov[1]; | 2020 | struct iovec iov[1]; |
2025 | mm_segment_t old_fs; | 2021 | mm_segment_t old_fs; |
@@ -2120,7 +2116,7 @@ static int core_scsi3_emulate_pro_register( | |||
2120 | struct se_lun *se_lun = cmd->se_lun; | 2116 | struct se_lun *se_lun = cmd->se_lun; |
2121 | struct se_portal_group *se_tpg; | 2117 | struct se_portal_group *se_tpg; |
2122 | struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_reg_tmp, *pr_reg_e; | 2118 | struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_reg_tmp, *pr_reg_e; |
2123 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 2119 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
2124 | /* Used for APTPL metadata w/ UNREGISTER */ | 2120 | /* Used for APTPL metadata w/ UNREGISTER */ |
2125 | unsigned char *pr_aptpl_buf = NULL; | 2121 | unsigned char *pr_aptpl_buf = NULL; |
2126 | unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; | 2122 | unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; |
@@ -2434,7 +2430,7 @@ static int core_scsi3_pro_reserve( | |||
2434 | struct se_session *se_sess = cmd->se_sess; | 2430 | struct se_session *se_sess = cmd->se_sess; |
2435 | struct se_lun *se_lun = cmd->se_lun; | 2431 | struct se_lun *se_lun = cmd->se_lun; |
2436 | struct t10_pr_registration *pr_reg, *pr_res_holder; | 2432 | struct t10_pr_registration *pr_reg, *pr_res_holder; |
2437 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 2433 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
2438 | char i_buf[PR_REG_ISID_ID_LEN]; | 2434 | char i_buf[PR_REG_ISID_ID_LEN]; |
2439 | int ret, prf_isid; | 2435 | int ret, prf_isid; |
2440 | 2436 | ||
@@ -2667,7 +2663,7 @@ static int core_scsi3_emulate_pro_release( | |||
2667 | struct se_session *se_sess = cmd->se_sess; | 2663 | struct se_session *se_sess = cmd->se_sess; |
2668 | struct se_lun *se_lun = cmd->se_lun; | 2664 | struct se_lun *se_lun = cmd->se_lun; |
2669 | struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_res_holder; | 2665 | struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_res_holder; |
2670 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 2666 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
2671 | int ret, all_reg = 0; | 2667 | int ret, all_reg = 0; |
2672 | 2668 | ||
2673 | if (!se_sess || !se_lun) { | 2669 | if (!se_sess || !se_lun) { |
@@ -2836,7 +2832,7 @@ static int core_scsi3_emulate_pro_clear( | |||
2836 | struct se_device *dev = cmd->se_dev; | 2832 | struct se_device *dev = cmd->se_dev; |
2837 | struct se_node_acl *pr_reg_nacl; | 2833 | struct se_node_acl *pr_reg_nacl; |
2838 | struct se_session *se_sess = cmd->se_sess; | 2834 | struct se_session *se_sess = cmd->se_sess; |
2839 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 2835 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
2840 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; | 2836 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; |
2841 | u32 pr_res_mapped_lun = 0; | 2837 | u32 pr_res_mapped_lun = 0; |
2842 | int calling_it_nexus = 0; | 2838 | int calling_it_nexus = 0; |
@@ -3006,7 +3002,7 @@ static int core_scsi3_pro_preempt( | |||
3006 | struct se_session *se_sess = cmd->se_sess; | 3002 | struct se_session *se_sess = cmd->se_sess; |
3007 | LIST_HEAD(preempt_and_abort_list); | 3003 | LIST_HEAD(preempt_and_abort_list); |
3008 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; | 3004 | struct t10_pr_registration *pr_reg, *pr_reg_tmp, *pr_reg_n, *pr_res_holder; |
3009 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 3005 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
3010 | u32 pr_res_mapped_lun = 0; | 3006 | u32 pr_res_mapped_lun = 0; |
3011 | int all_reg = 0, calling_it_nexus = 0, released_regs = 0; | 3007 | int all_reg = 0, calling_it_nexus = 0, released_regs = 0; |
3012 | int prh_type = 0, prh_scope = 0, ret; | 3008 | int prh_type = 0, prh_scope = 0, ret; |
@@ -3358,7 +3354,7 @@ static int core_scsi3_emulate_pro_register_and_move( | |||
3358 | struct se_portal_group *se_tpg, *dest_se_tpg = NULL; | 3354 | struct se_portal_group *se_tpg, *dest_se_tpg = NULL; |
3359 | struct target_core_fabric_ops *dest_tf_ops = NULL, *tf_ops; | 3355 | struct target_core_fabric_ops *dest_tf_ops = NULL, *tf_ops; |
3360 | struct t10_pr_registration *pr_reg, *pr_res_holder, *dest_pr_reg; | 3356 | struct t10_pr_registration *pr_reg, *pr_res_holder, *dest_pr_reg; |
3361 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 3357 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
3362 | unsigned char *buf; | 3358 | unsigned char *buf; |
3363 | unsigned char *initiator_str; | 3359 | unsigned char *initiator_str; |
3364 | char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN]; | 3360 | char *iport_ptr = NULL, dest_iport[64], i_buf[PR_REG_ISID_ID_LEN]; |
@@ -3823,7 +3819,7 @@ int target_scsi3_emulate_pr_out(struct se_cmd *cmd) | |||
3823 | * initiator or service action and shall terminate with a RESERVATION | 3819 | * initiator or service action and shall terminate with a RESERVATION |
3824 | * CONFLICT status. | 3820 | * CONFLICT status. |
3825 | */ | 3821 | */ |
3826 | if (cmd->se_dev->dev_flags & DF_SPC2_RESERVATIONS) { | 3822 | if (cmd->se_dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) { |
3827 | pr_err("Received PERSISTENT_RESERVE CDB while legacy" | 3823 | pr_err("Received PERSISTENT_RESERVE CDB while legacy" |
3828 | " SPC-2 reservation is held, returning" | 3824 | " SPC-2 reservation is held, returning" |
3829 | " RESERVATION_CONFLICT\n"); | 3825 | " RESERVATION_CONFLICT\n"); |
@@ -3959,8 +3955,7 @@ out: | |||
3959 | */ | 3955 | */ |
3960 | static int core_scsi3_pri_read_keys(struct se_cmd *cmd) | 3956 | static int core_scsi3_pri_read_keys(struct se_cmd *cmd) |
3961 | { | 3957 | { |
3962 | struct se_device *se_dev = cmd->se_dev; | 3958 | struct se_device *dev = cmd->se_dev; |
3963 | struct se_subsystem_dev *su_dev = se_dev->se_sub_dev; | ||
3964 | struct t10_pr_registration *pr_reg; | 3959 | struct t10_pr_registration *pr_reg; |
3965 | unsigned char *buf; | 3960 | unsigned char *buf; |
3966 | u32 add_len = 0, off = 8; | 3961 | u32 add_len = 0, off = 8; |
@@ -3973,13 +3968,13 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd) | |||
3973 | } | 3968 | } |
3974 | 3969 | ||
3975 | buf = transport_kmap_data_sg(cmd); | 3970 | buf = transport_kmap_data_sg(cmd); |
3976 | buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff); | 3971 | buf[0] = ((dev->t10_pr.pr_generation >> 24) & 0xff); |
3977 | buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff); | 3972 | buf[1] = ((dev->t10_pr.pr_generation >> 16) & 0xff); |
3978 | buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff); | 3973 | buf[2] = ((dev->t10_pr.pr_generation >> 8) & 0xff); |
3979 | buf[3] = (su_dev->t10_pr.pr_generation & 0xff); | 3974 | buf[3] = (dev->t10_pr.pr_generation & 0xff); |
3980 | 3975 | ||
3981 | spin_lock(&su_dev->t10_pr.registration_lock); | 3976 | spin_lock(&dev->t10_pr.registration_lock); |
3982 | list_for_each_entry(pr_reg, &su_dev->t10_pr.registration_list, | 3977 | list_for_each_entry(pr_reg, &dev->t10_pr.registration_list, |
3983 | pr_reg_list) { | 3978 | pr_reg_list) { |
3984 | /* | 3979 | /* |
3985 | * Check for overflow of 8byte PRI READ_KEYS payload and | 3980 | * Check for overflow of 8byte PRI READ_KEYS payload and |
@@ -3999,7 +3994,7 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd) | |||
3999 | 3994 | ||
4000 | add_len += 8; | 3995 | add_len += 8; |
4001 | } | 3996 | } |
4002 | spin_unlock(&su_dev->t10_pr.registration_lock); | 3997 | spin_unlock(&dev->t10_pr.registration_lock); |
4003 | 3998 | ||
4004 | buf[4] = ((add_len >> 24) & 0xff); | 3999 | buf[4] = ((add_len >> 24) & 0xff); |
4005 | buf[5] = ((add_len >> 16) & 0xff); | 4000 | buf[5] = ((add_len >> 16) & 0xff); |
@@ -4018,8 +4013,7 @@ static int core_scsi3_pri_read_keys(struct se_cmd *cmd) | |||
4018 | */ | 4013 | */ |
4019 | static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) | 4014 | static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) |
4020 | { | 4015 | { |
4021 | struct se_device *se_dev = cmd->se_dev; | 4016 | struct se_device *dev = cmd->se_dev; |
4022 | struct se_subsystem_dev *su_dev = se_dev->se_sub_dev; | ||
4023 | struct t10_pr_registration *pr_reg; | 4017 | struct t10_pr_registration *pr_reg; |
4024 | unsigned char *buf; | 4018 | unsigned char *buf; |
4025 | u64 pr_res_key; | 4019 | u64 pr_res_key; |
@@ -4033,13 +4027,13 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) | |||
4033 | } | 4027 | } |
4034 | 4028 | ||
4035 | buf = transport_kmap_data_sg(cmd); | 4029 | buf = transport_kmap_data_sg(cmd); |
4036 | buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff); | 4030 | buf[0] = ((dev->t10_pr.pr_generation >> 24) & 0xff); |
4037 | buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff); | 4031 | buf[1] = ((dev->t10_pr.pr_generation >> 16) & 0xff); |
4038 | buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff); | 4032 | buf[2] = ((dev->t10_pr.pr_generation >> 8) & 0xff); |
4039 | buf[3] = (su_dev->t10_pr.pr_generation & 0xff); | 4033 | buf[3] = (dev->t10_pr.pr_generation & 0xff); |
4040 | 4034 | ||
4041 | spin_lock(&se_dev->dev_reservation_lock); | 4035 | spin_lock(&dev->dev_reservation_lock); |
4042 | pr_reg = se_dev->dev_pr_res_holder; | 4036 | pr_reg = dev->dev_pr_res_holder; |
4043 | if (pr_reg) { | 4037 | if (pr_reg) { |
4044 | /* | 4038 | /* |
4045 | * Set the hardcoded Additional Length | 4039 | * Set the hardcoded Additional Length |
@@ -4090,7 +4084,7 @@ static int core_scsi3_pri_read_reservation(struct se_cmd *cmd) | |||
4090 | } | 4084 | } |
4091 | 4085 | ||
4092 | err: | 4086 | err: |
4093 | spin_unlock(&se_dev->dev_reservation_lock); | 4087 | spin_unlock(&dev->dev_reservation_lock); |
4094 | transport_kunmap_data_sg(cmd); | 4088 | transport_kunmap_data_sg(cmd); |
4095 | 4089 | ||
4096 | return 0; | 4090 | return 0; |
@@ -4104,7 +4098,7 @@ err: | |||
4104 | static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd) | 4098 | static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd) |
4105 | { | 4099 | { |
4106 | struct se_device *dev = cmd->se_dev; | 4100 | struct se_device *dev = cmd->se_dev; |
4107 | struct t10_reservation *pr_tmpl = &dev->se_sub_dev->t10_pr; | 4101 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
4108 | unsigned char *buf; | 4102 | unsigned char *buf; |
4109 | u16 add_len = 8; /* Hardcoded to 8. */ | 4103 | u16 add_len = 8; /* Hardcoded to 8. */ |
4110 | 4104 | ||
@@ -4159,12 +4153,11 @@ static int core_scsi3_pri_report_capabilities(struct se_cmd *cmd) | |||
4159 | */ | 4153 | */ |
4160 | static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) | 4154 | static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) |
4161 | { | 4155 | { |
4162 | struct se_device *se_dev = cmd->se_dev; | 4156 | struct se_device *dev = cmd->se_dev; |
4163 | struct se_node_acl *se_nacl; | 4157 | struct se_node_acl *se_nacl; |
4164 | struct se_subsystem_dev *su_dev = se_dev->se_sub_dev; | ||
4165 | struct se_portal_group *se_tpg; | 4158 | struct se_portal_group *se_tpg; |
4166 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; | 4159 | struct t10_pr_registration *pr_reg, *pr_reg_tmp; |
4167 | struct t10_reservation *pr_tmpl = &se_dev->se_sub_dev->t10_pr; | 4160 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
4168 | unsigned char *buf; | 4161 | unsigned char *buf; |
4169 | u32 add_desc_len = 0, add_len = 0, desc_len, exp_desc_len; | 4162 | u32 add_desc_len = 0, add_len = 0, desc_len, exp_desc_len; |
4170 | u32 off = 8; /* off into first Full Status descriptor */ | 4163 | u32 off = 8; /* off into first Full Status descriptor */ |
@@ -4179,10 +4172,10 @@ static int core_scsi3_pri_read_full_status(struct se_cmd *cmd) | |||
4179 | 4172 | ||
4180 | buf = transport_kmap_data_sg(cmd); | 4173 | buf = transport_kmap_data_sg(cmd); |
4181 | 4174 | ||
4182 | buf[0] = ((su_dev->t10_pr.pr_generation >> 24) & 0xff); | 4175 | buf[0] = ((dev->t10_pr.pr_generation >> 24) & 0xff); |
4183 | buf[1] = ((su_dev->t10_pr.pr_generation >> 16) & 0xff); | 4176 | buf[1] = ((dev->t10_pr.pr_generation >> 16) & 0xff); |
4184 | buf[2] = ((su_dev->t10_pr.pr_generation >> 8) & 0xff); | 4177 | buf[2] = ((dev->t10_pr.pr_generation >> 8) & 0xff); |
4185 | buf[3] = (su_dev->t10_pr.pr_generation & 0xff); | 4178 | buf[3] = (dev->t10_pr.pr_generation & 0xff); |
4186 | 4179 | ||
4187 | spin_lock(&pr_tmpl->registration_lock); | 4180 | spin_lock(&pr_tmpl->registration_lock); |
4188 | list_for_each_entry_safe(pr_reg, pr_reg_tmp, | 4181 | list_for_each_entry_safe(pr_reg, pr_reg_tmp, |
@@ -4316,7 +4309,7 @@ int target_scsi3_emulate_pr_in(struct se_cmd *cmd) | |||
4316 | * initiator or service action and shall terminate with a RESERVATION | 4309 | * initiator or service action and shall terminate with a RESERVATION |
4317 | * CONFLICT status. | 4310 | * CONFLICT status. |
4318 | */ | 4311 | */ |
4319 | if (cmd->se_dev->dev_flags & DF_SPC2_RESERVATIONS) { | 4312 | if (cmd->se_dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) { |
4320 | pr_err("Received PERSISTENT_RESERVE CDB while legacy" | 4313 | pr_err("Received PERSISTENT_RESERVE CDB while legacy" |
4321 | " SPC-2 reservation is held, returning" | 4314 | " SPC-2 reservation is held, returning" |
4322 | " RESERVATION_CONFLICT\n"); | 4315 | " RESERVATION_CONFLICT\n"); |
@@ -4363,30 +4356,25 @@ static int core_pt_seq_non_holder( | |||
4363 | return 0; | 4356 | return 0; |
4364 | } | 4357 | } |
4365 | 4358 | ||
4366 | int core_setup_reservations(struct se_device *dev, int force_pt) | 4359 | void core_setup_reservations(struct se_device *dev) |
4367 | { | 4360 | { |
4368 | struct se_subsystem_dev *su_dev = dev->se_sub_dev; | 4361 | struct t10_reservation *rest = &dev->t10_pr; |
4369 | struct t10_reservation *rest = &su_dev->t10_pr; | 4362 | |
4370 | /* | 4363 | /* |
4371 | * If this device is from Target_Core_Mod/pSCSI, use the reservations | 4364 | * If this device is from Target_Core_Mod/pSCSI, use the reservations |
4372 | * of the Underlying SCSI hardware. In Linux/SCSI terms, this can | 4365 | * of the Underlying SCSI hardware. In Linux/SCSI terms, this can |
4373 | * cause a problem because libata and some SATA RAID HBAs appear | 4366 | * cause a problem because libata and some SATA RAID HBAs appear |
4374 | * under Linux/SCSI, but to emulate reservations themselves. | 4367 | * under Linux/SCSI, but to emulate reservations themselves. |
4375 | */ | 4368 | */ |
4376 | if (((dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV) && | 4369 | if ((dev->se_hba->hba_flags & HBA_FLAGS_INTERNAL_USE) || |
4377 | !(dev->se_sub_dev->se_dev_attrib.emulate_reservations)) || force_pt) { | 4370 | (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV && |
4371 | !dev->dev_attrib.emulate_reservations)) { | ||
4378 | rest->res_type = SPC_PASSTHROUGH; | 4372 | rest->res_type = SPC_PASSTHROUGH; |
4379 | rest->pr_ops.t10_reservation_check = &core_pt_reservation_check; | 4373 | rest->pr_ops.t10_reservation_check = &core_pt_reservation_check; |
4380 | rest->pr_ops.t10_seq_non_holder = &core_pt_seq_non_holder; | 4374 | rest->pr_ops.t10_seq_non_holder = &core_pt_seq_non_holder; |
4381 | pr_debug("%s: Using SPC_PASSTHROUGH, no reservation" | 4375 | pr_debug("%s: Using SPC_PASSTHROUGH, no reservation" |
4382 | " emulation\n", dev->transport->name); | 4376 | " emulation\n", dev->transport->name); |
4383 | return 0; | 4377 | } else if (dev->transport->get_device_rev(dev) >= SCSI_3) { |
4384 | } | ||
4385 | /* | ||
4386 | * If SPC-3 or above is reported by real or emulated struct se_device, | ||
4387 | * use emulated Persistent Reservations. | ||
4388 | */ | ||
4389 | if (dev->transport->get_device_rev(dev) >= SCSI_3) { | ||
4390 | rest->res_type = SPC3_PERSISTENT_RESERVATIONS; | 4378 | rest->res_type = SPC3_PERSISTENT_RESERVATIONS; |
4391 | rest->pr_ops.t10_reservation_check = &core_scsi3_pr_reservation_check; | 4379 | rest->pr_ops.t10_reservation_check = &core_scsi3_pr_reservation_check; |
4392 | rest->pr_ops.t10_seq_non_holder = &core_scsi3_pr_seq_non_holder; | 4380 | rest->pr_ops.t10_seq_non_holder = &core_scsi3_pr_seq_non_holder; |
@@ -4400,6 +4388,4 @@ int core_setup_reservations(struct se_device *dev, int force_pt) | |||
4400 | pr_debug("%s: Using SPC2_RESERVATIONS emulation\n", | 4388 | pr_debug("%s: Using SPC2_RESERVATIONS emulation\n", |
4401 | dev->transport->name); | 4389 | dev->transport->name); |
4402 | } | 4390 | } |
4403 | |||
4404 | return 0; | ||
4405 | } | 4391 | } |