diff options
author | Andy Grover <agrover@redhat.com> | 2013-05-16 13:41:02 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-06-14 03:04:58 -0400 |
commit | 459f213ba162bd13e113d6f92a8fa6c780fd67ed (patch) | |
tree | 113fa4c5426487154a231c0f47a24cfca01f5ae3 | |
parent | 63e03349f5fb32e4e8494cb184c37d2db0bdd223 (diff) |
target: Allocate aptpl_buf inside update_and_write_aptpl()
Instead of taking the buffer and length, update_and_write_aptpl() will
allocate the buffer as needed, and then free it. Instead, the function
takes an 'aptpl' boolean parameter.
This enables us to remove memory alloc/frees from struct
t10_pr_registration and other spots.
There is a slight loss of functionality because each callsite doesn't get
its own pr_debug any more, but this info can be cleaned via ftrace if
necessary and I think the shorter code is worth it.
Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/target/target_core_pr.c | 203 | ||||
-rw-r--r-- | include/target/target_core_base.h | 2 |
2 files changed, 48 insertions, 157 deletions
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index c157b3f7b0e1..915edaab1919 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c | |||
@@ -606,13 +606,6 @@ static struct t10_pr_registration *__core_scsi3_do_alloc_registration( | |||
606 | return NULL; | 606 | return NULL; |
607 | } | 607 | } |
608 | 608 | ||
609 | pr_reg->pr_aptpl_buf = kzalloc(PR_APTPL_BUF_LEN, GFP_ATOMIC); | ||
610 | if (!pr_reg->pr_aptpl_buf) { | ||
611 | pr_err("Unable to allocate pr_reg->pr_aptpl_buf\n"); | ||
612 | kmem_cache_free(t10_pr_reg_cache, pr_reg); | ||
613 | return NULL; | ||
614 | } | ||
615 | |||
616 | INIT_LIST_HEAD(&pr_reg->pr_reg_list); | 609 | INIT_LIST_HEAD(&pr_reg->pr_reg_list); |
617 | INIT_LIST_HEAD(&pr_reg->pr_reg_abort_list); | 610 | INIT_LIST_HEAD(&pr_reg->pr_reg_abort_list); |
618 | INIT_LIST_HEAD(&pr_reg->pr_reg_aptpl_list); | 611 | INIT_LIST_HEAD(&pr_reg->pr_reg_aptpl_list); |
@@ -803,7 +796,6 @@ int core_scsi3_alloc_aptpl_registration( | |||
803 | pr_err("Unable to allocate struct t10_pr_registration\n"); | 796 | pr_err("Unable to allocate struct t10_pr_registration\n"); |
804 | return -ENOMEM; | 797 | return -ENOMEM; |
805 | } | 798 | } |
806 | pr_reg->pr_aptpl_buf = kzalloc(PR_APTPL_BUF_LEN, GFP_KERNEL); | ||
807 | 799 | ||
808 | INIT_LIST_HEAD(&pr_reg->pr_reg_list); | 800 | INIT_LIST_HEAD(&pr_reg->pr_reg_list); |
809 | INIT_LIST_HEAD(&pr_reg->pr_reg_abort_list); | 801 | INIT_LIST_HEAD(&pr_reg->pr_reg_abort_list); |
@@ -1272,7 +1264,6 @@ static void __core_scsi3_free_registration( | |||
1272 | if (!preempt_and_abort_list) { | 1264 | if (!preempt_and_abort_list) { |
1273 | pr_reg->pr_reg_deve = NULL; | 1265 | pr_reg->pr_reg_deve = NULL; |
1274 | pr_reg->pr_reg_nacl = NULL; | 1266 | pr_reg->pr_reg_nacl = NULL; |
1275 | kfree(pr_reg->pr_aptpl_buf); | ||
1276 | kmem_cache_free(t10_pr_reg_cache, pr_reg); | 1267 | kmem_cache_free(t10_pr_reg_cache, pr_reg); |
1277 | return; | 1268 | return; |
1278 | } | 1269 | } |
@@ -1341,7 +1332,6 @@ void core_scsi3_free_all_registrations( | |||
1341 | list_for_each_entry_safe(pr_reg, pr_reg_tmp, &pr_tmpl->aptpl_reg_list, | 1332 | list_for_each_entry_safe(pr_reg, pr_reg_tmp, &pr_tmpl->aptpl_reg_list, |
1342 | pr_reg_aptpl_list) { | 1333 | pr_reg_aptpl_list) { |
1343 | list_del(&pr_reg->pr_reg_aptpl_list); | 1334 | list_del(&pr_reg->pr_reg_aptpl_list); |
1344 | kfree(pr_reg->pr_aptpl_buf); | ||
1345 | kmem_cache_free(t10_pr_reg_cache, pr_reg); | 1335 | kmem_cache_free(t10_pr_reg_cache, pr_reg); |
1346 | } | 1336 | } |
1347 | spin_unlock(&pr_tmpl->aptpl_reg_lock); | 1337 | spin_unlock(&pr_tmpl->aptpl_reg_lock); |
@@ -1814,7 +1804,6 @@ out: | |||
1814 | kmem_cache_free(t10_pr_reg_cache, pr_reg_tmp); | 1804 | kmem_cache_free(t10_pr_reg_cache, pr_reg_tmp); |
1815 | } | 1805 | } |
1816 | 1806 | ||
1817 | kfree(dest_pr_reg->pr_aptpl_buf); | ||
1818 | kmem_cache_free(t10_pr_reg_cache, dest_pr_reg); | 1807 | kmem_cache_free(t10_pr_reg_cache, dest_pr_reg); |
1819 | 1808 | ||
1820 | if (dest_local_nexus) | 1809 | if (dest_local_nexus) |
@@ -1840,8 +1829,6 @@ static int core_scsi3_update_aptpl_buf( | |||
1840 | int reg_count = 0; | 1829 | int reg_count = 0; |
1841 | int ret = 0; | 1830 | int ret = 0; |
1842 | 1831 | ||
1843 | memset(buf, 0, pr_aptpl_buf_len); | ||
1844 | |||
1845 | spin_lock(&dev->dev_reservation_lock); | 1832 | spin_lock(&dev->dev_reservation_lock); |
1846 | spin_lock(&dev->t10_pr.registration_lock); | 1833 | spin_lock(&dev->t10_pr.registration_lock); |
1847 | /* | 1834 | /* |
@@ -1965,31 +1952,45 @@ static int __core_scsi3_write_aptpl_to_file( | |||
1965 | return ret ? -EIO : 0; | 1952 | return ret ? -EIO : 0; |
1966 | } | 1953 | } |
1967 | 1954 | ||
1968 | static int | 1955 | /* |
1969 | core_scsi3_update_and_write_aptpl(struct se_device *dev, unsigned char *in_buf, | 1956 | * Clear the APTPL metadata if APTPL has been disabled, otherwise |
1970 | u32 in_pr_aptpl_buf_len) | 1957 | * write out the updated metadata to struct file for this SCSI device. |
1958 | */ | ||
1959 | static int core_scsi3_update_and_write_aptpl(struct se_device *dev, bool aptpl) | ||
1971 | { | 1960 | { |
1972 | unsigned char null_buf[64], *buf; | 1961 | int ret = 0; |
1973 | int ret; | ||
1974 | 1962 | ||
1975 | /* | 1963 | if (!aptpl) { |
1976 | * Can be called with a NULL pointer from PROUT service action CLEAR | 1964 | char *null_buf = "No Registrations or Reservations\n"; |
1977 | */ | 1965 | |
1978 | if (!in_buf) { | 1966 | ret = __core_scsi3_write_aptpl_to_file(dev, null_buf); |
1979 | snprintf(null_buf, 64, "No Registrations or Reservations\n"); | 1967 | dev->t10_pr.pr_aptpl_active = 0; |
1980 | buf = null_buf; | 1968 | pr_debug("SPC-3 PR: Set APTPL Bit Deactivated\n"); |
1981 | } else { | 1969 | } else { |
1982 | ret = core_scsi3_update_aptpl_buf(dev, in_buf, in_pr_aptpl_buf_len); | 1970 | int ret; |
1983 | if (ret != 0) | 1971 | unsigned char *buf; |
1972 | |||
1973 | buf = kzalloc(PR_APTPL_BUF_LEN, GFP_KERNEL); | ||
1974 | if (!buf) | ||
1975 | return -ENOMEM; | ||
1976 | |||
1977 | ret = core_scsi3_update_aptpl_buf(dev, buf, PR_APTPL_BUF_LEN); | ||
1978 | if (ret < 0) { | ||
1979 | kfree(buf); | ||
1984 | return ret; | 1980 | return ret; |
1985 | buf = in_buf; | 1981 | } |
1982 | |||
1983 | ret = __core_scsi3_write_aptpl_to_file(dev, buf); | ||
1984 | if (ret != 0) { | ||
1985 | pr_err("SPC-3 PR: Could not update APTPL\n"); | ||
1986 | } else { | ||
1987 | dev->t10_pr.pr_aptpl_active = 1; | ||
1988 | pr_debug("SPC-3 PR: Set APTPL Bit Activated\n"); | ||
1989 | } | ||
1990 | kfree(buf); | ||
1986 | } | 1991 | } |
1987 | 1992 | ||
1988 | /* | 1993 | return ret; |
1989 | * __core_scsi3_write_aptpl_to_file() will call strlen() | ||
1990 | * on the passed buf to determine pr_aptpl_buf_len. | ||
1991 | */ | ||
1992 | return __core_scsi3_write_aptpl_to_file(dev, buf); | ||
1993 | } | 1994 | } |
1994 | 1995 | ||
1995 | static sense_reason_t | 1996 | static sense_reason_t |
@@ -2003,8 +2004,6 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, | |||
2003 | struct se_portal_group *se_tpg; | 2004 | struct se_portal_group *se_tpg; |
2004 | struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_reg_tmp, *pr_reg_e; | 2005 | struct t10_pr_registration *pr_reg, *pr_reg_p, *pr_reg_tmp, *pr_reg_e; |
2005 | struct t10_reservation *pr_tmpl = &dev->t10_pr; | 2006 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
2006 | /* Used for APTPL metadata w/ UNREGISTER */ | ||
2007 | unsigned char *pr_aptpl_buf = NULL; | ||
2008 | unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; | 2007 | unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; |
2009 | sense_reason_t ret = TCM_NO_SENSE; | 2008 | sense_reason_t ret = TCM_NO_SENSE; |
2010 | int pr_holder = 0, type; | 2009 | int pr_holder = 0, type; |
@@ -2066,31 +2065,8 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, | |||
2066 | if (ret != 0) | 2065 | if (ret != 0) |
2067 | return ret; | 2066 | return ret; |
2068 | } | 2067 | } |
2069 | /* | ||
2070 | * Nothing left to do for the APTPL=0 case. | ||
2071 | */ | ||
2072 | if (!aptpl) { | ||
2073 | pr_tmpl->pr_aptpl_active = 0; | ||
2074 | core_scsi3_update_and_write_aptpl(cmd->se_dev, NULL, 0); | ||
2075 | pr_debug("SPC-3 PR: Set APTPL Bit Deactivated for" | ||
2076 | " REGISTER\n"); | ||
2077 | return 0; | ||
2078 | } | ||
2079 | /* | ||
2080 | * Locate the newly allocated local I_T Nexus *pr_reg, and | ||
2081 | * update the APTPL metadata information using its | ||
2082 | * preallocated *pr_reg->pr_aptpl_buf. | ||
2083 | */ | ||
2084 | pr_reg = core_scsi3_locate_pr_reg(cmd->se_dev, | ||
2085 | se_sess->se_node_acl, se_sess); | ||
2086 | |||
2087 | if (core_scsi3_update_and_write_aptpl(cmd->se_dev, | ||
2088 | pr_reg->pr_aptpl_buf, PR_APTPL_BUF_LEN)) { | ||
2089 | pr_tmpl->pr_aptpl_active = 1; | ||
2090 | pr_debug("SPC-3 PR: Set APTPL Bit Activated for REGISTER\n"); | ||
2091 | } | ||
2092 | 2068 | ||
2093 | goto out_put_pr_reg; | 2069 | return core_scsi3_update_and_write_aptpl(dev, aptpl); |
2094 | } | 2070 | } |
2095 | 2071 | ||
2096 | /* | 2072 | /* |
@@ -2131,19 +2107,6 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, | |||
2131 | } | 2107 | } |
2132 | 2108 | ||
2133 | /* | 2109 | /* |
2134 | * Allocate APTPL metadata buffer used for UNREGISTER ops | ||
2135 | */ | ||
2136 | if (aptpl) { | ||
2137 | pr_aptpl_buf = kzalloc(PR_APTPL_BUF_LEN, GFP_KERNEL); | ||
2138 | if (!pr_aptpl_buf) { | ||
2139 | pr_err("Unable to allocate" | ||
2140 | " pr_aptpl_buf\n"); | ||
2141 | ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; | ||
2142 | goto out_put_pr_reg; | ||
2143 | } | ||
2144 | } | ||
2145 | |||
2146 | /* | ||
2147 | * sa_res_key=0 Unregister Reservation Key for registered I_T | 2110 | * sa_res_key=0 Unregister Reservation Key for registered I_T |
2148 | * Nexus sa_res_key=1 Change Reservation Key for registered I_T | 2111 | * Nexus sa_res_key=1 Change Reservation Key for registered I_T |
2149 | * Nexus. | 2112 | * Nexus. |
@@ -2152,7 +2115,6 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, | |||
2152 | pr_holder = core_scsi3_check_implict_release( | 2115 | pr_holder = core_scsi3_check_implict_release( |
2153 | cmd->se_dev, pr_reg); | 2116 | cmd->se_dev, pr_reg); |
2154 | if (pr_holder < 0) { | 2117 | if (pr_holder < 0) { |
2155 | kfree(pr_aptpl_buf); | ||
2156 | ret = TCM_RESERVATION_CONFLICT; | 2118 | ret = TCM_RESERVATION_CONFLICT; |
2157 | goto out_put_pr_reg; | 2119 | goto out_put_pr_reg; |
2158 | } | 2120 | } |
@@ -2214,21 +2176,8 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, | |||
2214 | } | 2176 | } |
2215 | spin_unlock(&pr_tmpl->registration_lock); | 2177 | spin_unlock(&pr_tmpl->registration_lock); |
2216 | 2178 | ||
2217 | if (!aptpl) { | 2179 | ret = core_scsi3_update_and_write_aptpl(dev, aptpl); |
2218 | pr_tmpl->pr_aptpl_active = 0; | 2180 | goto out_put_pr_reg; |
2219 | core_scsi3_update_and_write_aptpl(dev, NULL, 0); | ||
2220 | pr_debug("SPC-3 PR: Set APTPL Bit Deactivated" | ||
2221 | " for UNREGISTER\n"); | ||
2222 | return 0; | ||
2223 | } | ||
2224 | |||
2225 | if (!core_scsi3_update_and_write_aptpl(dev, pr_aptpl_buf, PR_APTPL_BUF_LEN)) { | ||
2226 | pr_tmpl->pr_aptpl_active = 1; | ||
2227 | pr_debug("SPC-3 PR: Set APTPL Bit Activated" | ||
2228 | " for UNREGISTER\n"); | ||
2229 | } | ||
2230 | |||
2231 | goto out_free_aptpl_buf; | ||
2232 | } | 2181 | } |
2233 | 2182 | ||
2234 | /* | 2183 | /* |
@@ -2245,24 +2194,8 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, | |||
2245 | pr_reg->pr_reg_nacl->initiatorname, | 2194 | pr_reg->pr_reg_nacl->initiatorname, |
2246 | pr_reg->pr_res_key, pr_reg->pr_res_generation); | 2195 | pr_reg->pr_res_key, pr_reg->pr_res_generation); |
2247 | 2196 | ||
2248 | if (!aptpl) { | 2197 | ret = core_scsi3_update_and_write_aptpl(dev, aptpl); |
2249 | pr_tmpl->pr_aptpl_active = 0; | ||
2250 | core_scsi3_update_and_write_aptpl(dev, NULL, 0); | ||
2251 | pr_debug("SPC-3 PR: Set APTPL Bit Deactivated" | ||
2252 | " for REGISTER\n"); | ||
2253 | ret = 0; | ||
2254 | goto out_put_pr_reg; | ||
2255 | } | ||
2256 | 2198 | ||
2257 | if (!core_scsi3_update_and_write_aptpl(dev, pr_aptpl_buf, PR_APTPL_BUF_LEN)) { | ||
2258 | pr_tmpl->pr_aptpl_active = 1; | ||
2259 | pr_debug("SPC-3 PR: Set APTPL Bit Activated" | ||
2260 | " for REGISTER\n"); | ||
2261 | } | ||
2262 | |||
2263 | out_free_aptpl_buf: | ||
2264 | kfree(pr_aptpl_buf); | ||
2265 | ret = 0; | ||
2266 | out_put_pr_reg: | 2199 | out_put_pr_reg: |
2267 | core_scsi3_put_pr_reg(pr_reg); | 2200 | core_scsi3_put_pr_reg(pr_reg); |
2268 | return ret; | 2201 | return ret; |
@@ -2437,13 +2370,8 @@ core_scsi3_pro_reserve(struct se_cmd *cmd, int type, int scope, u64 res_key) | |||
2437 | i_buf); | 2370 | i_buf); |
2438 | spin_unlock(&dev->dev_reservation_lock); | 2371 | spin_unlock(&dev->dev_reservation_lock); |
2439 | 2372 | ||
2440 | if (pr_tmpl->pr_aptpl_active) { | 2373 | if (pr_tmpl->pr_aptpl_active) |
2441 | if (!core_scsi3_update_and_write_aptpl(cmd->se_dev, | 2374 | core_scsi3_update_and_write_aptpl(cmd->se_dev, true); |
2442 | pr_reg->pr_aptpl_buf, PR_APTPL_BUF_LEN)) { | ||
2443 | pr_debug("SPC-3 PR: Updated APTPL metadata" | ||
2444 | " for RESERVE\n"); | ||
2445 | } | ||
2446 | } | ||
2447 | 2375 | ||
2448 | ret = 0; | 2376 | ret = 0; |
2449 | out_put_pr_reg: | 2377 | out_put_pr_reg: |
@@ -2657,12 +2585,9 @@ core_scsi3_emulate_pro_release(struct se_cmd *cmd, int type, int scope, | |||
2657 | spin_unlock(&pr_tmpl->registration_lock); | 2585 | spin_unlock(&pr_tmpl->registration_lock); |
2658 | 2586 | ||
2659 | write_aptpl: | 2587 | write_aptpl: |
2660 | if (pr_tmpl->pr_aptpl_active) { | 2588 | if (pr_tmpl->pr_aptpl_active) |
2661 | if (!core_scsi3_update_and_write_aptpl(cmd->se_dev, | 2589 | core_scsi3_update_and_write_aptpl(cmd->se_dev, true); |
2662 | pr_reg->pr_aptpl_buf, PR_APTPL_BUF_LEN)) { | 2590 | |
2663 | pr_debug("SPC-3 PR: Updated APTPL metadata for RELEASE\n"); | ||
2664 | } | ||
2665 | } | ||
2666 | out_put_pr_reg: | 2591 | out_put_pr_reg: |
2667 | core_scsi3_put_pr_reg(pr_reg); | 2592 | core_scsi3_put_pr_reg(pr_reg); |
2668 | return ret; | 2593 | return ret; |
@@ -2746,11 +2671,7 @@ core_scsi3_emulate_pro_clear(struct se_cmd *cmd, u64 res_key) | |||
2746 | pr_debug("SPC-3 PR [%s] Service Action: CLEAR complete\n", | 2671 | pr_debug("SPC-3 PR [%s] Service Action: CLEAR complete\n", |
2747 | cmd->se_tfo->get_fabric_name()); | 2672 | cmd->se_tfo->get_fabric_name()); |
2748 | 2673 | ||
2749 | if (pr_tmpl->pr_aptpl_active) { | 2674 | core_scsi3_update_and_write_aptpl(cmd->se_dev, false); |
2750 | core_scsi3_update_and_write_aptpl(cmd->se_dev, NULL, 0); | ||
2751 | pr_debug("SPC-3 PR: Updated APTPL metadata" | ||
2752 | " for CLEAR\n"); | ||
2753 | } | ||
2754 | 2675 | ||
2755 | core_scsi3_pr_generation(dev); | 2676 | core_scsi3_pr_generation(dev); |
2756 | return 0; | 2677 | return 0; |
@@ -2822,7 +2743,6 @@ static void core_scsi3_release_preempt_and_abort( | |||
2822 | 2743 | ||
2823 | pr_reg->pr_reg_deve = NULL; | 2744 | pr_reg->pr_reg_deve = NULL; |
2824 | pr_reg->pr_reg_nacl = NULL; | 2745 | pr_reg->pr_reg_nacl = NULL; |
2825 | kfree(pr_reg->pr_aptpl_buf); | ||
2826 | kmem_cache_free(t10_pr_reg_cache, pr_reg); | 2746 | kmem_cache_free(t10_pr_reg_cache, pr_reg); |
2827 | } | 2747 | } |
2828 | } | 2748 | } |
@@ -2984,14 +2904,8 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key, | |||
2984 | } | 2904 | } |
2985 | spin_unlock(&dev->dev_reservation_lock); | 2905 | spin_unlock(&dev->dev_reservation_lock); |
2986 | 2906 | ||
2987 | if (pr_tmpl->pr_aptpl_active) { | 2907 | if (pr_tmpl->pr_aptpl_active) |
2988 | if (!core_scsi3_update_and_write_aptpl(cmd->se_dev, | 2908 | core_scsi3_update_and_write_aptpl(cmd->se_dev, true); |
2989 | pr_reg_n->pr_aptpl_buf, PR_APTPL_BUF_LEN)) { | ||
2990 | pr_debug("SPC-3 PR: Updated APTPL" | ||
2991 | " metadata for PREEMPT%s\n", (preempt_type == PREEMPT_AND_ABORT) ? | ||
2992 | "_AND_ABORT" : ""); | ||
2993 | } | ||
2994 | } | ||
2995 | 2909 | ||
2996 | core_scsi3_put_pr_reg(pr_reg_n); | 2910 | core_scsi3_put_pr_reg(pr_reg_n); |
2997 | core_scsi3_pr_generation(cmd->se_dev); | 2911 | core_scsi3_pr_generation(cmd->se_dev); |
@@ -3119,13 +3033,8 @@ core_scsi3_pro_preempt(struct se_cmd *cmd, int type, int scope, u64 res_key, | |||
3119 | pr_reg_n); | 3033 | pr_reg_n); |
3120 | } | 3034 | } |
3121 | 3035 | ||
3122 | if (pr_tmpl->pr_aptpl_active) { | 3036 | if (pr_tmpl->pr_aptpl_active) |
3123 | if (!core_scsi3_update_and_write_aptpl(cmd->se_dev, | 3037 | core_scsi3_update_and_write_aptpl(cmd->se_dev, true); |
3124 | pr_reg_n->pr_aptpl_buf, PR_APTPL_BUF_LEN)) { | ||
3125 | pr_debug("SPC-3 PR: Updated APTPL metadata for PREEMPT" | ||
3126 | "%s\n", (preempt_type == PREEMPT_AND_ABORT) ? "_AND_ABORT" : ""); | ||
3127 | } | ||
3128 | } | ||
3129 | 3038 | ||
3130 | core_scsi3_put_pr_reg(pr_reg_n); | 3039 | core_scsi3_put_pr_reg(pr_reg_n); |
3131 | core_scsi3_pr_generation(cmd->se_dev); | 3040 | core_scsi3_pr_generation(cmd->se_dev); |
@@ -3552,23 +3461,7 @@ after_iport_check: | |||
3552 | } else | 3461 | } else |
3553 | core_scsi3_put_pr_reg(pr_reg); | 3462 | core_scsi3_put_pr_reg(pr_reg); |
3554 | 3463 | ||
3555 | /* | 3464 | core_scsi3_update_and_write_aptpl(cmd->se_dev, aptpl); |
3556 | * Clear the APTPL metadata if APTPL has been disabled, otherwise | ||
3557 | * write out the updated metadata to struct file for this SCSI device. | ||
3558 | */ | ||
3559 | if (!aptpl) { | ||
3560 | pr_tmpl->pr_aptpl_active = 0; | ||
3561 | core_scsi3_update_and_write_aptpl(cmd->se_dev, NULL, 0); | ||
3562 | pr_debug("SPC-3 PR: Set APTPL Bit Deactivated for" | ||
3563 | " REGISTER_AND_MOVE\n"); | ||
3564 | } else { | ||
3565 | pr_tmpl->pr_aptpl_active = 1; | ||
3566 | if (!core_scsi3_update_and_write_aptpl(cmd->se_dev, | ||
3567 | dest_pr_reg->pr_aptpl_buf, PR_APTPL_BUF_LEN)) { | ||
3568 | pr_debug("SPC-3 PR: Set APTPL Bit Activated for" | ||
3569 | " REGISTER_AND_MOVE\n"); | ||
3570 | } | ||
3571 | } | ||
3572 | 3465 | ||
3573 | transport_kunmap_data_sg(cmd); | 3466 | transport_kunmap_data_sg(cmd); |
3574 | 3467 | ||
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 5976dc3e4066..8952ee9f7cef 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h | |||
@@ -339,8 +339,6 @@ struct t10_pr_registration { | |||
339 | /* Used during APTPL metadata reading */ | 339 | /* Used during APTPL metadata reading */ |
340 | #define PR_APTPL_MAX_TPORT_LEN 256 | 340 | #define PR_APTPL_MAX_TPORT_LEN 256 |
341 | unsigned char pr_tport[PR_APTPL_MAX_TPORT_LEN]; | 341 | unsigned char pr_tport[PR_APTPL_MAX_TPORT_LEN]; |
342 | /* For writing out live meta data */ | ||
343 | unsigned char *pr_aptpl_buf; | ||
344 | u16 pr_aptpl_rpti; | 342 | u16 pr_aptpl_rpti; |
345 | u16 pr_reg_tpgt; | 343 | u16 pr_reg_tpgt; |
346 | /* Reservation effects all target ports */ | 344 | /* Reservation effects all target ports */ |