Skip to content

Commit

Permalink
Merge tag 'nfs-for-3.17-5' of git://git.linux-nfs.org/projects/trondm…
Browse files Browse the repository at this point in the history
…y/linux-nfs

Pull NFS client fixes from Trond Myklebust:
 "Highligts:
   - fix an Oops in nfs4_open_and_get_state
   - fix an Oops in the nfs4_state_manager
   - fix another bug in the close/open_downgrade code"

* tag 'nfs-for-3.17-5' of git://git.linux-nfs.org/projects/trondmy/linux-nfs:
  NFSv4: Fix another bug in the close/open_downgrade code
  NFSv4: nfs4_state_manager() vs. nfs_server_remove_lists()
  NFS: remove BUG possibility in nfs4_open_and_get_state
  • Loading branch information
Linus Torvalds committed Sep 19, 2014
2 parents b29f83a + cd9288f commit 81770f4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 36 deletions.
38 changes: 20 additions & 18 deletions fs/nfs/nfs4client.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,16 @@ int nfs40_walk_client_list(struct nfs_client *new,

spin_lock(&nn->nfs_client_lock);
list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) {

if (pos->rpc_ops != new->rpc_ops)
continue;

if (pos->cl_proto != new->cl_proto)
continue;

if (pos->cl_minorversion != new->cl_minorversion)
continue;

/* If "pos" isn't marked ready, we can't trust the
* remaining fields in "pos" */
if (pos->cl_cons_state > NFS_CS_READY) {
Expand All @@ -501,15 +511,6 @@ int nfs40_walk_client_list(struct nfs_client *new,
if (pos->cl_cons_state != NFS_CS_READY)
continue;

if (pos->rpc_ops != new->rpc_ops)
continue;

if (pos->cl_proto != new->cl_proto)
continue;

if (pos->cl_minorversion != new->cl_minorversion)
continue;

if (pos->cl_clientid != new->cl_clientid)
continue;

Expand Down Expand Up @@ -622,6 +623,16 @@ int nfs41_walk_client_list(struct nfs_client *new,

spin_lock(&nn->nfs_client_lock);
list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) {

if (pos->rpc_ops != new->rpc_ops)
continue;

if (pos->cl_proto != new->cl_proto)
continue;

if (pos->cl_minorversion != new->cl_minorversion)
continue;

/* If "pos" isn't marked ready, we can't trust the
* remaining fields in "pos", especially the client
* ID and serverowner fields. Wait for CREATE_SESSION
Expand All @@ -647,15 +658,6 @@ int nfs41_walk_client_list(struct nfs_client *new,
if (pos->cl_cons_state != NFS_CS_READY)
continue;

if (pos->rpc_ops != new->rpc_ops)
continue;

if (pos->cl_proto != new->cl_proto)
continue;

if (pos->cl_minorversion != new->cl_minorversion)
continue;

if (!nfs4_match_clientids(pos, new))
continue;

Expand Down
40 changes: 22 additions & 18 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2226,9 +2226,13 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
ret = _nfs4_proc_open(opendata);
if (ret != 0) {
if (ret == -ENOENT) {
d_drop(opendata->dentry);
d_add(opendata->dentry, NULL);
nfs_set_verifier(opendata->dentry,
dentry = opendata->dentry;
if (dentry->d_inode)
d_delete(dentry);
else if (d_unhashed(dentry))
d_add(dentry, NULL);

nfs_set_verifier(dentry,
nfs_save_change_attribute(opendata->dir->d_inode));
}
goto out;
Expand Down Expand Up @@ -2614,23 +2618,23 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
is_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags);
is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags);
is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags);
/* Calculate the current open share mode */
calldata->arg.fmode = 0;
if (is_rdonly || is_rdwr)
calldata->arg.fmode |= FMODE_READ;
if (is_wronly || is_rdwr)
calldata->arg.fmode |= FMODE_WRITE;
/* Calculate the change in open mode */
calldata->arg.fmode = 0;
if (state->n_rdwr == 0) {
if (state->n_rdonly == 0) {
call_close |= is_rdonly || is_rdwr;
calldata->arg.fmode &= ~FMODE_READ;
}
if (state->n_wronly == 0) {
call_close |= is_wronly || is_rdwr;
calldata->arg.fmode &= ~FMODE_WRITE;
}
}
if (state->n_rdonly == 0)
call_close |= is_rdonly;
else if (is_rdonly)
calldata->arg.fmode |= FMODE_READ;
if (state->n_wronly == 0)
call_close |= is_wronly;
else if (is_wronly)
calldata->arg.fmode |= FMODE_WRITE;
} else if (is_rdwr)
calldata->arg.fmode |= FMODE_READ|FMODE_WRITE;

if (calldata->arg.fmode == 0)
call_close |= is_rdwr;

if (!nfs4_valid_open_stateid(state))
call_close = 0;
spin_unlock(&state->owner->so_lock);
Expand Down

0 comments on commit 81770f4

Please sign in to comment.