From patchwork Mon Jun 20 00:27:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 9186361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6A6F960871 for ; Mon, 20 Jun 2016 00:43:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D18422376 for ; Mon, 20 Jun 2016 00:43:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DF8D200F5; Mon, 20 Jun 2016 00:43:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FCD0200F5 for ; Mon, 20 Jun 2016 00:43:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751809AbcFTAnd (ORCPT ); Sun, 19 Jun 2016 20:43:33 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35096 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbcFTAnc (ORCPT ); Sun, 19 Jun 2016 20:43:32 -0400 Received: by mail-pf0-f194.google.com with SMTP id t190so10245526pfb.2; Sun, 19 Jun 2016 17:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fLG/ZEtKuJqLsdCOW0mKki25lGy1p68B3eaKPBoPIzQ=; b=ygOFOahTREmULPSqFPfp9MJqcXBiXTpQZSh4kDxgofqg8GOgPDMWv460UmoWaQJZiA MMzLQSUK8IFa1bc+j36VZlpfu7JUS4Ke6HqG+t73PaF7f4C/34/QCkZprM6yKtgoiQhi wXFIJ7pcd58YI8kzNxFe8/LSnM4jLT9eAw4EuuX4Bv5hLzzTF8wRM7S8MWqECjqrSO32 pcpiEiCo/0eJDJZEn2VRt1Z1usGSPkrsOVrugNDt5O4xtV8ARNL/nCBaRdzchsgPfJrg fJ4V88CXUvVnWMDFu1hx2zihvhgYYanGKdD5XXXt1QlcGEsYKP4LEPU5ZoytDesOTe4Q Nv4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fLG/ZEtKuJqLsdCOW0mKki25lGy1p68B3eaKPBoPIzQ=; b=gLY6taYyjmxBafW9JAOJx2+8dSjqCcUW8Tvrq2YISD/6lMWouXdfdBlQLWsXG9zcjM pCshNqxDjuHrbJnOO3sw6RYkc2ETSb9ev8VtXrdk44BbeWRiuKcIAbAgh+CuItcZ3GoX P97f9HWTTSyUqgsflfT4xuaG7+aj33TYexvGZZUNplpssRxGv2BFwOI8k58mT6Yy8Jzz ayHBENO0zkbWcmv1o+iHyAbf1dddT24ZKV7lKBJtKtWmC3C/ZY71mMZbzzqXnURdg00X hq0Qs/rsWVZea5gvvA2b6DRzCXYvlPRgL+opy6uE5DlzYBjrYtk9r7iUHN5myo6KR2cf V6vQ== X-Gm-Message-State: ALyK8tKuIYNS/jAN1Ng+xsbW3+SA9Rw3jobuV3bEEAbHirg8kE5/UwebbxBMJHgGJGF4Cw== X-Received: by 10.98.158.206 with SMTP id f75mr18388799pfk.164.1466382515346; Sun, 19 Jun 2016 17:28:35 -0700 (PDT) Received: from deepa-ubuntu.hsd1.ca.comcast.net (c-73-252-251-201.hsd1.ca.comcast.net. [73.252.251.201]) by smtp.gmail.com with ESMTPSA id s12sm34984980pfj.57.2016.06.19.17.28.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 Jun 2016 17:28:34 -0700 (PDT) From: Deepa Dinamani To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, tglx@linutronix.de, torvalds@linux-foundation.org, tytso@mit.edu, viro@zeniv.linux.org.uk, y2038@lists.linaro.org, Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH v2 18/24] fs: nfs: Make nfs boot time y2038 safe Date: Sun, 19 Jun 2016 17:27:17 -0700 Message-Id: <1466382443-11063-19-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466382443-11063-1-git-send-email-deepa.kernel@gmail.com> References: <1466382443-11063-1-git-send-email-deepa.kernel@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Trond Myklebust Cc: Anna Schumaker Cc: linux-nfs@vger.kernel.org --- Changes from V1: * Use ktime_t instead of timespec64_t * Change algorithm to use boot_time accordingly 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 0c96528..d1aff29 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -1080,7 +1080,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 406dd3e..8d9b5a9 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5062,12 +5062,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 661e753..5944be0 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 */