Replace time_t type and get_seconds function which are not y2038 safe on 32-bit systems. Function ktime_get_seconds use monotonic instead of real time and therefore will not cause overflow.
Signed-off-by: Ksenija Stanojevic ksenija.stanojevic@gmail.com --- fs/nfsd/netns.h | 2 +- fs/nfsd/nfs4recover.c | 6 +++--- fs/nfsd/nfs4state.c | 8 ++++---- fs/nfsd/state.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index d8b16c2..d5cce15 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h @@ -53,7 +53,7 @@ struct nfsd_net {
struct lock_manager nfsd4_manager; bool grace_ended; - time_t boot_time; + u32 boot_time;
/* * reclaim_str_hashtbl[] holds known client info from previous reset/reboot diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index e3d4709..eec431a 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -1164,7 +1164,7 @@ nfsd4_cltrack_client_has_session(struct nfs4_client *clp) }
static char * -nfsd4_cltrack_grace_start(time_t grace_start) +nfsd4_cltrack_grace_start(unsigned long grace_start) { int copied; size_t len; @@ -1177,7 +1177,7 @@ nfsd4_cltrack_grace_start(time_t grace_start) if (!result) return result;
- copied = snprintf(result, len, GRACE_START_ENV_PREFIX "%ld", + copied = snprintf(result, len, GRACE_START_ENV_PREFIX "%lu", grace_start); if (copied >= len) { /* just return nothing if output was truncated */ @@ -1388,7 +1388,7 @@ nfsd4_umh_cltrack_grace_done(struct nfsd_net *nn) char *legacy; char timestr[22]; /* FIXME: better way to determine max size? */
- sprintf(timestr, "%ld", nn->boot_time); + sprintf(timestr, "%x", nn->boot_time); legacy = nfsd4_cltrack_legacy_topdir(); nfsd4_umh_cltrack_upcall("gracedone", timestr, legacy, NULL); kfree(legacy); diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 0f1d569..8245236 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1612,9 +1612,9 @@ STALE_CLIENTID(clientid_t *clid, struct nfsd_net *nn) * precisely 2^32 (about 136 years) before this one. That seems * a safe assumption: */ - if (clid->cl_boot == (u32)nn->boot_time) + if (clid->cl_boot == nn->boot_time) return 0; - dprintk("NFSD stale clientid (%08x/%08x) boot_time %08lx\n", + dprintk("NFSD stale clientid (%08x/%08x) boot_time %08x\n", clid->cl_boot, clid->cl_id, nn->boot_time); return 1; } @@ -4276,7 +4276,7 @@ nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, __be32 status; struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
- dprintk("process_renew(%08x/%08x): starting\n", + dprintk("process_renew(%08x/%08x): starting\n", clid->cl_boot, clid->cl_id); status = lookup_clientid(clid, cstate, nn); if (status) @@ -6603,7 +6603,7 @@ nfs4_state_start_net(struct net *net) ret = nfs4_state_create_net(net); if (ret) return ret; - nn->boot_time = get_seconds(); + nn->boot_time = ktime_get_seconds(); nn->grace_ended = false; nn->nfsd4_manager.block_opens = true; locks_start_grace(net, &nn->nfsd4_manager); diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 583ffc1..5c49ed65 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -305,7 +305,7 @@ struct nfs4_client { #endif struct xdr_netobj cl_name; /* id generated by client */ nfs4_verifier cl_verifier; /* generated by client */ - time_t cl_time; /* time of last lease renewal */ + u32 cl_time; /* time of last lease renewal */ struct sockaddr_storage cl_addr; /* client ipaddress */ bool cl_mach_cred; /* SP4_MACH_CRED in force */ struct svc_cred cl_cred; /* setclientid principal */