[RFC PATCH 29/48] target: core: store proto_id in APTPL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Store and read proto_id in APTPL to create TransportID.
That will allow to report registrations for not yet created TPG/ACL/LUNs

Signed-off-by: Dmitry Bogdanov <d.bogdanov@xxxxxxxxx>
---
 drivers/target/target_core_configfs.c | 13 +++++++++++--
 drivers/target/target_core_pr.c       | 15 ++++++++++-----
 drivers/target/target_core_pr.h       |  2 +-
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 0978279bd5e3..f63c37344104 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -1974,7 +1974,8 @@ enum {
 	Opt_initiator_fabric, Opt_initiator_node, Opt_initiator_sid,
 	Opt_sa_res_key, Opt_res_holder, Opt_res_type, Opt_res_scope,
 	Opt_res_all_tg_pt, Opt_mapped_lun, Opt_target_fabric,
-	Opt_target_node, Opt_tpgt, Opt_port_rtpi, Opt_target_lun, Opt_err
+	Opt_target_node, Opt_tpgt, Opt_port_rtpi, Opt_target_lun,
+	Opt_proto_id, Opt_err
 };
 
 static match_table_t tokens = {
@@ -1992,6 +1993,7 @@ static match_table_t tokens = {
 	{Opt_tpgt, "tpgt=%d"},
 	{Opt_port_rtpi, "port_rtpi=%d"},
 	{Opt_target_lun, "target_lun=%u"},
+	{Opt_proto_id, "proto_id=%u"},
 	{Opt_err, NULL}
 };
 
@@ -2010,6 +2012,7 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item,
 	u16 tpgt = 0;
 	u16 rtpi = 0;
 	u8 type = 0;
+	u8 proto_id = 0;
 
 	if (!dev->dev_attrib.emulate_pr ||
 	    (dev->transport_flags & TRANSPORT_FLAG_PASSTHROUGH_PGR))
@@ -2151,6 +2154,12 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item,
 				goto out;
 			target_lun = (u64)tmp_ll;
 			break;
+		case Opt_proto_id:
+			ret = match_int(args, &arg);
+			if (ret)
+				goto out;
+			proto_id = (u16)arg;
+			break;
 		default:
 			break;
 		}
@@ -2171,7 +2180,7 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item,
 
 	ret = core_scsi3_alloc_aptpl_registration(&dev->t10_pr, sa_res_key,
 			i_port, isid, mapped_lun, rtpi, target_lun,
-			res_holder, all_tg_pt, type);
+			res_holder, all_tg_pt, type, proto_id);
 out:
 	kfree(i_fabric);
 	kfree(i_port);
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index f5796d60ed76..d177db3024c9 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -842,7 +842,8 @@ int core_scsi3_alloc_aptpl_registration(
 	u64 target_lun,
 	int res_holder,
 	int all_tg_pt,
-	u8 type)
+	u8 type,
+	u8 proto_id)
 {
 	struct t10_pr_registration *pr_reg;
 
@@ -886,6 +887,7 @@ int core_scsi3_alloc_aptpl_registration(
 	 * Copy the i_port information from caller.
 	 */
 	snprintf(pr_reg->pr_iport, PR_APTPL_MAX_IPORT_LEN, "%s", i_port);
+	target_gen_pr_transport_id(pr_reg, proto_id, i_port, isid);
 	/*
 	 * Set pr_res_holder from caller, the pr_reg who is the reservation
 	 * holder will get it's pointer set in core_scsi3_aptpl_reserve() once
@@ -1836,19 +1838,22 @@ static int core_scsi3_update_aptpl_buf(
 				"sa_res_key=%llu\n"
 				"res_holder=1\nres_type=%02x\n"
 				"res_scope=%02x\nres_all_tg_pt=%d\n"
-				"mapped_lun=%llu\n", reg_count,
+				"mapped_lun=%llu\nproto_id=%u\n", reg_count,
 				pr_reg->pr_iport, isid_buf,
 				pr_reg->pr_res_key, pr_reg->pr_res_type,
 				pr_reg->pr_res_scope, pr_reg->pr_reg_all_tg_pt,
-				pr_reg->pr_res_mapped_lun);
+				pr_reg->pr_res_mapped_lun,
+				pr_reg->pr_tid[0] & 0xF);
 		} else {
 			snprintf(tmp, 512, "PR_REG_START: %d\n"
 				"initiator_node=%s\n%s"
 				"sa_res_key=%llu\nres_holder=0\n"
-				"res_all_tg_pt=%d\nmapped_lun=%llu\n",
+				"res_all_tg_pt=%d\nmapped_lun=%llu\n"
+				"proto_id=%u\n",
 				reg_count, pr_reg->pr_iport, isid_buf,
 				pr_reg->pr_res_key, pr_reg->pr_reg_all_tg_pt,
-				pr_reg->pr_res_mapped_lun);
+				pr_reg->pr_res_mapped_lun,
+				pr_reg->pr_tid[0] & 0xF);
 		}
 
 		if ((len + strlen(tmp) >= pr_aptpl_buf_len)) {
diff --git a/drivers/target/target_core_pr.h b/drivers/target/target_core_pr.h
index 954b0dff32bf..589fdac5470f 100644
--- a/drivers/target/target_core_pr.h
+++ b/drivers/target/target_core_pr.h
@@ -64,7 +64,7 @@ extern sense_reason_t target_scsi2_reservation_reserve(struct se_cmd *);
 extern int core_scsi3_alloc_aptpl_registration(
 			struct t10_reservation *, u64,
 			unsigned char *, unsigned char *, u64,
-			u16, u64, int, int, u8);
+			u16, u64, int, int, u8, u8);
 extern int core_scsi3_check_aptpl_registration(struct se_device *,
 			struct se_portal_group *, struct se_lun *,
 			struct se_node_acl *, u64);
-- 
2.25.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux