Skip to content

Commit

Permalink
Merge branch 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/n…
Browse files Browse the repository at this point in the history
…fs-2.6

* 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6:
  NFSv4: Fix a problem whereby a buggy server can oops the kernel
  NFSv4: Fix an NFSv4 mount regression
  NFSv4: Fix an Oops in nfs4_free_lock_state
  • Loading branch information
torvalds committed Jul 22, 2009
2 parents 0d517fb + d953126 commit 12e8ffe
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 28 deletions.
18 changes: 3 additions & 15 deletions fs/nfs/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1242,20 +1242,6 @@ static int nfs4_set_client(struct nfs_server *server,
return error;
}

/*
* Initialize a session.
* Note: save the mount rsize and wsize for create_server negotiation.
*/
static void nfs4_init_session(struct nfs_client *clp,
unsigned int wsize, unsigned int rsize)
{
#if defined(CONFIG_NFS_V4_1)
if (nfs4_has_session(clp)) {
clp->cl_session->fc_attrs.max_rqst_sz = wsize;
clp->cl_session->fc_attrs.max_resp_sz = rsize;
}
#endif /* CONFIG_NFS_V4_1 */
}

/*
* Session has been established, and the client marked ready.
Expand Down Expand Up @@ -1350,7 +1336,9 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
BUG_ON(!server->nfs_client->rpc_ops);
BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);

nfs4_init_session(server->nfs_client, server->wsize, server->rsize);
error = nfs4_init_session(server);
if (error < 0)
goto error;

/* Probe the root fh to retrieve its FSID */
error = nfs4_path_walk(server, mntfh, data->nfs_server.export_path);
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,12 +1025,12 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
res = NULL;
goto out;
/* This turned out not to be a regular file */
case -EISDIR:
case -ENOTDIR:
goto no_open;
case -ELOOP:
if (!(nd->intent.open.flags & O_NOFOLLOW))
goto no_open;
/* case -EISDIR: */
/* case -EINVAL: */
default:
goto out;
Expand Down
6 changes: 6 additions & 0 deletions fs/nfs/nfs4_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,19 @@ extern void nfs4_destroy_session(struct nfs4_session *session);
extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp);
extern int nfs4_proc_create_session(struct nfs_client *, int reset);
extern int nfs4_proc_destroy_session(struct nfs4_session *);
extern int nfs4_init_session(struct nfs_server *server);
#else /* CONFIG_NFS_v4_1 */
static inline int nfs4_setup_sequence(struct nfs_client *clp,
struct nfs4_sequence_args *args, struct nfs4_sequence_res *res,
int cache_reply, struct rpc_task *task)
{
return 0;
}

static inline int nfs4_init_session(struct nfs_server *server)
{
return 0;
}
#endif /* CONFIG_NFS_V4_1 */

extern struct nfs4_state_maintenance_ops *nfs4_state_renewal_ops[];
Expand Down
40 changes: 29 additions & 11 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2040,15 +2040,9 @@ static int _nfs4_lookup_root(struct nfs_server *server, struct nfs_fh *fhandle,
.rpc_argp = &args,
.rpc_resp = &res,
};
int status;

nfs_fattr_init(info->fattr);
status = nfs4_recover_expired_lease(server);
if (!status)
status = nfs4_check_client_ready(server->nfs_client);
if (!status)
status = nfs4_call_sync(server, &msg, &args, &res, 0);
return status;
return nfs4_call_sync(server, &msg, &args, &res, 0);
}

static int nfs4_lookup_root(struct nfs_server *server, struct nfs_fh *fhandle,
Expand Down Expand Up @@ -4099,15 +4093,23 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
if (request->fl_start < 0 || request->fl_end < 0)
return -EINVAL;

if (IS_GETLK(cmd))
return nfs4_proc_getlk(state, F_GETLK, request);
if (IS_GETLK(cmd)) {
if (state != NULL)
return nfs4_proc_getlk(state, F_GETLK, request);
return 0;
}

if (!(IS_SETLK(cmd) || IS_SETLKW(cmd)))
return -EINVAL;

if (request->fl_type == F_UNLCK)
return nfs4_proc_unlck(state, cmd, request);
if (request->fl_type == F_UNLCK) {
if (state != NULL)
return nfs4_proc_unlck(state, cmd, request);
return 0;
}

if (state == NULL)
return -ENOLCK;
do {
status = nfs4_proc_setlk(state, cmd, request);
if ((status != -EAGAIN) || IS_SETLK(cmd))
Expand Down Expand Up @@ -4793,6 +4795,22 @@ int nfs4_proc_destroy_session(struct nfs4_session *session)
return status;
}

int nfs4_init_session(struct nfs_server *server)
{
struct nfs_client *clp = server->nfs_client;
int ret;

if (!nfs4_has_session(clp))
return 0;

clp->cl_session->fc_attrs.max_rqst_sz = server->wsize;
clp->cl_session->fc_attrs.max_resp_sz = server->rsize;
ret = nfs4_recover_expired_lease(server);
if (!ret)
ret = nfs4_check_client_ready(clp);
return ret;
}

/*
* Renew the cl_session lease.
*/
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ static struct nfs4_lock_state *nfs4_alloc_lock_state(struct nfs4_state *state, f
INIT_LIST_HEAD(&lsp->ls_sequence.list);
lsp->ls_seqid.sequence = &lsp->ls_sequence;
atomic_set(&lsp->ls_count, 1);
lsp->ls_state = state;
lsp->ls_owner = fl_owner;
spin_lock(&clp->cl_lock);
nfs_alloc_unique_id(&clp->cl_lockowner_id, &lsp->ls_id, 1, 64);
Expand Down Expand Up @@ -587,7 +588,6 @@ static struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_
if (lsp != NULL)
break;
if (new != NULL) {
new->ls_state = state;
list_add(&new->ls_locks, &state->lock_states);
set_bit(LK_STATE_IN_USE, &state->flags);
lsp = new;
Expand Down

0 comments on commit 12e8ffe

Please sign in to comment.