diff options
author | Bryan Schumaker <bjschuma@netapp.com> | 2012-06-20 15:53:43 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-06-29 11:46:44 -0400 |
commit | 011e2a7fd5e9e0c2fdba6b9466d53fc437f8bfaf (patch) | |
tree | b88d11754a6ed0a4cea439dc43a39fb88a5b05a8 | |
parent | a5c58892b427a2752e3ec44b0aad4ce9221dc63b (diff) |
NFS: Create a have_delegation rpc_op
Delegations are a v4 feature, so push them out of the generic code.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/delegation.c | 2 | ||||
-rw-r--r-- | fs/nfs/delegation.h | 9 | ||||
-rw-r--r-- | fs/nfs/dir.c | 2 | ||||
-rw-r--r-- | fs/nfs/file.c | 6 | ||||
-rw-r--r-- | fs/nfs/inode.c | 2 | ||||
-rw-r--r-- | fs/nfs/nfs3proc.c | 6 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 5 | ||||
-rw-r--r-- | fs/nfs/proc.c | 6 | ||||
-rw-r--r-- | fs/nfs/write.c | 2 | ||||
-rw-r--r-- | include/linux/nfs_xdr.h | 1 |
10 files changed, 25 insertions, 16 deletions
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 9a7a1b488af9..36c7c647a1d0 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c | |||
@@ -47,7 +47,7 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation) | |||
47 | * | 47 | * |
48 | * Returns one if inode has the indicated delegation, otherwise zero. | 48 | * Returns one if inode has the indicated delegation, otherwise zero. |
49 | */ | 49 | */ |
50 | int nfs_have_delegation(struct inode *inode, fmode_t flags) | 50 | int nfs4_have_delegation(struct inode *inode, fmode_t flags) |
51 | { | 51 | { |
52 | struct nfs_delegation *delegation; | 52 | struct nfs_delegation *delegation; |
53 | int ret = 0; | 53 | int ret = 0; |
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 206db5679996..d134fc5fda70 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h | |||
@@ -56,14 +56,9 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl); | |||
56 | bool nfs4_copy_delegation_stateid(nfs4_stateid *dst, struct inode *inode, fmode_t flags); | 56 | bool nfs4_copy_delegation_stateid(nfs4_stateid *dst, struct inode *inode, fmode_t flags); |
57 | 57 | ||
58 | void nfs_mark_delegation_referenced(struct nfs_delegation *delegation); | 58 | void nfs_mark_delegation_referenced(struct nfs_delegation *delegation); |
59 | int nfs_have_delegation(struct inode *inode, fmode_t flags); | 59 | int nfs4_have_delegation(struct inode *inode, fmode_t flags); |
60 | 60 | ||
61 | #else | 61 | #else |
62 | static inline int nfs_have_delegation(struct inode *inode, fmode_t flags) | ||
63 | { | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | static inline int nfs_inode_return_delegation(struct inode *inode) | 62 | static inline int nfs_inode_return_delegation(struct inode *inode) |
68 | { | 63 | { |
69 | nfs_wb_all(inode); | 64 | nfs_wb_all(inode); |
@@ -73,7 +68,7 @@ static inline int nfs_inode_return_delegation(struct inode *inode) | |||
73 | 68 | ||
74 | static inline int nfs_have_delegated_attributes(struct inode *inode) | 69 | static inline int nfs_have_delegated_attributes(struct inode *inode) |
75 | { | 70 | { |
76 | return nfs_have_delegation(inode, FMODE_READ) && | 71 | return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ) && |
77 | !(NFS_I(inode)->cache_validity & NFS_INO_REVAL_FORCED); | 72 | !(NFS_I(inode)->cache_validity & NFS_INO_REVAL_FORCED); |
78 | } | 73 | } |
79 | 74 | ||
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index f430057ff3b3..4a3e23aea143 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -1144,7 +1144,7 @@ static int nfs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1144 | goto out_bad; | 1144 | goto out_bad; |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | if (nfs_have_delegation(inode, FMODE_READ)) | 1147 | if (NFS_PROTO(dir)->have_delegation(inode, FMODE_READ)) |
1148 | goto out_set_verifier; | 1148 | goto out_set_verifier; |
1149 | 1149 | ||
1150 | /* Force a full look up iff the parent directory has changed */ | 1150 | /* Force a full look up iff the parent directory has changed */ |
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 8941ac41c59b..57a22a1533e2 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -178,7 +178,7 @@ nfs_file_flush(struct file *file, fl_owner_t id) | |||
178 | * If we're holding a write delegation, then just start the i/o | 178 | * If we're holding a write delegation, then just start the i/o |
179 | * but don't wait for completion (or send a commit). | 179 | * but don't wait for completion (or send a commit). |
180 | */ | 180 | */ |
181 | if (nfs_have_delegation(inode, FMODE_WRITE)) | 181 | if (NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE)) |
182 | return filemap_fdatawrite(file->f_mapping); | 182 | return filemap_fdatawrite(file->f_mapping); |
183 | 183 | ||
184 | /* Flush writes to the server and return any errors */ | 184 | /* Flush writes to the server and return any errors */ |
@@ -677,7 +677,7 @@ do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local) | |||
677 | } | 677 | } |
678 | fl->fl_type = saved_type; | 678 | fl->fl_type = saved_type; |
679 | 679 | ||
680 | if (nfs_have_delegation(inode, FMODE_READ)) | 680 | if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) |
681 | goto out_noconflict; | 681 | goto out_noconflict; |
682 | 682 | ||
683 | if (is_local) | 683 | if (is_local) |
@@ -772,7 +772,7 @@ do_setlk(struct file *filp, int cmd, struct file_lock *fl, int is_local) | |||
772 | * This makes locking act as a cache coherency point. | 772 | * This makes locking act as a cache coherency point. |
773 | */ | 773 | */ |
774 | nfs_sync_mapping(filp->f_mapping); | 774 | nfs_sync_mapping(filp->f_mapping); |
775 | if (!nfs_have_delegation(inode, FMODE_READ)) { | 775 | if (!NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) { |
776 | if (is_time_granular(&NFS_SERVER(inode)->time_delta)) | 776 | if (is_time_granular(&NFS_SERVER(inode)->time_delta)) |
777 | __nfs_revalidate_inode(NFS_SERVER(inode), inode); | 777 | __nfs_revalidate_inode(NFS_SERVER(inode), inode); |
778 | else | 778 | else |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index f7296983eba6..0f0b928ef252 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -1457,7 +1457,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1457 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) | 1457 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) |
1458 | || S_ISLNK(inode->i_mode))) | 1458 | || S_ISLNK(inode->i_mode))) |
1459 | invalid &= ~NFS_INO_INVALID_DATA; | 1459 | invalid &= ~NFS_INO_INVALID_DATA; |
1460 | if (!nfs_have_delegation(inode, FMODE_READ) || | 1460 | if (!NFS_PROTO(inode)->have_delegation(inode, FMODE_READ) || |
1461 | (save_cache_validity & NFS_INO_REVAL_FORCED)) | 1461 | (save_cache_validity & NFS_INO_REVAL_FORCED)) |
1462 | nfsi->cache_validity |= invalid; | 1462 | nfsi->cache_validity |= invalid; |
1463 | 1463 | ||
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 2292a0fd2bff..08f832634ef9 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
@@ -877,6 +877,11 @@ nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl) | |||
877 | return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl); | 877 | return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl); |
878 | } | 878 | } |
879 | 879 | ||
880 | static int nfs3_have_delegation(struct inode *inode, fmode_t flags) | ||
881 | { | ||
882 | return 0; | ||
883 | } | ||
884 | |||
880 | const struct nfs_rpc_ops nfs_v3_clientops = { | 885 | const struct nfs_rpc_ops nfs_v3_clientops = { |
881 | .version = 3, /* protocol version */ | 886 | .version = 3, /* protocol version */ |
882 | .dentry_ops = &nfs_dentry_operations, | 887 | .dentry_ops = &nfs_dentry_operations, |
@@ -921,5 +926,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = { | |||
921 | .lock = nfs3_proc_lock, | 926 | .lock = nfs3_proc_lock, |
922 | .clear_acl_cache = nfs3_forget_cached_acls, | 927 | .clear_acl_cache = nfs3_forget_cached_acls, |
923 | .close_context = nfs_close_context, | 928 | .close_context = nfs_close_context, |
929 | .have_delegation = nfs3_have_delegation, | ||
924 | .init_client = nfs_init_client, | 930 | .init_client = nfs_init_client, |
925 | }; | 931 | }; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index e9a8ad2df7af..86f428bb5e07 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -294,7 +294,7 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struc | |||
294 | case 0: | 294 | case 0: |
295 | return 0; | 295 | return 0; |
296 | case -NFS4ERR_OPENMODE: | 296 | case -NFS4ERR_OPENMODE: |
297 | if (inode && nfs_have_delegation(inode, FMODE_READ)) { | 297 | if (inode && nfs4_have_delegation(inode, FMODE_READ)) { |
298 | nfs_inode_return_delegation(inode); | 298 | nfs_inode_return_delegation(inode); |
299 | exception->retry = 1; | 299 | exception->retry = 1; |
300 | return 0; | 300 | return 0; |
@@ -3466,7 +3466,7 @@ bool nfs4_write_need_cache_consistency_data(const struct nfs_write_data *data) | |||
3466 | /* Otherwise, request attributes if and only if we don't hold | 3466 | /* Otherwise, request attributes if and only if we don't hold |
3467 | * a delegation | 3467 | * a delegation |
3468 | */ | 3468 | */ |
3469 | return nfs_have_delegation(hdr->inode, FMODE_READ) == 0; | 3469 | return nfs4_have_delegation(hdr->inode, FMODE_READ) == 0; |
3470 | } | 3470 | } |
3471 | 3471 | ||
3472 | static void nfs4_proc_write_setup(struct nfs_write_data *data, struct rpc_message *msg) | 3472 | static void nfs4_proc_write_setup(struct nfs_write_data *data, struct rpc_message *msg) |
@@ -6804,6 +6804,7 @@ const struct nfs_rpc_ops nfs_v4_clientops = { | |||
6804 | .clear_acl_cache = nfs4_zap_acl_attr, | 6804 | .clear_acl_cache = nfs4_zap_acl_attr, |
6805 | .close_context = nfs4_close_context, | 6805 | .close_context = nfs4_close_context, |
6806 | .open_context = nfs4_atomic_open, | 6806 | .open_context = nfs4_atomic_open, |
6807 | .have_delegation = nfs4_have_delegation, | ||
6807 | .init_client = nfs4_init_client, | 6808 | .init_client = nfs4_init_client, |
6808 | }; | 6809 | }; |
6809 | 6810 | ||
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 617c7419a08e..4aed3ddf9bba 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c | |||
@@ -734,6 +734,11 @@ out_einval: | |||
734 | return -EINVAL; | 734 | return -EINVAL; |
735 | } | 735 | } |
736 | 736 | ||
737 | static int nfs_have_delegation(struct inode *inode, fmode_t flags) | ||
738 | { | ||
739 | return 0; | ||
740 | } | ||
741 | |||
737 | const struct nfs_rpc_ops nfs_v2_clientops = { | 742 | const struct nfs_rpc_ops nfs_v2_clientops = { |
738 | .version = 2, /* protocol version */ | 743 | .version = 2, /* protocol version */ |
739 | .dentry_ops = &nfs_dentry_operations, | 744 | .dentry_ops = &nfs_dentry_operations, |
@@ -777,5 +782,6 @@ const struct nfs_rpc_ops nfs_v2_clientops = { | |||
777 | .lock = nfs_proc_lock, | 782 | .lock = nfs_proc_lock, |
778 | .lock_check_bounds = nfs_lock_check_bounds, | 783 | .lock_check_bounds = nfs_lock_check_bounds, |
779 | .close_context = nfs_close_context, | 784 | .close_context = nfs_close_context, |
785 | .have_delegation = nfs_have_delegation, | ||
780 | .init_client = nfs_init_client, | 786 | .init_client = nfs_init_client, |
781 | }; | 787 | }; |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index ee929e5e1f7b..f163355b9618 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -410,7 +410,7 @@ static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req) | |||
410 | nfs_lock_request(req); | 410 | nfs_lock_request(req); |
411 | 411 | ||
412 | spin_lock(&inode->i_lock); | 412 | spin_lock(&inode->i_lock); |
413 | if (!nfsi->npages && nfs_have_delegation(inode, FMODE_WRITE)) | 413 | if (!nfsi->npages && NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE)) |
414 | inode->i_version++; | 414 | inode->i_version++; |
415 | set_bit(PG_MAPPED, &req->wb_flags); | 415 | set_bit(PG_MAPPED, &req->wb_flags); |
416 | SetPagePrivate(req->wb_page); | 416 | SetPagePrivate(req->wb_page); |
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 5c0014d1c969..8787f77c64b3 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h | |||
@@ -1422,6 +1422,7 @@ struct nfs_rpc_ops { | |||
1422 | struct nfs_open_context *ctx, | 1422 | struct nfs_open_context *ctx, |
1423 | int open_flags, | 1423 | int open_flags, |
1424 | struct iattr *iattr); | 1424 | struct iattr *iattr); |
1425 | int (*have_delegation)(struct inode *, fmode_t); | ||
1425 | struct nfs_client * | 1426 | struct nfs_client * |
1426 | (*init_client) (struct nfs_client *, const struct rpc_timeout *, | 1427 | (*init_client) (struct nfs_client *, const struct rpc_timeout *, |
1427 | const char *, rpc_authflavor_t); | 1428 | const char *, rpc_authflavor_t); |