aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-03-08 17:16:12 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-03-08 22:37:12 -0500
commit0032a7a749a49b2c044092a1d0af5cfd0077f35d (patch)
treeb73ca09268f9b6f1c6b5c8bb9301b088a305830d /fs
parent2dc317565b6fd264929b41aaa9674431d75178ef (diff)
NFS: Don't copy read delegation stateids in setattr
The server will just return an NFS4ERR_OPENMODE anyway. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/delegation.c16
-rw-r--r--fs/nfs/delegation.h2
-rw-r--r--fs/nfs/nfs4proc.c2
3 files changed, 12 insertions, 8 deletions
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 97d53574bf53..e27c0972f94e 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -694,21 +694,25 @@ int nfs_delegations_present(struct nfs_client *clp)
694 * nfs4_copy_delegation_stateid - Copy inode's state ID information 694 * nfs4_copy_delegation_stateid - Copy inode's state ID information
695 * @dst: stateid data structure to fill in 695 * @dst: stateid data structure to fill in
696 * @inode: inode to check 696 * @inode: inode to check
697 * @flags: delegation type requirement
697 * 698 *
698 * Returns one and fills in "dst->data" * if inode had a delegation, 699 * Returns "true" and fills in "dst->data" * if inode had a delegation,
699 * otherwise zero is returned. 700 * otherwise "false" is returned.
700 */ 701 */
701int nfs4_copy_delegation_stateid(nfs4_stateid *dst, struct inode *inode) 702bool nfs4_copy_delegation_stateid(nfs4_stateid *dst, struct inode *inode,
703 fmode_t flags)
702{ 704{
703 struct nfs_inode *nfsi = NFS_I(inode); 705 struct nfs_inode *nfsi = NFS_I(inode);
704 struct nfs_delegation *delegation; 706 struct nfs_delegation *delegation;
705 int ret = 0; 707 bool ret;
706 708
709 flags &= FMODE_READ|FMODE_WRITE;
707 rcu_read_lock(); 710 rcu_read_lock();
708 delegation = rcu_dereference(nfsi->delegation); 711 delegation = rcu_dereference(nfsi->delegation);
709 if (delegation != NULL) { 712 ret = (delegation != NULL && (delegation->type & flags) == flags);
713 if (ret) {
710 nfs4_stateid_copy(dst, &delegation->stateid); 714 nfs4_stateid_copy(dst, &delegation->stateid);
711 ret = 1; 715 nfs_mark_delegation_referenced(delegation);
712 } 716 }
713 rcu_read_unlock(); 717 rcu_read_unlock();
714 return ret; 718 return ret;
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
index 691a79609184..e193012123e7 100644
--- a/fs/nfs/delegation.h
+++ b/fs/nfs/delegation.h
@@ -54,7 +54,7 @@ void nfs_delegation_reap_unclaimed(struct nfs_client *clp);
54int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync); 54int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync);
55int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid); 55int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid);
56int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl); 56int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl);
57int nfs4_copy_delegation_stateid(nfs4_stateid *dst, struct inode *inode); 57bool nfs4_copy_delegation_stateid(nfs4_stateid *dst, struct inode *inode, fmode_t flags);
58 58
59void nfs_mark_delegation_referenced(struct nfs_delegation *delegation); 59void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);
60int nfs_have_delegation(struct inode *inode, fmode_t flags); 60int nfs_have_delegation(struct inode *inode, fmode_t flags);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index a8dd04db764f..3578ad36a5b8 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1929,7 +1929,7 @@ static int _nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
1929 1929
1930 nfs_fattr_init(fattr); 1930 nfs_fattr_init(fattr);
1931 1931
1932 if (nfs4_copy_delegation_stateid(&arg.stateid, inode)) { 1932 if (nfs4_copy_delegation_stateid(&arg.stateid, inode, FMODE_WRITE)) {
1933 /* Use that stateid */ 1933 /* Use that stateid */
1934 } else if (state != NULL) { 1934 } else if (state != NULL) {
1935 nfs4_select_rw_stateid(&arg.stateid, state, current->files, current->tgid); 1935 nfs4_select_rw_stateid(&arg.stateid, state, current->files, current->tgid);