aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorAndy Adamson <andros@netapp.com>2009-04-01 09:21:53 -0400
committerBenny Halevy <bhalevy@panasas.com>2009-06-17 13:46:19 -0400
commit557134a39c8d2ab79d8b8d53438e03e29feb5ec4 (patch)
tree3f6999d9601618102413fd535ff95f9be0babd85 /fs/nfs
parent9ff71c3a9827b99699510076dffa0bbe7c36bfd4 (diff)
nfs41: sessions client infrastructure
NFSv4.1 Sessions basic data types, initialization, and destruction. The session is always associated with a struct nfs_client that holds the exchange_id results. Signed-off-by: Rahul Iyer <iyer@netapp.com> Signed-off-by: Andy Adamson<andros@netapp.com> Signed-off-by: Benny Halevy <bhalevy@panasas.com> [remove extraneous rpc_clnt pointer, use the struct nfs_client cl_rpcclient. remove the rpc_clnt parameter from nfs4 nfs4_init_session] Signed-off-by: Andy Adamson<andros@netapp.com> Signed-off-by: Benny Halevy <bhalevy@panasas.com> [Use the presence of a session to determine behaviour instead of the minorversion number.] Signed-off-by: Andy Adamson <andros@netapp.com> [constified nfs4_has_session's struct nfs_client parameter] Signed-off-by: Benny Halevy <bhalevy@panasas.com> [Rename nfs4_put_session() to nfs4_destroy_session() and call it from nfs4_free_client() not nfs4_free_server(). Also get rid of nfs4_get_session() and the ref_count in nfs4_session struct as keeping track of nfs_client should be sufficient] Signed-off-by: Alexandros Batsakis <Alexandros.Batsakis@netapp.com> [nfs41: pass rsize and wsize into nfs4_init_session] Signed-off-by: Andy Adamson <andros@netapp.com> [separated out removal of rpc_clnt parameter from nfs4_init_session ot a patch of its own] Signed-off-by: Benny Halevy <bhalevy@panasas.com> [Pass the nfs_client pointer into nfs4_alloc_session] Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Benny Halevy <bhalevy@panasas.com> [nfs41: don't assign to session->clp->cl_session in nfs4_destroy_session] [nfs41: fixup nfs4_clear_client_minor_version] [introduce nfs4_clear_client_minor_version() in this patch] Signed-off-by: Benny Halevy <bhalevy@panasas.com> [Refactor nfs4_init_session] Moved session allocation into nfs4_init_client_minor_version, called from nfs4_init_client. Leave rwise and wsize initialization in nfs4_init_session, called from nfs4_init_server. Reverted moving of nfs_fsid definition to nfs_fs_sb.h Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Benny Halevy <bhalevy@panasas.com> [nfs41: Move NFS4_MAX_SLOT_TABLE define from under CONFIG_NFS_V4_1] [Fix comile error when CONFIG_NFS_V4_1 is not set.] Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Benny Halevy <bhalevy@panasas.com> [moved nfs4_init_slot_table definition to "create_session operation"] Signed-off-by: Benny Halevy <bhalevy@panasas.com> [nfs41: alloc session with GFP_KERNEL] Signed-off-by: Benny Halevy <bhalevy@panasas.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/client.c60
-rw-r--r--fs/nfs/internal.h12
-rw-r--r--fs/nfs/nfs4_fs.h4
-rw-r--r--fs/nfs/nfs4proc.c34
4 files changed, 110 insertions, 0 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index a736160046c3..f1506f148521 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -184,12 +184,27 @@ static void nfs4_shutdown_client(struct nfs_client *clp)
184} 184}
185 185
186/* 186/*
187 * Clears/puts all minor version specific parts from an nfs_client struct
188 * reverting it to minorversion 0.
189 */
190static void nfs4_clear_client_minor_version(struct nfs_client *clp)
191{
192#ifdef CONFIG_NFS_V4_1
193 if (nfs4_has_session(clp)) {
194 nfs4_destroy_session(clp->cl_session);
195 clp->cl_session = NULL;
196 }
197#endif /* CONFIG_NFS_V4_1 */
198}
199
200/*
187 * Destroy a shared client record 201 * Destroy a shared client record
188 */ 202 */
189static void nfs_free_client(struct nfs_client *clp) 203static void nfs_free_client(struct nfs_client *clp)
190{ 204{
191 dprintk("--> nfs_free_client(%u)\n", clp->rpc_ops->version); 205 dprintk("--> nfs_free_client(%u)\n", clp->rpc_ops->version);
192 206
207 nfs4_clear_client_minor_version(clp);
193 nfs4_shutdown_client(clp); 208 nfs4_shutdown_client(clp);
194 209
195 nfs_fscache_release_client_cookie(clp); 210 nfs_fscache_release_client_cookie(clp);
@@ -1054,6 +1069,30 @@ error:
1054 1069
1055#ifdef CONFIG_NFS_V4 1070#ifdef CONFIG_NFS_V4
1056/* 1071/*
1072 * Initialize the minor version specific parts of an NFS4 client record
1073 */
1074static int nfs4_init_client_minor_version(struct nfs_client *clp)
1075{
1076#if defined(CONFIG_NFS_V4_1)
1077 if (clp->cl_minorversion) {
1078 struct nfs4_session *session = NULL;
1079 /*
1080 * Create the session and mark it expired.
1081 * When a SEQUENCE operation encounters the expired session
1082 * it will do session recovery to initialize it.
1083 */
1084 session = nfs4_alloc_session(clp);
1085 if (!session)
1086 return -ENOMEM;
1087
1088 clp->cl_session = session;
1089 }
1090#endif /* CONFIG_NFS_V4_1 */
1091
1092 return 0;
1093}
1094
1095/*
1057 * Initialise an NFS4 client record 1096 * Initialise an NFS4 client record
1058 */ 1097 */
1059static int nfs4_init_client(struct nfs_client *clp, 1098static int nfs4_init_client(struct nfs_client *clp,
@@ -1087,6 +1126,10 @@ static int nfs4_init_client(struct nfs_client *clp,
1087 } 1126 }
1088 __set_bit(NFS_CS_IDMAP, &clp->cl_res_state); 1127 __set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
1089 1128
1129 error = nfs4_init_client_minor_version(clp);
1130 if (error < 0)
1131 goto error;
1132
1090 nfs_mark_client_ready(clp, NFS_CS_READY); 1133 nfs_mark_client_ready(clp, NFS_CS_READY);
1091 return 0; 1134 return 0;
1092 1135
@@ -1144,6 +1187,21 @@ error:
1144} 1187}
1145 1188
1146/* 1189/*
1190 * Initialize a session.
1191 * Note: save the mount rsize and wsize for create_server negotiation.
1192 */
1193static void nfs4_init_session(struct nfs_client *clp,
1194 unsigned int wsize, unsigned int rsize)
1195{
1196#if defined(CONFIG_NFS_V4_1)
1197 if (nfs4_has_session(clp)) {
1198 clp->cl_session->fc_attrs.max_rqst_sz = wsize;
1199 clp->cl_session->fc_attrs.max_resp_sz = rsize;
1200 }
1201#endif /* CONFIG_NFS_V4_1 */
1202}
1203
1204/*
1147 * Create a version 4 volume record 1205 * Create a version 4 volume record
1148 */ 1206 */
1149static int nfs4_init_server(struct nfs_server *server, 1207static int nfs4_init_server(struct nfs_server *server,
@@ -1221,6 +1279,8 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
1221 BUG_ON(!server->nfs_client->rpc_ops); 1279 BUG_ON(!server->nfs_client->rpc_ops);
1222 BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); 1280 BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);
1223 1281
1282 nfs4_init_session(server->nfs_client, server->wsize, server->rsize);
1283
1224 /* Probe the root fh to retrieve its FSID */ 1284 /* Probe the root fh to retrieve its FSID */
1225 error = nfs4_path_walk(server, mntfh, data->nfs_server.export_path); 1285 error = nfs4_path_walk(server, mntfh, data->nfs_server.export_path);
1226 if (error < 0) 1286 if (error < 0)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index ffa6bd54d439..7cef45db9257 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -207,6 +207,18 @@ extern int nfs4_path_walk(struct nfs_server *server,
207#endif 207#endif
208 208
209/* 209/*
210 * Determine if sessions are in use.
211 */
212static inline int nfs4_has_session(const struct nfs_client *clp)
213{
214#ifdef CONFIG_NFS_V4_1
215 if (clp->cl_session)
216 return 1;
217#endif /* CONFIG_NFS_V4_1 */
218 return 0;
219}
220
221/*
210 * Determine the device name as a string 222 * Determine the device name as a string
211 */ 223 */
212static inline char *nfs_devname(const struct vfsmount *mnt_parent, 224static inline char *nfs_devname(const struct vfsmount *mnt_parent,
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 84345deab26f..acac6f8c3d39 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -202,6 +202,10 @@ extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
202 202
203extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops; 203extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops;
204extern struct nfs4_state_recovery_ops nfs4_nograce_recovery_ops; 204extern struct nfs4_state_recovery_ops nfs4_nograce_recovery_ops;
205#if defined(CONFIG_NFS_V4_1)
206extern void nfs4_destroy_session(struct nfs4_session *session);
207extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp);
208#endif /* CONFIG_NFS_V4_1 */
205 209
206extern const u32 nfs4_fattr_bitmap[2]; 210extern const u32 nfs4_fattr_bitmap[2];
207extern const u32 nfs4_statfs_bitmap[2]; 211extern const u32 nfs4_statfs_bitmap[2];
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 4674f8092da8..cdd8e74c47d0 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3723,6 +3723,40 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
3723 return status; 3723 return status;
3724} 3724}
3725 3725
3726#ifdef CONFIG_NFS_V4_1
3727/* Destroy the slot table */
3728static void nfs4_destroy_slot_table(struct nfs4_session *session)
3729{
3730 if (session->fc_slot_table.slots == NULL)
3731 return;
3732 kfree(session->fc_slot_table.slots);
3733 session->fc_slot_table.slots = NULL;
3734 return;
3735}
3736
3737struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
3738{
3739 struct nfs4_session *session;
3740 struct nfs4_slot_table *tbl;
3741
3742 session = kzalloc(sizeof(struct nfs4_session), GFP_KERNEL);
3743 if (!session)
3744 return NULL;
3745 tbl = &session->fc_slot_table;
3746 spin_lock_init(&tbl->slot_tbl_lock);
3747 rpc_init_wait_queue(&tbl->slot_tbl_waitq, "Slot table");
3748 session->clp = clp;
3749 return session;
3750}
3751
3752void nfs4_destroy_session(struct nfs4_session *session)
3753{
3754 nfs4_destroy_slot_table(session);
3755 kfree(session);
3756}
3757
3758#endif /* CONFIG_NFS_V4_1 */
3759
3726struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops = { 3760struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops = {
3727 .owner_flag_bit = NFS_OWNER_RECLAIM_REBOOT, 3761 .owner_flag_bit = NFS_OWNER_RECLAIM_REBOOT,
3728 .state_flag_bit = NFS_STATE_RECLAIM_REBOOT, 3762 .state_flag_bit = NFS_STATE_RECLAIM_REBOOT,