Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 192459
b: refs/heads/master
c: 5d7220e
h: refs/heads/master
i:
  192457: b6954d5
  192455: 0448056
v: v3
  • Loading branch information
Tetsuo Handa authored and Roland Dreier committed Apr 21, 2010
1 parent 09bf625 commit 15215f5
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 66 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bc1db9af731a74c7eca04df5936214c800774113
refs/heads/master: 5d7220e8dc24feed4bbd66667b7696906a147ac4
70 changes: 25 additions & 45 deletions trunk/drivers/infiniband/core/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ static DEFINE_IDR(sdp_ps);
static DEFINE_IDR(tcp_ps);
static DEFINE_IDR(udp_ps);
static DEFINE_IDR(ipoib_ps);
static int next_port;

struct cma_device {
struct list_head list;
Expand Down Expand Up @@ -1970,47 +1969,33 @@ static int cma_alloc_port(struct idr *ps, struct rdma_id_private *id_priv,

static int cma_alloc_any_port(struct idr *ps, struct rdma_id_private *id_priv)
{
struct rdma_bind_list *bind_list;
int port, ret, low, high;

bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL);
if (!bind_list)
return -ENOMEM;

retry:
/* FIXME: add proper port randomization per like inet_csk_get_port */
do {
ret = idr_get_new_above(ps, bind_list, next_port, &port);
} while ((ret == -EAGAIN) && idr_pre_get(ps, GFP_KERNEL));

if (ret)
goto err1;
static unsigned int last_used_port;
int low, high, remaining;
unsigned int rover;

inet_get_local_port_range(&low, &high);
if (port > high) {
if (next_port != low) {
idr_remove(ps, port);
next_port = low;
goto retry;
}
ret = -EADDRNOTAVAIL;
goto err2;
remaining = (high - low) + 1;
rover = net_random() % remaining + low;
retry:
if (last_used_port != rover &&
!idr_find(ps, (unsigned short) rover)) {
int ret = cma_alloc_port(ps, id_priv, rover);
/*
* Remember previously used port number in order to avoid
* re-using same port immediately after it is closed.
*/
if (!ret)
last_used_port = rover;
if (ret != -EADDRNOTAVAIL)
return ret;
}

if (port == high)
next_port = low;
else
next_port = port + 1;

bind_list->ps = ps;
bind_list->port = (unsigned short) port;
cma_bind_port(bind_list, id_priv);
return 0;
err2:
idr_remove(ps, port);
err1:
kfree(bind_list);
return ret;
if (--remaining) {
rover++;
if ((rover < low) || (rover > high))
rover = low;
goto retry;
}
return -EADDRNOTAVAIL;
}

static int cma_use_port(struct idr *ps, struct rdma_id_private *id_priv)
Expand Down Expand Up @@ -2995,12 +2980,7 @@ static void cma_remove_one(struct ib_device *device)

static int __init cma_init(void)
{
int ret, low, high, remaining;

get_random_bytes(&next_port, sizeof next_port);
inet_get_local_port_range(&low, &high);
remaining = (high - low) + 1;
next_port = ((unsigned int) next_port % remaining) + low;
int ret;

cma_wq = create_singlethread_workqueue("rdma_cm");
if (!cma_wq)
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/infiniband/core/ucm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp)
file->filp = filp;
file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev);

return nonseekable_open(inode, filp);
return 0;
}

static int ib_ucm_close(struct inode *inode, struct file *filp)
Expand Down Expand Up @@ -1229,7 +1229,6 @@ static const struct file_operations ucm_fops = {
.release = ib_ucm_close,
.write = ib_ucm_write,
.poll = ib_ucm_poll,
.llseek = no_llseek,
};

static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
Expand Down
4 changes: 1 addition & 3 deletions trunk/drivers/infiniband/core/ucma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,8 +1220,7 @@ static int ucma_open(struct inode *inode, struct file *filp)

filp->private_data = file;
file->filp = filp;

return nonseekable_open(inode, filp);
return 0;
}

static int ucma_close(struct inode *inode, struct file *filp)
Expand Down Expand Up @@ -1251,7 +1250,6 @@ static const struct file_operations ucma_fops = {
.release = ucma_close,
.write = ucma_write,
.poll = ucma_poll,
.llseek = no_llseek,
};

static struct miscdevice ucma_misc = {
Expand Down
12 changes: 4 additions & 8 deletions trunk/drivers/infiniband/core/user_mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
{
struct ib_umad_port *port;
struct ib_umad_file *file;
int ret;
int ret = 0;

port = container_of(inode->i_cdev, struct ib_umad_port, cdev);
if (port)
Expand Down Expand Up @@ -814,8 +814,6 @@ static int ib_umad_open(struct inode *inode, struct file *filp)

list_add_tail(&file->port_list, &port->file_list);

ret = nonseekable_open(inode, filp);

out:
mutex_unlock(&port->file_mutex);
return ret;
Expand Down Expand Up @@ -868,8 +866,7 @@ static const struct file_operations umad_fops = {
.compat_ioctl = ib_umad_compat_ioctl,
#endif
.open = ib_umad_open,
.release = ib_umad_close,
.llseek = no_llseek,
.release = ib_umad_close
};

static int ib_umad_sm_open(struct inode *inode, struct file *filp)
Expand Down Expand Up @@ -906,7 +903,7 @@ static int ib_umad_sm_open(struct inode *inode, struct file *filp)

filp->private_data = port;

return nonseekable_open(inode, filp);
return 0;

fail:
kref_put(&port->umad_dev->ref, ib_umad_release_dev);
Expand Down Expand Up @@ -936,8 +933,7 @@ static int ib_umad_sm_close(struct inode *inode, struct file *filp)
static const struct file_operations umad_sm_fops = {
.owner = THIS_MODULE,
.open = ib_umad_sm_open,
.release = ib_umad_sm_close,
.llseek = no_llseek,
.release = ib_umad_sm_close
};

static struct ib_client umad_client = {
Expand Down
11 changes: 4 additions & 7 deletions trunk/drivers/infiniband/core/uverbs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ static const struct file_operations uverbs_event_fops = {
.read = ib_uverbs_event_read,
.poll = ib_uverbs_event_poll,
.release = ib_uverbs_event_close,
.fasync = ib_uverbs_event_fasync,
.llseek = no_llseek,
.fasync = ib_uverbs_event_fasync
};

void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
Expand Down Expand Up @@ -624,7 +623,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)

filp->private_data = file;

return nonseekable_open(inode, filp);
return 0;

err_module:
module_put(dev->ib_dev->owner);
Expand Down Expand Up @@ -652,17 +651,15 @@ static const struct file_operations uverbs_fops = {
.owner = THIS_MODULE,
.write = ib_uverbs_write,
.open = ib_uverbs_open,
.release = ib_uverbs_close,
.llseek = no_llseek,
.release = ib_uverbs_close
};

static const struct file_operations uverbs_mmap_fops = {
.owner = THIS_MODULE,
.write = ib_uverbs_write,
.mmap = ib_uverbs_mmap,
.open = ib_uverbs_open,
.release = ib_uverbs_close,
.llseek = no_llseek,
.release = ib_uverbs_close
};

static struct ib_client uverbs_client = {
Expand Down

0 comments on commit 15215f5

Please sign in to comment.