Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 308651
b: refs/heads/master
c: f411703
h: refs/heads/master
i:
  308649: 1656418
  308647: b9bfe2d
v: v3
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed May 22, 2012
1 parent ded6ce2 commit 53388dc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 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: f092075dd33ea04000590e8ffea65c2e7d03d764
refs/heads/master: f411703adc762a92b72f8a93c6464050d66cb87b
67 changes: 37 additions & 30 deletions trunk/fs/nfs/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,35 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
return NULL;
}

/*
* Found an existing client. Make sure it's ready before returning.
*/
static struct nfs_client *
nfs_found_client(const struct nfs_client_initdata *cl_init,
struct nfs_client *clp)
{
int error;

error = wait_event_killable(nfs_client_active_wq,
clp->cl_cons_state < NFS_CS_INITING);
if (error < 0) {
nfs_put_client(clp);
return ERR_PTR(-ERESTARTSYS);
}

if (clp->cl_cons_state < NFS_CS_READY) {
error = clp->cl_cons_state;
nfs_put_client(clp);
return ERR_PTR(error);
}

BUG_ON(clp->cl_cons_state != NFS_CS_READY);

dprintk("<-- %s found nfs_client %p for %s\n",
__func__, clp, cl_init->hostname ?: "");
return clp;
}

/*
* Look up a client by IP address and protocol version
* - creates a new record if one doesn't yet exist
Expand All @@ -528,8 +557,12 @@ nfs_get_client(const struct nfs_client_initdata *cl_init,
spin_lock(&nn->nfs_client_lock);

clp = nfs_match_client(cl_init);
if (clp)
goto found_client;
if (clp) {
spin_unlock(&nn->nfs_client_lock);
if (new)
nfs_free_client(new);
return nfs_found_client(cl_init, clp);
}
if (new)
goto install_client;

Expand All @@ -538,7 +571,8 @@ nfs_get_client(const struct nfs_client_initdata *cl_init,
new = nfs_alloc_client(cl_init);
} while (!IS_ERR(new));

dprintk("--> nfs_get_client() = %ld [failed]\n", PTR_ERR(new));
dprintk("<-- nfs_get_client() Failed to find %s (%ld)\n",
cl_init->hostname ?: "", PTR_ERR(new));
return new;

/* install a new client and return with it unready */
Expand All @@ -555,33 +589,6 @@ nfs_get_client(const struct nfs_client_initdata *cl_init,
}
dprintk("--> nfs_get_client() = %p [new]\n", clp);
return clp;

/* found an existing client
* - make sure it's ready before returning
*/
found_client:
spin_unlock(&nn->nfs_client_lock);

if (new)
nfs_free_client(new);

error = wait_event_killable(nfs_client_active_wq,
clp->cl_cons_state < NFS_CS_INITING);
if (error < 0) {
nfs_put_client(clp);
return ERR_PTR(-ERESTARTSYS);
}

if (clp->cl_cons_state < NFS_CS_READY) {
error = clp->cl_cons_state;
nfs_put_client(clp);
return ERR_PTR(error);
}

BUG_ON(clp->cl_cons_state != NFS_CS_READY);

dprintk("--> nfs_get_client() = %p [share]\n", clp);
return clp;
}

/*
Expand Down

0 comments on commit 53388dc

Please sign in to comment.