aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2013-03-15 14:57:33 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-03-25 12:04:11 -0400
commit4a1c089345a0f00ad0229bf895bf0e94d101f059 (patch)
tree1cf2e01511c5b13e9d4b66ba7976b6f4bc40930f /fs/nfs/nfs4proc.c
parent3b66486c4c7136f8d4bbe1306d581fadc6bce4c7 (diff)
NFSv4: Clean up nfs4_opendata_alloc in preparation for NFSv4.1 open modes
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 625a729ebcca..7bbb06f280fc 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -782,6 +782,7 @@ static void nfs4_init_opendata_res(struct nfs4_opendata *p)
782static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry, 782static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
783 struct nfs4_state_owner *sp, fmode_t fmode, int flags, 783 struct nfs4_state_owner *sp, fmode_t fmode, int flags,
784 const struct iattr *attrs, 784 const struct iattr *attrs,
785 enum open_claim_type4 claim,
785 gfp_t gfp_mask) 786 gfp_t gfp_mask)
786{ 787{
787 struct dentry *parent = dget_parent(dentry); 788 struct dentry *parent = dget_parent(dentry);
@@ -800,7 +801,6 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
800 p->dir = parent; 801 p->dir = parent;
801 p->owner = sp; 802 p->owner = sp;
802 atomic_inc(&sp->so_count); 803 atomic_inc(&sp->so_count);
803 p->o_arg.fh = NFS_FH(dir);
804 p->o_arg.open_flags = flags; 804 p->o_arg.open_flags = flags;
805 p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE); 805 p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);
806 /* don't put an ACCESS op in OPEN compound if O_EXCL, because ACCESS 806 /* don't put an ACCESS op in OPEN compound if O_EXCL, because ACCESS
@@ -818,7 +818,19 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
818 p->o_arg.server = server; 818 p->o_arg.server = server;
819 p->o_arg.bitmask = server->attr_bitmask; 819 p->o_arg.bitmask = server->attr_bitmask;
820 p->o_arg.open_bitmap = &nfs4_fattr_bitmap[0]; 820 p->o_arg.open_bitmap = &nfs4_fattr_bitmap[0];
821 p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; 821 p->o_arg.claim = claim;
822 switch (claim) {
823 case NFS4_OPEN_CLAIM_NULL:
824 case NFS4_OPEN_CLAIM_DELEGATE_CUR:
825 case NFS4_OPEN_CLAIM_DELEGATE_PREV:
826 p->o_arg.fh = NFS_FH(dir);
827 break;
828 case NFS4_OPEN_CLAIM_PREVIOUS:
829 case NFS4_OPEN_CLAIM_FH:
830 case NFS4_OPEN_CLAIM_DELEG_CUR_FH:
831 case NFS4_OPEN_CLAIM_DELEG_PREV_FH:
832 p->o_arg.fh = NFS_FH(dentry->d_inode);
833 }
822 if (attrs != NULL && attrs->ia_valid != 0) { 834 if (attrs != NULL && attrs->ia_valid != 0) {
823 __be32 verf[2]; 835 __be32 verf[2];
824 836
@@ -1200,11 +1212,13 @@ static struct nfs_open_context *nfs4_state_find_open_context(struct nfs4_state *
1200 return ERR_PTR(-ENOENT); 1212 return ERR_PTR(-ENOENT);
1201} 1213}
1202 1214
1203static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context *ctx, struct nfs4_state *state) 1215static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context *ctx,
1216 struct nfs4_state *state, enum open_claim_type4 claim)
1204{ 1217{
1205 struct nfs4_opendata *opendata; 1218 struct nfs4_opendata *opendata;
1206 1219
1207 opendata = nfs4_opendata_alloc(ctx->dentry, state->owner, 0, 0, NULL, GFP_NOFS); 1220 opendata = nfs4_opendata_alloc(ctx->dentry, state->owner, 0, 0,
1221 NULL, claim, GFP_NOFS);
1208 if (opendata == NULL) 1222 if (opendata == NULL)
1209 return ERR_PTR(-ENOMEM); 1223 return ERR_PTR(-ENOMEM);
1210 opendata->state = state; 1224 opendata->state = state;
@@ -1290,11 +1304,10 @@ static int _nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state
1290 fmode_t delegation_type = 0; 1304 fmode_t delegation_type = 0;
1291 int status; 1305 int status;
1292 1306
1293 opendata = nfs4_open_recoverdata_alloc(ctx, state); 1307 opendata = nfs4_open_recoverdata_alloc(ctx, state,
1308 NFS4_OPEN_CLAIM_PREVIOUS);
1294 if (IS_ERR(opendata)) 1309 if (IS_ERR(opendata))
1295 return PTR_ERR(opendata); 1310 return PTR_ERR(opendata);
1296 opendata->o_arg.claim = NFS4_OPEN_CLAIM_PREVIOUS;
1297 opendata->o_arg.fh = NFS_FH(state->inode);
1298 rcu_read_lock(); 1311 rcu_read_lock();
1299 delegation = rcu_dereference(NFS_I(state->inode)->delegation); 1312 delegation = rcu_dereference(NFS_I(state->inode)->delegation);
1300 if (delegation != NULL && test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags) != 0) 1313 if (delegation != NULL && test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags) != 0)
@@ -1338,10 +1351,10 @@ static int _nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs
1338 struct nfs4_opendata *opendata; 1351 struct nfs4_opendata *opendata;
1339 int ret; 1352 int ret;
1340 1353
1341 opendata = nfs4_open_recoverdata_alloc(ctx, state); 1354 opendata = nfs4_open_recoverdata_alloc(ctx, state,
1355 NFS4_OPEN_CLAIM_DELEGATE_CUR);
1342 if (IS_ERR(opendata)) 1356 if (IS_ERR(opendata))
1343 return PTR_ERR(opendata); 1357 return PTR_ERR(opendata);
1344 opendata->o_arg.claim = NFS4_OPEN_CLAIM_DELEGATE_CUR;
1345 nfs4_stateid_copy(&opendata->o_arg.u.delegation, stateid); 1358 nfs4_stateid_copy(&opendata->o_arg.u.delegation, stateid);
1346 ret = nfs4_open_recover(opendata, state); 1359 ret = nfs4_open_recover(opendata, state);
1347 nfs4_opendata_put(opendata); 1360 nfs4_opendata_put(opendata);
@@ -1727,7 +1740,8 @@ static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *s
1727 struct nfs4_opendata *opendata; 1740 struct nfs4_opendata *opendata;
1728 int ret; 1741 int ret;
1729 1742
1730 opendata = nfs4_open_recoverdata_alloc(ctx, state); 1743 opendata = nfs4_open_recoverdata_alloc(ctx, state,
1744 NFS4_OPEN_CLAIM_NULL);
1731 if (IS_ERR(opendata)) 1745 if (IS_ERR(opendata))
1732 return PTR_ERR(opendata); 1746 return PTR_ERR(opendata);
1733 ret = nfs4_open_recover(opendata, state); 1747 ret = nfs4_open_recover(opendata, state);
@@ -1927,7 +1941,9 @@ static int _nfs4_do_open(struct inode *dir,
1927 if (dentry->d_inode != NULL) 1941 if (dentry->d_inode != NULL)
1928 nfs4_return_incompatible_delegation(dentry->d_inode, fmode); 1942 nfs4_return_incompatible_delegation(dentry->d_inode, fmode);
1929 status = -ENOMEM; 1943 status = -ENOMEM;
1930 opendata = nfs4_opendata_alloc(dentry, sp, fmode, flags, sattr, GFP_KERNEL); 1944 opendata = nfs4_opendata_alloc(dentry, sp, fmode, flags, sattr,
1945 NFS4_OPEN_CLAIM_NULL,
1946 GFP_KERNEL);
1931 if (opendata == NULL) 1947 if (opendata == NULL)
1932 goto err_put_state_owner; 1948 goto err_put_state_owner;
1933 1949