提交 b9c0ef85 编写于 作者: S Stanislav Kinsbursky 提交者: J. Bruce Fields

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: NStanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 2c2fe290
...@@ -94,6 +94,11 @@ struct nfsd_net { ...@@ -94,6 +94,11 @@ struct nfsd_net {
time_t nfsd4_grace; time_t nfsd4_grace;
bool nfsd_net_up; bool nfsd_net_up;
/*
* Time of server startup
*/
struct timeval nfssvc_boot;
}; };
/* Simple check to find out if a given net was properly initialized */ /* Simple check to find out if a given net was properly initialized */
......
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
*/ */
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/sunrpc/svc_xprt.h>
#include "xdr3.h" #include "xdr3.h"
#include "auth.h" #include "auth.h"
#include "netns.h"
#define NFSDDBG_FACILITY NFSDDBG_XDR #define NFSDDBG_FACILITY NFSDDBG_XDR
...@@ -720,12 +722,14 @@ int ...@@ -720,12 +722,14 @@ int
nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p, nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_writeres *resp) struct nfsd3_writeres *resp)
{ {
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
p = encode_wcc_data(rqstp, p, &resp->fh); p = encode_wcc_data(rqstp, p, &resp->fh);
if (resp->status == 0) { if (resp->status == 0) {
*p++ = htonl(resp->count); *p++ = htonl(resp->count);
*p++ = htonl(resp->committed); *p++ = htonl(resp->committed);
*p++ = htonl(nfssvc_boot.tv_sec); *p++ = htonl(nn->nfssvc_boot.tv_sec);
*p++ = htonl(nfssvc_boot.tv_usec); *p++ = htonl(nn->nfssvc_boot.tv_usec);
} }
return xdr_ressize_check(rqstp, p); return xdr_ressize_check(rqstp, p);
} }
...@@ -1082,11 +1086,13 @@ int ...@@ -1082,11 +1086,13 @@ int
nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p, nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_commitres *resp) struct nfsd3_commitres *resp)
{ {
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
p = encode_wcc_data(rqstp, p, &resp->fh); p = encode_wcc_data(rqstp, p, &resp->fh);
/* Write verifier */ /* Write verifier */
if (resp->status == 0) { if (resp->status == 0) {
*p++ = htonl(nfssvc_boot.tv_sec); *p++ = htonl(nn->nfssvc_boot.tv_sec);
*p++ = htonl(nfssvc_boot.tv_usec); *p++ = htonl(nn->nfssvc_boot.tv_usec);
} }
return xdr_ressize_check(rqstp, p); return xdr_ressize_check(rqstp, p);
} }
......
...@@ -497,12 +497,13 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -497,12 +497,13 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
&access->ac_supported); &access->ac_supported);
} }
static void gen_boot_verifier(nfs4_verifier *verifier) static void gen_boot_verifier(nfs4_verifier *verifier, struct net *net)
{ {
__be32 verf[2]; __be32 verf[2];
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
verf[0] = (__be32)nfssvc_boot.tv_sec; verf[0] = (__be32)nn->nfssvc_boot.tv_sec;
verf[1] = (__be32)nfssvc_boot.tv_usec; verf[1] = (__be32)nn->nfssvc_boot.tv_usec;
memcpy(verifier->data, verf, sizeof(verifier->data)); memcpy(verifier->data, verf, sizeof(verifier->data));
} }
...@@ -510,7 +511,7 @@ static __be32 ...@@ -510,7 +511,7 @@ static __be32
nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct nfsd4_commit *commit) struct nfsd4_commit *commit)
{ {
gen_boot_verifier(&commit->co_verf); gen_boot_verifier(&commit->co_verf, SVC_NET(rqstp));
return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset, return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset,
commit->co_count); commit->co_count);
} }
...@@ -930,7 +931,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -930,7 +931,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
cnt = write->wr_buflen; cnt = write->wr_buflen;
write->wr_how_written = write->wr_stable_how; write->wr_how_written = write->wr_stable_how;
gen_boot_verifier(&write->wr_verifier); gen_boot_verifier(&write->wr_verifier, SVC_NET(rqstp));
nvecs = fill_in_write_vector(rqstp->rq_vec, write); nvecs = fill_in_write_vector(rqstp->rq_vec, write);
WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec)); WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec));
......
...@@ -269,11 +269,6 @@ void nfsd_lockd_shutdown(void); ...@@ -269,11 +269,6 @@ void nfsd_lockd_shutdown(void);
/* Check for dir entries '.' and '..' */ /* Check for dir entries '.' and '..' */
#define isdotent(n, l) (l < 3 && n[0] == '.' && (l == 1 || n[1] == '.')) #define isdotent(n, l) (l < 3 && n[0] == '.' && (l == 1 || n[1] == '.'))
/*
* Time of server startup
*/
extern struct timeval nfssvc_boot;
#ifdef CONFIG_NFSD_V4 #ifdef CONFIG_NFSD_V4
/* before processing a COMPOUND operation, we have to check that there /* before processing a COMPOUND operation, we have to check that there
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
extern struct svc_program nfsd_program; extern struct svc_program nfsd_program;
static int nfsd(void *vrqstp); static int nfsd(void *vrqstp);
struct timeval nfssvc_boot;
/* /*
* nfsd_mutex protects nfsd_serv -- both the pointer itself and the members * 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,6 +366,7 @@ static int nfsd_get_default_max_blksize(void)
int nfsd_create_serv(struct net *net) int nfsd_create_serv(struct net *net)
{ {
int error; int error;
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
WARN_ON(!mutex_is_locked(&nfsd_mutex)); WARN_ON(!mutex_is_locked(&nfsd_mutex));
if (nfsd_serv) { if (nfsd_serv) {
...@@ -388,7 +388,7 @@ int nfsd_create_serv(struct net *net) ...@@ -388,7 +388,7 @@ int nfsd_create_serv(struct net *net)
} }
set_max_drc(); set_max_drc();
do_gettimeofday(&nfssvc_boot); /* record boot time */ do_gettimeofday(&nn->nfssvc_boot); /* record boot time */
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册