diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2013-08-09 12:48:44 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2013-09-03 15:26:33 -0400 |
commit | 9d33059c1b76d77004753799479af6d359d83217 (patch) | |
tree | 884157e2098dbeb4f57c6caa830e18b6c06ed11c | |
parent | 220e09ccd36ab7836a6aa19295c314d7e04f7552 (diff) |
NFS: Enable slot table helpers for NFSv4.0
I'd like to re-use NFSv4.1's slot table machinery for NFSv4.0
transport blocking. Re-organize some of nfs4session.c so the slot
table code is built even when NFS_V4_1 is disabled.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/Makefile | 6 | ||||
-rw-r--r-- | fs/nfs/nfs4session.c | 29 | ||||
-rw-r--r-- | fs/nfs/nfs4session.h | 28 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 9 |
4 files changed, 37 insertions, 35 deletions
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile index 7238c4b4c70c..03192a66c143 100644 --- a/fs/nfs/Makefile +++ b/fs/nfs/Makefile | |||
@@ -23,11 +23,11 @@ obj-$(CONFIG_NFS_V4) += nfsv4.o | |||
23 | CFLAGS_nfs4trace.o += -I$(src) | 23 | CFLAGS_nfs4trace.o += -I$(src) |
24 | nfsv4-y := nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o nfs4super.o nfs4file.o \ | 24 | nfsv4-y := nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o nfs4super.o nfs4file.o \ |
25 | delegation.o idmap.o callback.o callback_xdr.o callback_proc.o \ | 25 | delegation.o idmap.o callback.o callback_xdr.o callback_proc.o \ |
26 | nfs4namespace.o nfs4getroot.o nfs4client.o dns_resolve.o \ | 26 | nfs4namespace.o nfs4getroot.o nfs4client.o nfs4session.o \ |
27 | nfs4trace.o | 27 | dns_resolve.o nfs4trace.o |
28 | nfsv4-$(CONFIG_NFS_USE_LEGACY_DNS) += cache_lib.o | 28 | nfsv4-$(CONFIG_NFS_USE_LEGACY_DNS) += cache_lib.o |
29 | nfsv4-$(CONFIG_SYSCTL) += nfs4sysctl.o | 29 | nfsv4-$(CONFIG_SYSCTL) += nfs4sysctl.o |
30 | nfsv4-$(CONFIG_NFS_V4_1) += nfs4session.o pnfs.o pnfs_dev.o | 30 | nfsv4-$(CONFIG_NFS_V4_1) += pnfs.o pnfs_dev.o |
31 | 31 | ||
32 | obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o | 32 | obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o |
33 | nfs_layout_nfsv41_files-y := nfs4filelayout.o nfs4filelayoutdev.o | 33 | nfs_layout_nfsv41_files-y := nfs4filelayout.o nfs4filelayoutdev.o |
diff --git a/fs/nfs/nfs4session.c b/fs/nfs/nfs4session.c index 0161ad26ee84..746675b74624 100644 --- a/fs/nfs/nfs4session.c +++ b/fs/nfs/nfs4session.c | |||
@@ -44,6 +44,17 @@ static void nfs4_shrink_slot_table(struct nfs4_slot_table *tbl, u32 newsize) | |||
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
47 | /** | ||
48 | * nfs4_slot_tbl_drain_complete - wake waiters when drain is complete | ||
49 | * @tbl - controlling slot table | ||
50 | * | ||
51 | */ | ||
52 | void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl) | ||
53 | { | ||
54 | if (nfs4_slot_tbl_draining(tbl)) | ||
55 | complete(&tbl->complete); | ||
56 | } | ||
57 | |||
47 | /* | 58 | /* |
48 | * nfs4_free_slot - free a slot and efficiently update slot table. | 59 | * nfs4_free_slot - free a slot and efficiently update slot table. |
49 | * | 60 | * |
@@ -212,13 +223,6 @@ out: | |||
212 | return ret; | 223 | return ret; |
213 | } | 224 | } |
214 | 225 | ||
215 | /* Destroy the slot table */ | ||
216 | static void nfs4_destroy_slot_tables(struct nfs4_session *session) | ||
217 | { | ||
218 | nfs4_shrink_slot_table(&session->fc_slot_table, 0); | ||
219 | nfs4_shrink_slot_table(&session->bc_slot_table, 0); | ||
220 | } | ||
221 | |||
222 | static bool nfs41_assign_slot(struct rpc_task *task, void *pslot) | 226 | static bool nfs41_assign_slot(struct rpc_task *task, void *pslot) |
223 | { | 227 | { |
224 | struct nfs4_sequence_args *args = task->tk_msg.rpc_argp; | 228 | struct nfs4_sequence_args *args = task->tk_msg.rpc_argp; |
@@ -383,6 +387,15 @@ void nfs41_update_target_slotid(struct nfs4_slot_table *tbl, | |||
383 | spin_unlock(&tbl->slot_tbl_lock); | 387 | spin_unlock(&tbl->slot_tbl_lock); |
384 | } | 388 | } |
385 | 389 | ||
390 | #if defined(CONFIG_NFS_V4_1) | ||
391 | |||
392 | /* Destroy the slot table */ | ||
393 | static void nfs4_destroy_slot_tables(struct nfs4_session *session) | ||
394 | { | ||
395 | nfs4_shrink_slot_table(&session->fc_slot_table, 0); | ||
396 | nfs4_shrink_slot_table(&session->bc_slot_table, 0); | ||
397 | } | ||
398 | |||
386 | /* | 399 | /* |
387 | * Initialize or reset the forechannel and backchannel tables | 400 | * Initialize or reset the forechannel and backchannel tables |
388 | */ | 401 | */ |
@@ -513,4 +526,4 @@ int nfs4_init_ds_session(struct nfs_client *clp, unsigned long lease_time) | |||
513 | } | 526 | } |
514 | EXPORT_SYMBOL_GPL(nfs4_init_ds_session); | 527 | EXPORT_SYMBOL_GPL(nfs4_init_ds_session); |
515 | 528 | ||
516 | 529 | #endif /* defined(CONFIG_NFS_V4_1) */ | |
diff --git a/fs/nfs/nfs4session.h b/fs/nfs/nfs4session.h index e3e6ce357f69..e069cf2d8c5f 100644 --- a/fs/nfs/nfs4session.h +++ b/fs/nfs/nfs4session.h | |||
@@ -72,15 +72,24 @@ enum nfs4_session_state { | |||
72 | NFS4_SESSION_INITING, | 72 | NFS4_SESSION_INITING, |
73 | }; | 73 | }; |
74 | 74 | ||
75 | #if defined(CONFIG_NFS_V4_1) | ||
76 | extern struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl); | 75 | extern struct nfs4_slot *nfs4_alloc_slot(struct nfs4_slot_table *tbl); |
77 | extern void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot); | 76 | extern void nfs4_free_slot(struct nfs4_slot_table *tbl, struct nfs4_slot *slot); |
78 | 77 | extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl); | |
79 | extern void nfs41_set_target_slotid(struct nfs4_slot_table *tbl, | ||
80 | u32 target_highest_slotid); | ||
81 | extern void nfs41_update_target_slotid(struct nfs4_slot_table *tbl, | 78 | extern void nfs41_update_target_slotid(struct nfs4_slot_table *tbl, |
82 | struct nfs4_slot *slot, | 79 | struct nfs4_slot *slot, |
83 | struct nfs4_sequence_res *res); | 80 | struct nfs4_sequence_res *res); |
81 | bool nfs41_wake_and_assign_slot(struct nfs4_slot_table *tbl, | ||
82 | struct nfs4_slot *slot); | ||
83 | void nfs41_wake_slot_table(struct nfs4_slot_table *tbl); | ||
84 | |||
85 | static inline bool nfs4_slot_tbl_draining(struct nfs4_slot_table *tbl) | ||
86 | { | ||
87 | return !!test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state); | ||
88 | } | ||
89 | |||
90 | #if defined(CONFIG_NFS_V4_1) | ||
91 | extern void nfs41_set_target_slotid(struct nfs4_slot_table *tbl, | ||
92 | u32 target_highest_slotid); | ||
84 | 93 | ||
85 | extern int nfs4_setup_session_slot_tables(struct nfs4_session *ses); | 94 | extern int nfs4_setup_session_slot_tables(struct nfs4_session *ses); |
86 | 95 | ||
@@ -89,17 +98,6 @@ extern void nfs4_destroy_session(struct nfs4_session *session); | |||
89 | extern int nfs4_init_session(struct nfs_client *clp); | 98 | extern int nfs4_init_session(struct nfs_client *clp); |
90 | extern int nfs4_init_ds_session(struct nfs_client *, unsigned long); | 99 | extern int nfs4_init_ds_session(struct nfs_client *, unsigned long); |
91 | 100 | ||
92 | extern void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl); | ||
93 | |||
94 | static inline bool nfs4_slot_tbl_draining(struct nfs4_slot_table *tbl) | ||
95 | { | ||
96 | return !!test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state); | ||
97 | } | ||
98 | |||
99 | bool nfs41_wake_and_assign_slot(struct nfs4_slot_table *tbl, | ||
100 | struct nfs4_slot *slot); | ||
101 | void nfs41_wake_slot_table(struct nfs4_slot_table *tbl); | ||
102 | |||
103 | /* | 101 | /* |
104 | * Determine if sessions are in use. | 102 | * Determine if sessions are in use. |
105 | */ | 103 | */ |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 25b7cf6a91d9..f5b043474c55 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -260,15 +260,6 @@ static void nfs4_end_drain_session(struct nfs_client *clp) | |||
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
263 | /* | ||
264 | * Signal state manager thread if session fore channel is drained | ||
265 | */ | ||
266 | void nfs4_slot_tbl_drain_complete(struct nfs4_slot_table *tbl) | ||
267 | { | ||
268 | if (nfs4_slot_tbl_draining(tbl)) | ||
269 | complete(&tbl->complete); | ||
270 | } | ||
271 | |||
272 | static int nfs4_drain_slot_tbl(struct nfs4_slot_table *tbl) | 263 | static int nfs4_drain_slot_tbl(struct nfs4_slot_table *tbl) |
273 | { | 264 | { |
274 | set_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state); | 265 | set_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state); |