aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@suse.de>2017-01-02 12:04:05 -0500
committerBart Van Assche <bart.vanassche@sandisk.com>2017-01-10 11:41:12 -0500
commit94aae4caacda89a1bdb7198b260f4ca3595b7ed7 (patch)
tree4717092498edd8368b38df97068b92bfb7c4c6dd
parentc243849720ac237e9e7191fe57f619bb3a871d4c (diff)
target: simplify XCOPY wwn->se_dev lookup helper
target_xcopy_locate_se_dev_e4() is used to locate an se_dev, based on the WWN provided with the XCOPY request. Remove a couple of unneeded arguments, and rely on the caller for the src/dst test. Signed-off-by: David Disseldorp <ddiss@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
-rw-r--r--drivers/target/target_core_xcopy.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index 52738a108e5f..155db18ee4e7 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -53,18 +53,13 @@ static int target_xcopy_gen_naa_ieee(struct se_device *dev, unsigned char *buf)
53 return 0; 53 return 0;
54} 54}
55 55
56static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op *xop, 56static int target_xcopy_locate_se_dev_e4(const unsigned char *dev_wwn,
57 bool src) 57 struct se_device **found_dev)
58{ 58{
59 struct se_device *se_dev; 59 struct se_device *se_dev;
60 unsigned char tmp_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN], *dev_wwn; 60 unsigned char tmp_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN];
61 int rc; 61 int rc;
62 62
63 if (src)
64 dev_wwn = &xop->dst_tid_wwn[0];
65 else
66 dev_wwn = &xop->src_tid_wwn[0];
67
68 mutex_lock(&g_device_mutex); 63 mutex_lock(&g_device_mutex);
69 list_for_each_entry(se_dev, &g_device_list, g_dev_node) { 64 list_for_each_entry(se_dev, &g_device_list, g_dev_node) {
70 65
@@ -78,15 +73,8 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
78 if (rc != 0) 73 if (rc != 0)
79 continue; 74 continue;
80 75
81 if (src) { 76 *found_dev = se_dev;
82 xop->dst_dev = se_dev; 77 pr_debug("XCOPY 0xe4: located se_dev: %p\n", se_dev);
83 pr_debug("XCOPY 0xe4: Setting xop->dst_dev: %p from located"
84 " se_dev\n", xop->dst_dev);
85 } else {
86 xop->src_dev = se_dev;
87 pr_debug("XCOPY 0xe4: Setting xop->src_dev: %p from located"
88 " se_dev\n", xop->src_dev);
89 }
90 78
91 rc = target_depend_item(&se_dev->dev_group.cg_item); 79 rc = target_depend_item(&se_dev->dev_group.cg_item);
92 if (rc != 0) { 80 if (rc != 0) {
@@ -247,9 +235,11 @@ static int target_xcopy_parse_target_descriptors(struct se_cmd *se_cmd,
247 } 235 }
248 236
249 if (xop->op_origin == XCOL_SOURCE_RECV_OP) 237 if (xop->op_origin == XCOL_SOURCE_RECV_OP)
250 rc = target_xcopy_locate_se_dev_e4(se_cmd, xop, true); 238 rc = target_xcopy_locate_se_dev_e4(xop->dst_tid_wwn,
239 &xop->dst_dev);
251 else 240 else
252 rc = target_xcopy_locate_se_dev_e4(se_cmd, xop, false); 241 rc = target_xcopy_locate_se_dev_e4(xop->src_tid_wwn,
242 &xop->src_dev);
253 /* 243 /*
254 * If a matching IEEE NAA 0x83 descriptor for the requested device 244 * If a matching IEEE NAA 0x83 descriptor for the requested device
255 * is not located on this node, return COPY_ABORTED with ASQ/ASQC 245 * is not located on this node, return COPY_ABORTED with ASQ/ASQC