]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/target/target_core_xcopy.c
target: target_core_configfs.h is not needed in fabric drivers
[karo-tx-linux.git] / drivers / target / target_core_xcopy.c
index 33ac39bf75e5e25e58145260718568ff01dac88b..3556a9dcee466ca8ed38eee76497f246f948b20a 100644 (file)
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
 #include <target/target_core_fabric.h>
-#include <target/target_core_configfs.h>
 
+#include "target_core_internal.h"
 #include "target_core_pr.h"
 #include "target_core_ua.h"
 #include "target_core_xcopy.h"
 
 static struct workqueue_struct *xcopy_wq = NULL;
-/*
- * From target_core_device.c
- */
-extern struct mutex g_device_mutex;
-extern struct list_head g_device_list;
-/*
- * From target_core_configfs.c
- */
-extern struct configfs_subsystem *target_core_subsystem[];
 
 static int target_xcopy_gen_naa_ieee(struct se_device *dev, unsigned char *buf)
 {
@@ -66,7 +57,6 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
                                        bool src)
 {
        struct se_device *se_dev;
-       struct configfs_subsystem *subsys = target_core_subsystem[0];
        unsigned char tmp_dev_wwn[XCOPY_NAA_IEEE_REGEX_LEN], *dev_wwn;
        int rc;
 
@@ -98,8 +88,7 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
                                " se_dev\n", xop->src_dev);
                }
 
-               rc = configfs_depend_item(subsys,
-                               &se_dev->dev_group.cg_item);
+               rc = target_depend_item(&se_dev->dev_group.cg_item);
                if (rc != 0) {
                        pr_err("configfs_depend_item attempt failed:"
                                " %d for se_dev: %p\n", rc, se_dev);
@@ -107,8 +96,8 @@ static int target_xcopy_locate_se_dev_e4(struct se_cmd *se_cmd, struct xcopy_op
                        return rc;
                }
 
-               pr_debug("Called configfs_depend_item for subsys: %p se_dev: %p"
-                       " se_dev->se_dev_group: %p\n", subsys, se_dev,
+               pr_debug("Called configfs_depend_item for se_dev: %p"
+                       " se_dev->se_dev_group: %p\n", se_dev,
                        &se_dev->dev_group);
 
                mutex_unlock(&g_device_mutex);
@@ -369,11 +358,6 @@ static char *xcopy_pt_get_fabric_name(void)
         return "xcopy-pt";
 }
 
-static u32 xcopy_pt_get_tag(struct se_cmd *se_cmd)
-{
-        return 0;
-}
-
 static int xcopy_pt_get_cmd_state(struct se_cmd *se_cmd)
 {
         return 0;
@@ -381,7 +365,6 @@ static int xcopy_pt_get_cmd_state(struct se_cmd *se_cmd)
 
 static void xcopy_pt_undepend_remotedev(struct xcopy_op *xop)
 {
-       struct configfs_subsystem *subsys = target_core_subsystem[0];
        struct se_device *remote_dev;
 
        if (xop->op_origin == XCOL_SOURCE_RECV_OP)
@@ -389,11 +372,11 @@ static void xcopy_pt_undepend_remotedev(struct xcopy_op *xop)
        else
                remote_dev = xop->src_dev;
 
-       pr_debug("Calling configfs_undepend_item for subsys: %p"
+       pr_debug("Calling configfs_undepend_item for"
                  " remote_dev: %p remote_dev->dev_group: %p\n",
-                 subsys, remote_dev, &remote_dev->dev_group.cg_item);
+                 remote_dev, &remote_dev->dev_group.cg_item);
 
-       configfs_undepend_item(subsys, &remote_dev->dev_group.cg_item);
+       target_undepend_item(&remote_dev->dev_group.cg_item);
 }
 
 static void xcopy_pt_release_cmd(struct se_cmd *se_cmd)
@@ -433,9 +416,8 @@ static int xcopy_pt_queue_status(struct se_cmd *se_cmd)
        return 0;
 }
 
-static struct target_core_fabric_ops xcopy_pt_tfo = {
+static const struct target_core_fabric_ops xcopy_pt_tfo = {
        .get_fabric_name        = xcopy_pt_get_fabric_name,
-       .get_task_tag           = xcopy_pt_get_tag,
        .get_cmd_state          = xcopy_pt_get_cmd_state,
        .release_cmd            = xcopy_pt_release_cmd,
        .check_stop_free        = xcopy_pt_check_stop_free,
@@ -548,33 +530,22 @@ static void target_xcopy_setup_pt_port(
        }
 }
 
-static int target_xcopy_init_pt_lun(
-       struct xcopy_pt_cmd *xpt_cmd,
-       struct xcopy_op *xop,
-       struct se_device *se_dev,
-       struct se_cmd *pt_cmd,
-       bool remote_port)
+static void target_xcopy_init_pt_lun(struct se_device *se_dev,
+               struct se_cmd *pt_cmd, bool remote_port)
 {
        /*
         * Don't allocate + init an pt_cmd->se_lun if honoring local port for
         * reservations.  The pt_cmd->se_lun pointer will be setup from within
         * target_xcopy_setup_pt_port()
         */
-       if (!remote_port) {
-               pt_cmd->se_cmd_flags |= SCF_SE_LUN_CMD | SCF_CMD_XCOPY_PASSTHROUGH;
-               return 0;
+       if (remote_port) {
+               pr_debug("Setup emulated se_dev: %p from se_dev\n",
+                       pt_cmd->se_dev);
+               pt_cmd->se_lun = &se_dev->xcopy_lun;
+               pt_cmd->se_dev = se_dev;
        }
 
-       pt_cmd->se_lun = &se_dev->xcopy_lun;
-       pt_cmd->se_dev = se_dev;
-
-       pr_debug("Setup emulated se_dev: %p from se_dev\n", pt_cmd->se_dev);
-       pt_cmd->se_cmd_flags |= SCF_SE_LUN_CMD | SCF_CMD_XCOPY_PASSTHROUGH;
-
-       pr_debug("Setup emulated se_dev: %p to pt_cmd->se_lun->lun_se_dev\n",
-               pt_cmd->se_lun->lun_se_dev);
-
-       return 0;
+       pt_cmd->se_cmd_flags |= SCF_SE_LUN_CMD;
 }
 
 static int target_xcopy_setup_pt_cmd(
@@ -592,14 +563,12 @@ static int target_xcopy_setup_pt_cmd(
         * Setup LUN+port to honor reservations based upon xop->op_origin for
         * X-COPY PUSH or X-COPY PULL based upon where the CDB was received.
         */
-       rc = target_xcopy_init_pt_lun(xpt_cmd, xop, se_dev, cmd, remote_port);
-       if (rc < 0) {
-               ret = rc;
-               goto out;
-       }
+       target_xcopy_init_pt_lun(se_dev, cmd, remote_port);
+
        xpt_cmd->xcopy_op = xop;
        target_xcopy_setup_pt_port(xpt_cmd, xop, remote_port);
 
+       cmd->tag = 0;
        sense_rc = target_setup_cmd_from_cdb(cmd, cdb);
        if (sense_rc) {
                ret = -EINVAL;