From patchwork Thu Oct 19 10:04:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10016335 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 DFD1B600CC for ; Thu, 19 Oct 2017 10:05:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4D3E28BAB for ; Thu, 19 Oct 2017 10:05:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9ADC28CC4; Thu, 19 Oct 2017 10:05:18 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 103AD28CC1 for ; Thu, 19 Oct 2017 10:05:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751890AbdJSKEr (ORCPT ); Thu, 19 Oct 2017 06:04:47 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:60147 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751142AbdJSKEp (ORCPT ); Thu, 19 Oct 2017 06:04:45 -0400 Received: from wuerfel.lan ([46.223.139.202]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.129]) with ESMTPA (Nemesis) id 0MNiRi-1e7qiE1uws-007EXM; Thu, 19 Oct 2017 12:04:36 +0200 From: Arnd Bergmann To: y2038@lists.linaro.org, "J. Bruce Fields" , Jeff Layton Cc: Deepa Dinamani , linux-fsdevel@vger.kernel.org, Arnd Bergmann , Trond Myklebust , NeilBrown , Kinglong Mee , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] nfds: avoid gettimeofday for nfssvc_boot time Date: Thu, 19 Oct 2017 12:04:11 +0200 Message-Id: <20171019100435.1170955-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:QOb+ReAaP1FDNEBreHWjsrg5HZbvP5sbKgzqUn0sWRL/BqhdRff eJNoeTvg9OJ7FDNRs/9HBDqamoZE+H+nqs0gKr+743ibGrxeV8dwCLH+Eo8L4SeEnExp2MT T4Ke1I2hQBYrOJn8oOlzZyHhyLaaGVDNZyR/xY4PQ8bVEquclGuVK/7bVILmYziSM7ULh2t /tfzYsAQSaMJ6mXA0uOSw== X-UI-Out-Filterresults: notjunk:1; V01:K0:M/vGjQBwHL4=:aRVUm5aFB+/JXtX5Ztj4QV mIVwxSck10Pxa8IyqpyW6C0ysalDo3grkfjHH1SsWHhHznsAkCUMYc7ipUkW1EHx5TaOo64gM 097UhCxU3qVbymFpsAVryWb9uzZ3wn6CtofZBjOebO5gqIyyT3doSWl0j7O7P1Bpx/4bgwNaR d12Mhsmn65Z83vAh2AdqSC8d5LS/OergBtUtEcmwr8LkO1cr9xZ/nhAnwBgYnNEj67j9VQkNr n8dcDQFFPcKak/Jg7h/kAs3veJ0jhIJ5bBtyFGHnwtW0JyMubQK8DlPcFD73z2LaParl8vVFH oCSP1AoVwRAgWlcDGtqp7z0eo5bELbO8YYKRiqU53ptE9AmNkW5I5YPcVQ7lS5oMawcfv8GLK i6w9jwQjpkjFgFTtpuycwm14ExE294rTgIux8eOpWdt+20jqD8fkOnCepNd9CiFdQ2TgkM+XQ azf1gPCFLcWoJcqyK9pBT9XDR77J2aPDyj4ykALkioxx/xT8LPjScgN/+70WEyPB7Q7JBVxX0 4CnKE+aowr4yhRq+ZbrqfQrV9IyIXH8zWOzIOes3cv7+fhb2H0Z2dU9tYg5kOF3ApnmfuXjTw x44M0UoqM+dGhLPQonWlgflyq0I5MVo4hizt3UmpL13tKrwW41EqPtHQEiMDCdAMioCQHCDRo sagKS2N0GrGsj2qPtFk0xoMVYiPBbJVsHhcuZl1IEIZ9xBqclAJy5VjMeg4xeP4Lhz1Kyt56c VSB22Ww8pjXv8mP0ppDeJrPW0BWAb4X0nB3wbw== 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 do_gettimeofday() is deprecated and we should generally use time64_t based functions instead. In case of nfsd, all three users of nfssvc_boot only use the initial time as a unique token, and are not affected by it overflowing, so they are not affected by the y2038 overflow. This converts the structure to timespec64 anyway and adds comments to all uses, to document that we have thought about it and avoid having to look at it again. Signed-off-by: Arnd Bergmann Reviewed-by: Jeff Layton --- fs/nfsd/netns.h | 2 +- fs/nfsd/nfs3xdr.c | 10 ++++++---- fs/nfsd/nfs4proc.c | 5 +++-- fs/nfsd/nfssvc.c | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index 3714231a9d0f..1c91391f4805 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h @@ -107,7 +107,7 @@ struct nfsd_net { bool lockd_up; /* Time of server startup */ - struct timeval nfssvc_boot; + struct timespec64 nfssvc_boot; /* * Max number of connections this nfsd container will allow. Defaults diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index bf444b664011..3579e0ae1131 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -747,8 +747,9 @@ nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p) if (resp->status == 0) { *p++ = htonl(resp->count); *p++ = htonl(resp->committed); - *p++ = htonl(nn->nfssvc_boot.tv_sec); - *p++ = htonl(nn->nfssvc_boot.tv_usec); + /* unique identifier, y2038 overflow can be ignored */ + *p++ = htonl((u32)nn->nfssvc_boot.tv_sec); + *p++ = htonl(nn->nfssvc_boot.tv_nsec); } return xdr_ressize_check(rqstp, p); } @@ -1118,8 +1119,9 @@ nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p) p = encode_wcc_data(rqstp, p, &resp->fh); /* Write verifier */ if (resp->status == 0) { - *p++ = htonl(nn->nfssvc_boot.tv_sec); - *p++ = htonl(nn->nfssvc_boot.tv_usec); + /* unique identifier, y2038 overflow can be ignored */ + *p++ = htonl((u32)nn->nfssvc_boot.tv_sec); + *p++ = htonl(nn->nfssvc_boot.tv_nsec); } return xdr_ressize_check(rqstp, p); } diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 7896f841482e..008ea0b627d0 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -564,10 +564,11 @@ static void gen_boot_verifier(nfs4_verifier *verifier, struct net *net) /* * This is opaque to client, so no need to byte-swap. Use - * __force to keep sparse happy + * __force to keep sparse happy. y2038 time_t overflow is + * irrelevant in this usage. */ verf[0] = (__force __be32)nn->nfssvc_boot.tv_sec; - verf[1] = (__force __be32)nn->nfssvc_boot.tv_usec; + verf[1] = (__force __be32)nn->nfssvc_boot.tv_nsec; memcpy(verifier->data, verf, sizeof(verifier->data)); } diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 6bbc717f40f2..28ff3e078af6 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -516,7 +516,7 @@ int nfsd_create_serv(struct net *net) register_inet6addr_notifier(&nfsd_inet6addr_notifier); #endif } - do_gettimeofday(&nn->nfssvc_boot); /* record boot time */ + ktime_get_real_ts64(&nn->nfssvc_boot); /* record boot time */ return 0; }