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: 116354 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp302466qgn; Thu, 19 Oct 2017 03:05:03 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QIDVRhD4SpcOoOzQBx8S8H5kGxQINaHwHy6VqR9LhM0H1UlmMkRh6R7pgW2kT57QIzYPa4 X-Received: by 10.84.178.164 with SMTP id z33mr1077773plb.333.1508407502904; Thu, 19 Oct 2017 03:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508407502; cv=none; d=google.com; s=arc-20160816; b=RoyX6GYsIib1568gQRzpjsnYqfNfpT2oGSwe3coorrHBvD93CdxFUmvA67D3NCjmCX Xj4E7HX9chEN4NGt6h7Xy3xqjW69gxY7BPeK/1cArn1lXmf8I9KNG/KNhgXUAhMlnIwY jtxywpO1QtNei0uRO394Lgvd7H2V/LHkzb+1uIEuZT8c/+xYMIu8glc39fVDqaKteXuO eu5o7gdpoMZnO6PB9eSMlRd4OgsnJpE472dVcssR8rFczTxWHaxUW3nKekRQ2rjMFU2s V/bCKBE8Sbh/NKqVJfNKX7WgrOyokz8ia4OGDUDWTiwL5grRR5QbX6dU+rO2vYf58lXa NLmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=7tYfxBXOzekbl1AuO0+mhOyJtnJoHcoyaQSmiPb6Cos=; b=UVFe2ElptkLOgf3RCStdw503ml1SHOhVwGuWQADTVI7sTAEwdTJvebFf0ZNmijPgM/ VtWbDAh7zX7iDGeMzMg4EbL0NQDOEpA8v5Qx1s/SBiVGabX04vwdDTg23DRNjFTKJL50 B+myL0us3DkWZzR7vhxcBEKLIJIp35NolETEnq8XlQPSpKqXIaXyeCjmfwgPMkfEWAT4 FlgoEDwVLFyszzUYIhEuLFd2sZKOuU5Ut9poallabYzP8qqvSRthLz+l2BH/i7PXjgEZ EcXm9WtkP7fk3Os+d4lhQLzMN20treAT9brcLTj3ir3J7gOGrPpsC8hsWhNWWElpa6O9 nFWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2si8345814pgc.696.2017.10.19.03.05.02; Thu, 19 Oct 2017 03:05:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752568AbdJSKEs (ORCPT + 27 others); Thu, 19 Oct 2017 06:04:48 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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(-) -- 2.9.0 Reviewed-by: Jeff Layton 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; }