Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1461786
| From | Deepa Dinamani <deepa.kernel@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v4 20/26] fs: nfs: Make nfs boot time y2038 safe |
| Date | 2016-08-14 12:40 +0200 |
| Message-ID | <s60ZK-6Ls-87@gated-at.bofh.it> (permalink) |
| References | <s5YXT-5oj-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
boot_time is represented as a struct timespec.
struct timespec and CURRENT_TIME are not y2038 safe.
Overall, the plan is to use timespec64 and ktime_t for
all internal kernel representation of timestamps.
CURRENT_TIME will also be removed.
boot_time is used to construct the nfs client boot verifier.
Use ktime_t to represent boot_time and ktime_get_real() for
the boot_time value.
Following Trond's request https://lkml.org/lkml/2016/6/9/22 ,
use ktime_t instead of converting to struct timespec64.
Use higher and lower 32 bit parts of ktime_t for the boot
verifier.
Use the lower 32 bit part of ktime_t for the authsys_parms
stamp field.
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Anna Schumaker <anna.schumaker@netapp.com>
Cc: linux-nfs@vger.kernel.org
---
fs/nfs/client.c | 2 +-
fs/nfs/netns.h | 2 +-
fs/nfs/nfs4proc.c | 10 ++++++----
fs/nfs/nfs4xdr.c | 2 +-
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 003ebce..a59ef22 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1078,7 +1078,7 @@ void nfs_clients_init(struct net *net)
idr_init(&nn->cb_ident_idr);
#endif
spin_lock_init(&nn->nfs_client_lock);
- nn->boot_time = CURRENT_TIME;
+ nn->boot_time = ktime_get_real();
}
#ifdef CONFIG_PROC_FS
diff --git a/fs/nfs/netns.h b/fs/nfs/netns.h
index f0e06e4..fbce0d8 100644
--- a/fs/nfs/netns.h
+++ b/fs/nfs/netns.h
@@ -29,7 +29,7 @@ struct nfs_net {
int cb_users[NFS4_MAX_MINOR_VERSION + 1];
#endif
spinlock_t nfs_client_lock;
- struct timespec boot_time;
+ ktime_t boot_time;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nfsfs;
#endif
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 1949bbd..9107f92 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5067,12 +5067,14 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp,
if (test_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state)) {
/* An impossible timestamp guarantees this value
* will never match a generated boot time. */
- verf[0] = 0;
- verf[1] = cpu_to_be32(NSEC_PER_SEC + 1);
+ verf[0] = cpu_to_be32(U32_MAX);
+ verf[1] = cpu_to_be32(U32_MAX);
} else {
struct nfs_net *nn = net_generic(clp->cl_net, nfs_net_id);
- verf[0] = cpu_to_be32(nn->boot_time.tv_sec);
- verf[1] = cpu_to_be32(nn->boot_time.tv_nsec);
+ u64 ns = ktime_to_ns(nn->boot_time);
+
+ verf[0] = cpu_to_be32(ns >> 32);
+ verf[1] = cpu_to_be32(ns);
}
memcpy(bootverf->data, verf, sizeof(bootverf->data));
}
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 7bd3a5c..a961e15 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1850,7 +1850,7 @@ static void encode_create_session(struct xdr_stream *xdr,
*p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */
/* authsys_parms rfc1831 */
- *p++ = cpu_to_be32(nn->boot_time.tv_nsec); /* stamp */
+ *p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */
p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
*p++ = cpu_to_be32(0); /* UID */
*p++ = cpu_to_be32(0); /* GID */
--
1.9.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[GIT PULL] [PATCH v4 00/26] Delete CURRENT_TIME and CURRENT_TIME_SEC macros Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 10:30 +0200
[PATCH v4 22/26] libceph: Replace CURRENT_TIME with ktime_get_real_ts Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:30 +0200
[PATCH v4 05/26] fs: Replace current_fs_time() with current_time() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:30 +0200
[PATCH v4 24/26] fnic: Use time64_t to represent trace timestamps Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:30 +0200
[PATCH v4 13/26] fs: cifs: Replace CURRENT_TIME with ktime_get_real_ts() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:30 +0200
[PATCH v4 07/26] fs: jfs: Replace CURRENT_TIME_SEC by current_time() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:40 +0200
[PATCH v4 21/26] block: Replace CURRENT_TIME with ktime_get_real_ts Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:40 +0200
[PATCH v4 14/26] fs: cifs: Replace CURRENT_TIME by get_seconds Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:40 +0200
[PATCH v4 06/26] fs: ufs: Use ktime_get_real_ts64() for birthtime Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:40 +0200
[PATCH v4 20/26] fs: nfs: Make nfs boot time y2038 safe Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:40 +0200
[PATCH v4 23/26] fs: ceph: Replace current_fs_time for request stamp Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:50 +0200
[PATCH v4 11/26] fs: udf: Replace CURRENT_TIME with current_time() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:50 +0200
[PATCH v4 09/26] fs: ubifs: Replace CURRENT_TIME_SEC with current_time Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 12:50 +0200
[PATCH v4 18/26] fs: ocfs2: Replace CURRENT_TIME macro Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 13:00 +0200
[PATCH v4 10/26] fs: btrfs: Use ktime_get_real_ts for root ctime Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 13:00 +0200
Re: [PATCH v4 10/26] fs: btrfs: Use ktime_get_real_ts for root ctime David Sterba <dsterba@suse.cz> - 2016-08-15 15:30 +0200
[PATCH v4 17/26] fs: ocfs2: Use time64_t to represent orphan scan times Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 13:10 +0200
[PATCH v4 15/26] fs: f2fs: Use ktime_get_real_seconds for sit_info times Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 13:10 +0200
[PATCH v4 26/26] time: Delete CURRENT_TIME_SEC and CURRENT_TIME Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 13:20 +0200
[PATCH v4 08/26] fs: ext4: Use current_time() for inode timestamps Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 13:20 +0200
[PATCH v4 02/26] fs: proc: Delete inode time initializations in proc_alloc_inode() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 13:30 +0200
[PATCH v4 12/26] fs: cifs: Replace CURRENT_TIME by current_time() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 13:40 +0200
[PATCH v4 19/26] audit: Use timespec64 to represent audit timestamps Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 13:40 +0200
[PATCH v4 25/26] time: Delete current_fs_time() function Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 13:50 +0200
Re: [PATCH v4 25/26] time: Delete current_fs_time() function John Stultz <john.stultz@linaro.org> - 2016-08-17 22:10 +0200
[PATCH v4 16/26] drivers: staging: lustre: Replace CURRENT_TIME with current_time() Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 14:00 +0200
[PATCH v4 01/26] vfs: Add current_time() api Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-14 16:50 +0200
Re: [GIT PULL] [PATCH v4 00/26] Delete CURRENT_TIME and CURRENT_TIME_SEC macros Greg KH <gregkh@linuxfoundation.org> - 2016-08-15 18:30 +0200
Re: [GIT PULL] [PATCH v4 00/26] Delete CURRENT_TIME and CURRENT_TIME_SEC macros Deepa Dinamani <deepa.kernel@gmail.com> - 2016-08-16 20:20 +0200
Re: [GIT PULL] [PATCH v4 00/26] Delete CURRENT_TIME and CURRENT_TIME_SEC macros Greg KH <gregkh@linuxfoundation.org> - 2016-08-16 21:00 +0200
Re: [GIT PULL] [PATCH v4 00/26] Delete CURRENT_TIME and CURRENT_TIME_SEC macros Arnd Bergmann <arnd@arndb.de> - 2016-08-23 17:10 +0200
csiph-web