From patchwork Thu Jun 27 01:00:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713674 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 333DFC30659 for ; Thu, 27 Jun 2024 01:00:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A8EF6B00B4; Wed, 26 Jun 2024 21:00:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9084C6B00B5; Wed, 26 Jun 2024 21:00:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7126B6B00B6; Wed, 26 Jun 2024 21:00:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 516C76B00B4 for ; Wed, 26 Jun 2024 21:00:43 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 036B91A1852 for ; Thu, 27 Jun 2024 01:00:42 +0000 (UTC) X-FDA: 82274863566.26.630F145 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf27.hostedemail.com (Postfix) with ESMTP id 96F3E4000F for ; Thu, 27 Jun 2024 01:00:40 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uu9bKpll; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719450027; a=rsa-sha256; cv=none; b=mJ8aKdgbmRliFlrcvOBsWriePhhtE4vEZtnw+Dc5SaXVdk5si9ePqOb0lrwcVTUtqutyz+ Y8Yev0Xwjl5uhHV7soPR+bUztaaLu7Migeijyq2NBzc8NbUa82cUnw046tv3JQs4MeL74C Z2nxfMYUYqrqB1/xdl9Nqc2ItkqoWYM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uu9bKpll; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719450027; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lJDs2AMrrLbY5Hmj/2eKGgKATawTe+aoHup90R0VtK0=; b=duH/xYosfnYRNMtYeKHN9xC9WlKw3WZnxwvBraEKH6nHo/Y4TuF1K19RK+vee6QiQQNdRP k9Jq1z+f5AIwA58KzXW65CloiQXAeGDk8gZQf0TXLsdXo96W016JdEMdqMKworv0HFuxzN unWWS7/xxbnBZC7O1IAMWgg4+bJwRBU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id AF47FCE2C47; Thu, 27 Jun 2024 01:00:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AE4CC4AF07; Thu, 27 Jun 2024 01:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450036; bh=G1sIrGm75KvOwnRqj2Qr6NVY9492uXV9G5iKNcaenQ4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uu9bKpllUfrdSsygooj3Il3q8igpsvcmeAJH22XWhg0c7R4ESyKAy6ypVts8fty9Q A4rOJR86fnWgQq6PivWKbjaJlnw70+VkTI7DxzP60N2Qrir9Ic2bnuGZY/Mn3Kmx5Y 5O2ksEpKXnGnV02Ipp03xM+6wdkL/rOB0LvOe1tMB76udcWzWHkFgREjMAvwSO8liD 62ifGHWLFKbFpThGH6t5XGg0SqzlkqAPGYdd97REc6rKf9Shq9XTLEajv6JPfzo53X Uxs4hQ1uF5VqaGNENGK+CE6KwJhtX1VVXAPDIijDBZZ6duDZxgFvzxWTznJk0QMxVs KZor/o/3gWLEQ== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:21 -0400 Subject: [PATCH 01/10] fs: turn inode ctime fields into a single ktime_t MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-1-a189352d0f8f@kernel.org> References: <20240626-mgtime-v1-0-a189352d0f8f@kernel.org> In-Reply-To: <20240626-mgtime-v1-0-a189352d0f8f@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton Cc: kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3344; i=jlayton@kernel.org; h=from:subject:message-id; bh=G1sIrGm75KvOwnRqj2Qr6NVY9492uXV9G5iKNcaenQ4=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmuOgyuFN9FzwPSoACp7/4FgL4U5ewrxzQPi h6LGQNjmoCJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rgAKCRAADmhBGVaC FX5ZEACvzw0eK1vFpOnF4nZM3s2zL0NqyeFfw2IuIbYubO0XzKfU/GlcdGAVZD1/oDZDN9X2Ntx tkSoujXFDXsMigQyoXVvDfxIpYSjogrB25YHg+5iMFM+/GLPQhReln8cY/xzbjx01IVuO0RXKE4 QCqFhVlV/I1AzaZ+xC2NOv8CXa/Gf1nSyV1llrK8t0wQT048zrREZqwJy2evRRRJ3ecwRRPh4cl IEJsjenGZNFF5pqNreGFh5eywBPrseN4m29EXntKoztrVnT8HM9FGHWXYI90hiugYxhtyUMLBl9 k7VrSVP5poWdnKgzfthiYN1qmCk4JMEVj0HsIcRPmQi+9kO9CtqDiWvTjKnLsTrNgCcvxWA7s3J fvxvlclGfrgwuT45eja71AqaiM3GYchiM0VjQebvZ8xZXFmqYsti088EqvJ+wjJH9xJgv9zRC66 G9eLzUdSnUckzPOx0BwcdvqOXD8/Dj2hrMXaC/2odyLZwF8XteERYsiPxnY88U2mWd5XGSXAouK D7d0B/OWH5OAovkc6IwLogJExZW8lY8ce4ubLrVbK8TVE5J1NsCvk2Jtj1jsTPlg/8qmVIWjqTz hfSDMcxZZ7/Njq2slc2PrWO+jzycNYolqZgeqH2NlccufsMKSRU4NLkED1LWFh8ynH9T1lR1mMw YmEPaOvwMbs8P+g== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 96F3E4000F X-Stat-Signature: d4gde87baiadf5ozbdrtmwzfjoj8ydrj X-Rspam-User: X-HE-Tag: 1719450040-744744 X-HE-Meta: U2FsdGVkX1/eeNtnooqU2XT3cSw/Wx9YVwd4e2bsCiCKL1AAkqGG03+AMSRoC8e2h8ZJghVbDVCW+xfnDt+aCQ1oBGHuBmwrKRmSrTuejTu+N0wKaDZaipO/LMtIkDCT2ven3MobbSWHb15DaTGt+H5R0B3t6MQOlYdpvt2nEmp2+p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NoVPCmt5iJAVuj4V2BbFf/go5RTIU/pd3qxrCfiLuYTKXzEGhOiqk1o= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The ctime is not settable to arbitrary values. It always comes from the system clock, so we'll never stamp an inode with a value that can't be represented there. If we disregard people setting their system clock past the year 2262, there is no reason we can't replace the ctime fields with a ktime_t. Switch the ctime fields to a single ktime_t. Move the i_generation down above i_fsnotify_mask and then move the i_version into the resulting 8 byte hole. This shrinks struct inode by 8 bytes total, and should improve the cache footprint as the i_version and ctime are usually updated together. The one downside I can see to switching to a ktime_t is that if someone has a filesystem with files on it that has ctimes outside the ktime_t range (before ~1678 AD or after ~2262 AD), we won't be able to display them properly in stat() without some special treatment in the filesystem. The operating assumption here is that that is not a practical problem. Signed-off-by: Jeff Layton --- include/linux/fs.h | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 5ff362277834..5139dec085f2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -662,11 +662,10 @@ struct inode { loff_t i_size; time64_t i_atime_sec; time64_t i_mtime_sec; - time64_t i_ctime_sec; u32 i_atime_nsec; u32 i_mtime_nsec; - u32 i_ctime_nsec; - u32 i_generation; + ktime_t __i_ctime; + atomic64_t i_version; spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ unsigned short i_bytes; u8 i_blkbits; @@ -701,7 +700,6 @@ struct inode { struct hlist_head i_dentry; struct rcu_head i_rcu; }; - atomic64_t i_version; atomic64_t i_sequence; /* see futex */ atomic_t i_count; atomic_t i_dio_count; @@ -724,6 +722,8 @@ struct inode { }; + u32 i_generation; + #ifdef CONFIG_FSNOTIFY __u32 i_fsnotify_mask; /* all events this inode cares about */ /* 32-bit hole reserved for expanding i_fsnotify_mask */ @@ -1608,29 +1608,25 @@ static inline struct timespec64 inode_set_mtime(struct inode *inode, return inode_set_mtime_to_ts(inode, ts); } -static inline time64_t inode_get_ctime_sec(const struct inode *inode) +static inline struct timespec64 inode_get_ctime(const struct inode *inode) { - return inode->i_ctime_sec; + return ktime_to_timespec64(inode->__i_ctime); } -static inline long inode_get_ctime_nsec(const struct inode *inode) +static inline time64_t inode_get_ctime_sec(const struct inode *inode) { - return inode->i_ctime_nsec; + return inode_get_ctime(inode).tv_sec; } -static inline struct timespec64 inode_get_ctime(const struct inode *inode) +static inline long inode_get_ctime_nsec(const struct inode *inode) { - struct timespec64 ts = { .tv_sec = inode_get_ctime_sec(inode), - .tv_nsec = inode_get_ctime_nsec(inode) }; - - return ts; + return inode_get_ctime(inode).tv_nsec; } static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts) { - inode->i_ctime_sec = ts.tv_sec; - inode->i_ctime_nsec = ts.tv_nsec; + inode->__i_ctime = ktime_set(ts.tv_sec, ts.tv_nsec); return ts; }