From 129008c92c701fe2fc247420da80140d4e4f976c Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 26 May 2010 18:26:52 +0000 Subject: [PATCH] CONFIG_SCST_ISCSI_SKIP_ISID removed, because it isn't needed git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1717 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/README | 7 ----- iscsi-scst/README_in-tree | 7 ----- iscsi-scst/kernel/Kconfig | 14 --------- iscsi-scst/kernel/Makefile | 2 -- iscsi-scst/kernel/config.c | 4 --- iscsi-scst/kernel/iscsi.c | 18 ----------- scst/include/scst.h | 1 - scst/src/scst_pres.c | 62 ++++++++++++++++++-------------------- 8 files changed, 30 insertions(+), 85 deletions(-) diff --git a/iscsi-scst/README b/iscsi-scst/README index 0a01938bb..d7ab60dd2 100644 --- a/iscsi-scst/README +++ b/iscsi-scst/README @@ -806,13 +806,6 @@ in/out in the kernel's module Makefile: - CONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES - simulates digest failures in random places. - - CONFIG_SCST_ISCSI_SKIP_ISID - makes iSCSI-SCST to always use iSCSI - initiator port TransportID format 0, i.e. always identify initiators - only by names and ignore ISID part in TransportIDs. This is useful - for Persistent Reservations with initiators which don't use ISID in a - standards confirming way, for instance by always incrementing it on - each reconnect, as well as to debug Persistent Reservations. - Creating version of put_page_callback patch for your kernel ----------------------------------------------------------- diff --git a/iscsi-scst/README_in-tree b/iscsi-scst/README_in-tree index 0912c8fe4..68f1a0a23 100644 --- a/iscsi-scst/README_in-tree +++ b/iscsi-scst/README_in-tree @@ -701,13 +701,6 @@ in/out in the kernel's module Makefile: - CONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES - simulates digest failures in random places. - - CONFIG_SCST_ISCSI_SKIP_ISID - makes iSCSI-SCST to always use iSCSI - initiator port TransportID format 0, i.e. always identify initiators - only by names and ignore ISID part in TransportIDs. This is useful - for Persistent Reservations with initiators which don't use ISID in a - standards confirming way, for instance by always incrementing it on - each reconnect, as well as to debug Persistent Reservations. - Credits ------- diff --git a/iscsi-scst/kernel/Kconfig b/iscsi-scst/kernel/Kconfig index 5c1172731..70c282422 100644 --- a/iscsi-scst/kernel/Kconfig +++ b/iscsi-scst/kernel/Kconfig @@ -23,17 +23,3 @@ config SCST_ISCSI_DEBUG_DIGEST_FAILURES iSCSI initiator that is talking to SCST. If unsure, say "N". - -config CONFIG_SCST_ISCSI_SKIP_ISID - bool "Do not use ISID in initiator port transport id" - depends on SCST_ISCSI - help - Makes iSCSI-SCST to always use iSCSI initiator port - TransportID format 0, i.e. always identify initiators only by - names and ignore ISID part in TransportIDs. This is useful for - Persistent Reservations with initiators which don't use ISID - in a standards confirming way, for instance by always - incrementing it on each reconnect, as well as to debug - Persistent Reservations. - - If unsure, say "N". diff --git a/iscsi-scst/kernel/Makefile b/iscsi-scst/kernel/Makefile index 176d4d90a..f9ed4d8d0 100644 --- a/iscsi-scst/kernel/Makefile +++ b/iscsi-scst/kernel/Makefile @@ -29,8 +29,6 @@ EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions #EXTRA_CFLAGS += -DCONFIG_SCST_ISCSI_DEBUG_DIGEST_FAILURES -#EXTRA_CFLAGS += -DCONFIG_SCST_ISCSI_SKIP_ISID - obj-m += iscsi-scst.o iscsi-scst-objs := iscsi.o nthread.o config.o digest.o \ conn.o session.o target.o event.o param.o diff --git a/iscsi-scst/kernel/config.c b/iscsi-scst/kernel/config.c index 9c5c1dd03..0d2b03ea3 100644 --- a/iscsi-scst/kernel/config.c +++ b/iscsi-scst/kernel/config.c @@ -260,10 +260,6 @@ static ssize_t iscsi_version_show(struct kobject *kobj, strcat(buf, "DEBUG_DIGEST_FAILURES\n"); #endif -#ifdef CONFIG_SCST_ISCSI_SKIP_ISID - strcat(buf, "CONFIG_SCST_ISCSI_SKIP_ISID\n"); -#endif - TRACE_EXIT(); return strlen(buf); } diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index 2068b7a9b..cd6a2e394 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -3525,14 +3525,8 @@ int iscsi_get_initiator_port_transport_id(struct scst_session *scst_sess, goto out; } -#ifdef CONFIG_SCST_ISCSI_SKIP_ISID - tr_id[0] = 0x0 | SCSI_TRANSPORTID_PROTOCOLID_ISCSI; - tr_id_size = 4 + sprintf(&tr_id[4], "%s", sess->initiator_name) + 1; - tr_id_size = (tr_id_size + 3) & -4; -#else tr_id[0] = 0x40 | SCSI_TRANSPORTID_PROTOCOLID_ISCSI; sprintf(&tr_id[4], "%s,i,0x%llx", sess->initiator_name, sid.id64); -#endif put_unaligned(cpu_to_be16(tr_id_size - 4), (__be16 *)&tr_id[2]); @@ -3744,12 +3738,6 @@ static int __init iscsi_init(void) #endif #endif -#ifdef CONFIG_SCST_ISCSI_SKIP_ISID - PRINT_WARNING("%s", "CONFIG_SCST_ISCSI_SKIP_ISID defined: identifying " - "initiators only by names and ignoring ISID part in " - "TransportIDs"); -#endif - ctr_major = register_chrdev(0, ctr_name, &ctr_fops); if (ctr_major < 0) { PRINT_ERROR("failed to register the control device %d", @@ -3788,12 +3776,6 @@ static int __init iscsi_init(void) if (err != 0) goto out_thr; -#ifdef CONFIG_SCST_ISCSI_SKIP_ISID - iscsi_tid_name_only = true; -#else - iscsi_tid_name_only = false; -#endif - out: return err; diff --git a/scst/include/scst.h b/scst/include/scst.h index 9e8a42e7a..5b784a1ee 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -3311,7 +3311,6 @@ struct scst_trace_log { }; extern struct mutex scst_mutex; -extern bool iscsi_tid_name_only; #ifdef CONFIG_SCST_PROC diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index 3a640dfca..ceed7e38c 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -65,15 +65,6 @@ #define isblank(c) ((c) == ' ' || (c) == '\t') #endif -/* - * Experimental hack to support CONFIG_SCST_ISCSI_SKIP_ISID. ISCSI-SCST sets - * this variable if CONFIG_SCST_ISCSI_SKIP_ISID defined, then tid_equal() - * uses it to perform for iSCSI TransportIDs only initiator names comparison - * ignoring the ISID part. - */ -bool iscsi_tid_name_only = false; -EXPORT_SYMBOL(iscsi_tid_name_only); - static inline int tid_size(const uint8_t *tid) { sBUG_ON(tid == NULL); @@ -121,7 +112,7 @@ static bool tid_equal(const uint8_t *tid_a, const uint8_t *tid_b) if (tid_a_fmt == 0x00) tid_a_len = strnlen(tid_a, tid_a_max); else if (tid_a_fmt == 0x40) { - if ((tid_a_fmt != tid_b_fmt) || iscsi_tid_name_only) { + if (tid_a_fmt != tid_b_fmt) { uint8_t *p = strnchr(tid_a, tid_a_max, ','); if (p == NULL) goto out_error; @@ -137,7 +128,7 @@ static bool tid_equal(const uint8_t *tid_a, const uint8_t *tid_b) if (tid_b_fmt == 0x00) tid_b_len = strnlen(tid_b, tid_b_max); else if (tid_b_fmt == 0x40) { - if ((tid_a_fmt != tid_b_fmt) || iscsi_tid_name_only) { + if (tid_a_fmt != tid_b_fmt) { uint8_t *p = strnchr(tid_b, tid_b_max, ','); if (p == NULL) goto out_error; @@ -297,11 +288,11 @@ static void scst_pr_find_registrants_list_key(struct scst_device *dev, } /* dev_pr_mutex must be locked */ -static struct scst_dev_registrant *scst_pr_find_reg_not_used_first( +static struct scst_dev_registrant *scst_pr_find_reg( struct scst_device *dev, const uint8_t *transport_id, - const uint16_t rel_tgt_id, bool not_used_only) + const uint16_t rel_tgt_id) { - struct scst_dev_registrant *reg, *res = NULL, *res_used = NULL; + struct scst_dev_registrant *reg, *res = NULL; TRACE_ENTRY(); @@ -309,17 +300,11 @@ static struct scst_dev_registrant *scst_pr_find_reg_not_used_first( dev_registrants_list_entry) { if ((reg->rel_tgt_id == rel_tgt_id) && tid_equal(reg->transport_id, transport_id)) { - if (reg->tgt_dev == NULL) { - res = reg; - break; - } else if (!not_used_only && (res_used == NULL)) - res_used = reg; + res = reg; + break; } } - if (res == NULL) - res = res_used; - TRACE_EXIT_HRES(res); return res; } @@ -367,13 +352,27 @@ static struct scst_dev_registrant *scst_pr_add_registrant( const uint16_t rel_tgt_id, uint64_t key, struct scst_tgt_dev *tgt_dev, gfp_t gfp_flags) { - struct scst_dev_registrant *reg = NULL; + struct scst_dev_registrant *reg; TRACE_ENTRY(); sBUG_ON(dev == NULL); sBUG_ON(transport_id == NULL); + reg = scst_pr_find_reg(dev, transport_id, rel_tgt_id); + if (reg != NULL) { + /* + * It might happen when a target driver would make >1 session + * from the same initiator to the same target. + */ + PRINT_ERROR("Registrant X/%d (dev %s) already exists!", + rel_tgt_id, dev->virt_name); + PRINT_BUFFER("TransportID", transport_id, 24); + WARN_ON(1); + reg = NULL; + goto out; + } + TRACE_PR("Registering %s/%d (dev %s, tgt_dev %p)", debug_transport_id_to_initiator_name(transport_id), rel_tgt_id, dev->virt_name, tgt_dev); @@ -1224,9 +1223,8 @@ int scst_pr_init_tgt_dev(struct scst_tgt_dev *tgt_dev) scst_pr_write_lock(dev); - reg = scst_pr_find_reg_not_used_first(dev, transport_id, rel_tgt_id, - true); - if (reg != NULL) { + reg = scst_pr_find_reg(dev, transport_id, rel_tgt_id); + if ((reg != NULL) && (reg->tgt_dev == NULL)) { TRACE_PR("Assigning reg %p to tgt_dev %p", reg, tgt_dev); tgt_dev->registrant = reg; reg->tgt_dev = tgt_dev; @@ -1254,10 +1252,12 @@ void scst_pr_clear_tgt_dev(struct scst_tgt_dev *tgt_dev) tgt_dev->registrant = NULL; reg->tgt_dev = NULL; + /* Just in case, actually. It should never happen. */ list_for_each_entry(t, &dev->dev_tgt_dev_list, dev_tgt_dev_list_entry) { - if ((t->registrant == NULL) && - (t->sess->tgt->rel_tgt_id == reg->rel_tgt_id) && + if (t == tgt_dev) + continue; + if ((t->sess->tgt->rel_tgt_id == reg->rel_tgt_id) && tid_equal(t->sess->transport_id, reg->transport_id)) { TRACE_PR("Reassigning reg %s/%d (%p) to tgt_dev " "%p (being cleared tgt_dev %p)", @@ -1361,8 +1361,7 @@ static int scst_pr_register_with_spec_i_pt(struct scst_cmd *cmd, } spin_unlock_bh(&dev->dev_lock); } else { - reg = scst_pr_find_reg_not_used_first(dev, transport_id, - rel_tgt_id, false); + reg = scst_pr_find_reg(dev, transport_id, rel_tgt_id); if (reg != NULL) { TRACE_PR("Changing key of reg %p (tgt_dev %p)", reg, reg->tgt_dev); @@ -1742,8 +1741,7 @@ void scst_pr_register_and_move(struct scst_cmd *cmd, uint8_t *buffer, goto out; } - reg_move = scst_pr_find_reg_not_used_first(dev, transport_id_move, - rel_tgt_id_move, false); + reg_move = scst_pr_find_reg(dev, transport_id_move, rel_tgt_id_move); if (reg_move == NULL) { reg_move = scst_pr_add_registrant(dev, transport_id_move, rel_tgt_id_move, action_key, NULL, GFP_KERNEL);