From patchwork Wed Jun 20 08:29:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139296 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp513072lji; Wed, 20 Jun 2018 01:49:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKxJSdwyU5bSWpex5OGE7VYC1c7EeUeorjLlA3diUD6/QMtN0obikWZuU+pElKaNGd9CUbs X-Received: by 2002:a17:902:bd95:: with SMTP id q21-v6mr22486805pls.237.1529484586000; Wed, 20 Jun 2018 01:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529484585; cv=none; d=google.com; s=arc-20160816; b=GpjJ20mDI1Ogau6QHJlOie1LPlqQZJsjK+Yb73KcQScFRNCAsjHSzT772vV4qd5ZD6 cdrcRrpelHndTUa+DNOjTKHX/wwIzkCLAIEPmaZ1LWnP6qvEczZdFEUVCGZoySpPz2B0 mkv/YKsz156cCQjcfApgMkxRCmiU33tSHcGXRXne629ZKJn/MEvXm9QTVMH2AJ+LUMGH oQ65BcVuupP8Sna5a6+M+p3T0qIfBPkb9uMFcQrpCVjgrhpBtQXH93dQsGvNkxfflfoR G7S/ieWGdwV1gjbyMIJ7gETTyHz3XHqToHNVxpizWAPaGYaJ138jYc7ZKxEm2jcasz0o ubYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:dkim-signature :arc-authentication-results; bh=8JKQ1+7goVHPCvr5KPjaDkjSzig0VXKxuQF0cuA+UrU=; b=AggufK5Gt2IESuZ6+DZpdFIjgRY9YWm6PykDDx0rwpvCtMqQvWBLykWGo7KchkpWNp KwTCRiHDvgWuyx+HVgiHKfVEbcPQjUiTAnct9JdVfijuehfU6+Spou8dB5SAJxgdZWNQ Lu3VC/Oijz3jBLfXIpjuLlSDDGBkMtRxyZjhXPNcMhm7pt1zrHFzioVQZiG8mP2NhChR kVp9ktjoUtKWHwEkj8dF+0oXPGDRcB3Av2fLat6+hcjfI1MiLEDVAsCMdKY2UXqyzxvb tvnX8c9faxJvoQAnnWTNM9l25bqXGi2MbR5SNs9IRmlbzPrFsqfmvkLUUxUDR5ylBWW8 fEtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=gCijcXj3; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id e1-v6si1555373pgr.318.2018.06.20.01.49.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Jun 2018 01:49:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=gCijcXj3; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=8JKQ1+7goVHPCvr5KPjaDkjSzig0VXKxuQF0cuA+UrU=; b=gCi jcXj3paHJ+Z7Wd8O5mTnuA6eJp3MOA/vfW579FYgo6RabUUU9/AJZfV4Y9px/zP8BQoUA6unOy6ue isyH6caJQ6M3q4JPEamJvFjdkPNZA9HJ/jRI2vSd2UMAizvoE2zNPmo17fI4TuZI7fguXhr6dI1rw fsqOKsKG6bRji7FhX+NRzYSM6xj2nHvS+dLQ+9kP72BuNoZNiI0KEABD059L5Ezh9agFsS8eV1n1e hvhw6sKEJUosk+L9oQhpaYaAhO93izsVprZEGZI0EY4/20OPlsSE1eGyWc1JhOePZPSIhI93FnSRK f6nnPfIiVMeImT+bp5dnM1CTRThzGuA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVYo7-00089Z-BM; Wed, 20 Jun 2018 08:49:39 +0000 Received: from mout.kundenserver.de ([217.72.192.74]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVYaM-0006Lw-7z for linux-mtd@lists.infradead.org; Wed, 20 Jun 2018 08:37:26 +0000 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0M1hZS-1gJoru1vOU-00tgex; Wed, 20 Jun 2018 10:29:40 +0200 From: Arnd Bergmann To: Richard Weinberger , Artem Bityutskiy , Adrian Hunter Subject: [PATCH] ubifs: tnc: use monotonic znode timestamp Date: Wed, 20 Jun 2018 10:29:11 +0200 Message-Id: <20180620082937.719067-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:vxIMLQRBGMGZ82FXIXw3ZVG74RVbmt6DfFiQ3KR9OdnR8K8rjyx pzo8DMnWdiKdjKfV/Y+22HPFE07gRGye4EOG90/MpyWgMH4j2DhKBnFjP5DNLkrnmQ0Yhyi bdYTLufQRGFQUio5CzKWbV/kuo87DYulhY/iU8mP7Tj4TWKRDyxU3deiygtfaJE7fJJo8A6 Up5WAJaVKUk/fjkwaiF2A== X-UI-Out-Filterresults: notjunk:1; V01:K0:FfqoIHIi4XU=:/yqiOp2CR3szwYP/211yDj q8r3CQ/KPoVIB/sNnAfr+qv2hIQ3U6HBNZId/lFJY8UF1Y9i/8IN6+1ByU4cMGFiDC9RapwAd YZijno5SETnwYaQNgDWn8DvGHOzL9mdHrMEA8kn5XJPijXOaEqtZr4MBp1DTPxzKu8vRkIZdN f8pbtiR+13noiZWZ3JiUZMVfgBFdi943O3FsZSh5c9NNFJRgz+qJbtt8aySFeA97SDO20NEvw TvQ69aQhgdopji4hOUsnxiVshv3Pr8rMJq5EfYjA8GHKJGWFUcxVrce+uo9aXzJXNLwBVAxwF /y+C3UMWMJ46fiicXLnTwFolspamz5Zzt0+l7FyFbctLJ+j3sHAEFTNB+fcPoWg6ZgWHbg7Ra mJS6LBdovkD6V08GXhctnrdfOrddeQflrSI74FXkTFWmCNMQLkHooIb01fEMYWGZYKlCVWC5q +Xp0G02+K8pf2IuQlS+23JHIWWM5wwyGHVPElSRbJTfIiQ0xljEb6RkSaNcY9kAXvvI1kMlf5 G5IGHDhOD/3u1LkTyOtws9sEZTf/sPnhNtdViaDaCpSj9xAqmuDdn2IuazUqRXXKoVBO7L/fZ dVzz0YejvE08XyoBtcpTLnV70wi+4puKwFC9bsdUgeMClPsSmkrBuuVTyxJ8duM4zm0yK0uFD uNjbDfsGSpiSH073NyKDDt7wthgxSYGBfV2c7Me0jDWYP0Fcdvxw4TPMs6vQZvY+9nRE= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180620_013526_614230_EE092FA4 X-CRM114-Status: GOOD ( 12.29 ) X-Spam-Note: SpamAssassin invocation failed X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: y2038@lists.linaro.org, linux-mtd@lists.infradead.org, Deepa Dinamani , Arnd Bergmann , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org The tnc uses get_seconds() based timestamps to check the age of a znode, which has two problems: on 32-bit architectures this may overflow in 2038 or 2106, and it gives incorrect information when the system time is updated using settimeofday(). Using montonic timestamps with ktime_get_seconds() solves both thes problems. Signed-off-by: Arnd Bergmann --- fs/ubifs/shrinker.c | 2 +- fs/ubifs/tnc.c | 4 ++-- fs/ubifs/tnc_misc.c | 2 +- fs/ubifs/ubifs.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) -- 2.9.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/fs/ubifs/shrinker.c b/fs/ubifs/shrinker.c index 9a9fb94a41c6..9d10cbdec2cc 100644 --- a/fs/ubifs/shrinker.c +++ b/fs/ubifs/shrinker.c @@ -71,7 +71,7 @@ static int shrink_tnc(struct ubifs_info *c, int nr, int age, int *contention) { int total_freed = 0; struct ubifs_znode *znode, *zprev; - int time = get_seconds(); + time64_t time = ktime_get_seconds(); ubifs_assert(mutex_is_locked(&c->umount_mutex)); ubifs_assert(mutex_is_locked(&c->tnc_mutex)); diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index 4a21e7f75e7a..6c497fb48b98 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c @@ -1179,7 +1179,7 @@ int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key, { int err, exact; struct ubifs_znode *znode; - unsigned long time = get_seconds(); + time64_t time = ktime_get_seconds(); dbg_tnck(key, "search key "); ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY); @@ -1315,7 +1315,7 @@ static int lookup_level0_dirty(struct ubifs_info *c, const union ubifs_key *key, { int err, exact; struct ubifs_znode *znode; - unsigned long time = get_seconds(); + time64_t time = ktime_get_seconds(); dbg_tnck(key, "search and dirty key "); diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c index 93f5b7859e6f..49f647bc88f0 100644 --- a/fs/ubifs/tnc_misc.c +++ b/fs/ubifs/tnc_misc.c @@ -435,7 +435,7 @@ struct ubifs_znode *ubifs_load_znode(struct ubifs_info *c, zbr->znode = znode; znode->parent = parent; - znode->time = get_seconds(); + znode->time = ktime_get_seconds(); znode->iip = iip; return znode; diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 04bf84d71e7b..54fb6b1cd042 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -758,7 +758,7 @@ struct ubifs_znode { struct ubifs_znode *parent; struct ubifs_znode *cnext; unsigned long flags; - unsigned long time; + time64_t time; int level; int child_cnt; int iip;