aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f82bde005a8..60d5f4c26dd 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -838,7 +838,8 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
838 p->o_arg.open_flags = flags; 838 p->o_arg.open_flags = flags;
839 p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE); 839 p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);
840 p->o_arg.clientid = server->nfs_client->cl_clientid; 840 p->o_arg.clientid = server->nfs_client->cl_clientid;
841 p->o_arg.id = sp->so_seqid.owner_id; 841 p->o_arg.id.create_time = ktime_to_ns(sp->so_seqid.create_time);
842 p->o_arg.id.uniquifier = sp->so_seqid.owner_id;
842 p->o_arg.name = &dentry->d_name; 843 p->o_arg.name = &dentry->d_name;
843 p->o_arg.server = server; 844 p->o_arg.server = server;
844 p->o_arg.bitmask = server->attr_bitmask; 845 p->o_arg.bitmask = server->attr_bitmask;
@@ -1466,8 +1467,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
1466 goto unlock_no_action; 1467 goto unlock_no_action;
1467 rcu_read_unlock(); 1468 rcu_read_unlock();
1468 } 1469 }
1469 /* Update sequence id. */ 1470 /* Update client id. */
1470 data->o_arg.id = sp->so_seqid.owner_id;
1471 data->o_arg.clientid = sp->so_server->nfs_client->cl_clientid; 1471 data->o_arg.clientid = sp->so_server->nfs_client->cl_clientid;
1472 if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) { 1472 if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) {
1473 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR]; 1473 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR];
@@ -1954,10 +1954,19 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
1954 }; 1954 };
1955 int err; 1955 int err;
1956 do { 1956 do {
1957 err = nfs4_handle_exception(server, 1957 err = _nfs4_do_setattr(inode, cred, fattr, sattr, state);
1958 _nfs4_do_setattr(inode, cred, fattr, sattr, state), 1958 switch (err) {
1959 &exception); 1959 case -NFS4ERR_OPENMODE:
1960 if (state && !(state->state & FMODE_WRITE)) {
1961 err = -EBADF;
1962 if (sattr->ia_valid & ATTR_OPEN)
1963 err = -EACCES;
1964 goto out;
1965 }
1966 }
1967 err = nfs4_handle_exception(server, err, &exception);
1960 } while (exception.retry); 1968 } while (exception.retry);
1969out:
1961 return err; 1970 return err;
1962} 1971}
1963 1972
@@ -4558,7 +4567,9 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
4558static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request) 4567static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request)
4559{ 4568{
4560 struct nfs_server *server = NFS_SERVER(state->inode); 4569 struct nfs_server *server = NFS_SERVER(state->inode);
4561 struct nfs4_exception exception = { }; 4570 struct nfs4_exception exception = {
4571 .inode = state->inode,
4572 };
4562 int err; 4573 int err;
4563 4574
4564 do { 4575 do {
@@ -4576,7 +4587,9 @@ static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request
4576static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request) 4587static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request)
4577{ 4588{
4578 struct nfs_server *server = NFS_SERVER(state->inode); 4589 struct nfs_server *server = NFS_SERVER(state->inode);
4579 struct nfs4_exception exception = { }; 4590 struct nfs4_exception exception = {
4591 .inode = state->inode,
4592 };
4580 int err; 4593 int err;
4581 4594
4582 err = nfs4_set_lock_state(state, request); 4595 err = nfs4_set_lock_state(state, request);
@@ -4676,6 +4689,7 @@ static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *
4676{ 4689{
4677 struct nfs4_exception exception = { 4690 struct nfs4_exception exception = {
4678 .state = state, 4691 .state = state,
4692 .inode = state->inode,
4679 }; 4693 };
4680 int err; 4694 int err;
4681 4695
@@ -4721,6 +4735,20 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
4721 4735
4722 if (state == NULL) 4736 if (state == NULL)
4723 return -ENOLCK; 4737 return -ENOLCK;
4738 /*
4739 * Don't rely on the VFS having checked the file open mode,
4740 * since it won't do this for flock() locks.
4741 */
4742 switch (request->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) {
4743 case F_RDLCK:
4744 if (!(filp->f_mode & FMODE_READ))
4745 return -EBADF;
4746 break;
4747 case F_WRLCK:
4748 if (!(filp->f_mode & FMODE_WRITE))
4749 return -EBADF;
4750 }
4751
4724 do { 4752 do {
4725 status = nfs4_proc_setlk(state, cmd, request); 4753 status = nfs4_proc_setlk(state, cmd, request);
4726 if ((status != -EAGAIN) || IS_SETLK(cmd)) 4754 if ((status != -EAGAIN) || IS_SETLK(cmd))