diff options
author | Andy Adamson <andros@netapp.com> | 2009-04-01 09:22:34 -0400 |
---|---|---|
committer | Benny Halevy <bhalevy@panasas.com> | 2009-06-17 15:24:55 -0400 |
commit | 0f3e66c6a6cae479028d31198288e524fe5ff90d (patch) | |
tree | e221fc927077a22485d5befc0136f1e77ecc55c5 /fs | |
parent | 96b09e024fedf0a6604c8c688a3994d5ed991434 (diff) |
nfs41: destroy_session operation
Implement the destroy_session operation conforming to
http://tools.ietf.org/html/draft-ietf-nfsv4-minorversion1-26
Signed-off-by: Ricardo Labiaga <ricardo.labiaga@netapp.com>
Signed-off-by: Andy Adamson<andros@umich.edu>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: remove extraneous rpc_clnt pointer]
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41; NFS_CS_READY required for DESTROY_SESSION]
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: pass *session in seq_args and seq_res]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
[nfs41: fix encode_destroy_session's xdr Xcoding pointer type]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/nfs4proc.c | 30 | ||||
-rw-r--r-- | fs/nfs/nfs4xdr.c | 59 | ||||
-rw-r--r-- | fs/nfs/super.c | 2 |
3 files changed, 91 insertions, 0 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 4d7a8b9e1291..59e8bf5b10bb 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -4532,6 +4532,36 @@ out: | |||
4532 | return status; | 4532 | return status; |
4533 | } | 4533 | } |
4534 | 4534 | ||
4535 | /* | ||
4536 | * Issue the over-the-wire RPC DESTROY_SESSION. | ||
4537 | * The caller must serialize access to this routine. | ||
4538 | */ | ||
4539 | int nfs4_proc_destroy_session(struct nfs4_session *session) | ||
4540 | { | ||
4541 | int status = 0; | ||
4542 | struct rpc_message msg; | ||
4543 | |||
4544 | dprintk("--> nfs4_proc_destroy_session\n"); | ||
4545 | |||
4546 | /* session is still being setup */ | ||
4547 | if (session->clp->cl_cons_state != NFS_CS_READY) | ||
4548 | return status; | ||
4549 | |||
4550 | msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DESTROY_SESSION]; | ||
4551 | msg.rpc_argp = session; | ||
4552 | msg.rpc_resp = NULL; | ||
4553 | msg.rpc_cred = NULL; | ||
4554 | status = rpc_call_sync(session->clp->cl_rpcclient, &msg, 0); | ||
4555 | |||
4556 | if (status) | ||
4557 | printk(KERN_WARNING | ||
4558 | "Got error %d from the server on DESTROY_SESSION. " | ||
4559 | "Session has been destroyed regardless...\n", status); | ||
4560 | |||
4561 | dprintk("<-- nfs4_proc_destroy_session\n"); | ||
4562 | return status; | ||
4563 | } | ||
4564 | |||
4535 | #endif /* CONFIG_NFS_V4_1 */ | 4565 | #endif /* CONFIG_NFS_V4_1 */ |
4536 | 4566 | ||
4537 | struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops = { | 4567 | struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops = { |
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 7a243a2cf0be..a81e49648ccb 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -294,6 +294,8 @@ static int nfs4_stat_to_errno(int); | |||
294 | 1 /* csr_flags */ + \ | 294 | 1 /* csr_flags */ + \ |
295 | decode_channel_attrs_maxsz + \ | 295 | decode_channel_attrs_maxsz + \ |
296 | decode_channel_attrs_maxsz) | 296 | decode_channel_attrs_maxsz) |
297 | #define encode_destroy_session_maxsz (op_encode_hdr_maxsz + 4) | ||
298 | #define decode_destroy_session_maxsz (op_decode_hdr_maxsz) | ||
297 | #define encode_sequence_maxsz 0 /* stub */ | 299 | #define encode_sequence_maxsz 0 /* stub */ |
298 | #define decode_sequence_maxsz 0 /* stub */ | 300 | #define decode_sequence_maxsz 0 /* stub */ |
299 | #else /* CONFIG_NFS_V4_1 */ | 301 | #else /* CONFIG_NFS_V4_1 */ |
@@ -655,6 +657,10 @@ static int nfs4_stat_to_errno(int); | |||
655 | #define NFS4_dec_create_session_sz \ | 657 | #define NFS4_dec_create_session_sz \ |
656 | (compound_decode_hdr_maxsz + \ | 658 | (compound_decode_hdr_maxsz + \ |
657 | decode_create_session_maxsz) | 659 | decode_create_session_maxsz) |
660 | #define NFS4_enc_destroy_session_sz (compound_encode_hdr_maxsz + \ | ||
661 | encode_destroy_session_maxsz) | ||
662 | #define NFS4_dec_destroy_session_sz (compound_decode_hdr_maxsz + \ | ||
663 | decode_destroy_session_maxsz) | ||
658 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ | 664 | #define NFS4_enc_get_lease_time_sz (compound_encode_hdr_maxsz + \ |
659 | encode_sequence_maxsz + \ | 665 | encode_sequence_maxsz + \ |
660 | encode_putrootfh_maxsz + \ | 666 | encode_putrootfh_maxsz + \ |
@@ -1609,6 +1615,18 @@ static void encode_create_session(struct xdr_stream *xdr, | |||
1609 | hdr->nops++; | 1615 | hdr->nops++; |
1610 | hdr->replen += decode_create_session_maxsz; | 1616 | hdr->replen += decode_create_session_maxsz; |
1611 | } | 1617 | } |
1618 | |||
1619 | static void encode_destroy_session(struct xdr_stream *xdr, | ||
1620 | struct nfs4_session *session, | ||
1621 | struct compound_hdr *hdr) | ||
1622 | { | ||
1623 | __be32 *p; | ||
1624 | RESERVE_SPACE(4 + NFS4_MAX_SESSIONID_LEN); | ||
1625 | WRITE32(OP_DESTROY_SESSION); | ||
1626 | WRITEMEM(session->sess_id.data, NFS4_MAX_SESSIONID_LEN); | ||
1627 | hdr->nops++; | ||
1628 | hdr->replen += decode_destroy_session_maxsz; | ||
1629 | } | ||
1612 | #endif /* CONFIG_NFS_V4_1 */ | 1630 | #endif /* CONFIG_NFS_V4_1 */ |
1613 | 1631 | ||
1614 | static void encode_sequence(struct xdr_stream *xdr, | 1632 | static void encode_sequence(struct xdr_stream *xdr, |
@@ -2355,6 +2373,24 @@ static int nfs4_xdr_enc_create_session(struct rpc_rqst *req, uint32_t *p, | |||
2355 | } | 2373 | } |
2356 | 2374 | ||
2357 | /* | 2375 | /* |
2376 | * a DESTROY_SESSION request | ||
2377 | */ | ||
2378 | static int nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, uint32_t *p, | ||
2379 | struct nfs4_session *session) | ||
2380 | { | ||
2381 | struct xdr_stream xdr; | ||
2382 | struct compound_hdr hdr = { | ||
2383 | .minorversion = session->clp->cl_minorversion, | ||
2384 | }; | ||
2385 | |||
2386 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | ||
2387 | encode_compound_hdr(&xdr, req, &hdr); | ||
2388 | encode_destroy_session(&xdr, session, &hdr); | ||
2389 | encode_nops(&hdr); | ||
2390 | return 0; | ||
2391 | } | ||
2392 | |||
2393 | /* | ||
2358 | * a GET_LEASE_TIME request | 2394 | * a GET_LEASE_TIME request |
2359 | */ | 2395 | */ |
2360 | static int nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, uint32_t *p, | 2396 | static int nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, uint32_t *p, |
@@ -4188,6 +4224,11 @@ static int decode_create_session(struct xdr_stream *xdr, | |||
4188 | status = decode_chan_attrs(xdr, &session->bc_attrs); | 4224 | status = decode_chan_attrs(xdr, &session->bc_attrs); |
4189 | return status; | 4225 | return status; |
4190 | } | 4226 | } |
4227 | |||
4228 | static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) | ||
4229 | { | ||
4230 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); | ||
4231 | } | ||
4191 | #endif /* CONFIG_NFS_V4_1 */ | 4232 | #endif /* CONFIG_NFS_V4_1 */ |
4192 | 4233 | ||
4193 | static int decode_sequence(struct xdr_stream *xdr, | 4234 | static int decode_sequence(struct xdr_stream *xdr, |
@@ -5123,6 +5164,23 @@ static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p, | |||
5123 | } | 5164 | } |
5124 | 5165 | ||
5125 | /* | 5166 | /* |
5167 | * a DESTROY_SESSION request | ||
5168 | */ | ||
5169 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p, | ||
5170 | void *dummy) | ||
5171 | { | ||
5172 | struct xdr_stream xdr; | ||
5173 | struct compound_hdr hdr; | ||
5174 | int status; | ||
5175 | |||
5176 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | ||
5177 | status = decode_compound_hdr(&xdr, &hdr); | ||
5178 | if (!status) | ||
5179 | status = decode_destroy_session(&xdr, dummy); | ||
5180 | return status; | ||
5181 | } | ||
5182 | |||
5183 | /* | ||
5126 | * a GET_LEASE_TIME request | 5184 | * a GET_LEASE_TIME request |
5127 | */ | 5185 | */ |
5128 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p, | 5186 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p, |
@@ -5316,6 +5374,7 @@ struct rpc_procinfo nfs4_procedures[] = { | |||
5316 | #if defined(CONFIG_NFS_V4_1) | 5374 | #if defined(CONFIG_NFS_V4_1) |
5317 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), | 5375 | PROC(EXCHANGE_ID, enc_exchange_id, dec_exchange_id), |
5318 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), | 5376 | PROC(CREATE_SESSION, enc_create_session, dec_create_session), |
5377 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), | ||
5319 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), | 5378 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
5320 | #endif /* CONFIG_NFS_V4_1 */ | 5379 | #endif /* CONFIG_NFS_V4_1 */ |
5321 | }; | 5380 | }; |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 5a8fdc791cc1..73db6f8c145a 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -2485,12 +2485,14 @@ static void nfs4_kill_super(struct super_block *sb) | |||
2485 | { | 2485 | { |
2486 | struct nfs_server *server = NFS_SB(sb); | 2486 | struct nfs_server *server = NFS_SB(sb); |
2487 | 2487 | ||
2488 | dprintk("--> %s\n", __func__); | ||
2488 | nfs_super_return_all_delegations(sb); | 2489 | nfs_super_return_all_delegations(sb); |
2489 | kill_anon_super(sb); | 2490 | kill_anon_super(sb); |
2490 | 2491 | ||
2491 | nfs4_renewd_prepare_shutdown(server); | 2492 | nfs4_renewd_prepare_shutdown(server); |
2492 | nfs_fscache_release_super_cookie(sb); | 2493 | nfs_fscache_release_super_cookie(sb); |
2493 | nfs_free_server(server); | 2494 | nfs_free_server(server); |
2495 | dprintk("<-- %s\n", __func__); | ||
2494 | } | 2496 | } |
2495 | 2497 | ||
2496 | /* | 2498 | /* |