From patchwork Wed Jun 20 08:25:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139302 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp562482lji; Wed, 20 Jun 2018 02:46:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKCjfZ1q49/tu+kjyuZCxZrbm3uERWicvJU+oO4MH2NsJTWkQzX8nDTCQJEzY9AmAx8nDWT X-Received: by 2002:a63:40c7:: with SMTP id n190-v6mr18207675pga.248.1529487992311; Wed, 20 Jun 2018 02:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529487992; cv=none; d=google.com; s=arc-20160816; b=oocibOjIeMLR60KlOSn3oDAH54zBOEGLPZvtQlGEC2oehvFmzbPF1JTOTUlQ6i5IJD KLV975vgVkqNTuSnC1bAZAihPy/+Ui1sXliaJRMYtcquqjF253CwI6OgPofPwW4gDe8r T//4enxiFxhieFFu7rJ1P609q+MOFDAKYxb3CtJqy90+TQN0CXQugI4op5IBPeOwEu4k LbXcdjK6Tz79eMaYeckblf+KzsaPpFgyQDAFSjxJKjOGAnFXKesUafX4N0A57jHkqmv9 vQhs3bdJJpbEWd1rL19hAifGc98obFk0gd7bRKMb0Nkmbzlx9anCesRJCryd4CXpEO8B Dqbg== 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=1orIHpFIFqhvQD7PHab5hdq2+kB3jFVjjeG/7IrMEK4=; b=hCshLYbYBifDFT2kEsjbYbJ7HThhDb2fssZ2QNXmbYNI2SoI+Qz8smmzduh22vhagK pK1WddMCFPRI3ZflHd6t4VLpehlBXDzBYFQ3XoaoQoAQrGnUvLMk8/rR0efQ/D7bEJ8o f/2qxPQcAz8HLb+V5Zm0BW0MjHvmq1qoqBHEYvruUbc7B5OUL4nXLG3sqYz6q+DPjSG4 T5XpZ14ibJ4zArXA7ItWIf3N88gBO76jmFrpC27HCUjv0PkoJjeHV4aRB65xTdjfvOV/ /xLrLmt/0/stCfxs0R0kYtdXrcFNRuXX07YKVwsO//7BUM81qPkqLtX+Mp2wcMgdnzde R9Vw== 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 k187-v6si1718011pge.421.2018.06.20.02.46.32; Wed, 20 Jun 2018 02:46:32 -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 S1754388AbeFTJqa (ORCPT + 30 others); Wed, 20 Jun 2018 05:46:30 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:44253 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752392AbeFTI0Q (ORCPT ); Wed, 20 Jun 2018 04:26:16 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.129]) with ESMTPA (Nemesis) id 0MCMK5-1fN3zl1vDV-009AdF; Wed, 20 Jun 2018 10:26:00 +0200 From: Arnd Bergmann To: Andrew Morton , Hugh Dickins Cc: y2038@lists.linaro.org, Arnd Bergmann , Mike Kravetz , "Kirill A. Shutemov" , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] shmem: use monotonic time for i_generation Date: Wed, 20 Jun 2018 10:25:39 +0200 Message-Id: <20180620082556.581543-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:m52VVL/SbVyYo0XHY4gYT+4xhV/5/hRoisTXVmmwfR9B4xWnaoR Oi5feigR2AVITHxFdLHmzHmJQABDqDZ6Ls6lvS3IpIoYSbUGakIOe70OlyercSRBmnAr3OQ hniNGPgqI5LJT7uZWNrAZQRNZfsJGg+5uu0Jgxt4IV7hDNlviicbtKDFXCSUjbsu4rOBm7Q o4UCV63oSzhc82iTcJ4Pg== X-UI-Out-Filterresults: notjunk:1; V01:K0:qNNG7wysrmc=:feNUcb6fcdKF6/64JwuPZ2 +Zi+KX85xlbm5KmXLdW7uoI2bMs5M4//IlWhfUtUhkDbtddfAsx9Bk/lcutuFzg8uYj2D1VJe 3RLQ1KlqMtFI5uXHE8SPNHSO9JVWgARZnCWKqefV6v/n04jbxWSIyHzMnV7Hm3+RTPsnV4eBP lMeUqgWDOlyS6waXwuQ6J/Qehs+bJ60aWJTBFHVJKQuJL5ns7EH3JgblW9eAUVLEr2auC+C/g hQ9SdwUUp5EWH/1RULw30EtVbf8Nrc252pKSup/uWcG6oZmZqnx+wlXxRK/mb8RtOk502tf1q rueTBSos6/qHOrlBuq/CBeKyWOARHQKDEPcFHP0J8Z2+oS/dqZ1/aYU2ofFawPB2MN1561Djj lwdq53BnscQOwAVfBdrLkgtyxZ83wjL+C4JrTYCQvf3RayQTnVnae1B7/M4VvsE+TzNVx93nY Pg06S5O3FNwbZaqZO0Odjl4uC+7Rs3Zu3PeCDlROvBUS7yuyYAeK3nManfKeOKWZU6/zQ60VU tgmp9MqZtWZeValriGQieJAHrJEOWUNN13lRMX9AU1gMtRyUv0L/EHcfSBP7yVtn1tR9Xpudb L4075/eicW6EgV23GcDfA1tffVKKMXsp8UNF8wHECD5OYy/pBWWGCdSxPmjPleqAmtISWZTgv IcTeoeJCRw5PvbSJRfVkjv+52K8ccaEGvP+H/PVTr8x95tvHY/SpluGRBWqgVPULguOs= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org get_seconds() is deprecated because it will lead to a 32-bit overflow in 2038 or 2106. We don't need the i_generation to be strictly monotonic anyway, and other file systems like ext4 and xfs just use prandom_u32(), so let's use the same one here. If this is considered too slow, we could also use ktime_get_seconds() or ktime_get_real_seconds() to keep the previous behavior. Both of these return a time64_t and are not deprecated, but only return a unique value once per second, and are predictable. Signed-off-by: Arnd Bergmann --- mm/shmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.9.0 diff --git a/mm/shmem.c b/mm/shmem.c index 2cab84403055..387ae5323f56 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -2187,7 +2188,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode inode_init_owner(inode, dir, mode); inode->i_blocks = 0; inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); - inode->i_generation = get_seconds(); + inode->i_generation = prandom_u32(); info = SHMEM_I(inode); memset(info, 0, (char *)inode - (char *)info); spin_lock_init(&info->lock);