From fd0060b8013774826ebdb15b41992270088090e8 Mon Sep 17 00:00:00 2001 From: Vladimir Sokolovsky Date: Thu, 5 Sep 2019 16:01:03 -0500 Subject: [PATCH] Updated backports with SLES15 support Signed-off-by: Vladimir Sokolovsky --- ofed_scripts/gen-compat-config.sh | 24 +++++++ patches/0002-BACKPORT-ib_core.patch | 46 +++++++++++++- patches/0006-BACKPORT-iser.patch | 24 ++++--- patches/0007-BACKPORT-srp.patch | 99 +++++++++++++++++++---------- 4 files changed, 149 insertions(+), 44 deletions(-) diff --git a/ofed_scripts/gen-compat-config.sh b/ofed_scripts/gen-compat-config.sh index 3f3fa56..7d23aaf 100755 --- a/ofed_scripts/gen-compat-config.sh +++ b/ofed_scripts/gen-compat-config.sh @@ -807,3 +807,27 @@ if (grep -qw "const struct dcbnl_rtnl_ops \*dcbnl_ops" ${KLIB_BUILD}/include/lin set_config CONFIG_COMPAT_IS_DCBNL_OPS_CONST y fi +KSRC=/lib/modules/${KVERSION}/source + +if (grep -qw "static.* fib_lookup" ${KLIB_BUILD}/include/net/ip_fib.h > /dev/null 2>&1 || grep -qw "static.* fib_lookup" ${KSRC}/include/net/ip_fib.h > /dev/null 2>&1) && + (grep -qw "extern.* fib_lookup" ${KLIB_BUILD}/include/net/ip_fib.h > /dev/null 2>&1 || grep -qw "extern.* fib_lookup" ${KSRC}/include/net/ip_fib.h > /dev/null 2>&1); then + set_config CONFIG_COMPAT_IS_FIB_LOOKUP_STATIC_AND_EXTERN y +fi + +HASH_TYPES=${KLIB_BUILD}/include/linux/rhashtable-types.h +HASH_TYPES2=${KSRC}/include/linux/rhashtable-types.h + +if (test ! -f "$HASH_TYPES" -a ! -f "$HASH_TYPES2"); then + if (grep -E -A10 "struct rhashtable \{" ${KLIB_BUILD}/include/linux/rhashtable.h 2>&1 | grep -qw rhlist || grep -A5 "struct rhashtable \{" ${KSRC}/include/linux/rhashtable 2>&1 | grep -qw rhlist); then + if (grep -E -A5 "if \(\!key \|\|" ${KLIB_BUILD}/include/linux/rhashtable.h 2>&1 | grep -qw pprev || grep -A5 "if \(\!key \|\|" ${KSRC}/include/linux/rhashtable 2>&1 | grep -qw pprev); then + set_config CONFIG_COMPAT_RHASHTABLE_FIXED y + fi + if (grep -E -A5 "struct rhashtable \{" ${KLIB_BUILD}/include/linux/rhashtable.h 2>&1 | grep -qw nelems || grep -A5 "struct rhashtable \{" ${KSRC}/include/linux/rhashtable 2>&1 | grep -qw nelems); then + set_config CONFIG_COMPAT_RHASHTABLE_NOT_REORG y + fi + if (grep -E -A2 "struct rhashtable_params \{" ${KLIB_BUILD}/include/linux/rhashtable.h 2>&1 | grep -qw u16 || grep -A2 "struct rhashtable_params \{" ${KSRC}/include/linux/rhashtable 2>&1 | grep -qw u16); then + set_config CONFIG_COMPAT_RHASHTABLE_PARAM_COMPACT y + fi + fi +fi + diff --git a/patches/0002-BACKPORT-ib_core.patch b/patches/0002-BACKPORT-ib_core.patch index 3ce7fa8..0f94324 100644 --- a/patches/0002-BACKPORT-ib_core.patch +++ b/patches/0002-BACKPORT-ib_core.patch @@ -4,6 +4,7 @@ Subject: [PATCH] BACKPORT: ib_core Signed-off-by: Vladimir Sokolovsky --- drivers/infiniband/core/addr.c | 51 +++- + drivers/infiniband/core/cache.c | 5 + drivers/infiniband/core/cma.c | 27 ++ drivers/infiniband/core/cma_configfs.c | 104 ++++++++ drivers/infiniband/core/core_priv.h | 38 +++ @@ -35,7 +36,7 @@ Signed-off-by: Vladimir Sokolovsky include/rdma/restrack.h | 9 + include/rdma/uverbs_ioctl.h | 3 + include/trace/events/ib_mad.h | 7 + - 32 files changed, 1616 insertions(+), 7 deletions(-) + 33 files changed, 1621 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index xxxxxxx..xxxxxxx 100644 @@ -166,6 +167,49 @@ index xxxxxxx..xxxxxxx 100644 ndev->type != ARPHRD_INFINIBAND) dev_addr->network = dst_in->sa_family == AF_INET ? RDMA_NETWORK_IPV4 : +diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c +index xxxxxxx..xxxxxxx 100644 +--- a/drivers/infiniband/core/cache.c ++++ b/drivers/infiniband/core/cache.c +@@ -41,6 +41,7 @@ + #include + + #include ++#include + + #include "core_priv.h" + +@@ -1299,6 +1300,7 @@ struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr) + } + EXPORT_SYMBOL(rdma_read_gid_attr_ndev_rcu); + ++#ifdef HAVE_NETDEV_WALK_ALL_LOWER_DEV_RCU + static int get_lower_dev_vlan(struct net_device *lower_dev, void *data) + { + u16 *vlan_id = data; +@@ -1311,6 +1313,7 @@ static int get_lower_dev_vlan(struct net_device *lower_dev, void *data) + */ + return 1; + } ++#endif + + /** + * rdma_read_gid_l2_fields - Read the vlan ID and source MAC address +@@ -1342,12 +1345,14 @@ int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr, + if (is_vlan_dev(ndev)) { + *vlan_id = vlan_dev_vlan_id(ndev); + } else { ++#ifdef HAVE_NETDEV_WALK_ALL_LOWER_DEV_RCU + /* If the netdev is upper device and if it's lower + * device is vlan device, consider vlan id of the + * the lower vlan device for this gid entry. + */ + netdev_walk_all_lower_dev_rcu(attr->ndev, + get_lower_dev_vlan, vlan_id); ++#endif + } + } + rcu_read_unlock(); diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index xxxxxxx..xxxxxxx 100644 --- a/drivers/infiniband/core/cma.c diff --git a/patches/0006-BACKPORT-iser.patch b/patches/0006-BACKPORT-iser.patch index f503414..bf7430e 100644 --- a/patches/0006-BACKPORT-iser.patch +++ b/patches/0006-BACKPORT-iser.patch @@ -3,10 +3,10 @@ Subject: [PATCH] BACKPORT: iser Signed-off-by: Vladimir Sokolovsky --- - drivers/infiniband/ulp/iser/iscsi_iser.c | 39 ++++++++++++++++ - drivers/infiniband/ulp/iser/iscsi_iser.h | 10 +++++ - drivers/infiniband/ulp/iser/iser_memory.c | 54 ++++++++++++++++++++++- - 3 files changed, 102 insertions(+), 1 deletion(-) + drivers/infiniband/ulp/iser/iscsi_iser.c | 39 +++++++++++++++ + drivers/infiniband/ulp/iser/iscsi_iser.h | 10 ++++ + drivers/infiniband/ulp/iser/iser_memory.c | 58 ++++++++++++++++++++++- + 3 files changed, 106 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index xxxxxxx..xxxxxxx 100644 @@ -107,21 +107,25 @@ diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/ index xxxxxxx..xxxxxxx 100644 --- a/drivers/infiniband/ulp/iser/iser_memory.c +++ b/drivers/infiniband/ulp/iser/iser_memory.c -@@ -305,8 +305,13 @@ static void +@@ -305,8 +305,17 @@ static void iser_set_dif_domain(struct scsi_cmnd *sc, struct ib_sig_domain *domain) { domain->sig_type = IB_SIG_TYPE_T10_DIF; +#ifdef HAVE_SCSI_CMND_PROT_FLAGS domain->sig.dif.pi_interval = scsi_prot_interval(sc); ++#ifdef HAVE_T10_PI_REF_TAG domain->sig.dif.ref_tag = t10_pi_ref_tag(sc->request); +#else ++ domain->sig.dif.ref_tag = scsi_prot_ref_tag(sc); ++#endif ++#else + domain->sig.dif.pi_interval = sc->device->sector_size; + domain->sig.dif.ref_tag = scsi_get_lba(sc) & 0xffffffff; +#endif /* * At the moment we hard code those, but in the future * we will take them from sc. -@@ -314,9 +319,15 @@ iser_set_dif_domain(struct scsi_cmnd *sc, struct ib_sig_domain *domain) +@@ -314,9 +323,15 @@ iser_set_dif_domain(struct scsi_cmnd *sc, struct ib_sig_domain *domain) domain->sig.dif.apptag_check_mask = 0xffff; domain->sig.dif.app_escape = true; domain->sig.dif.ref_escape = true; @@ -138,7 +142,7 @@ index xxxxxxx..xxxxxxx 100644 static int iser_set_sig_attrs(struct scsi_cmnd *sc, struct ib_sig_attrs *sig_attrs) -@@ -332,16 +343,26 @@ iser_set_sig_attrs(struct scsi_cmnd *sc, struct ib_sig_attrs *sig_attrs) +@@ -332,16 +347,26 @@ iser_set_sig_attrs(struct scsi_cmnd *sc, struct ib_sig_attrs *sig_attrs) case SCSI_PROT_WRITE_STRIP: sig_attrs->wire.sig_type = IB_SIG_TYPE_NONE; iser_set_dif_domain(sc, &sig_attrs->mem); @@ -165,7 +169,7 @@ index xxxxxxx..xxxxxxx 100644 break; default: iser_err("Unsupported PI operation %d\n", -@@ -352,6 +373,7 @@ iser_set_sig_attrs(struct scsi_cmnd *sc, struct ib_sig_attrs *sig_attrs) +@@ -352,6 +377,7 @@ iser_set_sig_attrs(struct scsi_cmnd *sc, struct ib_sig_attrs *sig_attrs) return 0; } @@ -173,7 +177,7 @@ index xxxxxxx..xxxxxxx 100644 static inline void iser_set_prot_checks(struct scsi_cmnd *sc, u8 *mask) { -@@ -361,6 +383,30 @@ iser_set_prot_checks(struct scsi_cmnd *sc, u8 *mask) +@@ -361,6 +387,30 @@ iser_set_prot_checks(struct scsi_cmnd *sc, u8 *mask) if (sc->prot_flags & SCSI_PROT_GUARD_CHECK) *mask |= IB_SIG_CHECK_GUARD; } @@ -204,7 +208,7 @@ index xxxxxxx..xxxxxxx 100644 static inline void iser_inv_rkey(struct ib_send_wr *inv_wr, -@@ -395,7 +441,13 @@ iser_reg_sig_mr(struct iscsi_iser_task *iser_task, +@@ -395,7 +445,13 @@ iser_reg_sig_mr(struct iscsi_iser_task *iser_task, if (ret) goto err; diff --git a/patches/0007-BACKPORT-srp.patch b/patches/0007-BACKPORT-srp.patch index 1083461..7a9a59a 100644 --- a/patches/0007-BACKPORT-srp.patch +++ b/patches/0007-BACKPORT-srp.patch @@ -3,10 +3,10 @@ Subject: [PATCH] BACKPORT: srp Signed-off-by: Vladimir Sokolovsky --- - drivers/infiniband/ulp/srp/ib_srp.c | 246 ++++++++++++++++++++++++++++ + drivers/infiniband/ulp/srp/ib_srp.c | 254 ++++++++++++++++++++++++++++ drivers/infiniband/ulp/srp/ib_srp.h | 36 ++++ drivers/scsi/scsi_transport_srp.c | 39 +++++ - 3 files changed, 321 insertions(+) + 3 files changed, 329 insertions(+) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index xxxxxxx..xxxxxxx 100644 @@ -123,7 +123,17 @@ index xxxxxxx..xxxxxxx 100644 } ret = 0; -@@ -1120,6 +1169,10 @@ static void srp_remove_target(struct srp_target_port *target) +@@ -1109,7 +1158,9 @@ static void srp_remove_target(struct srp_target_port *target) + scsi_remove_host(target->scsi_host); + srp_stop_rport_timers(target->rport); + srp_disconnect_target(target); ++#ifdef HAVE_KOBJ_NS_GRAB_CURRENT_EXPORTED + kobj_ns_drop(KOBJ_NS_TYPE_NET, target->net); ++#endif + for (i = 0; i < target->ch_count; i++) { + ch = &target->ch[i]; + srp_free_ch_ib(target, ch); +@@ -1120,6 +1171,10 @@ static void srp_remove_target(struct srp_target_port *target) ch = &target->ch[i]; srp_free_req_data(target, ch); } @@ -134,7 +144,7 @@ index xxxxxxx..xxxxxxx 100644 kfree(target->ch); target->ch = NULL; -@@ -1328,6 +1381,9 @@ static void srp_free_req(struct srp_rdma_ch *ch, struct srp_request *req, +@@ -1328,6 +1383,9 @@ static void srp_free_req(struct srp_rdma_ch *ch, struct srp_request *req, spin_lock_irqsave(&ch->lock, flags); ch->req_lim += req_lim_delta; @@ -144,7 +154,7 @@ index xxxxxxx..xxxxxxx 100644 spin_unlock_irqrestore(&ch->lock, flags); } -@@ -1763,6 +1819,7 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req, +@@ -1763,6 +1821,7 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req, return 0; } @@ -152,7 +162,7 @@ index xxxxxxx..xxxxxxx 100644 static void srp_check_mapping(struct srp_map_state *state, struct srp_rdma_ch *ch, struct srp_request *req, struct scatterlist *scat, int count) -@@ -1786,6 +1843,7 @@ static void srp_check_mapping(struct srp_map_state *state, +@@ -1786,6 +1845,7 @@ static void srp_check_mapping(struct srp_map_state *state, scsi_bufflen(req->scmnd), desc_len, mr_len, state->ndesc, state->nmdesc); } @@ -160,7 +170,7 @@ index xxxxxxx..xxxxxxx 100644 /** * srp_map_data() - map SCSI data buffer onto an SRP request -@@ -1902,12 +1960,14 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch, +@@ -1902,12 +1962,14 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch, if (ret < 0) goto unmap; @@ -175,7 +185,7 @@ index xxxxxxx..xxxxxxx 100644 /* We've mapped the request, now pull as much of the indirect * descriptor table as we can into the command buffer. If this -@@ -2118,6 +2178,9 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp) +@@ -2118,6 +2180,9 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp) struct srp_request *req; struct scsi_cmnd *scmnd; unsigned long flags; @@ -185,7 +195,7 @@ index xxxxxxx..xxxxxxx 100644 if (unlikely(rsp->tag & SRP_TAG_TSK_MGMT)) { spin_lock_irqsave(&ch->lock, flags); -@@ -2134,6 +2197,7 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp) +@@ -2134,6 +2199,7 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp) } spin_unlock_irqrestore(&ch->lock, flags); } else { @@ -193,7 +203,7 @@ index xxxxxxx..xxxxxxx 100644 scmnd = scsi_host_find_tag(target->scsi_host, rsp->tag); if (scmnd && scmnd->host_scribble) { req = (void *)scmnd->host_scribble; -@@ -2141,6 +2205,18 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp) +@@ -2141,6 +2207,18 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp) } else { scmnd = NULL; } @@ -212,7 +222,7 @@ index xxxxxxx..xxxxxxx 100644 if (!scmnd) { shost_printk(KERN_ERR, target->scsi_host, "Null scmnd for RSP w/tag %#016llx received on ch %td / QP %#x\n", -@@ -2237,8 +2313,13 @@ static void srp_process_aer_req(struct srp_rdma_ch *ch, +@@ -2237,8 +2315,13 @@ static void srp_process_aer_req(struct srp_rdma_ch *ch, }; s32 delta = be32_to_cpu(req->req_lim_delta); @@ -226,7 +236,7 @@ index xxxxxxx..xxxxxxx 100644 if (srp_response_common(ch, delta, &rsp, sizeof(rsp))) shost_printk(KERN_ERR, target->scsi_host, PFX -@@ -2337,6 +2418,13 @@ static void srp_handle_qp_err(struct ib_cq *cq, struct ib_wc *wc, +@@ -2337,6 +2420,13 @@ static void srp_handle_qp_err(struct ib_cq *cq, struct ib_wc *wc, target->qp_in_error = true; } @@ -240,7 +250,7 @@ index xxxxxxx..xxxxxxx 100644 static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) { struct srp_target_port *target = host_to_target(shost); -@@ -2347,13 +2435,16 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) +@@ -2347,13 +2437,16 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) struct ib_device *dev; unsigned long flags; u32 tag; @@ -257,7 +267,7 @@ index xxxxxxx..xxxxxxx 100644 WARN_ON_ONCE(scmnd->request->tag < 0); tag = blk_mq_unique_tag(scmnd->request); ch = &target->ch[blk_mq_unique_tag_to_hwq(tag)]; -@@ -2361,15 +2452,28 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) +@@ -2361,15 +2454,28 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) WARN_ONCE(idx >= target->req_ring_size, "%s: tag %#x: idx %d >= %d\n", dev_name(&shost->shost_gendev), tag, idx, target->req_ring_size); @@ -286,7 +296,7 @@ index xxxxxxx..xxxxxxx 100644 dev = target->srp_host->srp_dev->dev; ib_dma_sync_single_for_cpu(dev, iu->dma, ch->max_it_iu_len, DMA_TO_DEVICE); -@@ -2431,6 +2535,14 @@ err_iu: +@@ -2431,6 +2537,14 @@ err_iu: */ req->scmnd = NULL; @@ -301,7 +311,7 @@ index xxxxxxx..xxxxxxx 100644 err: if (scmnd->result) { scmnd->scsi_done(scmnd); -@@ -2897,13 +3009,40 @@ static int srp_rdma_cm_handler(struct rdma_cm_id *cm_id, +@@ -2897,13 +3011,40 @@ static int srp_rdma_cm_handler(struct rdma_cm_id *cm_id, * * Returns queue depth. */ @@ -342,7 +352,7 @@ index xxxxxxx..xxxxxxx 100644 static int srp_send_tsk_mgmt(struct srp_rdma_ch *ch, u64 req_tag, u64 lun, u8 func, u8 *status) -@@ -2984,8 +3123,13 @@ static int srp_abort(struct scsi_cmnd *scmnd) +@@ -2984,8 +3125,13 @@ static int srp_abort(struct scsi_cmnd *scmnd) if (!req) return SUCCESS; @@ -356,7 +366,7 @@ index xxxxxxx..xxxxxxx 100644 if (WARN_ON_ONCE(ch_idx >= target->ch_count)) return SUCCESS; ch = &target->ch[ch_idx]; -@@ -3046,6 +3190,21 @@ static int srp_target_alloc(struct scsi_target *starget) +@@ -3046,6 +3192,21 @@ static int srp_target_alloc(struct scsi_target *starget) return 0; } @@ -378,7 +388,7 @@ index xxxxxxx..xxxxxxx 100644 static int srp_slave_configure(struct scsi_device *sdev) { struct Scsi_Host *shost = sdev->host; -@@ -3248,6 +3407,9 @@ static struct scsi_host_template srp_template = { +@@ -3248,6 +3409,9 @@ static struct scsi_host_template srp_template = { .name = "InfiniBand SRP initiator", .proc_name = DRV_NAME, .target_alloc = srp_target_alloc, @@ -388,7 +398,7 @@ index xxxxxxx..xxxxxxx 100644 .slave_configure = srp_slave_configure, .info = srp_target_info, .queuecommand = srp_queuecommand, -@@ -3262,7 +3424,9 @@ static struct scsi_host_template srp_template = { +@@ -3262,7 +3426,9 @@ static struct scsi_host_template srp_template = { .this_id = -1, .cmd_per_lun = SRP_DEFAULT_CMD_SQ_SIZE, .shost_attrs = srp_host_attrs, @@ -398,7 +408,7 @@ index xxxxxxx..xxxxxxx 100644 }; static int srp_sdev_count(struct Scsi_Host *host) -@@ -3311,8 +3475,13 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) +@@ -3311,8 +3477,13 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) list_add_tail(&target->list, &host->target_list); spin_unlock(&host->target_lock); @@ -412,7 +422,7 @@ index xxxxxxx..xxxxxxx 100644 if (srp_connected_ch(target) < target->ch_count || target->qp_in_error) { -@@ -3710,12 +3879,21 @@ static int srp_parse_options(struct net *net, const char *buf, +@@ -3710,12 +3881,21 @@ static int srp_parse_options(struct net *net, const char *buf, break; case SRP_OPT_SG_TABLESIZE: @@ -434,7 +444,7 @@ index xxxxxxx..xxxxxxx 100644 target->sg_tablesize = token; break; -@@ -3775,7 +3953,11 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3775,7 +3955,11 @@ static ssize_t srp_create_target(struct device *dev, struct srp_device *srp_dev = host->srp_dev; struct ib_device *ibdev = srp_dev->dev; int ret, node_idx, node, cpu, i; @@ -446,7 +456,7 @@ index xxxxxxx..xxxxxxx 100644 bool multich = false; uint32_t max_iu_len; -@@ -3789,10 +3971,14 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3789,21 +3973,47 @@ static ssize_t srp_create_target(struct device *dev, target_host->max_id = 1; target_host->max_lun = -1LL; target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb; @@ -461,7 +471,14 @@ index xxxxxxx..xxxxxxx 100644 target = host_to_target(target_host); -@@ -3803,7 +3989,25 @@ static ssize_t srp_create_target(struct device *dev, ++#ifdef HAVE_KOBJ_NS_GRAB_CURRENT_EXPORTED + target->net = kobj_ns_grab_current(KOBJ_NS_TYPE_NET); ++#else ++ target->net = &init_net; ++#endif + target->io_class = SRP_REV16A_IB_IO_CLASS; + target->scsi_host = target_host; + target->srp_host = host; target->lkey = host->srp_dev->pd->local_dma_lkey; target->global_rkey = host->srp_dev->global_rkey; target->cmd_sg_cnt = cmd_sg_entries; @@ -487,7 +504,7 @@ index xxxxxxx..xxxxxxx 100644 target->allow_ext_sg = allow_ext_sg; target->tl_retry_count = 7; target->queue_size = SRP_DEFAULT_QUEUE_SIZE; -@@ -3852,9 +4056,12 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3852,9 +4062,12 @@ static ssize_t srp_create_target(struct device *dev, bool gaps_reg = (ibdev->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG); @@ -500,7 +517,7 @@ index xxxxxxx..xxxxxxx 100644 /* * FR and FMR can only map one HCA page per entry. If * the start address is not aligned on a HCA page -@@ -3871,15 +4078,26 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3871,15 +4084,26 @@ static ssize_t srp_create_target(struct device *dev, mr_per_cmd = register_always + (target->scsi_host->max_sectors + 1 + max_sectors_per_mr - 1) / max_sectors_per_mr; @@ -527,7 +544,7 @@ index xxxxxxx..xxxxxxx 100644 } target_host->sg_tablesize = target->sg_tablesize; -@@ -3907,6 +4125,12 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3907,6 +4131,12 @@ static ssize_t srp_create_target(struct device *dev, if (!target->ch) goto out; @@ -540,7 +557,7 @@ index xxxxxxx..xxxxxxx 100644 node_idx = 0; for_each_online_node(node) { const int ch_start = (node_idx * target->ch_count / -@@ -3922,6 +4146,10 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3922,6 +4152,10 @@ static ssize_t srp_create_target(struct device *dev, for_each_online_cpu(cpu) { if (cpu_to_node(cpu) != node) continue; @@ -551,7 +568,7 @@ index xxxxxxx..xxxxxxx 100644 if (ch_start + cpu_idx >= ch_end) continue; ch = &target->ch[ch_start + cpu_idx]; -@@ -3961,6 +4189,9 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3961,6 +4195,9 @@ static ssize_t srp_create_target(struct device *dev, } else { srp_free_ch_ib(target, ch); srp_free_req_data(target, ch); @@ -561,7 +578,7 @@ index xxxxxxx..xxxxxxx 100644 target->ch_count = ch - target->ch; goto connected; } -@@ -3973,7 +4204,9 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3973,7 +4210,9 @@ static ssize_t srp_create_target(struct device *dev, } connected: @@ -571,7 +588,23 @@ index xxxxxxx..xxxxxxx 100644 ret = srp_add_target(host, target); if (ret) -@@ -4028,6 +4261,11 @@ free_ch: +@@ -4006,6 +4245,7 @@ out: + put: + scsi_host_put(target->scsi_host); + if (ret < 0) { ++#ifdef HAVE_KOBJ_NS_GRAB_CURRENT_EXPORTED + /* + * If a call to srp_remove_target() has not been scheduled, + * drop the network namespace reference now that was obtained +@@ -4013,6 +4253,7 @@ put: + */ + if (target->state != SRP_TARGET_REMOVED) + kobj_ns_drop(KOBJ_NS_TYPE_NET, target->net); ++#endif + scsi_host_put(target->scsi_host); + } + +@@ -4028,6 +4269,11 @@ free_ch: srp_free_req_data(target, ch); } @@ -583,7 +616,7 @@ index xxxxxxx..xxxxxxx 100644 kfree(target->ch); goto out; } -@@ -4276,11 +4514,19 @@ static int __init srp_init_module(void) +@@ -4276,11 +4522,19 @@ static int __init srp_init_module(void) indirect_sg_entries = cmd_sg_entries; } -- 2.41.0