Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target...
[sfrench/cifs-2.6.git] / drivers / target / target_core_fabric_configfs.c
index 8caef31da415bc88606a286928303be624ecbd7a..1bd5c72b663e29a32d50c88dd0fccf344bb72f30 100644 (file)
@@ -78,7 +78,7 @@ static int target_fabric_mappedlun_link(
                        struct se_lun_acl, se_lun_group);
        struct se_portal_group *se_tpg;
        struct config_item *nacl_ci, *tpg_ci, *tpg_ci_s, *wwn_ci, *wwn_ci_s;
-       int lun_access;
+       bool lun_access_ro;
 
        if (lun->lun_link_magic != SE_LUN_LINK_MAGIC) {
                pr_err("Bad lun->lun_link_magic, not a valid lun_ci pointer:"
@@ -115,19 +115,18 @@ static int target_fabric_mappedlun_link(
        }
        /*
         * If this struct se_node_acl was dynamically generated with
-        * tpg_1/attrib/generate_node_acls=1, use the existing deve->lun_flags,
-        * which be will write protected (READ-ONLY) when
+        * tpg_1/attrib/generate_node_acls=1, use the existing
+        * deve->lun_access_ro value, which will be true when
         * tpg_1/attrib/demo_mode_write_protect=1
         */
        rcu_read_lock();
        deve = target_nacl_find_deve(lacl->se_lun_nacl, lacl->mapped_lun);
        if (deve)
-               lun_access = deve->lun_flags;
+               lun_access_ro = deve->lun_access_ro;
        else
-               lun_access =
+               lun_access_ro =
                        (se_tpg->se_tpg_tfo->tpg_check_prod_mode_write_protect(
-                               se_tpg)) ? TRANSPORT_LUNFLAGS_READ_ONLY :
-                                          TRANSPORT_LUNFLAGS_READ_WRITE;
+                               se_tpg)) ? true : false;
        rcu_read_unlock();
        /*
         * Determine the actual mapped LUN value user wants..
@@ -135,7 +134,7 @@ static int target_fabric_mappedlun_link(
         * This value is what the SCSI Initiator actually sees the
         * $FABRIC/$WWPN/$TPGT/lun/lun_* as on their SCSI Initiator Ports.
         */
-       return core_dev_add_initiator_node_lun_acl(se_tpg, lacl, lun, lun_access);
+       return core_dev_add_initiator_node_lun_acl(se_tpg, lacl, lun, lun_access_ro);
 }
 
 static int target_fabric_mappedlun_unlink(
@@ -167,8 +166,7 @@ static ssize_t target_fabric_mappedlun_write_protect_show(
        rcu_read_lock();
        deve = target_nacl_find_deve(se_nacl, lacl->mapped_lun);
        if (deve) {
-               len = sprintf(page, "%d\n",
-                       (deve->lun_flags & TRANSPORT_LUNFLAGS_READ_ONLY) ? 1 : 0);
+               len = sprintf(page, "%d\n", deve->lun_access_ro);
        }
        rcu_read_unlock();
 
@@ -181,25 +179,23 @@ static ssize_t target_fabric_mappedlun_write_protect_store(
        struct se_lun_acl *lacl = item_to_lun_acl(item);
        struct se_node_acl *se_nacl = lacl->se_lun_nacl;
        struct se_portal_group *se_tpg = se_nacl->se_tpg;
-       unsigned long op;
+       unsigned long wp;
        int ret;
 
-       ret = kstrtoul(page, 0, &op);
+       ret = kstrtoul(page, 0, &wp);
        if (ret)
                return ret;
 
-       if ((op != 1) && (op != 0))
+       if ((wp != 1) && (wp != 0))
                return -EINVAL;
 
-       core_update_device_list_access(lacl->mapped_lun, (op) ?
-                       TRANSPORT_LUNFLAGS_READ_ONLY :
-                       TRANSPORT_LUNFLAGS_READ_WRITE,
-                       lacl->se_lun_nacl);
+       /* wp=1 means lun_access_ro=true */
+       core_update_device_list_access(lacl->mapped_lun, wp, lacl->se_lun_nacl);
 
        pr_debug("%s_ConfigFS: Changed Initiator ACL: %s"
                " Mapped LUN: %llu Write Protect bit to %s\n",
                se_tpg->se_tpg_tfo->get_fabric_name(),
-               se_nacl->initiatorname, lacl->mapped_lun, (op) ? "ON" : "OFF");
+               se_nacl->initiatorname, lacl->mapped_lun, (wp) ? "ON" : "OFF");
 
        return count;