aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorJ.Bruce Fields <bfields@fieldses.org>2006-12-13 03:35:27 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-13 12:05:54 -0500
commitca3643171bc6e08b7c4d1f9a2ce659541a01a7fe (patch)
tree2128accc9584e7dd69f6b62c62ef6631f5da231f /fs/nfsd/nfs4state.c
parent01f3bd1f03599470e4695392b6ae055ed8506978 (diff)
[PATCH] knfsd: nfsd4: pass saved and current fh together into nfsd4 operations
Pass the saved and current filehandles together into all the nfsd4 compound operations. I want a unified interface to these operations so we can just call them by pointer and throw out the huge switch statement. Also I'll eventually want a structure like this--that holds the state used during compound processing--for deferral. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c68
1 files changed, 41 insertions, 27 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 393624340d13..f0a994e3b2c5 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2241,24 +2241,26 @@ check_replay:
2241} 2241}
2242 2242
2243__be32 2243__be32
2244nfsd4_open_confirm(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_confirm *oc, struct nfs4_stateowner **replay_owner) 2244nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2245 struct nfsd4_open_confirm *oc,
2246 struct nfs4_stateowner **replay_owner)
2245{ 2247{
2246 __be32 status; 2248 __be32 status;
2247 struct nfs4_stateowner *sop; 2249 struct nfs4_stateowner *sop;
2248 struct nfs4_stateid *stp; 2250 struct nfs4_stateid *stp;
2249 2251
2250 dprintk("NFSD: nfsd4_open_confirm on file %.*s\n", 2252 dprintk("NFSD: nfsd4_open_confirm on file %.*s\n",
2251 (int)current_fh->fh_dentry->d_name.len, 2253 (int)cstate->current_fh.fh_dentry->d_name.len,
2252 current_fh->fh_dentry->d_name.name); 2254 cstate->current_fh.fh_dentry->d_name.name);
2253 2255
2254 status = fh_verify(rqstp, current_fh, S_IFREG, 0); 2256 status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0);
2255 if (status) 2257 if (status)
2256 return status; 2258 return status;
2257 2259
2258 nfs4_lock_state(); 2260 nfs4_lock_state();
2259 2261
2260 if ((status = nfs4_preprocess_seqid_op(current_fh, oc->oc_seqid, 2262 if ((status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2261 &oc->oc_req_stateid, 2263 oc->oc_seqid, &oc->oc_req_stateid,
2262 CHECK_FH | CONFIRM | OPEN_STATE, 2264 CHECK_FH | CONFIRM | OPEN_STATE,
2263 &oc->oc_stateowner, &stp, NULL))) 2265 &oc->oc_stateowner, &stp, NULL)))
2264 goto out; 2266 goto out;
@@ -2310,22 +2312,26 @@ reset_union_bmap_deny(unsigned long deny, unsigned long *bmap)
2310} 2312}
2311 2313
2312__be32 2314__be32
2313nfsd4_open_downgrade(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open_downgrade *od, struct nfs4_stateowner **replay_owner) 2315nfsd4_open_downgrade(struct svc_rqst *rqstp,
2316 struct nfsd4_compound_state *cstate,
2317 struct nfsd4_open_downgrade *od,
2318 struct nfs4_stateowner **replay_owner)
2314{ 2319{
2315 __be32 status; 2320 __be32 status;
2316 struct nfs4_stateid *stp; 2321 struct nfs4_stateid *stp;
2317 unsigned int share_access; 2322 unsigned int share_access;
2318 2323
2319 dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n", 2324 dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n",
2320 (int)current_fh->fh_dentry->d_name.len, 2325 (int)cstate->current_fh.fh_dentry->d_name.len,
2321 current_fh->fh_dentry->d_name.name); 2326 cstate->current_fh.fh_dentry->d_name.name);
2322 2327
2323 if (!access_valid(od->od_share_access) 2328 if (!access_valid(od->od_share_access)
2324 || !deny_valid(od->od_share_deny)) 2329 || !deny_valid(od->od_share_deny))
2325 return nfserr_inval; 2330 return nfserr_inval;
2326 2331
2327 nfs4_lock_state(); 2332 nfs4_lock_state();
2328 if ((status = nfs4_preprocess_seqid_op(current_fh, od->od_seqid, 2333 if ((status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2334 od->od_seqid,
2329 &od->od_stateid, 2335 &od->od_stateid,
2330 CHECK_FH | OPEN_STATE, 2336 CHECK_FH | OPEN_STATE,
2331 &od->od_stateowner, &stp, NULL))) 2337 &od->od_stateowner, &stp, NULL)))
@@ -2365,18 +2371,20 @@ out:
2365 * nfs4_unlock_state() called after encode 2371 * nfs4_unlock_state() called after encode
2366 */ 2372 */
2367__be32 2373__be32
2368nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_close *close, struct nfs4_stateowner **replay_owner) 2374nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2375 struct nfsd4_close *close, struct nfs4_stateowner **replay_owner)
2369{ 2376{
2370 __be32 status; 2377 __be32 status;
2371 struct nfs4_stateid *stp; 2378 struct nfs4_stateid *stp;
2372 2379
2373 dprintk("NFSD: nfsd4_close on file %.*s\n", 2380 dprintk("NFSD: nfsd4_close on file %.*s\n",
2374 (int)current_fh->fh_dentry->d_name.len, 2381 (int)cstate->current_fh.fh_dentry->d_name.len,
2375 current_fh->fh_dentry->d_name.name); 2382 cstate->current_fh.fh_dentry->d_name.name);
2376 2383
2377 nfs4_lock_state(); 2384 nfs4_lock_state();
2378 /* check close_lru for replay */ 2385 /* check close_lru for replay */
2379 if ((status = nfs4_preprocess_seqid_op(current_fh, close->cl_seqid, 2386 if ((status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2387 close->cl_seqid,
2380 &close->cl_stateid, 2388 &close->cl_stateid,
2381 CHECK_FH | OPEN_STATE | CLOSE_STATE, 2389 CHECK_FH | OPEN_STATE | CLOSE_STATE,
2382 &close->cl_stateowner, &stp, NULL))) 2390 &close->cl_stateowner, &stp, NULL)))
@@ -2404,15 +2412,17 @@ out:
2404} 2412}
2405 2413
2406__be32 2414__be32
2407nfsd4_delegreturn(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_delegreturn *dr) 2415nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2416 struct nfsd4_delegreturn *dr)
2408{ 2417{
2409 __be32 status; 2418 __be32 status;
2410 2419
2411 if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0))) 2420 if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0)))
2412 goto out; 2421 goto out;
2413 2422
2414 nfs4_lock_state(); 2423 nfs4_lock_state();
2415 status = nfs4_preprocess_stateid_op(current_fh, &dr->dr_stateid, DELEG_RET, NULL); 2424 status = nfs4_preprocess_stateid_op(&cstate->current_fh,
2425 &dr->dr_stateid, DELEG_RET, NULL);
2416 nfs4_unlock_state(); 2426 nfs4_unlock_state();
2417out: 2427out:
2418 return status; 2428 return status;
@@ -2635,7 +2645,8 @@ check_lock_length(u64 offset, u64 length)
2635 * LOCK operation 2645 * LOCK operation
2636 */ 2646 */
2637__be32 2647__be32
2638nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock *lock, struct nfs4_stateowner **replay_owner) 2648nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2649 struct nfsd4_lock *lock, struct nfs4_stateowner **replay_owner)
2639{ 2650{
2640 struct nfs4_stateowner *open_sop = NULL; 2651 struct nfs4_stateowner *open_sop = NULL;
2641 struct nfs4_stateowner *lock_sop = NULL; 2652 struct nfs4_stateowner *lock_sop = NULL;
@@ -2654,7 +2665,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2654 if (check_lock_length(lock->lk_offset, lock->lk_length)) 2665 if (check_lock_length(lock->lk_offset, lock->lk_length))
2655 return nfserr_inval; 2666 return nfserr_inval;
2656 2667
2657 if ((status = fh_verify(rqstp, current_fh, S_IFREG, MAY_LOCK))) { 2668 if ((status = fh_verify(rqstp, &cstate->current_fh,
2669 S_IFREG, MAY_LOCK))) {
2658 dprintk("NFSD: nfsd4_lock: permission denied!\n"); 2670 dprintk("NFSD: nfsd4_lock: permission denied!\n");
2659 return status; 2671 return status;
2660 } 2672 }
@@ -2675,7 +2687,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2675 goto out; 2687 goto out;
2676 2688
2677 /* validate and update open stateid and open seqid */ 2689 /* validate and update open stateid and open seqid */
2678 status = nfs4_preprocess_seqid_op(current_fh, 2690 status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2679 lock->lk_new_open_seqid, 2691 lock->lk_new_open_seqid,
2680 &lock->lk_new_open_stateid, 2692 &lock->lk_new_open_stateid,
2681 CHECK_FH | OPEN_STATE, 2693 CHECK_FH | OPEN_STATE,
@@ -2702,7 +2714,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2702 goto out; 2714 goto out;
2703 } else { 2715 } else {
2704 /* lock (lock owner + lock stateid) already exists */ 2716 /* lock (lock owner + lock stateid) already exists */
2705 status = nfs4_preprocess_seqid_op(current_fh, 2717 status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2706 lock->lk_old_lock_seqid, 2718 lock->lk_old_lock_seqid,
2707 &lock->lk_old_lock_stateid, 2719 &lock->lk_old_lock_stateid,
2708 CHECK_FH | LOCK_STATE, 2720 CHECK_FH | LOCK_STATE,
@@ -2794,7 +2806,8 @@ out:
2794 * LOCKT operation 2806 * LOCKT operation
2795 */ 2807 */
2796__be32 2808__be32
2797nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lockt *lockt) 2809nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2810 struct nfsd4_lockt *lockt)
2798{ 2811{
2799 struct inode *inode; 2812 struct inode *inode;
2800 struct file file; 2813 struct file file;
@@ -2815,14 +2828,14 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2815 if (STALE_CLIENTID(&lockt->lt_clientid)) 2828 if (STALE_CLIENTID(&lockt->lt_clientid))
2816 goto out; 2829 goto out;
2817 2830
2818 if ((status = fh_verify(rqstp, current_fh, S_IFREG, 0))) { 2831 if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) {
2819 dprintk("NFSD: nfsd4_lockt: fh_verify() failed!\n"); 2832 dprintk("NFSD: nfsd4_lockt: fh_verify() failed!\n");
2820 if (status == nfserr_symlink) 2833 if (status == nfserr_symlink)
2821 status = nfserr_inval; 2834 status = nfserr_inval;
2822 goto out; 2835 goto out;
2823 } 2836 }
2824 2837
2825 inode = current_fh->fh_dentry->d_inode; 2838 inode = cstate->current_fh.fh_dentry->d_inode;
2826 locks_init_lock(&file_lock); 2839 locks_init_lock(&file_lock);
2827 switch (lockt->lt_type) { 2840 switch (lockt->lt_type) {
2828 case NFS4_READ_LT: 2841 case NFS4_READ_LT:
@@ -2861,7 +2874,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2861 * only the dentry:inode set. 2874 * only the dentry:inode set.
2862 */ 2875 */
2863 memset(&file, 0, sizeof (struct file)); 2876 memset(&file, 0, sizeof (struct file));
2864 file.f_path.dentry = current_fh->fh_dentry; 2877 file.f_path.dentry = cstate->current_fh.fh_dentry;
2865 2878
2866 status = nfs_ok; 2879 status = nfs_ok;
2867 if (posix_test_lock(&file, &file_lock, &conflock)) { 2880 if (posix_test_lock(&file, &file_lock, &conflock)) {
@@ -2874,7 +2887,8 @@ out:
2874} 2887}
2875 2888
2876__be32 2889__be32
2877nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_locku *locku, struct nfs4_stateowner **replay_owner) 2890nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2891 struct nfsd4_locku *locku, struct nfs4_stateowner **replay_owner)
2878{ 2892{
2879 struct nfs4_stateid *stp; 2893 struct nfs4_stateid *stp;
2880 struct file *filp = NULL; 2894 struct file *filp = NULL;
@@ -2891,7 +2905,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
2891 2905
2892 nfs4_lock_state(); 2906 nfs4_lock_state();
2893 2907
2894 if ((status = nfs4_preprocess_seqid_op(current_fh, 2908 if ((status = nfs4_preprocess_seqid_op(&cstate->current_fh,
2895 locku->lu_seqid, 2909 locku->lu_seqid,
2896 &locku->lu_stateid, 2910 &locku->lu_stateid,
2897 CHECK_FH | LOCK_STATE, 2911 CHECK_FH | LOCK_STATE,