Merge r5839 from the iser branch

git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.0.x@6263 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2015-06-11 16:27:18 +00:00
parent c728d4e3af
commit bd520b5e23
5 changed files with 37 additions and 35 deletions

View File

@@ -61,7 +61,7 @@ static int isert_buf_alloc_pg(struct ib_device *ib_dev,
size_t page_len = min_t(size_t, size, PAGE_SIZE);
page = alloc_page(GFP_KERNEL);
if (!page) {
if (unlikely(!page)) {
pr_err("Failed to allocate page\n");
res = -ENOMEM;
goto out_map_failed;
@@ -116,7 +116,7 @@ static int isert_buf_malloc(struct ib_device *ib_dev,
}
isert_buf->addr = kmalloc(size, GFP_KERNEL);
if (!isert_buf->addr) {
if (unlikely(!isert_buf->addr)) {
pr_err("Failed to allocate data buffer\n");
res = -ENOMEM;
goto data_malloc_failed;

View File

@@ -45,7 +45,7 @@ int isert_datamover_init(void)
int err;
err = isert_global_init();
if (err) {
if (unlikely(err)) {
pr_err("iser datamover init failed, err:%d\n", err);
return err;
}
@@ -168,17 +168,18 @@ void isert_release_rx_pdu(struct iscsi_cmnd *iscsi_pdu)
int isert_login_rsp_tx(struct iscsi_cmnd *login_rsp, int last, int discovery)
{
struct isert_connection *isert_conn = (struct isert_connection *)login_rsp->conn;
int err;
if (last && !discovery) {
int err = isert_alloc_conn_resources(isert_conn);
if (err) {
err = isert_alloc_conn_resources(isert_conn);
if (unlikely(err)) {
pr_err("Failed to init conn resources\n");
return err;
}
isert_pdu_free(isert_conn->login_req_pdu);
isert_conn->login_req_pdu = NULL;
} else {
int err = isert_post_recv(isert_conn,
err = isert_post_recv(isert_conn,
&isert_conn->login_req_pdu->wr[0],
1);
if (unlikely(err)) {

View File

@@ -772,7 +772,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
TRACE_ENTRY();
isert_dev = kzalloc(sizeof(*isert_dev), GFP_KERNEL);
if (isert_dev == NULL) {
if (unlikely(isert_dev == NULL)) {
pr_err("Failed to allocate iser dev\n");
err = -ENOMEM;
goto out;
@@ -780,7 +780,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
dev_attr = &isert_dev->device_attr;
err = ib_query_device(ib_dev, dev_attr);
if (err) {
if (unlikely(err)) {
pr_err("Failed to query device, err: %d\n", err);
goto fail_query;
}
@@ -790,14 +790,14 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
isert_dev->cq_qps = kzalloc(sizeof(*isert_dev->cq_qps) * isert_dev->num_cqs,
GFP_KERNEL);
if (isert_dev->cq_qps == NULL) {
if (unlikely(isert_dev->cq_qps == NULL)) {
pr_err("Failed to allocate iser cq_qps\n");
err = -ENOMEM;
goto fail_cq_qps;
}
isert_dev->cq_desc = vmalloc(sizeof(*isert_dev->cq_desc) * isert_dev->num_cqs);
if (isert_dev->cq_desc == NULL) {
if (unlikely(isert_dev->cq_desc == NULL)) {
pr_err("Failed to allocate %ld bytes for iser cq_desc\n",
sizeof(*isert_dev->cq_desc) * isert_dev->num_cqs);
err = -ENOMEM;
@@ -805,14 +805,14 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
}
pd = ib_alloc_pd(ib_dev);
if (IS_ERR(pd)) {
if (unlikely(IS_ERR(pd))) {
err = PTR_ERR(pd);
pr_err("Failed to alloc iser dev pd, err:%d\n", err);
goto fail_pd;
}
mr = ib_get_dma_mr(pd, IB_ACCESS_LOCAL_WRITE);
if (IS_ERR(mr)) {
if (unlikely(IS_ERR(mr))) {
err = PTR_ERR(mr);
pr_err("Failed to get dma mr, err: %d\n", err);
goto fail_mr;
@@ -851,7 +851,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
WQ_MEM_RECLAIM, 1);
#endif
#endif
if (!cq_desc->cq_workqueue) {
if (unlikely(!cq_desc->cq_workqueue)) {
pr_err("Failed to alloc iser cq work queue for dev:%s\n",
ib_dev->name);
err = -ENOMEM;
@@ -864,7 +864,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
cq_desc, /* context */
cqe_num,
i); /* completion vector */
if (IS_ERR(cq)) {
if (unlikely(IS_ERR(cq))) {
cq_desc->cq = NULL;
err = PTR_ERR(cq);
pr_err("Failed to create iser dev cq, err:%d\n", err);
@@ -873,7 +873,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
cq_desc->cq = cq;
err = ib_req_notify_cq(cq, IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS);
if (err) {
if (unlikely(err)) {
pr_err("Failed to request notify cq, err: %d\n", err);
goto fail_cq;
}
@@ -940,17 +940,17 @@ static void isert_device_release(struct isert_device *isert_dev)
#endif
err = ib_destroy_cq(cq_desc->cq);
if (err)
if (unlikely(err))
pr_err("Failed to destroy cq, err:%d\n", err);
destroy_workqueue(cq_desc->cq_workqueue);
}
err = ib_dereg_mr(isert_dev->mr);
if (err)
if (unlikely(err))
pr_err("Failed to destroy mr, err:%d\n", err);
err = ib_dealloc_pd(isert_dev->pd);
if (err)
if (unlikely(err))
pr_err("Failed to destroy pd, err:%d\n", err);
vfree(isert_dev->cq_desc);
@@ -1069,7 +1069,7 @@ static struct isert_connection *isert_conn_create(struct rdma_cm_id *cm_id,
TRACE_ENTRY();
if (!try_module_get(THIS_MODULE)) {
if (unlikely(!try_module_get(THIS_MODULE))) {
err = -EINVAL;
goto fail_get;
}
@@ -1559,7 +1559,7 @@ struct isert_portal *isert_portal_create(void)
struct rdma_cm_id *cm_id;
int err;
if (!try_module_get(THIS_MODULE)) {
if (unlikely(!try_module_get(THIS_MODULE))) {
pr_err("Unable increment module reference\n");
portal = ERR_PTR(-EINVAL);
goto out;
@@ -1700,7 +1700,7 @@ struct isert_portal *isert_portal_start(struct sockaddr *sa, size_t addr_len)
int err;
portal = isert_portal_create();
if (IS_ERR(portal))
if (unlikely(IS_ERR(portal)))
return portal;
err = isert_portal_listen(portal, sa, addr_len);

View File

@@ -479,11 +479,12 @@ static int __init isert_init_module(void)
int ret;
ret = iscsit_reg_transport(&isert_transport);
if (ret)
return ret;
if (unlikely(ret))
goto out;
ret = isert_init_login_devs(isert_nr_devs);
out:
return ret;
}

View File

@@ -373,7 +373,7 @@ wait_for_connection:
conn_dev->idx);
++res; /* copy trailing \0 as well */
if (copy_to_user(buf, k_buff, res))
if (unlikely(copy_to_user(buf, k_buff, res)))
res = -EFAULT;
out:
@@ -394,13 +394,13 @@ static long isert_listen_ioctl(struct file *filp, unsigned int cmd,
switch (cmd) {
case SET_LISTEN_ADDR:
rc = copy_from_user(&dev->info, ptr, sizeof(dev->info));
if (rc != 0) {
if (unlikely(rc != 0)) {
PRINT_ERROR("Failed to copy %d user's bytes\n", rc);
res = -EFAULT;
goto out;
}
if (dev->free_portal_idx >= ISERT_MAX_PORTALS) {
if (unlikely(dev->free_portal_idx >= ISERT_MAX_PORTALS)) {
PRINT_ERROR("Maximum number of portals exceeded: %d\n",
ISERT_MAX_PORTALS);
res = -EINVAL;
@@ -693,7 +693,7 @@ static long isert_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
if (val) {
if (!dev->login_rsp) {
cmnd = isert_alloc_login_rsp_pdu(dev->conn);
if (!cmnd) {
if (unlikely(!cmnd)) {
res = -ENOMEM;
goto out;
}
@@ -706,7 +706,7 @@ static long isert_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
struct iscsi_login_rsp_hdr *rsp;
bool last;
if (!dev->login_rsp) {
if (unlikely(!dev->login_rsp)) {
res = -EINVAL;
goto out;
}
@@ -742,7 +742,7 @@ static long isert_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
goto out;
rc = copy_to_user(ptr, &addr, sizeof(addr));
if (rc)
if (unlikely(rc != 0))
res = -EFAULT;
}
break;
@@ -804,7 +804,7 @@ int isert_login_req_rx(struct iscsi_cmnd *login_req)
switch (dev->state) {
case CS_INIT:
case CS_RSP_FINISHED:
if (dev->login_req != NULL) {
if (unlikely(dev->login_req != NULL)) {
sBUG();
res = -EINVAL;
goto out;
@@ -891,7 +891,7 @@ static void __init isert_setup_cdev(struct isert_conn_dev *dev,
dev->state = CS_INIT;
err = cdev_add(&dev->cdev, dev->devno, 1);
/* Fail gracefully if need be */
if (err)
if (unlikely(err))
PRINT_ERROR("Error %d adding "ISER_CONN_DEV_PREFIX"%d", err,
index);
@@ -919,7 +919,7 @@ static void __init isert_setup_listener_cdev(struct isert_listener_dev *dev)
atomic_set(&dev->available, 1);
err = cdev_add(&dev->cdev, dev->devno, 1);
/* Fail gracefully if need be */
if (err)
if (unlikely(err))
PRINT_ERROR("Error %d adding isert_scst", err);
dev->dev = device_create(isert_class, NULL, dev->devno, NULL,
@@ -941,7 +941,7 @@ int __init isert_init_login_devs(unsigned int ndevs)
"isert_scst");
isert_major = MAJOR(devno);
if (res < 0) {
if (unlikely(res < 0)) {
PRINT_ERROR("isert: can't get major %d\n", isert_major);
goto out;
}
@@ -952,7 +952,7 @@ int __init isert_init_login_devs(unsigned int ndevs)
*/
isert_conn_devices = kzalloc(n_devs * sizeof(struct isert_conn_dev),
GFP_KERNEL);
if (!isert_conn_devices) {
if (unlikely(!isert_conn_devices)) {
res = -ENOMEM;
goto fail; /* Make this more graceful */
}
@@ -966,7 +966,7 @@ int __init isert_init_login_devs(unsigned int ndevs)
isert_setup_cdev(&isert_conn_devices[i], i);
res = isert_datamover_init();
if (res) {
if (unlikely(res)) {
PRINT_ERROR("Unable to initialize datamover: %d\n", res);
goto fail;
}