diff options
author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2012-12-06 06:23:19 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-12-10 16:25:38 -0500 |
commit | b9c0ef8571c6ae33465dcf41d496ce2ad783c49d (patch) | |
tree | 5216e0d3be135d6b73bb7f2acc539bcf6fffadba /fs | |
parent | 2c2fe2909e124c32a34dbbb3ac129112524fc540 (diff) |
nfsd: make NFSd service boot time per-net
This is simple: an NFSd service can be started at different times in
different network environments. So, its "boot time" has to be assigned
per net.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/netns.h | 5 | ||||
-rw-r--r-- | fs/nfsd/nfs3xdr.c | 14 | ||||
-rw-r--r-- | fs/nfsd/nfs4proc.c | 11 | ||||
-rw-r--r-- | fs/nfsd/nfsd.h | 5 | ||||
-rw-r--r-- | fs/nfsd/nfssvc.c | 4 |
5 files changed, 23 insertions, 16 deletions
diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index 543ac486fd5..3b283eaab10 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h | |||
@@ -94,6 +94,11 @@ struct nfsd_net { | |||
94 | time_t nfsd4_grace; | 94 | time_t nfsd4_grace; |
95 | 95 | ||
96 | bool nfsd_net_up; | 96 | bool nfsd_net_up; |
97 | |||
98 | /* | ||
99 | * Time of server startup | ||
100 | */ | ||
101 | struct timeval nfssvc_boot; | ||
97 | }; | 102 | }; |
98 | 103 | ||
99 | /* Simple check to find out if a given net was properly initialized */ | 104 | /* Simple check to find out if a given net was properly initialized */ |
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 43f46cd9ede..2b8618de6c2 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c | |||
@@ -7,8 +7,10 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/namei.h> | 9 | #include <linux/namei.h> |
10 | #include <linux/sunrpc/svc_xprt.h> | ||
10 | #include "xdr3.h" | 11 | #include "xdr3.h" |
11 | #include "auth.h" | 12 | #include "auth.h" |
13 | #include "netns.h" | ||
12 | 14 | ||
13 | #define NFSDDBG_FACILITY NFSDDBG_XDR | 15 | #define NFSDDBG_FACILITY NFSDDBG_XDR |
14 | 16 | ||
@@ -720,12 +722,14 @@ int | |||
720 | nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p, | 722 | nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p, |
721 | struct nfsd3_writeres *resp) | 723 | struct nfsd3_writeres *resp) |
722 | { | 724 | { |
725 | struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); | ||
726 | |||
723 | p = encode_wcc_data(rqstp, p, &resp->fh); | 727 | p = encode_wcc_data(rqstp, p, &resp->fh); |
724 | if (resp->status == 0) { | 728 | if (resp->status == 0) { |
725 | *p++ = htonl(resp->count); | 729 | *p++ = htonl(resp->count); |
726 | *p++ = htonl(resp->committed); | 730 | *p++ = htonl(resp->committed); |
727 | *p++ = htonl(nfssvc_boot.tv_sec); | 731 | *p++ = htonl(nn->nfssvc_boot.tv_sec); |
728 | *p++ = htonl(nfssvc_boot.tv_usec); | 732 | *p++ = htonl(nn->nfssvc_boot.tv_usec); |
729 | } | 733 | } |
730 | return xdr_ressize_check(rqstp, p); | 734 | return xdr_ressize_check(rqstp, p); |
731 | } | 735 | } |
@@ -1082,11 +1086,13 @@ int | |||
1082 | nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p, | 1086 | nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p, |
1083 | struct nfsd3_commitres *resp) | 1087 | struct nfsd3_commitres *resp) |
1084 | { | 1088 | { |
1089 | struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); | ||
1090 | |||
1085 | p = encode_wcc_data(rqstp, p, &resp->fh); | 1091 | p = encode_wcc_data(rqstp, p, &resp->fh); |
1086 | /* Write verifier */ | 1092 | /* Write verifier */ |
1087 | if (resp->status == 0) { | 1093 | if (resp->status == 0) { |
1088 | *p++ = htonl(nfssvc_boot.tv_sec); | 1094 | *p++ = htonl(nn->nfssvc_boot.tv_sec); |
1089 | *p++ = htonl(nfssvc_boot.tv_usec); | 1095 | *p++ = htonl(nn->nfssvc_boot.tv_usec); |
1090 | } | 1096 | } |
1091 | return xdr_ressize_check(rqstp, p); | 1097 | return xdr_ressize_check(rqstp, p); |
1092 | } | 1098 | } |
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 1a0b1fdb5ad..bd67f4d6dfc 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -497,12 +497,13 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
497 | &access->ac_supported); | 497 | &access->ac_supported); |
498 | } | 498 | } |
499 | 499 | ||
500 | static void gen_boot_verifier(nfs4_verifier *verifier) | 500 | static void gen_boot_verifier(nfs4_verifier *verifier, struct net *net) |
501 | { | 501 | { |
502 | __be32 verf[2]; | 502 | __be32 verf[2]; |
503 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | ||
503 | 504 | ||
504 | verf[0] = (__be32)nfssvc_boot.tv_sec; | 505 | verf[0] = (__be32)nn->nfssvc_boot.tv_sec; |
505 | verf[1] = (__be32)nfssvc_boot.tv_usec; | 506 | verf[1] = (__be32)nn->nfssvc_boot.tv_usec; |
506 | memcpy(verifier->data, verf, sizeof(verifier->data)); | 507 | memcpy(verifier->data, verf, sizeof(verifier->data)); |
507 | } | 508 | } |
508 | 509 | ||
@@ -510,7 +511,7 @@ static __be32 | |||
510 | nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | 511 | nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, |
511 | struct nfsd4_commit *commit) | 512 | struct nfsd4_commit *commit) |
512 | { | 513 | { |
513 | gen_boot_verifier(&commit->co_verf); | 514 | gen_boot_verifier(&commit->co_verf, SVC_NET(rqstp)); |
514 | return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset, | 515 | return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset, |
515 | commit->co_count); | 516 | commit->co_count); |
516 | } | 517 | } |
@@ -930,7 +931,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
930 | 931 | ||
931 | cnt = write->wr_buflen; | 932 | cnt = write->wr_buflen; |
932 | write->wr_how_written = write->wr_stable_how; | 933 | write->wr_how_written = write->wr_stable_how; |
933 | gen_boot_verifier(&write->wr_verifier); | 934 | gen_boot_verifier(&write->wr_verifier, SVC_NET(rqstp)); |
934 | 935 | ||
935 | nvecs = fill_in_write_vector(rqstp->rq_vec, write); | 936 | nvecs = fill_in_write_vector(rqstp->rq_vec, write); |
936 | WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec)); | 937 | WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec)); |
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 18f99966554..71ba60d3623 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h | |||
@@ -269,11 +269,6 @@ void nfsd_lockd_shutdown(void); | |||
269 | /* Check for dir entries '.' and '..' */ | 269 | /* Check for dir entries '.' and '..' */ |
270 | #define isdotent(n, l) (l < 3 && n[0] == '.' && (l == 1 || n[1] == '.')) | 270 | #define isdotent(n, l) (l < 3 && n[0] == '.' && (l == 1 || n[1] == '.')) |
271 | 271 | ||
272 | /* | ||
273 | * Time of server startup | ||
274 | */ | ||
275 | extern struct timeval nfssvc_boot; | ||
276 | |||
277 | #ifdef CONFIG_NFSD_V4 | 272 | #ifdef CONFIG_NFSD_V4 |
278 | 273 | ||
279 | /* before processing a COMPOUND operation, we have to check that there | 274 | /* before processing a COMPOUND operation, we have to check that there |
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 6e17efdd8af..40992cd5bff 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -27,7 +27,6 @@ | |||
27 | 27 | ||
28 | extern struct svc_program nfsd_program; | 28 | extern struct svc_program nfsd_program; |
29 | static int nfsd(void *vrqstp); | 29 | static int nfsd(void *vrqstp); |
30 | struct timeval nfssvc_boot; | ||
31 | 30 | ||
32 | /* | 31 | /* |
33 | * nfsd_mutex protects nfsd_serv -- both the pointer itself and the members | 32 | * nfsd_mutex protects nfsd_serv -- both the pointer itself and the members |
@@ -367,6 +366,7 @@ static int nfsd_get_default_max_blksize(void) | |||
367 | int nfsd_create_serv(struct net *net) | 366 | int nfsd_create_serv(struct net *net) |
368 | { | 367 | { |
369 | int error; | 368 | int error; |
369 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | ||
370 | 370 | ||
371 | WARN_ON(!mutex_is_locked(&nfsd_mutex)); | 371 | WARN_ON(!mutex_is_locked(&nfsd_mutex)); |
372 | if (nfsd_serv) { | 372 | if (nfsd_serv) { |
@@ -388,7 +388,7 @@ int nfsd_create_serv(struct net *net) | |||
388 | } | 388 | } |
389 | 389 | ||
390 | set_max_drc(); | 390 | set_max_drc(); |
391 | do_gettimeofday(&nfssvc_boot); /* record boot time */ | 391 | do_gettimeofday(&nn->nfssvc_boot); /* record boot time */ |
392 | return 0; | 392 | return 0; |
393 | } | 393 | } |
394 | 394 | ||