Commit 81770f41 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'nfs-for-3.17-5' of git://git.linux-nfs.org/projects/trondmy/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
parents b29f83aa cd9288ff
...@@ -482,6 +482,16 @@ int nfs40_walk_client_list(struct nfs_client *new, ...@@ -482,6 +482,16 @@ int nfs40_walk_client_list(struct nfs_client *new,
spin_lock(&nn->nfs_client_lock); spin_lock(&nn->nfs_client_lock);
list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) { 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 /* If "pos" isn't marked ready, we can't trust the
* remaining fields in "pos" */ * remaining fields in "pos" */
if (pos->cl_cons_state > NFS_CS_READY) { if (pos->cl_cons_state > NFS_CS_READY) {
...@@ -501,15 +511,6 @@ int nfs40_walk_client_list(struct nfs_client *new, ...@@ -501,15 +511,6 @@ int nfs40_walk_client_list(struct nfs_client *new,
if (pos->cl_cons_state != NFS_CS_READY) if (pos->cl_cons_state != NFS_CS_READY)
continue; 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) if (pos->cl_clientid != new->cl_clientid)
continue; continue;
...@@ -622,6 +623,16 @@ int nfs41_walk_client_list(struct nfs_client *new, ...@@ -622,6 +623,16 @@ int nfs41_walk_client_list(struct nfs_client *new,
spin_lock(&nn->nfs_client_lock); spin_lock(&nn->nfs_client_lock);
list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) { 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 /* If "pos" isn't marked ready, we can't trust the
* remaining fields in "pos", especially the client * remaining fields in "pos", especially the client
* ID and serverowner fields. Wait for CREATE_SESSION * ID and serverowner fields. Wait for CREATE_SESSION
...@@ -647,15 +658,6 @@ int nfs41_walk_client_list(struct nfs_client *new, ...@@ -647,15 +658,6 @@ int nfs41_walk_client_list(struct nfs_client *new,
if (pos->cl_cons_state != NFS_CS_READY) if (pos->cl_cons_state != NFS_CS_READY)
continue; 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)) if (!nfs4_match_clientids(pos, new))
continue; continue;
......
...@@ -2226,9 +2226,13 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, ...@@ -2226,9 +2226,13 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
ret = _nfs4_proc_open(opendata); ret = _nfs4_proc_open(opendata);
if (ret != 0) { if (ret != 0) {
if (ret == -ENOENT) { if (ret == -ENOENT) {
d_drop(opendata->dentry); dentry = opendata->dentry;
d_add(opendata->dentry, NULL); if (dentry->d_inode)
nfs_set_verifier(opendata->dentry, d_delete(dentry);
else if (d_unhashed(dentry))
d_add(dentry, NULL);
nfs_set_verifier(dentry,
nfs_save_change_attribute(opendata->dir->d_inode)); nfs_save_change_attribute(opendata->dir->d_inode));
} }
goto out; goto out;
...@@ -2614,23 +2618,23 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data) ...@@ -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_rdwr = test_bit(NFS_O_RDWR_STATE, &state->flags);
is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags); is_rdonly = test_bit(NFS_O_RDONLY_STATE, &state->flags);
is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags); is_wronly = test_bit(NFS_O_WRONLY_STATE, &state->flags);
/* Calculate the current open share mode */ /* Calculate the change in open mode */
calldata->arg.fmode = 0; calldata->arg.fmode = 0;
if (is_rdonly || is_rdwr) if (state->n_rdwr == 0) {
if (state->n_rdonly == 0)
call_close |= is_rdonly;
else if (is_rdonly)
calldata->arg.fmode |= FMODE_READ; calldata->arg.fmode |= FMODE_READ;
if (is_wronly || is_rdwr) if (state->n_wronly == 0)
call_close |= is_wronly;
else if (is_wronly)
calldata->arg.fmode |= FMODE_WRITE; calldata->arg.fmode |= FMODE_WRITE;
/* Calculate the change in open mode */ } else if (is_rdwr)
if (state->n_rdwr == 0) { calldata->arg.fmode |= FMODE_READ|FMODE_WRITE;
if (state->n_rdonly == 0) {
call_close |= is_rdonly || is_rdwr; if (calldata->arg.fmode == 0)
calldata->arg.fmode &= ~FMODE_READ; call_close |= is_rdwr;
}
if (state->n_wronly == 0) {
call_close |= is_wronly || is_rdwr;
calldata->arg.fmode &= ~FMODE_WRITE;
}
}
if (!nfs4_valid_open_stateid(state)) if (!nfs4_valid_open_stateid(state))
call_close = 0; call_close = 0;
spin_unlock(&state->owner->so_lock); spin_unlock(&state->owner->so_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment