@@ -350,22 +350,27 @@ u32 iscsi_parse_pr_out_transport_id(
return out_tid_len;
}
-int target_get_pr_transport_id_len(struct t10_pr_registration *pr_reg)
+static int __target_get_pr_transport_id_len(const char *tid)
{
- switch (pr_reg->pr_tid[0] & 0xF) {
+ switch (tid[0] & 0xF) {
case SCSI_PROTOCOL_FCP:
case SCSI_PROTOCOL_SBP:
case SCSI_PROTOCOL_SRP:
case SCSI_PROTOCOL_SAS:
return 24;
case SCSI_PROTOCOL_ISCSI:
- return get_unaligned_be16(&pr_reg->pr_tid[2]) + 4;
+ return get_unaligned_be16(&tid[2]) + 4;
default:
- WARN(1, "Unknown proto_id: %#x\n", pr_reg->pr_tid[0] & 0xF);
+ WARN(1, "Unknown proto_id: %#x\n", tid[0] & 0xF);
return -EINVAL;
}
}
+int target_get_pr_transport_id_len(struct t10_pr_registration *pr_reg)
+{
+ return __target_get_pr_transport_id_len(pr_reg->pr_tid);
+}
+
int target_get_pr_transport_id(
struct t10_pr_registration *pr_reg,
unsigned char *buf)
@@ -378,6 +383,20 @@ int target_get_pr_transport_id(
return len;
}
+int target_cmp_pr_transport_id(
+ struct t10_pr_registration *pr_reg,
+ unsigned char *tid)
+{
+ int len1 = __target_get_pr_transport_id_len(pr_reg->pr_tid);
+ int len2 = __target_get_pr_transport_id_len(tid);
+
+ if (len1 != len2)
+ return 1;
+
+ return memcmp(pr_reg->pr_tid, tid, len1);
+}
+
+
int target_gen_pr_transport_id(
struct t10_pr_registration *pr_reg,
int proto_id,
@@ -101,6 +101,8 @@ int target_fabric_setup_cits(struct target_fabric_configfs *);
int target_get_pr_transport_id_len(struct t10_pr_registration *pr_reg);
int target_get_pr_transport_id(struct t10_pr_registration *pr_reg,
unsigned char *buf);
+int target_cmp_pr_transport_id(struct t10_pr_registration *pr_reg,
+ unsigned char *tid);
int target_gen_pr_transport_id(struct t10_pr_registration *pr_reg,
int proto_id,
const char *initiatorname,
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com> --- drivers/target/target_core_fabric_lib.c | 27 +++++++++++++++++++++---- drivers/target/target_core_internal.h | 2 ++ 2 files changed, 25 insertions(+), 4 deletions(-)