diff --git a/iscsi-scst/kernel/isert-scst/TODO b/iscsi-scst/kernel/isert-scst/TODO index e1708f820..9f2663f36 100644 --- a/iscsi-scst/kernel/isert-scst/TODO +++ b/iscsi-scst/kernel/isert-scst/TODO @@ -1,8 +1,7 @@ -* Add suppport for immediate data in iSER -* Add suppport for data-out in iSER +* Add support for immediate data in iSER +* Add support for data-out in iSER * Look into separating between RX pdu and TX pdu * Do not signal every "response sent" notification * Make the code NUMA aware * Add support for AHS * Add support for bidi commands - diff --git a/iscsi-scst/kernel/isert-scst/iser.h b/iscsi-scst/kernel/isert-scst/iser.h index 6a08153ec..1cb920547 100644 --- a/iscsi-scst/kernel/isert-scst/iser.h +++ b/iscsi-scst/kernel/isert-scst/iser.h @@ -173,7 +173,6 @@ struct isert_conn { spinlock_t post_recv_lock; - spinlock_t tx_lock ____cacheline_aligned; /* Following two protected by tx_lock */ diff --git a/iscsi-scst/kernel/isert-scst/iser_datamover.c b/iscsi-scst/kernel/isert-scst/iser_datamover.c index d8241c027..1441a49fc 100644 --- a/iscsi-scst/kernel/isert-scst/iser_datamover.c +++ b/iscsi-scst/kernel/isert-scst/iser_datamover.c @@ -193,9 +193,7 @@ int isert_login_rsp_tx(struct iscsi_cmnd *login_rsp, int last, int discovery) isert_pdu_free(isert_conn->login_req_pdu); isert_conn->login_req_pdu = NULL; } else { - err = isert_post_recv(isert_conn, - &isert_conn->login_req_pdu->wr[0], - 1); + err = isert_post_recv(isert_conn, &isert_conn->login_req_pdu->wr[0], 1); if (unlikely(err)) { PRINT_ERROR("Failed to post recv login req rx buf, err:%d", err); diff --git a/iscsi-scst/kernel/isert-scst/iser_global.c b/iscsi-scst/kernel/isert-scst/iser_global.c index c070a66fa..7f7ec72bc 100644 --- a/iscsi-scst/kernel/isert-scst/iser_global.c +++ b/iscsi-scst/kernel/isert-scst/iser_global.c @@ -144,16 +144,14 @@ int isert_global_init(void) return -ENOMEM; } - isert_cmnd_cache = KMEM_CACHE_USERCOPY(isert_cmnd, - SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN, - iscsi); + isert_cmnd_cache = KMEM_CACHE_USERCOPY(isert_cmnd, SCST_SLAB_FLAGS | SLAB_HWCACHE_ALIGN, + iscsi); if (!isert_cmnd_cache) { PRINT_ERROR("Failed to alloc iser command cache"); goto free_wq; } - isert_conn_cache = KMEM_CACHE(isert_conn, - SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN); + isert_conn_cache = KMEM_CACHE(isert_conn, SCST_SLAB_FLAGS | SLAB_HWCACHE_ALIGN); if (!isert_conn_cache) { PRINT_ERROR("Failed to alloc iser connection cache"); goto free_cmnd_cache; diff --git a/iscsi-scst/kernel/isert-scst/iser_pdu.c b/iscsi-scst/kernel/isert-scst/iser_pdu.c index b4b5b5eea..2d54a0626 100644 --- a/iscsi-scst/kernel/isert-scst/iser_pdu.c +++ b/iscsi-scst/kernel/isert-scst/iser_pdu.c @@ -43,23 +43,21 @@ #include "iser_datamover.h" static inline int isert_pdu_rx_buf_init(struct isert_cmnd *isert_pdu, - struct isert_conn *isert_conn) + struct isert_conn *isert_conn) { struct isert_buf *isert_buf = &isert_pdu->buf; - return isert_wr_init(&isert_pdu->wr[0], ISER_WR_RECV, isert_buf, - isert_conn, isert_pdu, isert_pdu->sg_pool, - 0, isert_buf->sg_cnt, 0); + return isert_wr_init(&isert_pdu->wr[0], ISER_WR_RECV, isert_buf, isert_conn, isert_pdu, + isert_pdu->sg_pool, 0, isert_buf->sg_cnt, 0); } static inline int isert_pdu_tx_buf_init(struct isert_cmnd *isert_pdu, - struct isert_conn *isert_conn) + struct isert_conn *isert_conn) { struct isert_buf *isert_buf = &isert_pdu->buf; - return isert_wr_init(&isert_pdu->wr[0], ISER_WR_SEND, isert_buf, - isert_conn, isert_pdu, isert_pdu->sg_pool, - 0, isert_buf->sg_cnt, 0); + return isert_wr_init(&isert_pdu->wr[0], ISER_WR_SEND, isert_buf, isert_conn, isert_pdu, + isert_pdu->sg_pool, 0, isert_buf->sg_cnt, 0); } static inline void isert_pdu_set_hdr_plain(struct isert_cmnd *isert_pdu) @@ -139,11 +137,9 @@ void isert_tx_pdu_convert_from_iscsi(struct isert_cmnd *isert_cmnd, #endif TRACE_EXIT(); - return; } -static inline int isert_pdu_prepare_send(struct isert_conn *isert_conn, - struct isert_cmnd *tx_pdu) +static inline int isert_pdu_prepare_send(struct isert_conn *isert_conn, struct isert_cmnd *tx_pdu) { struct isert_device *isert_dev = isert_conn->isert_dev; struct ib_sge *sge = tx_pdu->wr[0].sge_list; @@ -176,14 +172,14 @@ static int isert_alloc_for_rdma(struct isert_cmnd *pdu, int sge_cnt, int wr_cnt; sg_pool = kmalloc_array(sge_cnt, sizeof(*sg_pool), GFP_KERNEL); - if (unlikely(sg_pool == NULL)) { + if (unlikely(!sg_pool)) { ret = -ENOMEM; goto out; } wr_cnt = DIV_ROUND_UP(sge_cnt, isert_conn->max_sge); wr = kmalloc_array(wr_cnt, sizeof(*wr), GFP_KERNEL); - if (unlikely(wr == NULL)) { + if (unlikely(!wr)) { ret = -ENOMEM; goto out_free_sg_pool; } @@ -465,7 +461,7 @@ int isert_alloc_conn_resources(struct isert_conn *isert_conn) goto clean_pdus; } - if (unlikely(first_pdu == NULL)) + if (unlikely(!first_pdu)) first_pdu = pdu; else isert_link_recv_pdu_wrs(prev_pdu, pdu); @@ -529,7 +525,7 @@ int isert_rx_pdu_done(struct isert_cmnd *pdu) if (++isert_conn->to_post_recv > isert_conn->repost_threshold) { err = isert_post_recv(isert_conn, isert_conn->post_recv_first, - isert_conn->to_post_recv); + isert_conn->to_post_recv); isert_conn->to_post_recv = 0; } spin_unlock(&isert_conn->post_recv_lock); @@ -650,4 +646,3 @@ int isert_pdu_post_rdma_read(struct isert_conn *isert_conn, TRACE_EXIT_RES(err); return err; } - diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index 08a7bbeaa..a096d6f14 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -63,7 +63,7 @@ static int isert_num_recv_posted_on_err(struct ib_recv_wr *first_ib_wr, struct ib_recv_wr *wr; int num_posted = 0; - for (wr = first_ib_wr; wr != NULL && wr != bad_wr; wr = wr->next) + for (wr = first_ib_wr; wr && wr != bad_wr; wr = wr->next) num_posted++; return num_posted; @@ -106,7 +106,7 @@ static int isert_num_send_posted_on_err(struct ib_send_wr *first_ib_wr, struct ib_send_wr *wr; int num_posted = 0; - for (wr = first_ib_wr; wr != NULL && wr != bad_wr; wr = wr->next) + for (wr = first_ib_wr; wr && wr != bad_wr; wr = wr->next) num_posted++; return num_posted; @@ -429,7 +429,6 @@ static void isert_send_completion_handler(struct isert_wr *wr) struct isert_cmnd *isert_req_pdu = container_of(iscsi_req_pdu, struct isert_cmnd, iscsi); - TRACE_ENTRY(); if (iscsi_req_pdu && iscsi_req_pdu->bufflen && @@ -764,7 +763,6 @@ static void isert_cq_comp_work_cb(struct work_struct *work) out: TRACE_EXIT(); - return; } static void isert_cq_comp_handler(struct ib_cq *cq, void *context) @@ -909,7 +907,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev) TRACE_ENTRY(); isert_dev = kzalloc(sizeof(*isert_dev), GFP_KERNEL); - if (unlikely(isert_dev == NULL)) { + if (unlikely(!isert_dev)) { PRINT_ERROR("Failed to allocate iser dev"); err = -ENOMEM; goto out; @@ -931,7 +929,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev) isert_dev->cq_qps = kcalloc(isert_dev->num_cqs, sizeof(*isert_dev->cq_qps), GFP_KERNEL); - if (unlikely(isert_dev->cq_qps == NULL)) { + if (unlikely(!isert_dev->cq_qps)) { PRINT_ERROR("Failed to allocate %d iser cq_qps", isert_dev->num_cqs); err = -ENOMEM; @@ -939,7 +937,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev) } isert_dev->cq_desc = vmalloc_array(isert_dev->num_cqs, sizeof(*isert_dev->cq_desc)); - if (unlikely(isert_dev->cq_desc == NULL)) { + if (unlikely(!isert_dev->cq_desc)) { PRINT_ERROR("Failed to allocate %zd bytes for iser cq_desc", sizeof(*isert_dev->cq_desc) * isert_dev->num_cqs); err = -ENOMEM; @@ -1196,7 +1194,7 @@ isert_init_conn(struct isert_conn *isert_conn) } static struct isert_conn *isert_conn_create(struct rdma_cm_id *cm_id, - struct isert_device *isert_dev) + struct isert_device *isert_dev) { struct isert_conn *isert_conn; int err; @@ -1333,7 +1331,6 @@ static void isert_release_kref(struct kref *kref) isert_portal_free(isert_conn->portal); mutex_unlock(&dev_list_mutex); - if (atomic_read(&isert_conn->dev_removed)) { atomic_set(&isert_conn->dev_removed, 0); wake_up_interruptible(&isert_conn->rem_wait); @@ -1572,7 +1569,7 @@ static void isert_portal_reinit_id_work(struct work_struct *w) portal->cm_id = isert_setup_id(portal); if (IS_ERR(portal->cm_id)) { PRINT_ERROR("Failed to create rdma id, err:%ld\n", - PTR_ERR(portal->cm_id)); + PTR_ERR(portal->cm_id)); portal->cm_id = NULL; } } @@ -1725,11 +1722,9 @@ isert_setup_id(struct isert_portal *portal) sa = (struct sockaddr *)&portal->addr; #if !RDMA_CREATE_ID_TAKES_NET_ARG - id = rdma_create_id(isert_cm_evt_handler, portal, RDMA_PS_TCP, - IB_QPT_RC); + id = rdma_create_id(isert_cm_evt_handler, portal, RDMA_PS_TCP, IB_QPT_RC); #else - id = rdma_create_id(iscsi_net_ns, isert_cm_evt_handler, portal, - RDMA_PS_TCP, IB_QPT_RC); + id = rdma_create_id(iscsi_net_ns, isert_cm_evt_handler, portal, RDMA_PS_TCP, IB_QPT_RC); #endif if (IS_ERR(id)) { ret = PTR_ERR(id); diff --git a/iscsi-scst/kernel/isert-scst/isert.c b/iscsi-scst/kernel/isert-scst/isert.c index 56c136d72..8c2686247 100644 --- a/iscsi-scst/kernel/isert-scst/isert.c +++ b/iscsi-scst/kernel/isert-scst/isert.c @@ -54,7 +54,7 @@ unsigned long isert_trace_flag = ISERT_DEFAULT_LOG_FLAGS; #endif static unsigned int isert_nr_devs = ISERT_NR_DEVS; -module_param(isert_nr_devs, uint, S_IRUGO); +module_param(isert_nr_devs, uint, 0444); MODULE_PARM_DESC(isert_nr_devs, "Maximum concurrent number of connection requests to handle (up to 999)."); @@ -206,10 +206,10 @@ static void isert_cmnd_free(struct iscsi_cmnd *cmnd) struct iscsi_scsi_cmd_hdr *req = cmnd_hdr(cmnd); PRINT_CRIT_ERROR("cmnd %p still on some list?, %x, %x, %x, %x, %x, %x, %x", - cmnd, req->opcode, req->scb[0], - req->flags, req->itt, be32_to_cpu(req->data_length), - req->cmd_sn, - be32_to_cpu((__force __be32)(cmnd->pdu.datasize))); + cmnd, req->opcode, req->scb[0], + req->flags, req->itt, be32_to_cpu(req->data_length), + req->cmd_sn, + be32_to_cpu((__force __be32)(cmnd->pdu.datasize))); if (unlikely(cmnd->parent_req)) { struct iscsi_scsi_cmd_hdr *preq = @@ -233,8 +233,7 @@ static void isert_preprocessing_done(struct iscsi_cmnd *req) req->scst_state = ISCSI_CMD_STATE_AFTER_PREPROC; } -static void isert_set_sense_data(struct iscsi_cmnd *rsp, - const u8 *sense_buf, int sense_len) +static void isert_set_sense_data(struct iscsi_cmnd *rsp, const u8 *sense_buf, int sense_len) { u8 *buf; @@ -432,18 +431,15 @@ static ssize_t isert_get_initiator_ip(struct iscsi_conn *conn, switch (ss.ss_family) { case AF_INET: - pos = scnprintf(buf, size, - "%pI4", &((struct sockaddr_in *)&ss)->sin_addr.s_addr); + pos = scnprintf(buf, size, "%pI4", &((struct sockaddr_in *)&ss)->sin_addr.s_addr); break; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) case AF_INET6: - pos = scnprintf(buf, size, "[%pI6]", - &((struct sockaddr_in6 *)&ss)->sin6_addr); + pos = scnprintf(buf, size, "[%pI6]", &((struct sockaddr_in6 *)&ss)->sin6_addr); break; #endif default: - pos = scnprintf(buf, size, "Unknown family %d", - ss.ss_family); + pos = scnprintf(buf, size, "Unknown family %d", ss.ss_family); break; } @@ -505,7 +501,6 @@ MODULE_LICENSE("Dual BSD/GPL"); MODULE_IMPORT_NS(SCST); #define DRV_VERSION "3.9.0-pre" "#" __stringify(OFED_FLAVOR) #define DRV_RELDATE "15 January 2024" -MODULE_DESCRIPTION("iSER target transport driver " - "v" DRV_VERSION " (" DRV_RELDATE ")"); +MODULE_DESCRIPTION("iSER target transport driver v" DRV_VERSION " (" DRV_RELDATE ")"); module_init(isert_init_module); module_exit(isert_cleanup_module); diff --git a/iscsi-scst/kernel/isert-scst/isert_login.c b/iscsi-scst/kernel/isert-scst/isert_login.c index 6516217e2..859f6a06d 100644 --- a/iscsi-scst/kernel/isert-scst/isert_login.c +++ b/iscsi-scst/kernel/isert-scst/isert_login.c @@ -212,7 +212,7 @@ int isert_conn_alloc(struct iscsi_session *session, cmnd = dev->login_rsp; - sBUG_ON(cmnd == NULL); + sBUG_ON(!cmnd); dev->login_rsp = NULL; *new_conn = dev->conn; @@ -340,8 +340,7 @@ static ssize_t isert_listen_read(struct file *filp, char __user *buf, wait_for_connection: if (filp->f_flags & O_NONBLOCK) return -EAGAIN; - res = wait_event_freezable(dev->waitqueue, - !have_new_connection(dev)); + res = wait_event_freezable(dev->waitqueue, !have_new_connection(dev)); if (res < 0) goto out; } @@ -358,7 +357,7 @@ wait_for_connection: mutex_unlock(&dev->conn_lock); to_write = min_t(size_t, sizeof(k_buff), count); - res = scnprintf(k_buff, to_write, "/dev/"ISER_CONN_DEV_PREFIX"%d", + res = scnprintf(k_buff, to_write, "/dev/" ISER_CONN_DEV_PREFIX "%d", conn_dev->idx); ++res; /* copy trailing \0 as well */ @@ -494,7 +493,7 @@ static bool will_read_block(struct isert_conn_dev *dev) bool res = true; spin_lock(&dev->pdu_lock); - if (dev->login_req != NULL) { + if (dev->login_req) { switch (dev->state) { case CS_REQ_BHS: case CS_REQ_DATA: @@ -596,8 +595,7 @@ static ssize_t isert_read(struct file *filp, char __user *buf, size_t count, mutex_unlock(&conn_mgmt_mutex); return -EAGAIN; } - ret = wait_event_freezable(dev->waitqueue, - !will_read_block(dev)); + ret = wait_event_freezable(dev->waitqueue, !will_read_block(dev)); if (ret < 0) { mutex_unlock(&conn_mgmt_mutex); return ret; @@ -767,9 +765,7 @@ static long isert_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) spin_lock(&dev->pdu_lock); dev->login_req = NULL; spin_unlock(&dev->pdu_lock); - res = isert_login_rsp_tx(dev->login_rsp, - last, - dev->is_discovery); + res = isert_login_rsp_tx(dev->login_rsp, last, dev->is_discovery); vunmap(dev->sg_virt); dev->sg_virt = NULL; dev->login_rsp = NULL; @@ -781,9 +777,8 @@ static long isert_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct isert_addr_info addr; - res = isert_get_target_addr(dev->conn, - (struct sockaddr *)&addr.addr, - &addr.addr_len); + res = isert_get_target_addr(dev->conn, (struct sockaddr *)&addr.addr, + &addr.addr_len); if (unlikely(res)) goto out; @@ -850,7 +845,7 @@ int isert_login_req_rx(struct iscsi_cmnd *login_req) switch (dev->state) { case CS_INIT: case CS_RSP_FINISHED: - if (unlikely(dev->login_req != NULL)) + if (unlikely(dev->login_req)) sBUG(); break; @@ -870,7 +865,6 @@ int isert_login_req_rx(struct iscsi_cmnd *login_req) sBUG(); } - spin_lock(&dev->pdu_lock); dev->login_req = login_req; dev->read_len = sizeof(login_req->pdu.bhs); @@ -937,12 +931,12 @@ static void __init isert_setup_cdev(struct isert_conn_dev *dev, err = cdev_add(&dev->cdev, dev->devno, 1); /* Fail gracefully if need be */ if (unlikely(err)) - PRINT_ERROR("Error %d adding "ISER_CONN_DEV_PREFIX"%d", err, + PRINT_ERROR("Error %d adding " ISER_CONN_DEV_PREFIX "%d", err, index); dev->dev = device_create(isert_class, NULL, dev->devno, NULL, - ISER_CONN_DEV_PREFIX"%d", index); + ISER_CONN_DEV_PREFIX "%d", index); TRACE_EXIT(); } @@ -984,8 +978,7 @@ int __init isert_init_login_devs(unsigned int ndevs) n_devs = ndevs; - res = alloc_chrdev_region(&devno, 0, n_devs, - "isert_scst"); + res = alloc_chrdev_region(&devno, 0, n_devs, "isert_scst"); isert_major = MAJOR(devno); if (unlikely(res < 0)) {