Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 331640
b: refs/heads/master
c: 1f7ba33
h: refs/heads/master
v: v3
  • Loading branch information
Alex Elder committed Oct 1, 2012
1 parent afe8ab0 commit 8e651be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 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: cc4829e5967de577794b25dfcd1a65e509d171ed
refs/heads/master: 1f7ba3311530993801d6877889efff0382bcd641
29 changes: 16 additions & 13 deletions trunk/drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,19 +322,28 @@ static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts,
}

/*
* Find a ceph client with specific addr and configuration.
* Find a ceph client with specific addr and configuration. If
* found, bump its reference count.
*/
static struct rbd_client *__rbd_client_find(struct ceph_options *ceph_opts)
static struct rbd_client *rbd_client_find(struct ceph_options *ceph_opts)
{
struct rbd_client *client_node;
bool found = false;

if (ceph_opts->flags & CEPH_OPT_NOSHARE)
return NULL;

list_for_each_entry(client_node, &rbd_client_list, node)
if (!ceph_compare_options(ceph_opts, client_node->client))
return client_node;
return NULL;
spin_lock(&rbd_client_list_lock);
list_for_each_entry(client_node, &rbd_client_list, node) {
if (!ceph_compare_options(ceph_opts, client_node->client)) {
kref_get(&client_node->kref);
found = true;
break;
}
}
spin_unlock(&rbd_client_list_lock);

return found ? client_node : NULL;
}

/*
Expand Down Expand Up @@ -416,22 +425,16 @@ static struct rbd_client *rbd_get_client(const char *mon_addr,
return ERR_CAST(ceph_opts);
}

spin_lock(&rbd_client_list_lock);
rbdc = __rbd_client_find(ceph_opts);
rbdc = rbd_client_find(ceph_opts);
if (rbdc) {
/* using an existing client */
kref_get(&rbdc->kref);
spin_unlock(&rbd_client_list_lock);

ceph_destroy_options(ceph_opts);
kfree(rbd_opts);

return rbdc;
}
spin_unlock(&rbd_client_list_lock);

rbdc = rbd_client_create(ceph_opts, rbd_opts);

if (IS_ERR(rbdc))
kfree(rbd_opts);

Expand Down

0 comments on commit 8e651be

Please sign in to comment.