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+pNUFbBgQDTS5JYVptb0VLXKA/w4iATdTosvyDy4FfqfcSMPuSPH5gvMajmuO976qj8WAGrxkUCBg5+aJrFvcR97AXlQsKrYnuZYOjFiWZqk6/sR46aFLmXtFgV2r8ryhJpQh1vVBnxuixYG8ZtAcWFsHlTU2g5ijnvxZixM4jwp6Hu1GtA5sBWzcbxi1uSfTE+nk6kTYK647bRjELOQs1uJ+UdTIx07gu5yxK1l4UbuKDkzjlGi1jTXkAWU78h66exCJ48MZevPPFDo+h0rWUE6eO4++S5kx++5A+xvQlMmyGN8DCWq2trQs/c8RyjieQ3L2U8452eP6ta/57L6a1d1lWCPFCiWdqfkScso/h0dlgnVPT/LZPS0VnzPBumld3j2TUl1AIt1gJmWA47SON+2Qh7aj4kdgfHHbmwdQsiEyIXbfRUf4b/PwnGQTE+kvIUqSFQR+FSG8glaaO0uSdjfT/QzBqI2S4LFakvdvS3GRd9G2TbM4St5pbWhDfDnhZ+2cXXvC/Ef5VJkq7vGWQHMFZ5b6lNW0Tl6g8HLeTRjKUTaWhgYE+8ouQdXWtRKC4brMZkrj1KdJCqsn6pdt1LomfOA0Zp/ET1Nv9o55tWWxCGHIgheRzSZ/3DRckTedDQzo9UwFlCYjb7lqU9RupkSIlSuVFKfZMLukTqKdkyh9cm1lo5e3DBnjHL19h524jmYa+wBRThRzudRjvQMlImrqhGbQ3P2DKd9ljCvcDuyTZ9uq+ONzt8G+SlFjAg9BXGAP5Pkt7Fv09CYPMFpK4t7Fa4hztquB2RW+Ei Fdv/vCYs 91648W/ZLipZNsvWNpRBGEc6YEOpgG7Wa5DJHxca6OkZ1LYGB+z9T/LBEsz3+2e7zSCS4S+T7rLpE6h+8keJJ5AmRx6GW6QT4pUAc1cyolUfihiMsgFAOVszLvaujD5BIZDVS8hvRwmfUEli8GAd/1fiu1WkDrDBCt5Yg50Y6KlMYHb7S8JkmO0KCBrm6WoH98l4Jax7V4TyvpA0Dja6r+3b7AEGf/jVlgwUyiVjxnyjuiVj7hc/6LXsPNoVPCmt5iJAVuj4V2BbFf/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; } From patchwork Thu Jun 27 01:00:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713673 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 714C7C27C4F for ; Thu, 27 Jun 2024 01:00:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 058D86B00B3; Wed, 26 Jun 2024 21:00:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 008506B00B4; Wed, 26 Jun 2024 21:00:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC4196B00B5; Wed, 26 Jun 2024 21:00:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BC1576B00B3 for ; Wed, 26 Jun 2024 21:00:41 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 84810A45B7 for ; Thu, 27 Jun 2024 01:00:41 +0000 (UTC) X-FDA: 82274863482.21.594A370 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id A320D1C0008 for ; Thu, 27 Jun 2024 01:00:39 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gwls8z49; spf=pass (imf21.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=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=NC4aXYcOuRdqBKxS88rxgvltp9fcYZDkhSRNom2QayU=; b=yK3JhLDilBc49E9YCOAcMbyGkZ0lqzhaS/xl6LumbQX6f6zA6K4ZKdKggfGd2xAX4UbfDC i7H6v6y2aefsiJ1fayGXsV8IclfMDwUxU38ZtYlKPOosL1Rpf4n3TmVrywYs9uUnFVbKI7 4QwF7my5eyBsMD1EO/ZyfATWtnjx8W4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gwls8z49; spf=pass (imf21.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719450027; a=rsa-sha256; cv=none; b=4lZC4XO3rpCdAW0iuV/AjoycIhiHu1jQ++FJLkeM9CAc/wxlVUvBJF0Llf3X5aMIQdXWmx FIixQRCutmRzHzbEkCAdoNtwBFC9oJ2mfmrfPRrAu3t4Jvn1h6ba+xpfvyUEFKOOEhyGy9 Qit9dJPZuqsS4xE3Z7yLZNjPkuC8Zq8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D972461D72; Thu, 27 Jun 2024 01:00:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90D1CC116B1; Thu, 27 Jun 2024 01:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450038; bh=nUcEwSwalHgLZDUtP3erKKCOQirbIJlYfFYWIa0nODA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gwls8z49Bh6Z5E9hFJjXsBHm9SIs3cp2ZvAOef69OmFSUYxfKHGAVuX7LlJovim/5 SOafG37Usb6GgKtzkT0nz61+eEqb8xuu4hcpr7Hp8uXmTD9dHHTJYoJky7EOIrUzKS xPXP68NHYs6kL5d2drislL3eImS37sOgVS5w8cIee2N1ffPopUER5AIJKrYBI9CUTa H/cCqB0eyQLUc4dFwsYoUV9Tu5W9/EX4j4y82h1eqmSF3IEsqTMRSRDxFEa8dZBvhF Bvu5d61LKLUifHm4lGDnvgWLQDNH+VloCxi+AOd2FGnxxOkPj4PKblhSCxJVwkWDiK Bezx1LULDHrag== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:22 -0400 Subject: [PATCH 02/10] fs: uninline inode_get_ctime and inode_set_ctime_to_ts MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-2-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=2576; i=jlayton@kernel.org; h=from:subject:message-id; bh=nUcEwSwalHgLZDUtP3erKKCOQirbIJlYfFYWIa0nODA=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmu8R1wuP4JGpygk6wU7fHbGTPeS3QYH6KLh UBB5zc49iOJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rgAKCRAADmhBGVaC FabcD/4mM1N+8adbvf5i1jdMSPTFwAr4F+w2yWSohHk9014i/dOuMmEmBpgENJ9AtMK5P2y/bv+ P4MY+eEzXnZ05buHgOs0fdObTEpWuMllwhp2KLU68Z2WG+m11BNai7RUYL0EBU31kOwlFLhRVbq ZTMo+6ORcgl4cWZXadf1Tn01l3772cp/xMeDoyS7kDe3MjgcYqxBwzIiLLAXLiBuqbpAXS5rrnP QEn6NCAGzt+LK1V+YTfi1YVsfMyHmROqpLaQ1XzN7SwmwPErX+ZAy/Cc5aImHBmQcaaTE9hq4Bm s6Tc+KRNHo9U75RN/LaCGPOfbOchz4QB78rXLAOEGt2GHWzBb2Djp3g81jLUpVNRajBNPmlVUdw +HqFECfXB6Mo3uUmG8pJo6++cuB9YZaGG+XVolyOHgH8THScVWV8qKc3XWA5Gph32Xgp34I0g+v rUqtcNJdxkVIThR5M0aJP7NBzNupu/cXUq4GzXMB465v30QcD9xvBcknMCWM18UgfD2x33oRuHV SNxQLu6ZlxnzkGbki8odyQYjD/cDeYIwq2kiQNrxlG+y5m7q1ypr6sfh41VWgY9xHiHNSCZOoPr ZNw8ruynyO9s8OBJfE2sgYZvJw7bRXa69ctiGQGq0u0sbxgokuiDD/3m1oody4GB9YB7nDqAI0u W20ZxJx5YHBWvEg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: 53of3oqxhp1cekwex4dobtkxboh411n6 X-Rspam-User: X-Rspamd-Queue-Id: A320D1C0008 X-Rspamd-Server: rspam02 X-HE-Tag: 1719450039-778156 X-HE-Meta: U2FsdGVkX1/wteDrt35mVYbTiC+InWbVXTRH/0LmY5wvmF3OCvQJeBMkIj1CFMJs31Z8C0/A3sQsj496WYghUze4iROj99vi182rwHhmBDoOmicw0QrVE9fUdKYZnubegOmAWkE7IX5/27VgrNsxEfGkCXHqeroA6lSCK8u/LgHJnCEAex7tbyBcqL8lJqXKzMGNHV1+TL4TFUY47/bfIG6YEcNCjKbPJL6qDSur+wuuiw2ecrIUpVeybZUyz7UnGoiD7l49tRu3XLkqSS9VW1kcXwDcr5yfzlwTWji/wT4i4jP6PKAk8uEF5fDnJy/d4d/qkqJcBD+r6U76VclVRQNTh4YWfHEOpWN8KzCnGbUiYwYNAiy6hyMzZPUVT4pkmNmtKKUzsYjQz5wGEgeEf4eOPpWNOg5vW6nn/uhH2kOI/RyLNx1jndzl6eO/1oIoj4aIE88+JU55mMcDIecEhE+ZblJtxhRCOSOkIeVPsmd8QZTGk9BPDth9CY+IjequbQALLLkXu363uO7ERO9KnOQXY0jHkkm+SLsaqxh8aU5Cp04Ds+ytIE8eYI1eZj3UpILBKb5UZRa+rvtYa5f8b/hnmNawWTzsHTQj8MmRZKTdD7qqDpwPu4kFcS7vJdJ6DY6A9sFp1uAIof0L2uTYJOzfxmCZI6W9PFohg0oAdDJ0u0mkqeNZ0+tqZ1ktD3cgP+ivKCnSgci3XId+OF6Z4RYWg93XW8m189rvjLXxHwW2Hln5nEYGTj3oEtRcRYb0zJ2EqRH/5d5GU4cNqBv5iGvYH9taF9D5i37NBvzT4XF5zvOHyQVKaluFktt8hL9L2PflhI2Xq8FFNgv2WGVG7sSyLKeJtNEobqColVE8XnvB4YFK5Fr3YieISBcPqFEtS6Hjz9ltQBguDfARa/IOLYwY+be6BLYfZZQnct7T/ue0k7VZL1y2L9A9O65s58h/ck6vC6Ht6MVmfYR/255 ycaRaglU r1GdCIOrM0GRF40un0cKphX6KWpHzW6SANWLv8K62xoSxrx7S7tKgMk6tvKaPIOcNI7OfRcVrfn47YRdkAKtpbppRonwCq4CqIVGLsjRAQsWfF1/FpyI4xHO7VYtEtPwZ4nI+AiBGMbBlxP65JM+0JgLI9zGwPKWbnRJo9zoXIM6B9zkPqvHB4oCeUzzafu7ODV9ufJguvJAFkTRY8DiYxwKSJk/kU3ffzTKIb2aQfn6kU99Mfj1/EOHvjU3+k48vT21pxhfzGXlb9yfVImf6veK86e541N99cD280fc0vUgTVIc= 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: Move both functions to fs/inode.c as they have grown a little large for inlining. Signed-off-by: Jeff Layton --- fs/inode.c | 25 +++++++++++++++++++++++++ include/linux/fs.h | 13 ++----------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index e0815acc5abb..7b0a73ed499d 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2501,6 +2501,31 @@ struct timespec64 current_time(struct inode *inode) } EXPORT_SYMBOL(current_time); +/** + * inode_get_ctime - fetch the current ctime from the inode + * @inode: inode from which to fetch ctime + * + * Grab the current ctime tv_nsec field from the inode, mask off the + * I_CTIME_QUERIED flag and return it. This is mostly intended for use by + * internal consumers of the ctime that aren't concerned with ensuring a + * fine-grained update on the next change (e.g. when preparing to store + * the value in the backing store for later retrieval). + */ +struct timespec64 inode_get_ctime(const struct inode *inode) +{ + ktime_t ctime = inode->__i_ctime; + + return ktime_to_timespec64(ctime); +} +EXPORT_SYMBOL(inode_get_ctime); + +struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts) +{ + inode->__i_ctime = ktime_set(ts.tv_sec, ts.tv_nsec); + return ts; +} +EXPORT_SYMBOL(inode_set_ctime_to_ts); + /** * inode_set_ctime_current - set the ctime to current_time * @inode: inode diff --git a/include/linux/fs.h b/include/linux/fs.h index 5139dec085f2..4b10db12725d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1608,10 +1608,8 @@ static inline struct timespec64 inode_set_mtime(struct inode *inode, return inode_set_mtime_to_ts(inode, ts); } -static inline struct timespec64 inode_get_ctime(const struct inode *inode) -{ - return ktime_to_timespec64(inode->__i_ctime); -} +struct timespec64 inode_get_ctime(const struct inode *inode); +struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts); static inline time64_t inode_get_ctime_sec(const struct inode *inode) { @@ -1623,13 +1621,6 @@ static inline long inode_get_ctime_nsec(const struct inode *inode) 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 = ktime_set(ts.tv_sec, ts.tv_nsec); - return ts; -} - /** * inode_set_ctime - set the ctime in the inode * @inode: inode in which to set the ctime From patchwork Thu Jun 27 01:00:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713675 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 80766C30653 for ; Thu, 27 Jun 2024 01:00:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62A4A6B00B6; Wed, 26 Jun 2024 21:00:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5AE666B00B7; Wed, 26 Jun 2024 21:00:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44ED36B00B8; Wed, 26 Jun 2024 21:00:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1A92A6B00B6 for ; Wed, 26 Jun 2024 21:00:44 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C23AFC1825 for ; Thu, 27 Jun 2024 01:00:43 +0000 (UTC) X-FDA: 82274863566.20.519FB18 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 02AF540022 for ; Thu, 27 Jun 2024 01:00:41 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ksKFkOIP; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 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=1719450023; 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=CEbmpuovWZg11HIw93Qn3x7IEhnefIXy04xLDYqx/cw=; b=FcPlm4PQOrxiYuSMk54onlqQjZqi54FI/X4rQbapbg64d5HPg7kjOyWokjX4f0uh6fqeqK xVeluavzOIHB0ji/52Xr9AG2uaIomqmQzpKDHagdfhybCFFpgXtJzvzFJYJIZ0RTKFTBK8 MBI1fguaeXqrcSxjfObQFcfjy+AcEJ4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719450023; a=rsa-sha256; cv=none; b=L/YMAJhVEnJ13vZ0nuzmuDhwEmqtJWAiS+XkSlo/U38ihOJxuDu6SVilN9MmbDwXFKxeZs 5cJG/opVX8BQK5x8Hf+4a3QK9RlrdkhCZYK5AFIhBUOtJ4a/rw11ch2mBnRBFMtrnS5GGO 41NG2b/6TQDlNu9frPgmL0adeLzWIzI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ksKFkOIP; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 262DF61D74; Thu, 27 Jun 2024 01:00:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAC7AC4AF0B; Thu, 27 Jun 2024 01:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450040; bh=TvAqWM+1osikcEDt9i0N4WD9vik81z9fLBMKtBzROY8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ksKFkOIPD8B+IxtigbTwAuwg7Zi3C4sksnJDk2qwCJDFyBnx1CPl9lxXsmpzlgulQ oLA6EsYD01q3aGiBq4BfIGKTX52cJ08PoKvb/WjeTLD7aXGncsmrJ5iQqkIs6koBN5 PntCYREhRs+JdmWkpQPu4EYd2sOl9h5/ef20IY8uXouz6gRCbIZn6/h+Cu9qX++hGI wWq1wfUzUDxJm8GlIJ7HqUjuKqY4jEcJInvTHEOkFgVNG8iGkrKAsAUbep1WEVNkDa 7//UcWBy59SpfzyrHYM9wjhLB9RsJ7Qt0zcefYSVywwoenGVR3Jq4SIO75qebeN1JB Cb1MI9Oqjs3LQ== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:23 -0400 Subject: [PATCH 03/10] fs: tracepoints for inode_needs_update_time and inode_set_ctime_to_ts MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-3-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=3425; i=jlayton@kernel.org; h=from:subject:message-id; bh=TvAqWM+1osikcEDt9i0N4WD9vik81z9fLBMKtBzROY8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmu38o34Gc3uLqCC/KtRitsdQUwQQbBScUNZ xY97hHdyEiJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rgAKCRAADmhBGVaC FUP6EACD4iVg9GXP9iA3Hn8lRNdHlGJ6Zy6M9ZhDcO6x6OiRZzdFfP0NgHKsFPdn2OnfETkahlZ GUYNkkiTUcbmS8kx8uGOv0t2By1BwU5Gig2xbUvCChWSNLlpJhfcSACoiyd3Z59dwnqyIlknHWL 8lAD6m4QwwRpgRn8dz96Nbern/BwQ0MwgiSe7fxAD3xczDWM9eA7g9oxyCUy0x4Cgm+whV328Z9 hVdTS7f3eBcfHjWyeP1EnceVlTAsZs55rwZp/uq53sUR8IZE31t8KK3XM2rOrGg6SXH51CWroSb 45P0mbHembc5ibT3BDy30BAAEXJscI/6aAaL1BfiROPo1JseAG/df7eQmzoAmTlFy9t+UvqCnhd 7c2goYMJrTEA3tUyWUa0RwqW6+bDSu3Gv2LxV4qNB0WaQF/rIGLZ6hdnysOdxXn80tLhbfatHuX YGY/56WUTpv9/Z5ooc6sHzggBFFcg0dFcPodRFmWgU4xTPL/xHRvRCpRSMLnPdW7mv4n3eswylP Q6K9QndkigtGk0lmq2U3HKGnXQR0K5wAJa9j1z1I3itPf1HVhdOxbBdQo5JOWaCOpXwovRowb4v pAEjUph2heWJ8O4jIFjj59Ct5FN1CInMMqtcROERa4vnmgpo4B2FVbZ8yTNqEDCkpdZaG2hby5r 9MAyoeJnmKNLXKw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 02AF540022 X-Stat-Signature: 534nmrzxwn5dktfhwbom8insc4iiuq95 X-Rspam-User: X-HE-Tag: 1719450041-57208 X-HE-Meta: U2FsdGVkX1/HWXdl2eLw/uX6ErK0Zi4RclsYNLRJQDjz1R2BcudxDmtn5RmeDAQNirIKXjRr2Ema5gG7u2eCeJeGIyTu5HAyWsbSRgNMOGoFRZcn+qepTHk4SZkN939zUGcxJ2vxgc0Yv25Zy44zIfiVgcXLT8ugCWmm/ydULx9K/dLPz53v5i3dGkohnO49uZT1Q54mLd13vRQpS+X+OZz1oyGZkgn4pFpBB/bxu0b1w448a9YByc4E57Z7W75W5WAsxpH216yU0Ra6rJY2OdyWlkZXcn5Mxt1jUm8eGjEpHWpocmvUOpCAiST6MqJNBmtLKdYL2y3Rlm8MwhXMY2+dgbvvt26N5BbNn0tP3Hl2X/r8fkSNyksDEZbgUVgW1GPEkWDF1c33OFVKj/kpcpq2L3958ZY4UgUzQCUblmNs8TzmWDMgXOTLcMT9xtoMjhhbT8aoBhxHtM2xMbEKWWgTcfC4KjsmNcUE9v1zcXPpRhFGdedoATpSLMt/tScY+nit6kEyvK7Szu42yTUvz67ImfpRv45g3ZvWKUkrMVAPzdnO1TRokf7P715Yery1KJfmIyLj4/KSw/PqUSlC+HBedeRUe4MtIq7hZIfba2oyMv0LqQSogv7upRJf1snMW5G968S7JGoAUJp54CLGGInUgKp6ltMA8pk+yOjgOp3JijMKPPlocnw9kwWGt+/jVPfo54MfpSBDPj/KGnq4L8dj3c43elT93oqPo3+ZSIrjAMtu3687dLsZPxYLoEif1v0jX5cgvJiNW3V3BGlPQNfMdW5/Pvz/jSdygbuBlaSLzr6pXlkD8QykRWab5zYu50dxoN0DBHnFn+F4jf7J+UJTX5AHCDSY1LNa4LI3RXU15R6027BcTsoH5jeM64PChOh3RUny9MDyq6Y+yS4XcgwKOpq6YZrEt2pcIi/bhZlEvuWDoZZF65fT/QnKcb+2BAOs5MMx2WcPR+fi5X+ ESJvtsq2 qhj8IxNmp1gsFwwcYBpE98ClUvHO8C11x6OyYZSnt7JYW+hqyk0GTMuQzqA4uNMkjKe9mwBwNTzDPdW9O3zFxtnoqVP5ulno01ni3ImpsV3YJCcUwI06E/FtMLiN+o19Qd5QWY4usFg5iDrEmJwiz+lLz+keUHNJuGbp8tuI5qr65xDvSMZfIb8Wq2zzp8PEQGTaF/R4FCEpPwBlY94cA0Ol3tLTjoLJbYdKZSdyGc9S5BGC5eCK2+fVUk436bfzG2AgGK/kDUt53vWMi4JaNDIdFtgyTRG81iS8fy/iRfHXSgPs2sp3+Iej9saUsCFWc8Ssxvn7Ap1Y/j9Q= 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: Add a new tracepoint for when we're testing whether the timestamps need updating, and around the update itself. Signed-off-by: Jeff Layton --- fs/inode.c | 4 +++ include/trace/events/timestamp.h | 76 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/fs/inode.c b/fs/inode.c index 7b0a73ed499d..5d2b0dfe48c3 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -22,6 +22,8 @@ #include #include #include +#define CREATE_TRACE_POINTS +#include #include "internal.h" /* @@ -2096,6 +2098,7 @@ static int inode_needs_update_time(struct inode *inode) if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode)) sync_it |= S_VERSION; + trace_inode_needs_update_time(inode, &now, &ts, sync_it); return sync_it; } @@ -2522,6 +2525,7 @@ EXPORT_SYMBOL(inode_get_ctime); struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts) { inode->__i_ctime = ktime_set(ts.tv_sec, ts.tv_nsec); + trace_inode_set_ctime_to_ts(inode, &ts); return ts; } EXPORT_SYMBOL(inode_set_ctime_to_ts); diff --git a/include/trace/events/timestamp.h b/include/trace/events/timestamp.h new file mode 100644 index 000000000000..35ff875d3800 --- /dev/null +++ b/include/trace/events/timestamp.h @@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM timestamp + +#if !defined(_TRACE_TIMESTAMP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_TIMESTAMP_H + +#include +#include + +TRACE_EVENT(inode_needs_update_time, + TP_PROTO(struct inode *inode, + struct timespec64 *now, + struct timespec64 *ctime, + int sync_it), + + TP_ARGS(inode, now, ctime, sync_it), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(time64_t, now_sec) + __field(time64_t, ctime_sec) + __field(long, now_nsec) + __field(long, ctime_nsec) + __field(int, sync_it) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->sync_it = sync_it; + __entry->now_sec = now->tv_sec; + __entry->ctime_sec = ctime->tv_sec; + __entry->now_nsec = now->tv_nsec; + __entry->ctime_nsec = ctime->tv_nsec; + __entry->sync_it = sync_it; + ), + + TP_printk("ino=%d:%d:%ld sync_it=%d now=%llu.%ld ctime=%llu.%lu", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, + __entry->sync_it, + __entry->now_sec, __entry->now_nsec, + __entry->ctime_sec, __entry->ctime_nsec + ) +); + +TRACE_EVENT(inode_set_ctime_to_ts, + TP_PROTO(struct inode *inode, + struct timespec64 *ts), + + TP_ARGS(inode, ts), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(time64_t, ts_sec) + __field(long, ts_nsec) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->ts_sec = ts->tv_sec; + __entry->ts_nsec = ts->tv_nsec; + ), + + TP_printk("ino=%d:%d:%ld ts=%llu.%lu", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, + __entry->ts_sec, __entry->ts_nsec + ) +); +#endif /* _TRACE_TIMESTAMP_H */ + +/* This part must be outside protection */ +#include From patchwork Thu Jun 27 01:00:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713676 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 3968DC27C4F for ; Thu, 27 Jun 2024 01:00:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 625496B00BA; Wed, 26 Jun 2024 21:00:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D4FB6B00B8; Wed, 26 Jun 2024 21:00:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D99A6B00BA; Wed, 26 Jun 2024 21:00:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 18BC06B00B7 for ; Wed, 26 Jun 2024 21:00:47 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 45886A187B for ; Thu, 27 Jun 2024 01:00:46 +0000 (UTC) X-FDA: 82274863692.03.E657237 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id 6C751120008 for ; Thu, 27 Jun 2024 01:00:44 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ADt2zPJQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719450031; a=rsa-sha256; cv=none; b=iQtfhTCDha56xaV/Ti0K3JhD2/CVWcOwmCTzjM/AqlurVFqmYEoYHTamStDNO7h4pM1hg+ TdTDblTQKveUe+0lqmi+NDkkKwvHzFPaufPIWUtv4QRGmelVGJPbpnclh7XR3n86Ouou3+ CpbkHoA3V9OgRUkte+NAh6CWL+ghcJY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ADt2zPJQ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 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=1719450031; 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=rwvoJAWQPmTJKGlJ2r2QwKs8qEymlTktT9cBxbYtTfc=; b=PZVhgcZoNyo8ucxM1ocQkUxHO47GRUwFat9PeYBd7UTO9+RYUd2BMb4+gGP4A1w5Fn5WyW HQLB4jIXecGxzl/QHs2wfGKH/3Y8KhSFgKfVFIEQGKnzL6mALoOEo5lvCeMKoXp06FzCjv wbRYnNW4ZrJTnQo5wzcug7QMbs/WFmk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7E11661D5F; Thu, 27 Jun 2024 01:00:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 295CEC4AF0A; Thu, 27 Jun 2024 01:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450043; bh=Zzq8jWA/Kk2bPUKmgRBlJrGF4tQqJYIhxawzWzrrb7k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ADt2zPJQvrK/Z5fpE6uaX6AXnERdqG4eGSf0nq+i+NyUhEeaI5RBiscGCF7PcxzsY kGi3BwDmIsqCcO0u/tbyF/QUVx2Ztb3yydX6ziQTWYU+kmWciEUY1PYrHNgZCkoyvx 4rftKezzUBBuMdLDoBsMMhnSnjF8nxYR8wfOXl1teu3wzBx57iVF92E672SCTgpL62 VJffhtyEZm0YaiDsKfToKTtS0lMUMIe6gFtNghCX6mooUugMALq3KB9eA9JTF9PyN+ sifX1JkcmGX0kJkC+15WGs2RI3r1m6bGovGIbSh+SNdK0vPQPCcfGYZK4lRg/oUH6k oUHWZSUUh7VoQ== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:24 -0400 Subject: [PATCH 04/10] fs: add infrastructure for multigrain timestamps MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-4-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=18627; i=jlayton@kernel.org; h=from:subject:message-id; bh=Zzq8jWA/Kk2bPUKmgRBlJrGF4tQqJYIhxawzWzrrb7k=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmueVUy3Y677ALjjDWAZtpp0SEirlyEc31s0 J/q6NUTdRKJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rgAKCRAADmhBGVaC FfALD/9W/bdTpCKKPP/NV+SRRKOj6gtf6ugtcDDsL2yKb+eab98MVNCwmmYoPy4sBsMjVsETooo uyepyoWqvIbUluK986om+DWzVaX+IXmAoaft4PLjAefN3X9aqehbYgGMZ6Zg3Y+x/C5o1sKvKgn cn+xl4A7jcXdKERstTF6bNXIvijlh+ZwctNSMsfAj1p1QNE6sUuorjPBGU22yTcBGw8pgx9hdf3 XEBmhgjNr/bCE6SldYPlOROainOTpCkOUd+OlDnDOIbvZHuHfnLK1MXYTXGkR/j9swfkJ6tMrMa JzqTamLsZJJO+FTdMxT5k3k7Z2UrUk80wXss3l1xDUnHA2ZHd5ZrHImbOTwtvf7h0yT6L9Av+EO akhiZ5FvnsZhLTD7ZX7yUq/ZqvqRK6VN/IG+d+sJzzNkr6qZu0iZ0nANh9BZYqHMTL9gJ6kgO+X sG7LcjiaDGhWQjwa3sZu+NiUPdd78fnU2SWCtKIbCgUbTqX2OEnPbTBLqb3k/pvIJTibGKPmUTf fghk7eBp0nXBF3zSpno3f/drsspfUEU2GnFKkJCHAR9NOAel4Dd1tGR+BZuagf2YD1DtEvzp5tQ c5U44IRhmv0GKUe7RMmv6nQ4lBlyeNn31z2ZrDcFGCYlxaI5xJt5dZ+wxAMAxc5b3OFqExeuKMH DVLLoL5tXHQxkxQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6C751120008 X-Stat-Signature: ci98bgo3oq7kirwz6hierrxc31wywcit X-Rspam-User: X-HE-Tag: 1719450044-618052 X-HE-Meta: U2FsdGVkX18kDuXCyozWgeVgZBzbvLCKQE2qiGt6RtwASxenfi1Ai00TMiHTJ5+h2ZCy9K9Jq0EXDYIP+S++IqlxV2umQ2AzngyU9D6ioq2XTtSsm9MxuZ8rXYQ5WPj4mYGICBxSpr/ABVZ6YaLvBpnhqpV6QLHI3BKbEMcHqHKqB4hFeXcDkBaOiS+mDEfwTqagiiyzzN3m85OMlDth59q+gB1DeYJ8wgcUQc5ROoYRakwu6/L1e3UPBK5siWf/+bn8ELEvly81L899Cd3B7V7Z+Hm9tPbNCZejUekCQNtTGe1eLHupGCN5rYeEgp1LNMD5j8Vk4shAmxFYPeC7x4edyf8KEocvJTRn2oCiTj8AQf6CMqg65owKtQUABo3xJKo2ZxE0P0fzENqIxMGOxCiysFmKO8UA540HEfva+7Jm3Fq/xHechLMLmmk30LUjPtDBuhcZ4dWfrqmtrxM0Ma+JjAlA8EdhawU/Mw8BP7RwKDCYhxia8fjwV7+GdHop7EQ4/dXCeQIl2i4hb6fx/hAgjcmWtogEYpYn5zYcOyZHv8lQlp8Nvd+JUE2dd5Jk3+oepBL9fua2CNg5KTm6yHuJKOMRrIvEZnipRQ6EyRZvfdsRtyAoVRwGDGFVrmb69+nBGgmxlYFSf9fBmVWAjduYfFZdGTuWZNiXhbBdl30Y5uT8VifDfe20c7mmjUy2LnZu8+jIq+xu4EkEb1sLr2lWAYv4BWZppVr+6bW02P6P/4YBvMvkQVZEzJih5yGTMJQXo6xfKy7/G1EAJH051aYlK49uqGP/7Yca5LiioMFHDm9A2g13HCMSo4U4rw/mNbK+LZo90B5eGcQ1MLXFWUefECJ6Y7Hw1bAGaErqT3aYilLPajxiDgvWd/o3Xrmh2QO94WYolVVjs6plJsGYulcRMq0VZjZ9GdfUzBo9WqR0wyImZ17XQxb5xCvs0OW9NPGbcZgPuaQvGYLGbJ/ AmW8JhFL seyYixoZzhWIdqHq7HvDcAG7qYy7TW8aDtDQmjAq25Q0QZ+9nJS8jfjsg1amCjOAy60TPqRtIKRPajeAoUPaE3B8C4v9+eIy25FXr5isagIkaXu/9OM69WoHR6v5dQiRMT4Vfh2PTsVxImZZV65ckSRYxK3zLoKlTbclwZQPA5czJCv2JJiz5dioudiofbSXDKTJJDIKSbrmEOVcBe/wFRmXSFMUZ5BM79nQW3pVFJzsEkzmoC9ZAhujk0w== 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 VFS always uses coarse-grained timestamps when updating the ctime and mtime after a change. This has the benefit of allowing filesystems to optimize away a lot metadata updates, down to around 1 per jiffy, even when a file is under heavy writes. Unfortunately, this has always been an issue when we're exporting via NFSv3, which relies on timestamps to validate caches. A lot of changes can happen in a jiffy, so timestamps aren't sufficient to help the client decide to invalidate the cache. Even with NFSv4, a lot of exported filesystems don't properly support a change attribute and are subject to the same problems with timestamp granularity. Other applications have similar issues with timestamps (e.g backup applications). If we were to always use fine-grained timestamps, that would improve the situation, but that becomes rather expensive, as the underlying filesystem would have to log a lot more metadata updates. What we need is a way to only use fine-grained timestamps when they are being actively queried. Now that the ctime is stored as a ktime_t, we can sacrifice the lowest bit in the word to act as a flag marking whether the current timestamp has been queried via stat() or the like. This solves the problem of being able to distinguish the timestamp between updates, but introduces a new problem: it's now possible for a file being changed to get a fine-grained timestamp and then a file that was altered later to get a coarse-grained one that appears older than the earlier fine-grained time. To remedy this, keep a global ktime_t value that acts as a timestamp floor. When we go to stamp a file, we first get the latter of the current floor value and the current coarse-grained time (call this "now"). If the current inode ctime hasn't been queried then we just attempt to stamp it with that value using a cmpxchg() operation. If it has been queried, then first see whether the current coarse time appears later than what we have. If it does, then we accept that value. If it doesn't, then we get a fine-grained time and try to swap that into the global floor. Whether that succeeds or fails, we take the resulting floor time and try to swap that into the ctime. There is still one remaining problem: All of this works as long as the realtime clock is monotonically increasing. If the clock ever jumps backwards, then we could end up in a situation where the floor value is "stuck" far in advance of the clock. To remedy this, sanity check the floor value and if it's more than 6ms (~2 jiffies) ahead of the current coarse-grained clock, disregard the floor value, and just accept the current coarse-grained clock. Filesystems opt into this by setting the FS_MGTIME fstype flag. One caveat: those that do will always present ctimes that have the lowest bit unset, even when the on-disk ctime has it set. Signed-off-by: Jeff Layton --- fs/inode.c | 168 +++++++++++++++++++++++++++++++++------ fs/stat.c | 39 ++++++++- include/linux/fs.h | 30 +++++++ include/trace/events/timestamp.h | 97 ++++++++++++++++++++++ 4 files changed, 306 insertions(+), 28 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 5d2b0dfe48c3..12790a26102c 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -62,6 +62,8 @@ static unsigned int i_hash_shift __ro_after_init; static struct hlist_head *inode_hashtable __ro_after_init; static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock); +/* Don't send out a ctime lower than this (modulo backward clock jumps). */ +static __cacheline_aligned_in_smp ktime_t ctime_floor; /* * Empty aops. Can be used for the cases where the user does not * define any of the address_space operations. @@ -2077,19 +2079,86 @@ int file_remove_privs(struct file *file) } EXPORT_SYMBOL(file_remove_privs); +/* + * The coarse-grained clock ticks once per jiffy (every 2ms or so). If the + * current floor is >6ms in the future, assume that the clock has jumped + * backward. + */ +#define CTIME_FLOOR_MAX_NS 6000000 + +/** + * coarse_ctime - return the current coarse-grained time + * @floor: current ctime_floor value + * + * Get the coarse-grained time, and then determine whether to + * return it or the current floor value. Returns the later of the + * floor and coarse grained time, unless the floor value is too + * far into the future. If that happens, assume the clock has jumped + * backward, and that the floor should be ignored. + */ +static ktime_t coarse_ctime(ktime_t floor) +{ + ktime_t now = ktime_get_coarse_real() & ~I_CTIME_QUERIED; + + /* If coarse time is already newer, return that */ + if (ktime_before(floor, now)) + return now; + + /* Ensure floor is not _too_ far in the future */ + if (ktime_after(floor, now + CTIME_FLOOR_MAX_NS)) + return now; + + return floor; +} + +/** + * current_time - Return FS time (possibly fine-grained) + * @inode: inode. + * + * Return the current time truncated to the time granularity supported by + * the fs, as suitable for a ctime/mtime change. If the ctime is flagged + * as having been QUERIED, get a fine-grained timestamp. + */ +struct timespec64 current_time(struct inode *inode) +{ + ktime_t ctime, floor = smp_load_acquire(&ctime_floor); + ktime_t now = coarse_ctime(floor); + struct timespec64 now_ts = ktime_to_timespec64(now); + + if (!is_mgtime(inode)) + goto out; + + /* If nothing has queried it, then coarse time is fine */ + ctime = smp_load_acquire(&inode->__i_ctime); + if (ctime & I_CTIME_QUERIED) { + /* + * If there is no apparent change, then + * get a fine-grained timestamp. + */ + if ((now | I_CTIME_QUERIED) == ctime) { + ktime_get_real_ts64(&now_ts); + now_ts.tv_nsec &= ~I_CTIME_QUERIED; + } + } +out: + return timestamp_truncate(now_ts, inode); +} +EXPORT_SYMBOL(current_time); + static int inode_needs_update_time(struct inode *inode) { + struct timespec64 now, ts; int sync_it = 0; - struct timespec64 now = current_time(inode); - struct timespec64 ts; /* First try to exhaust all avenues to not sync */ if (IS_NOCMTIME(inode)) return 0; + now = current_time(inode); + ts = inode_get_mtime(inode); if (!timespec64_equal(&ts, &now)) - sync_it = S_MTIME; + sync_it |= S_MTIME; ts = inode_get_ctime(inode); if (!timespec64_equal(&ts, &now)) @@ -2485,25 +2554,6 @@ struct timespec64 timestamp_truncate(struct timespec64 t, struct inode *inode) } EXPORT_SYMBOL(timestamp_truncate); -/** - * current_time - Return FS time - * @inode: inode. - * - * Return the current time truncated to the time granularity supported by - * the fs. - * - * Note that inode and inode->sb cannot be NULL. - * Otherwise, the function warns and returns time without truncation. - */ -struct timespec64 current_time(struct inode *inode) -{ - struct timespec64 now; - - ktime_get_coarse_real_ts64(&now); - return timestamp_truncate(now, inode); -} -EXPORT_SYMBOL(current_time); - /** * inode_get_ctime - fetch the current ctime from the inode * @inode: inode from which to fetch ctime @@ -2518,12 +2568,18 @@ struct timespec64 inode_get_ctime(const struct inode *inode) { ktime_t ctime = inode->__i_ctime; + if (is_mgtime(inode)) + ctime &= ~I_CTIME_QUERIED; return ktime_to_timespec64(ctime); } EXPORT_SYMBOL(inode_get_ctime); struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts) { + trace_inode_set_ctime_to_ts(inode, &ts); + + if (is_mgtime(inode)) + ts.tv_nsec &= ~I_CTIME_QUERIED; inode->__i_ctime = ktime_set(ts.tv_sec, ts.tv_nsec); trace_inode_set_ctime_to_ts(inode, &ts); return ts; @@ -2535,14 +2591,74 @@ EXPORT_SYMBOL(inode_set_ctime_to_ts); * @inode: inode * * Set the inode->i_ctime to the current value for the inode. Returns - * the current value that was assigned to i_ctime. + * the current value that was assigned to i_ctime. If this is a not + * multigrain inode, then we just set it to whatever the coarse time is. + * + * If it is multigrain, then we first see if the coarse-grained + * timestamp is distinct from what we have. If so, then we'll just use + * that. If we have to get a fine-grained timestamp, then do so, and + * try to swap it into the floor. We accept the new floor value + * regardless of the outcome of the cmpxchg. After that, we try to + * swap the new value into __i_ctime. Again, we take the resulting + * ctime, regardless of the outcome of the swap. */ struct timespec64 inode_set_ctime_current(struct inode *inode) { - struct timespec64 now = current_time(inode); + ktime_t ctime, now, cur, floor = smp_load_acquire(&ctime_floor); + + now = coarse_ctime(floor); - inode_set_ctime_to_ts(inode, now); - return now; + /* Just return that if this is not a multigrain fs */ + if (!is_mgtime(inode)) { + inode->__i_ctime = now; + goto out; + } + + /* + * We only need a fine-grained time if someone has queried it, + * and the current coarse grained time isn't later than what's + * already there. + */ + ctime = smp_load_acquire(&inode->__i_ctime); + if ((ctime & I_CTIME_QUERIED) && !ktime_after(now, ctime & ~I_CTIME_QUERIED)) { + ktime_t old; + + /* Get a fine-grained time */ + now = ktime_get_real() & ~I_CTIME_QUERIED; + + /* + * If the cmpxchg works, we take the new floor value. If + * not, then that means that someone else changed it after we + * fetched it but before we got here. That value is just + * as good, so keep it. + */ + old = cmpxchg(&ctime_floor, floor, now); + trace_ctime_floor_update(inode, floor, now, old); + if (old != floor) + now = old; + } +retry: + /* Try to swap the ctime into place. */ + cur = cmpxchg(&inode->__i_ctime, ctime, now); + trace_ctime_inode_update(inode, ctime, now, cur); + + /* If swap occurred, then we're done */ + if (cur != ctime) { + /* + * Was the change due to someone marking the old ctime QUERIED? + * If so then retry the swap. This can only happen once since + * the only way to clear I_CTIME_QUERIED is to stamp the inode + * with a new ctime. + */ + if (!(ctime & I_CTIME_QUERIED) && (ctime | I_CTIME_QUERIED) == cur) { + ctime = cur; + goto retry; + } + /* Otherwise, take the new ctime */ + now = cur & ~I_CTIME_QUERIED; + } +out: + return timestamp_truncate(ktime_to_timespec64(now), inode); } EXPORT_SYMBOL(inode_set_ctime_current); diff --git a/fs/stat.c b/fs/stat.c index 6f65b3456cad..7e9bd16b553b 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -22,10 +22,39 @@ #include #include +#include #include "internal.h" #include "mount.h" +/** + * fill_mg_cmtime - Fill in the mtime and ctime and flag ctime as QUERIED + * @stat: where to store the resulting values + * @request_mask: STATX_* values requested + * @inode: inode from which to grab the c/mtime + * + * Given @inode, grab the ctime and mtime out if it and store the result + * in @stat. When fetching the value, flag it as queried so the next write + * will ensure a distinct timestamp. + */ +void fill_mg_cmtime(struct kstat *stat, u32 request_mask, struct inode *inode) +{ + atomic_long_t *pc = (atomic_long_t *)&inode->__i_ctime; + + /* If neither time was requested, then don't report them */ + if (!(request_mask & (STATX_CTIME|STATX_MTIME))) { + stat->result_mask &= ~(STATX_CTIME|STATX_MTIME); + return; + } + + stat->mtime.tv_sec = inode->i_mtime_sec; + stat->mtime.tv_nsec = inode->i_mtime_nsec; + stat->ctime = ktime_to_timespec64(atomic_long_fetch_or(I_CTIME_QUERIED, pc) & + ~I_CTIME_QUERIED); + trace_fill_mg_cmtime(inode, atomic_long_read(pc)); +} +EXPORT_SYMBOL(fill_mg_cmtime); + /** * generic_fillattr - Fill in the basic attributes from the inode struct * @idmap: idmap of the mount the inode was found from @@ -58,8 +87,14 @@ void generic_fillattr(struct mnt_idmap *idmap, u32 request_mask, stat->rdev = inode->i_rdev; stat->size = i_size_read(inode); stat->atime = inode_get_atime(inode); - stat->mtime = inode_get_mtime(inode); - stat->ctime = inode_get_ctime(inode); + + if (is_mgtime(inode)) { + fill_mg_cmtime(stat, request_mask, inode); + } else { + stat->ctime = inode_get_ctime(inode); + stat->mtime = inode_get_mtime(inode); + } + stat->blksize = i_blocksize(inode); stat->blocks = inode->i_blocks; diff --git a/include/linux/fs.h b/include/linux/fs.h index 4b10db12725d..5694cb6c4dc2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1608,6 +1608,23 @@ static inline struct timespec64 inode_set_mtime(struct inode *inode, return inode_set_mtime_to_ts(inode, ts); } +/* + * Multigrain timestamps + * + * Conditionally use fine-grained ctime and mtime timestamps when there + * are users actively observing them via getattr. The primary use-case + * for this is NFS clients that use the ctime to distinguish between + * different states of the file, and that are often fooled by multiple + * operations that occur in the same coarse-grained timer tick. + * + * We use the least significant bit of the ktime_t to track the QUERIED + * flag. This means that filesystems with multigrain timestamps effectively + * have 2ns resolution for the ctime, even if they advertise 1ns s_time_gran. + */ +#define I_CTIME_QUERIED (1LL) + +static inline bool is_mgtime(const struct inode *inode); + struct timespec64 inode_get_ctime(const struct inode *inode); struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts); @@ -2477,6 +2494,7 @@ struct file_system_type { #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ #define FS_DISALLOW_NOTIFY_PERM 16 /* Disable fanotify permission events */ #define FS_ALLOW_IDMAP 32 /* FS has been updated to handle vfs idmappings. */ +#define FS_MGTIME 64 /* FS uses multigrain timestamps */ #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ int (*init_fs_context)(struct fs_context *); const struct fs_parameter_spec *parameters; @@ -2500,6 +2518,17 @@ struct file_system_type { #define MODULE_ALIAS_FS(NAME) MODULE_ALIAS("fs-" NAME) +/** + * is_mgtime: is this inode using multigrain timestamps + * @inode: inode to test for multigrain timestamps + * + * Return true if the inode uses multigrain timestamps, false otherwise. + */ +static inline bool is_mgtime(const struct inode *inode) +{ + return inode->i_sb->s_type->fs_flags & FS_MGTIME; +} + extern struct dentry *mount_bdev(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, int (*fill_super)(struct super_block *, void *, int)); @@ -3234,6 +3263,7 @@ extern void page_put_link(void *); extern int page_symlink(struct inode *inode, const char *symname, int len); extern const struct inode_operations page_symlink_inode_operations; extern void kfree_link(void *); +void fill_mg_cmtime(struct kstat *stat, u32 request_mask, struct inode *inode); void generic_fillattr(struct mnt_idmap *, u32, struct inode *, struct kstat *); void generic_fill_statx_attr(struct inode *inode, struct kstat *stat); extern int vfs_getattr_nosec(const struct path *, struct kstat *, u32, unsigned int); diff --git a/include/trace/events/timestamp.h b/include/trace/events/timestamp.h index 35ff875d3800..1f71738aa38c 100644 --- a/include/trace/events/timestamp.h +++ b/include/trace/events/timestamp.h @@ -8,6 +8,78 @@ #include #include +TRACE_EVENT(ctime_floor_update, + TP_PROTO(struct inode *inode, + ktime_t old, + ktime_t new, + ktime_t cur), + + TP_ARGS(inode, old, new, cur), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(ktime_t, old) + __field(ktime_t, new) + __field(ktime_t, cur) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->old = old; + __entry->new = new; + __entry->cur = cur; + ), + + TP_printk("ino=%d:%d:%lu old=%llu.%lu new=%llu.%lu cur=%llu.%lu swp=%c", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, + ktime_to_timespec64(__entry->old).tv_sec, + ktime_to_timespec64(__entry->old).tv_nsec, + ktime_to_timespec64(__entry->new).tv_sec, + ktime_to_timespec64(__entry->new).tv_nsec, + ktime_to_timespec64(__entry->cur).tv_sec, + ktime_to_timespec64(__entry->cur).tv_nsec, + (__entry->old == __entry->cur) ? 'Y' : 'N' + ) +); + +TRACE_EVENT(ctime_inode_update, + TP_PROTO(struct inode *inode, + ktime_t old, + ktime_t new, + ktime_t cur), + + TP_ARGS(inode, old, new, cur), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(ktime_t, old) + __field(ktime_t, new) + __field(ktime_t, cur) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->old = old; + __entry->new = new; + __entry->cur = cur; + ), + + TP_printk("ino=%d:%d:%ld old=%llu.%ld new=%llu.%ld cur=%llu.%ld swp=%c", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, + ktime_to_timespec64(__entry->old).tv_sec, + ktime_to_timespec64(__entry->old).tv_nsec, + ktime_to_timespec64(__entry->new).tv_sec, + ktime_to_timespec64(__entry->new).tv_nsec, + ktime_to_timespec64(__entry->cur).tv_sec, + ktime_to_timespec64(__entry->cur).tv_nsec, + (__entry->old == __entry->cur ? 'Y' : 'N') + ) +); + TRACE_EVENT(inode_needs_update_time, TP_PROTO(struct inode *inode, struct timespec64 *now, @@ -70,6 +142,31 @@ TRACE_EVENT(inode_set_ctime_to_ts, __entry->ts_sec, __entry->ts_nsec ) ); + +TRACE_EVENT(fill_mg_cmtime, + TP_PROTO(struct inode *inode, + ktime_t ctime), + + TP_ARGS(inode, ctime), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(ktime_t, ctime) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->ctime = ctime; + ), + + TP_printk("ino=%d:%d:%ld ctime=%llu.%lu", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, + ktime_to_timespec64(__entry->ctime).tv_sec, + ktime_to_timespec64(__entry->ctime).tv_nsec + ) +); #endif /* _TRACE_TIMESTAMP_H */ /* This part must be outside protection */ From patchwork Thu Jun 27 01:00:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713677 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 9047FC30653 for ; Thu, 27 Jun 2024 01:00:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 191FB6B00B8; Wed, 26 Jun 2024 21:00:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1420D6B00BB; Wed, 26 Jun 2024 21:00:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAF896B00BC; Wed, 26 Jun 2024 21:00:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C16A06B00B8 for ; Wed, 26 Jun 2024 21:00:51 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 66E3FC1868 for ; Thu, 27 Jun 2024 01:00:51 +0000 (UTC) X-FDA: 82274863902.03.39679BD Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id ECE331C0005 for ; Thu, 27 Jun 2024 01:00:48 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B2qBsDkL; spf=pass (imf18.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719450040; 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=dqvbR/ksUpOrrPO+D5G3n1uKBNVPH7yx2hwqQYkG+mc=; b=6HjEE4EVue/CpyQ5DjaUwN1N0qLiGmK/qNlJI0AghvtrHCrSNoEmZwO6uV+TNj84mETwYj rr37KP6Kd5eezWjGZzoVFf0sL6wi/OU8vttfnzlQKBLFdBqYtLTTztRaxZ8IPghCwqoF1h 9V80R/aRJ0fR9iQ2wCo+4aepBjnicMo= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B2qBsDkL; spf=pass (imf18.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719450040; a=rsa-sha256; cv=none; b=KgpK1JO0NYDzF5ZrWmDZyAiomq6kisR/fywodSV3jL8lO3NR6DMU3TpktdYkRCDdNgPPtH +Mgm2ovLuw+69jYiSPQPLz+OeqOvl4wx5XxaJV0Fgove0KFLnKXluPhhX0XmyGDrSay8gO 6hp2PBeknFHnCZcz+mTp84px2rNhe/U= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 41C38CE2D2C; Thu, 27 Jun 2024 01:00:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FBB2C4AF0B; Thu, 27 Jun 2024 01:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450045; bh=alV5zibd2F0pMNbUX/mWZ+tG97f9Xo1V9J1WqjSbP8A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=B2qBsDkL0dxLN9WUghKk/yCHEP7gA4zZFWEppqkoSjuXlX1Ly40r0xAI0yucOKYj2 HkDxytNHwn6CwxUDEusjmW+bsaESAP8HANhfrp4Hj6j9T2veupYhwNtdMLFVItDMXy j2AzGP0bDuO5MEAcmbTEA8R6/zOCUPOj1CJK3xDa2DXG6IVhGxDkzhdSDwRe61LRAX 5Bhrp4Fg9F3xougTOgKp/XrG031v71BPC58JJcUR1kCgeVG73za33yIuZXm6I36dPO 7FIbSwBzm1okS9/gCa3hCBqZ0AcgJiP9QpSZYiFE/bURPowb8jz+OV5NoVTfNtlZKW aqydfCIOCqxvw== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:25 -0400 Subject: [PATCH 05/10] fs: add percpu counters to count fine vs. coarse timestamps MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-5-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=2307; i=jlayton@kernel.org; h=from:subject:message-id; bh=alV5zibd2F0pMNbUX/mWZ+tG97f9Xo1V9J1WqjSbP8A=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmvP3m8cgNO12xHkX/kvGeeOvTHePjzc/p9E 73Z0udL2yeJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rwAKCRAADmhBGVaC FVlYD/4q+QmTQ2BI3Y18pmSgyzhp+KsUaATjRNzT+mnMep2m7m1Gs2NuvWMCE7ogykMMDOjDMsJ sNvujib/blGj7gu3gYUWWOvZxnG34l4mhlVhdGs6xANPbLR5FMECfrsa5uQdJMLzuqOPgNnOhzU XieSHD6nsA4r4Hmqii/LDHKEwCU2HlAhtEgwdMOjVcQzKHiHoxuH03WR6yZaEzw1da20OJs5I8N B+gsf15KKvItUFHdBLu53BeVIVaAklaFg4DWvJm6MaxweD2QSVAjQ9Knf5dYJm4f29NcjElQ/pV V+hmOYJPtu3L5Dj9txMdu5fH5b4tOHT8a41rNL/eyU9PUta0GQX2uWHh7HLEZErUSiK7z4f1+tZ SMmcj45nVV6QYF+RMcnXcRG0aJGDxT9pNGhkkUhDmxNqdoAFbIwEGw2bbAEfpAx4lkWlHltyOE/ C3RWGGnPKRRHCBOXnb76vJHiDsT1yG3EyzsQEVCSnKohcNYKBcYMI6a0PnpL4QfyHqq8wZi2+f9 ZFGXq9RdXZPuIR4UwZt/YZE5SRl5MznqGcYcMVcU86xVjMkFUKKkDglI8O6xhHBbUw7CxN6GRiu DNbxDJGy3MTBLASlA+MkUOayWh4rJcPzch7NEoW2ex55o0g2b8Lg/qrEEVnEIGuk9Eo6/H8WmZh eav0qapDN1tVzpA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: ECE331C0005 X-Stat-Signature: bws7ff1sm4tpbhosxgo9mmi19mkymj5d X-Rspam-User: X-HE-Tag: 1719450048-520864 X-HE-Meta: U2FsdGVkX1+XNm3bAcDPFOK2M6ItbbUnQTY78PjydTQme7nbOG/CNTcWrUbx2FBozbkgn6EMI4AoXgAZ1lLYW+3JA83hNtWQBJbU45bCnBEwFWb5QQ36n/57D1KPpq1NE6ADf97W0NJhAWrOF1+EwSDJ2De53MaTfhClpSs0GWcHPOOV4MDFAunwbul0+LQ9lJ2wHP23myk7iAcFkrSLikjGn71LT93k7CUxxTcFneeqoEVYSUm53E5Tu7vP2sm25aNMh1qxKmBl4kSSFlVmiBekkVln9vPHguyW2uKGeAKyokwDyQ8J4In23A8g9YxnNa0ogjq68M7NYfiYyCqCcd0tMl6b7JChnsJIMf3lcFHjy3+4C4SlxJtXEZ1X/zdCOMFuBkrtodArNCIVaXGX+WYl171KYh6N1de5gEM2CEferbWZmH/iFyC5t9mSjyfxvhHLxz/d1/ICP92bePh0oVL2MxbzYJYfDg7wEGEmcKNSATU1ZJWOi/2FEGuWLwB8mz8vw/ZTylK3Qq5OwH0UWj9MLAFbaxw2optvPxmnYF6EyTDdVXtnrGtpxgERbH47iThcfcMRMzYwsl8FTxM/jAT21VF7Nn8j1Z76lEbFN3TfyT/WOLuaeR4uKD4Tizc9btd+6k+GVPy+uSB9HlOnAj+UCwvNS0+BwBBAjdGh9JxRfiffAIij18zLmwqwr2n84mpXskBHXeLgAAgVPvtv/O3SXY25VfBNSNWjvFSNrBv3nGzT7ylwbLXvUlyyDEKodqLtS5jUhj+boo/CwONR6uQMRcUoJ/tWCHusLbvu1nAl88sIAjLydvlgam2Lz9/CLgiZVi1Yik+LKnpFCUANY7Sh5T//WBVqMyvAFpA2LaU4TM+HFNc+tHESHMHRzpN8/s7A/986l7r88PcwGuIYu/mdJp1kJ+uGVJCl1q9a8tx2V/VrQuAibWA/8i9iUJ/X497jzXlcy/8mUcXBm06 5c3RVhyd /vhdBJuwD0H3JOG+OeJ3UdGVirGXFrl1/CjtQXSNBC0CY4dGijOoIYHZeixic/2zbe3WdPdK+Ayz0D9DH512uvbqoJb6UTGnaA0n8eEWYbx691Jve65uzFI9lXTzAti197lH8Yj7Gv5TNEaQZn9NuktEAbu5/SxePFB3QvHtRYRXw5LY+gKkNoJ7/Ajx4CoQFm5NvmQPkdCAWlt7m8SQjWMYDMK9jyPqQkX/veE603/JF1rZsfTysLPYDG0/F3b4t0ieWJIAOhn9rOXXwQQc2fRnDkkd6fwmskJ9E 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: Keep a pair of percpu counters so we can track what proportion of timestamps is fine-grained. Signed-off-by: Jeff Layton --- fs/inode.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/fs/inode.c b/fs/inode.c index 12790a26102c..18a9d1398773 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #define CREATE_TRACE_POINTS #include @@ -64,6 +66,11 @@ static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock); /* Don't send out a ctime lower than this (modulo backward clock jumps). */ static __cacheline_aligned_in_smp ktime_t ctime_floor; + +/* Keep track of the number of fine vs. coarse timestamp fetches */ +static struct percpu_counter mg_fine_ts; +static struct percpu_counter mg_coarse_ts; + /* * Empty aops. Can be used for the cases where the user does not * define any of the address_space operations. @@ -2636,6 +2643,9 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) trace_ctime_floor_update(inode, floor, now, old); if (old != floor) now = old; + percpu_counter_inc(&mg_fine_ts); + } else { + percpu_counter_inc(&mg_coarse_ts); } retry: /* Try to swap the ctime into place. */ @@ -2711,3 +2721,32 @@ umode_t mode_strip_sgid(struct mnt_idmap *idmap, return mode & ~S_ISGID; } EXPORT_SYMBOL(mode_strip_sgid); + +static int mgts_show(struct seq_file *s, void *p) +{ + u64 fine = percpu_counter_sum(&mg_fine_ts); + u64 coarse = percpu_counter_sum(&mg_coarse_ts); + + seq_printf(s, "%llu %llu\n", fine, coarse); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(mgts); + +static int __init mg_debugfs_init(void) +{ + int ret = percpu_counter_init(&mg_fine_ts, 0, GFP_KERNEL); + + if (ret) + return ret; + + ret = percpu_counter_init(&mg_coarse_ts, 0, GFP_KERNEL); + if (ret) { + percpu_counter_destroy(&mg_fine_ts); + return ret; + } + + debugfs_create_file("multigrain_timestamps", S_IFREG | S_IRUGO, NULL, NULL, &mgts_fops); + return 0; +} +late_initcall(mg_debugfs_init); From patchwork Thu Jun 27 01:00:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713678 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 6383EC27C4F for ; Thu, 27 Jun 2024 01:00:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1487E6B009C; Wed, 26 Jun 2024 21:00:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F52D6B00BC; Wed, 26 Jun 2024 21:00:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E88436B00BE; Wed, 26 Jun 2024 21:00:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C062D6B00BC for ; Wed, 26 Jun 2024 21:00:53 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 75D1CC1869 for ; Thu, 27 Jun 2024 01:00:53 +0000 (UTC) X-FDA: 82274863986.29.2EBFE19 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf17.hostedemail.com (Postfix) with ESMTP id 1E34C40008 for ; Thu, 27 Jun 2024 01:00:50 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KSM4D+ht; spf=pass (imf17.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719450043; 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=bJddfqUYKfPkL5IaapNTI+DPloFTuokezQWldk1boEE=; b=Q4cV5ZS2xpKMma+twJ/QLIcECSKthinPvG7DUwYW4USwOZn0JXqlX7m4Y+PjcQqAsVtInC 7lbxg4YfQhmdi10OJ0R7txW7R4eAtr/U2H3uDcTE0Iek9QiXvoGBD5yYTy5IsUViGT3cuA Phlv9v3q5/E8vFx/9Vi9b76dC+9UrYQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KSM4D+ht; spf=pass (imf17.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719450043; a=rsa-sha256; cv=none; b=U3bMh7THXxbWY5IgQBOyaXTMD52sflVxWEtoxnEC8miCXwJKi6jHoB1Mzz8JRxvUiTyrgZ XbdRQ/MtqFu1G5ezKr9ES7OzFKEIXF0f1empayXOU5+MiFazWyUBQhAxyb9hxMyalQhXwe ipAOq/tvD3XDGG4LcVF5jq/EM5Q7zVA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 8FEEFCE2C25; Thu, 27 Jun 2024 01:00:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3019C4AF0E; Thu, 27 Jun 2024 01:00:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450047; bh=/g1ddIto05q7VUdUuGmHZRulUXiGWzaifPHAIEfpWmk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KSM4D+htEiLS5wQkJ0zKSjaJMxEwEGG22qWwF5spro00SlDHI78pzriunnpq0F0r0 SEiKrQAn1yP0PiAuxzXGm/wpgfD6W7meGA/ajicCqaKrmAGh0UdMrYy+9VbOvrR4xn wZVLZQ/sAbDRmk40zheaQiul+emOnfSR5ZIlq8Mmjva2FuMDNaAHR7SwxUqbvNUrn+ dgEHvLNTiA+ojAscpgRun2J2bDaZdpcD8nJqbdH934KxKG/9g0VcIGFwJ1LbbsHKP7 k6VTzDDiPm6BUQBeYGVtOEt7lA76YYCB6lEyFiOLjVl1fO0jBTHHTIJNN6c25FUKkG VFQjHsF6PG5mQ== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:26 -0400 Subject: [PATCH 06/10] fs: have setattr_copy handle multigrain timestamps appropriately MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-6-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=3403; i=jlayton@kernel.org; h=from:subject:message-id; bh=/g1ddIto05q7VUdUuGmHZRulUXiGWzaifPHAIEfpWmk=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmvt5FijKuOW1vA/E+4WT59dqYyFM7dMPgmC 4a5LSWoXmeJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rwAKCRAADmhBGVaC FXZUD/9B/x8/Zq9asfvRQABKDRs5+rE6zIeYgHTsok96TS49jId7AW+yvJZzcQ60z97OjtIAwTo YkmpaooiGCxQNKKMQAna8eVpiHzmg9VJIeDL9bZiWowREYsAWCOpDXRAMJo1s90ZIiSDa0WrmRh 5b/wgqt63vJ2eAJJxLQXFkbsv3j+brsUJRCCZXZBQq0Ray0Zqczrdc66Lr08hFF00X0OYtkkh+f mguCF4lxXVmuLkVvakLq46OWh7scp0GkjI4CmJflY11gO1qdhzjiiUCtdLok9uUjracDuHQVslb Q8j+odXGCtFdhLXrIWYVn5w3RQIsbGnSa2kNZTYpYKojuj8gRFXsUQksMEfOyegcLoSrWojFfci WoiEmrLy6Z+nOrsixHBXd0N2ePqm8cgf5l1M+ybnnIKsrBHoFN2mioRSQv2rFGIcD940lBwMCL2 UOmWHXsj7KU/boDxh5NhAAT7uKUc8wQUrrRqZk2bt1kp3G4EY5wMkZlz+Hv9p6DjLFzMuz7oaqk NY/ITCGlhOXe1tBCHwLKEKYef7RQ4Hp/DiPJSJ/mxYfissEXHANFM9kcATDHFqeLC9asainf8m7 8TUD1m1SxoBCy9x1KRRD/VsvxGq0eU3u6xtnOggG360rkUMuCK43V4F9y8eR45mYIg0XVjj/BTY Y7he/1P2G/b39LA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 1E34C40008 X-Stat-Signature: o7tcfd8iahkn47d9o3nto5w6ouygqqun X-HE-Tag: 1719450050-555264 X-HE-Meta: U2FsdGVkX1/BAymY8tYy+37Btebmhw39yVA0Du3fHE/seXPZWmS6Hmm4BEEF63sbePg1yHQ8tewa2hWXM84TsCsmvfpIDqEVm+6LVL4/zWGyqcESIGDSSwdRX2dnjsUeRx/6gcjnsptYLK5c+Jadhx/niuJKv1A1T+lNOjd5Or0gY/ZHgCBKa2GGmg+HsmgMy/fWuxp/vDnx6JR8jIgj3mhWLw4r2GyZll42X/Dwl+j8Z+r3Y9r5jd1xMDXKoCambLP40RFTtIanAd2cWAdkaPY59mUG3zmuz35s6y2rhFOwfxqX4awDRhKR0d+LoS9PsSQy8F/KDwc9Xts10YNqsNcQ3LrSMAgxxEs99tOdMcmlh75QNT+u8e1h5hYDWAIXB4FdrYq0SQiudYihwDwBLqIdzInQUBpaX3azkbUFc42x9bEAp2uQr+Og7+3jRvVYUQuhB9qWNGLW+FH+pHUECwF90H4x0PpxRAKPsFOZaMUjvzxd6W2L2Yd4nRRzOs6uyNU/F0enGUoadUx3rWUHX9PbDg35/Q21Kp6fm24mKk4rlP+lN74e8tKIQShdVtU4k1whPdZ5It2AGQp5ZMa7uDd6LBbQf+cU8btNivqF2A2suSx0oWUxoZzyBakKvYhQrC6DmZ0eBSVCkEhReXVCVQmK8Un7YAo9u5f15MTHPuyHB1SObTDc8FBCVsl94acKcSEgCKuT4SlFMKIqUK9vzzpc+lbRqDQKO1wBEkgLSzWfY55O1lloJh4xxRQf4ojyc73aYbs6qwTLlMOup8vf3eFdG2rfT4PAAWl7DmfUBSD+EY/SA7dSE87R7o2JgZxWZyBs7xdMLQfwCQ653vyjkVk4Txmx2vt2ZH2srJyYnSKS0bJTh43toF2FEay+kmEln+MWCpTvx0nymRF5nLPzOYbf61GXMuCpPQdxrxyQOZBDd1QnDZtqVJS7nQMnnmP+yKGrs4mJNvmI7dq5uCe mbJyPjmU ihZjKzNhXeUsO58Gmko4B6R9UczrVWw44m15yoX2WPVoWWhPWWvCNtFHV+gcuIACS1/Icb+oVD/P4fzp41gpK+NsmMvmSZbQ1jDnL6nn6HqzkIFbPBnuGWmrPU7otrV2AbhD1rqqRj4aKpQLJRmOzHlF1U5gf2oJ4wVYc7V0qfkVbj0W9Xh0pfRVAer2nmRZUECRfXS0cd7LhGZVh4EvtL6rOMH1xK/Hx6AkRBvYKZiQlNBldAzHxup/c6ZMjqxaclFRX15TQjT9tU+evreTTgXxaoRlcdkfuYaxC 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 setattr codepath is still using coarse-grained timestamps, even on multigrain filesystems. To fix this, we need to fetch the timestamp for ctime updates later, at the point where the assignment occurs in setattr_copy. On a multigrain inode, ignore the ia_ctime in the attrs, and always update the ctime to the current clock value. Update the atime and mtime with the same value (if needed) unless they are being set to other specific values, a'la utimes(). Note that we don't want to do this universally however, as some filesystems (e.g. most networked fs) want to do an explicit update elsewhere before updating the local inode. Signed-off-by: Jeff Layton --- fs/attr.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index 825007d5cda4..e03ea6951864 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -271,6 +271,42 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset) } EXPORT_SYMBOL(inode_newsize_ok); +/** + * setattr_copy_mgtime - update timestamps for mgtime inodes + * @inode: inode timestamps to be updated + * @attr: attrs for the update + * + * With multigrain timestamps, we need to take more care to prevent races + * when updating the ctime. Always update the ctime to the very latest + * using the standard mechanism, and use that to populate the atime and + * mtime appropriately (unless we're setting those to specific values). + */ +static void setattr_copy_mgtime(struct inode *inode, const struct iattr *attr) +{ + unsigned int ia_valid = attr->ia_valid; + struct timespec64 now; + + /* + * If the ctime isn't being updated then nothing else should be + * either. + */ + if (!(ia_valid & ATTR_CTIME)) { + WARN_ON_ONCE(ia_valid & (ATTR_ATIME|ATTR_MTIME)); + return; + } + + now = inode_set_ctime_current(inode); + if (ia_valid & ATTR_ATIME_SET) + inode_set_atime_to_ts(inode, attr->ia_atime); + else if (ia_valid & ATTR_ATIME) + inode_set_atime_to_ts(inode, now); + + if (ia_valid & ATTR_MTIME_SET) + inode_set_mtime_to_ts(inode, attr->ia_mtime); + else if (ia_valid & ATTR_MTIME) + inode_set_mtime_to_ts(inode, now); +} + /** * setattr_copy - copy simple metadata updates into the generic inode * @idmap: idmap of the mount the inode was found from @@ -303,12 +339,6 @@ void setattr_copy(struct mnt_idmap *idmap, struct inode *inode, i_uid_update(idmap, attr, inode); i_gid_update(idmap, attr, inode); - if (ia_valid & ATTR_ATIME) - inode_set_atime_to_ts(inode, attr->ia_atime); - if (ia_valid & ATTR_MTIME) - inode_set_mtime_to_ts(inode, attr->ia_mtime); - if (ia_valid & ATTR_CTIME) - inode_set_ctime_to_ts(inode, attr->ia_ctime); if (ia_valid & ATTR_MODE) { umode_t mode = attr->ia_mode; if (!in_group_or_capable(idmap, inode, @@ -316,6 +346,16 @@ void setattr_copy(struct mnt_idmap *idmap, struct inode *inode, mode &= ~S_ISGID; inode->i_mode = mode; } + + if (is_mgtime(inode)) + return setattr_copy_mgtime(inode, attr); + + if (ia_valid & ATTR_ATIME) + inode_set_atime_to_ts(inode, attr->ia_atime); + if (ia_valid & ATTR_MTIME) + inode_set_mtime_to_ts(inode, attr->ia_mtime); + if (ia_valid & ATTR_CTIME) + inode_set_ctime_to_ts(inode, attr->ia_ctime); } EXPORT_SYMBOL(setattr_copy); From patchwork Thu Jun 27 01:00:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713679 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 4BF15C30653 for ; Thu, 27 Jun 2024 01:00:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7FC246B00BD; Wed, 26 Jun 2024 21:00:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 782C96B00BE; Wed, 26 Jun 2024 21:00:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D40A6B00BF; Wed, 26 Jun 2024 21:00:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3D5F66B00BD for ; Wed, 26 Jun 2024 21:00:56 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E01AF1C348F for ; Thu, 27 Jun 2024 01:00:55 +0000 (UTC) X-FDA: 82274864070.11.1411E7C Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf04.hostedemail.com (Postfix) with ESMTP id 834D940009 for ; Thu, 27 Jun 2024 01:00:53 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EfzWTGRJ; spf=pass (imf04.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719450041; 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=mHBJ8P9xJvRjsbven5uK4O/4I8I92/ECjqgL0Z/oVQk=; b=JU7/+xXfOKN2UUaoo8CEGbIKvBbdEbHAnnwYjMhEBhlunqfp4Dtz0Fr46hxL1lgozXGR89 UwyNTIOo40Soj1GWkRvVLsabZY9fj1McB4aOVGfo1BQCklt7vcX4dVcf+BeenuBsBG3dzz OvWcbWD+L6vTWuaVoKwexoo65hc0g8Q= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EfzWTGRJ; spf=pass (imf04.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719450041; a=rsa-sha256; cv=none; b=XE8mbIJWn9R+ZtDZjA1jI11jTXvHPe/P4hAgF2mzadkBCcv/MdboShXsQYTm9a6zs3PBHr 1q+Uxp6EiDnUKO22OoOaf1PjTtI+B3pnRmkXZ5XejY6ht2IXRLX73qg8QrvOLM3dHe91o6 09qhEeTZIfAZxC5xiSej+hnXWmXGeIE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id D9A95CE2D55; Thu, 27 Jun 2024 01:00:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21F05C4AF0F; Thu, 27 Jun 2024 01:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450050; bh=3rezV2gQwo9fH4xuVx823NKSfsCiMN8Xp4bd4oV0yb0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EfzWTGRJrOxCHnENJtqkTnFlbrYiNVm3Dtx+RYkf+tPkSUBOWalH+ZJXKWd6RDU3W YbIMpRqootIbyjiSHsXYL4WHyI58VPZgs/rn5wnyd1pNU9Yj9MdEFMFVGSPa0vMIpw erwoqImb0BeLarz0pB1AysZlCkhfHAUmFQvLQiRhTDyqGzMtBV1Voalxm4tbLh9gGV y73R4UwcKJMH6klQe0euDWaZU8vbA2cJ7K37Obxew60jD/3Klcu0JLP27DhEYmMHbJ aP1zaQMbakES7jdHpXa9HBN/Kou4lPJhjdrSc1beOux17fNM6L8ekNdL02W9V2oOOH jW5FYGG+kqj9Q== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:27 -0400 Subject: [PATCH 07/10] xfs: switch to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-7-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=2415; i=jlayton@kernel.org; h=from:subject:message-id; bh=3rezV2gQwo9fH4xuVx823NKSfsCiMN8Xp4bd4oV0yb0=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmvW5qoH8Bt7MTLdRrQHNrS4Yp96iCkYHnk8 FyVEve6YHyJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rwAKCRAADmhBGVaC FaFmD/wOagd7+4hFoYYtjpsB5K282B4LYANFzcPFXtXXPlrjjs7Ut0fwhI9WnYgAUHQekuPeK+A zDPV0MjYGwTZEDSr5BQGrKKaxff/X/gRbvNZIGsXSb54XtHH1+DEOPktNYObH43KjUfh83Yj3z1 y+tHn7ZbOu77J4lV2A32MWXQU5+uoLrqOlaYs+9vxFD18XxYQB+eidU8SFupTRIf9va4/KpRud3 X3FubvF7WzxgFVT4I6tht9+07MuaPmMxFULyqz/ptHe+kIEaCPBcs+zPIZFdc/m6hbz0VnFo1RB t5Jv2kgTnFF3pATlt6f4ioOWKct8PJT+2RitCv9Oxysxi60hmwsc1edesy5GJDZIKkyzDJnios4 vDqLZOvcsR1LwsJh7+1bizC/9FkuOX2Ssv6Kg8CM8wskPkw3HsnD8enqQseE1orfuygkYtW4vBj rpsLXWrbOMfT5DnGZGTkrEWl9Yc5j0hS7oJrujxu8WQ1o8qPMwnVMGvo9NRBzBI50ZpdI3iyFg2 EO+wgd0QFeW9Xwq8k5J/7TUExgdVXaWtMJwtFC5Kf49BfF8iUjfycWKG/8Er65r6TDQo1uWSBnr xAdLH+DVUkj8CT3cBfRstYF1uecD1uiUAMU9tjRxn+8uUMcmbLeCsEf4q2HTdAwwLRt+U26Zq4m QlSvFJ3+h/BDd1w== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: bgxck8bbsmdga1jcddabn9ugciy7hshn X-Rspam-User: X-Rspamd-Queue-Id: 834D940009 X-Rspamd-Server: rspam02 X-HE-Tag: 1719450053-8724 X-HE-Meta: U2FsdGVkX198lcW0Qtv9mfRiqdmkWogTakurvuAJSEEGnCXefQJGrWifir2O+mPQMi04CBv4/pj8trEh/6QNdEKFccK0dCqOwwP4Y484KIa/QYfcoejjXm4E5v2/aa/yl5TQvWtfHvWgJnZlTGxjJJnT7mIKaLUWvv83Dsy60FSPHblaWgkegGggrdm6ObiZtBmdMb9fbom+e9iavL23n9FV+8hGrPovjrDYVPywsO6HbrPjPXPbho/fSUKyZM2h89IoXDGONS7D/ESzytTO6+dSTL6B9R42sKzxgURHREI7Gvod+oK20NoL81XDBMwrRWth6l6IikY89DO/oK8RQ2OX2/3/9OzOp/0BlOfaaRAGGS3Wj5scHyQcN4d/972Yhv7ui+eaEZuzb8Ggapb+DnVAgZDpS+H8V7KvxvtQF2pF8PoaCxKEgAyNRK82FIj1mB2/zRCxuN0I7bItnpCyOCjv1pm5Kk0frqfdqf10oerrCRFdIv43LmsbDVJWN38B/Kr8b1m4QSbDKprtjo1Cq1EdN6GHcQ92Je7ZJu8cs/EuM4oQAHyqS/e7zHBOOgZWr+OTL8GqWeZsLTZGc0MPM8XnezA4nDpqx/sRJ+Zpp6/OIHZTLfAeGWkaxjl4d7zOgs9jwTIlkzPQuUGQVfCJtEmHqQMts2RhIMbqskKdiXNgBiRwefHw2Hj7C3N9Gc91dddMjzeJKx07StcPSSGPEVQcpxwm+LKYEJj/Kf9/Br9BFbQf1raGIrp/AXvEI1+sE0ji5viLQJVzOJWhooxqrux3kCx92eW2qhA8c5wlOgAuBPF0wC9UXJ2v+2+9L2BJ+uKdtrKk3C8AdKSDrhkvWI8LM3gkww8Zq5ZZqrCM/ZTgA4SHfyB2Q+g5WG8PEqXOdhxWlNSBwcBScvXW4693CkU9efCa0GsK0THyTOdIdXmHkwC0rlqzBRoKn76yPmwZ2UBm2G4PSMOwdcB3iI7 lYTvAEPa 0rPrzgF5jOgPYEyMUVKQAvREw0kvkNNWcW3YvfA7MavBKgWCK8CgpkpXV4PTVgRHtt3+r6HsNKW6p/FeAzLtL/bCMbpDjdzeXgkZJlC+HOccfEvd9w8b9SvNalZkoPvXEOxe+aOriaDmjiyNT1GCY9mPltwhno9iuTlKrmyEJAx32HS+hUivnzso68iJPycH1JFwvbxjxIbEBt8MClUEfMF0x9uzkSQrkGjvBTEWBRe49xifmhFT0tq3bbA== 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: Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. Also, anytime the mtime changes, the ctime must also change, and those are now the only two options for xfs_trans_ichgtime. Have that function unconditionally bump the ctime, and ASSERT that XFS_ICHGTIME_CHG is always set. Signed-off-by: Jeff Layton --- fs/xfs/libxfs/xfs_trans_inode.c | 6 +++--- fs/xfs/xfs_iops.c | 6 ++++-- fs/xfs/xfs_super.c | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c index 69fc5b981352..1f3639bbf5f0 100644 --- a/fs/xfs/libxfs/xfs_trans_inode.c +++ b/fs/xfs/libxfs/xfs_trans_inode.c @@ -62,12 +62,12 @@ xfs_trans_ichgtime( ASSERT(tp); xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); - tv = current_time(inode); + /* If the mtime changes, then ctime must also change */ + ASSERT(flags & XFS_ICHGTIME_CHG); + tv = inode_set_ctime_current(inode); if (flags & XFS_ICHGTIME_MOD) inode_set_mtime_to_ts(inode, tv); - if (flags & XFS_ICHGTIME_CHG) - inode_set_ctime_to_ts(inode, tv); if (flags & XFS_ICHGTIME_CREATE) ip->i_crtime = tv; } diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index ff222827e550..ed6e6d9507df 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -590,10 +590,12 @@ xfs_vn_getattr( stat->gid = vfsgid_into_kgid(vfsgid); stat->ino = ip->i_ino; stat->atime = inode_get_atime(inode); - stat->mtime = inode_get_mtime(inode); - stat->ctime = inode_get_ctime(inode); + + fill_mg_cmtime(stat, request_mask, inode); + stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks); + if (xfs_has_v3inodes(mp)) { if (request_mask & STATX_BTIME) { stat->result_mask |= STATX_BTIME; diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 27e9f749c4c7..210481b03fdb 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -2052,7 +2052,7 @@ static struct file_system_type xfs_fs_type = { .init_fs_context = xfs_init_fs_context, .parameters = xfs_fs_parameters, .kill_sb = xfs_kill_sb, - .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, + .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP | FS_MGTIME, }; MODULE_ALIAS_FS("xfs"); From patchwork Thu Jun 27 01:00:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713680 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 ABFE0C27C4F for ; Thu, 27 Jun 2024 01:01:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5FF2B6B00BF; Wed, 26 Jun 2024 21:00:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 586A26B00BE; Wed, 26 Jun 2024 21:00:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 428466B00C1; Wed, 26 Jun 2024 21:00:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1B3EF6B00BE for ; Wed, 26 Jun 2024 21:00:58 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C3C411217A0 for ; Thu, 27 Jun 2024 01:00:57 +0000 (UTC) X-FDA: 82274864154.26.36A2580 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf07.hostedemail.com (Postfix) with ESMTP id 6964840015 for ; Thu, 27 Jun 2024 01:00:55 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Sr9ChiUu; spf=pass (imf07.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719450039; 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=wFi9VCa4KervgflwMUv/qihS+sFTtts0CvoK0wS/B+8=; b=EwGlJRhT7OZaGf3a267Gxu2vi5DtTdAgDAXzWdhdjWO7Ev06EC7cWqsDvhjc38c4OyslXl c6QMLg2lYC6nXKHS6BCWrcAiB49/rboZ2cV4kc8XIfpbIw8QnrAOMx5nrH0jpZ122AVzn1 EN0Vw+/zF7xSlnJGgyXxzadMO2pMZ94= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719450039; a=rsa-sha256; cv=none; b=oo7sHtEvZrHPR6roUB1GtnYvC9/cGypAqVn9qP5uQKbxiJI/KM0VO9HKZGtWah5JvWduKj vDJb5n3P3h3K/WNA2GvwtAjbXPUFS0grMJn8xDZt1LQnv20Ify9z0L4SOaGhCV5g77BEV6 BmSqX2zv431RLijEdPZamOROgwZLq68= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Sr9ChiUu; spf=pass (imf07.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C940ACE2D18; Thu, 27 Jun 2024 01:00:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66928C4AF0D; Thu, 27 Jun 2024 01:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450052; bh=Rk22CdrDmdQOqV9B263elJ8j6v40sRU7F5SFeqVcw0c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Sr9ChiUu/HOsm1DsI0g6vQFuwDNK9Yj0f/PnCpCU6pRp+u4CF7nqtx+HCVqlhx6Hj HMTeApGIieSv04dS6W3ujYsyGSeOP+p4Dgc1VMLOPUKjQ55g221rFhfVjU/hDgAgry uZbBTcKyh+Gkh0gLcEU/sf3UGuZEFrHIRejP82Td27zeA7N0srKiiFyu08z33MisE0 OsyehPxrgZC658BcQmWV0tJhgFbFJ4EeNilJ9UaxG65NIxrqO367fFlOTlnIgnIxPS OjlR+ht+u63kFmQB6jCkY0npDtqM9sB9F4X9IOKGN+m4jSon1PX/mJOJlA5CxISIcn VlAzfenYaviWw== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:28 -0400 Subject: [PATCH 08/10] ext4: switch to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-8-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=839; i=jlayton@kernel.org; h=from:subject:message-id; bh=Rk22CdrDmdQOqV9B263elJ8j6v40sRU7F5SFeqVcw0c=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmvqkH1GH6QlyLmqwfY2ESip2uk0QjCTjONT BWdPqsbpveJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rwAKCRAADmhBGVaC Ffc+D/9f0X0vSHUxlsnazyA1xAWKX2SHeCtT2+4AWal62qmtzL0zDfdsa9FrQjjYp2Lb4y2cqIE BxzRUA+YHUkqyhEjKitJQs53rlXD1v80bjzOWwIkxaKqNPFbZ7aAudQIbTZy789FfEZuiC/w3BZ KkQoB88sOffNZMQj0TTwlMoeWj1fk24AWCvsXkjXtyF6vhA3n4JkWhik0UtV47RDe8RVAbBb1F9 Q1sxt5fHsjxEf7XeQYezhIZzQ9gYFmUFxeKOz0+On39zx/WU9bXr2BfB9bkl9iCcY1K1ZHCtX2g i14XcGB/btpbkld+TOhURgTVbNyfffpEPxe4Zcke22To5jcLoZRsYn0MSPPClhhAZpsd6pXahia /JaVEkCoRXpHPbUbo7hnVUewiomTNU3AsJXcmWrQaL4S793aijKo2q86UPV5n5GBDMS/XWkYNVO g8Vm50/QN5pqeMtsNgO0qySwNglfhAQ8Yb15ImlD4cQtgHNmcIZ9YFwI+T3lTivNKrwkaaH1HKk E+0JmRxCW0dAmw4niwg2v9T3RCNtIQl41GkKrNFSe5n6bIZwA+ql6pZqqP+Nwh8CRjrpOFOt6Ga WAd2d9Kq/s1MV+pCktB4A6JbvYjEAUc/VPvlpU+BoUfMshyfeo0t557aEfD9pgeAVJnopa4O0Al IVvzX5z4937vJLg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: 4581jk5yibyw6whap3gw3jkrx5zi1gj3 X-Rspamd-Queue-Id: 6964840015 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1719450055-238695 X-HE-Meta: U2FsdGVkX1+Afjo5Kw9PCVTq0MIS5gbdNXNUIBhyvSZkVPMgPCTS+RrG5gyRPxTwIv7ADlqd3eOsNT0IyCYuuAKBoJMp8rQgi12kgGRmkAEZVWtpxk9PFhnok3VeHNrsdhFBK7QFvrbAnDAO8N+ngtBW5cCS3e5JqWdGHLBP1AW7gjgaXQjmuX7ul2wdbFZaI+QD6WLhY8tLcwMi9A7AhQo2tavnbzg5GeQa7PzIqdVoE1+NJoDNcxl1j/W1AnDlQpML5QI/snowsIs34/Shw+xYcHQ267aA9PW7Yo0YDDRuKwWWOl4CGcPXuOInDR4qTzsUN8CZBdNcn8P7R1KDAspGGKp0V8styUV2nHLAlmvQkHJ85SkpJBHe67F4ruduE1rQ4gMBQR3/4Uc3nnjQfdLbSxBCAa3wA0utgPVIyMl5O/KgSgIXsbA/IwMs6S60xjmuMl8r61f9D2oqpasuCnmNoxxgCKGxhzIiiSa72tDtqk/lAfz7hs7e97sYky3DX2Glsm4cWdLjW+zZDDbTf8gGA7coviYWOFGHOsF3F9kjRHzNhPu1CLlcbjEUimjtMKIJjyyS40/cqPdotlMlBP7GDs/FjyAgck619e+BCUdU46uVMDoBrfNM/K+xnc+g8DkKvtMykNnmIeEo28v7ozWCpypVYPyaWa2vXnKcZvNt4K82BiRil9lmYs4ga5hegfdvcoMYmurNk2cMGFH2Vu70Wer4VAMXoBEMAWMUb81CXuO0mGKKBTRhM1nA+AKMdR8O+MTFAZCOKE66MjVYHyebYXJqq26y460GMk+qHAXMueR8u0AFj3UzkRu7GHUR7ZVYCLo9bt50X9hLUKJHEZ8tzfJ6hITQssNGM9Va0ZuWjQqeuLhg1X0qNj7nb6aw2UeToFvyuATU/O873fMAFrOWYjGrKSSI8VErGjugcEgciz/f7/qaGY3X1l1Bs916gLsiEQV17Qhg4sAs1os oSbKoDJK iELE3k/2pEK4FM7FmqCOD74+Qs5y/CAAZLbBMg/mdcFePZ6iOWFK8YLpEf3GoEmu6FEeJSSoY+Gd+/YIAFmFwwD54pwcNRZmUkGr6XP3SGGZNQO3g2175gky0mjqeW8CQA6urU7KH6qag/B0uG2y1c96+OCE1Hnw5fetx1kk9Rcl+jeZo3zd/MH19W485xrwgIJOEPszP2qr7CYUFrMTciUK29+Ux6LNB4XWerdCIaptCBB4WtTfx/otB1A== 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: Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. For ext4, we only need to enable the FS_MGTIME flag. Signed-off-by: Jeff Layton --- fs/ext4/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index c682fb927b64..9ae48763f81f 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -7310,7 +7310,7 @@ static struct file_system_type ext4_fs_type = { .init_fs_context = ext4_init_fs_context, .parameters = ext4_param_specs, .kill_sb = ext4_kill_sb, - .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, + .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP | FS_MGTIME, }; MODULE_ALIAS_FS("ext4"); From patchwork Thu Jun 27 01:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713681 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 25768C30653 for ; Thu, 27 Jun 2024 01:01:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82C486B00BE; Wed, 26 Jun 2024 21:00:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 795346B00C2; Wed, 26 Jun 2024 21:00:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5392B6B00C0; Wed, 26 Jun 2024 21:00:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 282E56B00BF for ; Wed, 26 Jun 2024 21:00:58 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D37661A187E for ; Thu, 27 Jun 2024 01:00:57 +0000 (UTC) X-FDA: 82274864154.19.330955E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id 1BE2280028 for ; Thu, 27 Jun 2024 01:00:55 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Tj/hEUIr"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719450043; a=rsa-sha256; cv=none; b=HJaDsQW3RwTIC6gjDq1tlHkOfxf8FbA7ohqhwNxVDfbC/nMbF7ubNrV9lxJkLIxc4hDGOQ 8I4fTT6uYY4lgb+ZMnmTFSDIrztUY4vUDDzl2vk+2EwmTGIP6sd6BhrDRIlm8cc/ZcCUHW 6rtkcCcZtm3nc1hLu1IoCQjwcVqFJ14= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Tj/hEUIr"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 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=1719450043; 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=x1vxj44RVuP7S/qIvh4Qwx4ry6ReCTsAuhYNCcVPTzY=; b=QmLNcuT+pc/5J5T01nTgG+4kRNHhLR2sj9IJKafKAqAKGkO+2jFo5QKDo2fTpyBDzEP91Q Q/wJ2SCZJcahyyZTcmuzAtI72+vPvzT4tSkBy4IE5t/LyAexVGbkht91di+XHcytp4L2DK f11Gy2FYSHCUhs3SmPb40wwqH21FSCY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 28A5F61D4D; Thu, 27 Jun 2024 01:00:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB109C2BD10; Thu, 27 Jun 2024 01:00:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450054; bh=AsDPx0Ikfq9IqUjWUD0+xKOHhj2Nou+J4XvWGSgrXC0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Tj/hEUIre2HagQVaZas9rsjLhPRUO2hyax4Y7W9EnRv12Cjx/OdmSrPL7Zttpk+xq 5Ba8mOxPKVAwOyDP00R84XX3ZgPCwYbUTsZNK1eDhp45m/x1q0AbjF9E60otPJmKUS yb0Hj2apyXo2eO+AnolBGG7LnHDlafrI9vTLwedCknDoDe2I75koVeuL+w3DjMpKHz y0JAUppCwXl6NhlcJ3nq1vc9N9Dub+1Ds4N14Adm+nQZQpCBBvaoKsKBNAFRTzf06u UyJol3cTmjhqJWyHF1zdj/CbH8lcBmL2aUpQGGc47GGxPSDgiZZeL6oCUu/UB2OQyU hl3ynx0u2A4wA== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:29 -0400 Subject: [PATCH 09/10] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-9-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=2439; i=jlayton@kernel.org; h=from:subject:message-id; bh=AsDPx0Ikfq9IqUjWUD0+xKOHhj2Nou+J4XvWGSgrXC0=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmvrjqqUO8F1XQYn7/QtHzz3TvRUyNVZtAnM UYAmCEwGkaJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rwAKCRAADmhBGVaC FVqnD/4lHKGuZjjFq7gg39FIdC0KjRoA7ilhtV7sBg5JQMPyIWf7VpxhqDFqsp6thwF4xwHOzdX oWJMtPQ8TIiEEeNNNf0rRwZt2RFNR8IV5hZJ7q3IqK/63Vn2/vHVVO0i24t32dMvI9TG/vYlTUV gtrw93u7uKQwYD8nRgWmOHf5tQHp0Wrs7FGnmydNQqm46KAaCpjzmIVj5f0ZoKkhs9FsfX3Ni4R HW+auAgJL9zz73vucgy8en74RvQNC5oZsEZQukRLmmS5yUAj7Ls+LRFV59NBuk/w6EmUo++xE1o XtWIMX2PGsln4F8Lc2nIPzme8RgpArnXVVxJJ4IKlNMMAvgaZjrKu/JFRzcinZEQNfe7NEy/BoO YHK9/mIkcFqNr49cOQSdN9zJC9u2XvQFx2/MhShIUugeHnemNQQtgubesIKR/2UpWOndhhPnqII +f8U6wf1uslr1zeP9V4+0GDNuqUZoyDq2Z4eFtM08eDhwLrZHtfOhYl5y51XTdLmt7/3/sO3TyD PupvMCacRh1NlnE/Ne7bKF9zES6Vxcm82a/Q6VZPOLv2Lb/gRxoctePxinPCj90FPpgqVlxZJEH 182F3kKrCLx38YvdJSWmD12Oisp6B13QlZi025Hx1U+BJKmg0fGsHQoVGIaY3AHSEUH+cT4TljH /+c1ye9qlC2quTQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 1BE2280028 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fosyqsuqzb16efxh6es9s4qgb6bybn73 X-HE-Tag: 1719450055-656155 X-HE-Meta: U2FsdGVkX1/cSHh6Ef+kgOsEjDXmECmVLbCT4Ysd20g/tBQXCMV8S+Yu78HcyKLjjrQgi04Ead2z8SEr7XZezN9gXC9xt3Lq2I0w59Rb+R3InU60y3ntAjMDv0nROEyXlDYJFy9NyzzTP1IlZUxnE+s9dZ8NuAXPOEXDiL17aYAdk0FUs1OSG3FG8KtcugFCDei4mNT+afCoOOLv5yQNiFDqPmd+BEMRfFJYkI5APcsiR1POOlNWJc/MXYhAZy70ZEGsZOqVfhfKGeNX0FSYH32B0wsz3ToztCYU2icPVtBdQphs+VlXifV4XKEK/Gx7EAetK5Msd7QWN2iJoCSy5bjuLeSmd+9OPvCOjTHrXVUoRX1LjG7u/LNVCYLankYXRJ6/OyPOBwsj7QeZJbpfbfWJgdKn5+chwBxlxBgSNcNMzEdl4in71HQ51p1RN0B9G3viecnYM/P8WcSMvFC0vlNwiaPhTT3fWev6Rvw/wHt7NWK+eZzQjTZnLRMIiF0lBw5mI09Bgh8B7rQRHq+7B2quBqhutxvT42hhVyUzhGu0rt6tceSQTkOQBLBaMZ7FUC97uabOjBCVwl9taJZXzwnJeuKOPE14JpgNXDQnp/SrvmBqT//3JZ6yvQpymKd46Jeo3vPoQQW4z0jCa9Q2bvxrTl8mGdKegpxv09vB4uo4zOOpgXRU8JAbNFE90qDRY6kPLRvPIT+6Jo6nBZebee/wlQn1jpAsKS3V3QVzoPEYYx2NcgwPHzMI/nMgav6hE54+tfWFwYyYGmws+554styZNDMO+SM9RjV64v/npfdgVuFWkdsFWCGXKt4Dzb8MUrEh+RWmfsVWnYKZS4jKEMnvUeK5oyQAXMo76urn2y+o53fVqDkp+fou7fF0rT85AjPFv7P/L157qOcM4A4S+XHS0wMqS9HqqSZpC+nqT5i80u01kpb//GY7tq2t2cgnUQkZ2fFBA3Uqw7jGZQ+ eje1bygw qvXeTxpXVrpGJ9M7kwPdSVBbykIU9wFBVqRZpn26TjNcfg5u16kugr9VCtIGM7MHAdLgYXgq+qoAdsJC02zzGwYRSyOabcU6XFvdEZ5+wDgFkTSkH2wX9QvhIzqOvDzCyt0dCegwXq2MPzr4RZHcSZ/a6njvU3zn4bMNJmkEHhPxL26e+29lZfPh/ZMNb4D8nNqsiFw9lC9Ja8i5ENUvSg9LgOQ22Ud50cNyxbi+ltfXMxF2WBgYfxvyPEw== 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: Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. Beyond enabling the FS_MGTIME flag, this patch eliminates update_time_for_write, which goes to great pains to avoid in-memory stores. Just have it overwrite the timestamps unconditionally. Signed-off-by: Jeff Layton --- fs/btrfs/file.c | 25 ++++--------------------- fs/btrfs/super.c | 3 ++- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index e764ac3f22e2..89b3c200c374 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1120,26 +1120,6 @@ void btrfs_check_nocow_unlock(struct btrfs_inode *inode) btrfs_drew_write_unlock(&inode->root->snapshot_lock); } -static void update_time_for_write(struct inode *inode) -{ - struct timespec64 now, ts; - - if (IS_NOCMTIME(inode)) - return; - - now = current_time(inode); - ts = inode_get_mtime(inode); - if (!timespec64_equal(&ts, &now)) - inode_set_mtime_to_ts(inode, now); - - ts = inode_get_ctime(inode); - if (!timespec64_equal(&ts, &now)) - inode_set_ctime_to_ts(inode, now); - - if (IS_I_VERSION(inode)) - inode_inc_iversion(inode); -} - static int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from, size_t count) { @@ -1171,7 +1151,10 @@ static int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from, * need to start yet another transaction to update the inode as we will * update the inode when we finish writing whatever data we write. */ - update_time_for_write(inode); + if (!IS_NOCMTIME(inode)) { + inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); + inode_inc_iversion(inode); + } start_pos = round_down(pos, fs_info->sectorsize); oldsize = i_size_read(inode); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index f05cce7c8b8d..1cd50293b98d 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2173,7 +2173,8 @@ static struct file_system_type btrfs_fs_type = { .init_fs_context = btrfs_init_fs_context, .parameters = btrfs_fs_parameters, .kill_sb = btrfs_kill_super, - .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_ALLOW_IDMAP, + .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | + FS_ALLOW_IDMAP | FS_MGTIME, }; MODULE_ALIAS_FS("btrfs"); From patchwork Thu Jun 27 01:00:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13713682 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 1506EC27C4F for ; Thu, 27 Jun 2024 01:01:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53BCD6B00C2; Wed, 26 Jun 2024 21:01:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49C8E6B00C3; Wed, 26 Jun 2024 21:01:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C8DD6B00C4; Wed, 26 Jun 2024 21:01:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 022096B00C2 for ; Wed, 26 Jun 2024 21:01:02 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B3693A45BD for ; Thu, 27 Jun 2024 01:01:02 +0000 (UTC) X-FDA: 82274864364.14.3B6B059 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf14.hostedemail.com (Postfix) with ESMTP id 4C0C310000C for ; Thu, 27 Jun 2024 01:00:59 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="nwfaFDJ/"; spf=pass (imf14.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719450053; 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=qFhhcNXFbGADWCnsMtfmKxpIQSQe3wWDYA+SCFOEVTk=; b=n7JIQTUjIjhKxz7V4T73ephZhyVzyK5wAmQYV3f85w39wTr/3Rzz80d39p3bR5JUCMywYr 4OJn8hmMR9TsieTTyHnMiwkcLn5FFQFyf8xEZTxlKHbhjSC8wpJeX8EcTU7uU/TsOAe0QN HpPN7t3KN/if0gqmjbqVIj1elF0LS20= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="nwfaFDJ/"; spf=pass (imf14.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719450053; a=rsa-sha256; cv=none; b=qA5JZstLupKDsCwd9k/wyPrLKngUcoO6XlU9sumUU86SciMbVApLCarADRBhIsJvgqXDkE MU1fVDzFpd/JbXLlPLIZPc1UgG6AlR0A51gwyO62VHVt15nQSBoec5tqYjFt+B7ktnxmu2 ndSS7o2i967WMI/vngxPfREGQvp+VTI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B34B3CE2D43; Thu, 27 Jun 2024 01:00:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F045DC116B1; Thu, 27 Jun 2024 01:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719450057; bh=cVjMReDf/y0/Eps4SzleHHnDCMnHwvcYHN7Dj4UkNNg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nwfaFDJ/c30GiYmVc82cD+AdVo7ASrnc05c022cx7CwFpW+ctla+QGAWhR7g1u/0N FYQFKuzWEbo7DOQHlPOPzqZ9JMeE0rDVK2Z9M4eU1oHAd2ynL1MMg1rhKgKBK5LXIA N57GBUcpsaC9GC0Vd33/hTbi+JuMNBPY7ftTa2coNIlhKyUl9lKFV375aDLvjgKRlh W34ZJnjvdQcAdBbpmX5o392KQ/rt6/HfqCiZTEzUsxfJdRLGhocUh1i3gvv/k3wsHo 0HntC5Inb6+MF0og3whrwgsMnla76xGCkDZAFd7OXXdWHpqiiGu+SiRTccaF1IsHZd ziBcVX92FrFqw== From: Jeff Layton Date: Wed, 26 Jun 2024 21:00:30 -0400 Subject: [PATCH 10/10] tmpfs: add support for multigrain timestamps MIME-Version: 1.0 Message-Id: <20240626-mgtime-v1-10-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=775; i=jlayton@kernel.org; h=from:subject:message-id; bh=cVjMReDf/y0/Eps4SzleHHnDCMnHwvcYHN7Dj4UkNNg=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmfLmvmuG1qE25UPrDynn3xIhwH5hC1wcY+8bCj oncJyX2Q2OJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZny5rwAKCRAADmhBGVaC FZiQEADD/GWDUAnr+QPK/65D/8cdJ2MjbHRshcq6JjFg04ftIlKReTiXHUgZFibwslcU1/KJXqA AeCQYsajkGNfClYJdPooe+9fYkC/bZ9TuTbCx8vgEkdy5spW1PqMwKpcYnaOtz0rt+y7f+dDbvZ Il5HQomOyFFjic4OS56a9d3g7ZKHKrMT25Wr1E2xXYMp/1TFSnsZ6PzqJZC83R08MKAk9AiLN8W ATgs3TQWKeBloEOKCB49jcfGIHtirxKLivKHL04iaZImju21FOjEedEXy021mtUKZyS7/UIF7Vy 7tSTQr9F9vTxs93vtzmWUDC0cLFTtfaog4o/C9zuhVTW/mjZ4JmWIalSU6uBqnFqemiucQSCe45 q9afVDCLHijyoaX+aX1D2/8vYg//+/oDAPzmt0VmULKwekM+f3ZtbPVKqSOI9HaVAhV769zRd9u MWeehoAPSlcJTBKBZrQVCIX5aX7q0CQnuN7+t/nESwmDBtRnwLzpAj//XiDM68TFxPn6wHMV+O3 e0sUqEzWfynVDKhu9OXrLQb1Pq0wfWdW/G60LQlJCK1iST4tmUat5GbRh6rexvj9nTJXgdnyJ0R YLi8/dD1+0aE1S1yt8LtuIzPrKFhLnTNMcmcmi1DKRiDPpKRcRqI7FY3mFi18w9FfIKybfXInFJ Sm7/fCDwxamE4rw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 4C0C310000C X-Stat-Signature: x4m6g1qq1ie8ybyq4uubek1gquceifft X-HE-Tag: 1719450059-415004 X-HE-Meta: U2FsdGVkX1+3QnJ9ClPq9eIt4B74T8vqyN7ILwjXegcyGxTbLGWIxy4exXQjZ4GdDsjkoyVKJBVS0Uv0Lad6cBC+EnJJQLcXIKo9OYLY9Rv3WlVzZaDBrd7ZUY3KX4kykvbEbdQylDXb2b4oNDPCB4PV4QUsOCi+6xNV6MVkFiA4h0qBleyP11nuB7Sh7XRq5JWUtw5a7uwwv5/oegNKN9Lapt3tB3pcrq6WsH1YGl3AUB9XbjAv/M2EO/+n/igwMwarMO3mi+8TDAqpaeyc2BYnt+e08eujtgWPkcWZHGnGYtMEC3Po8203WVLcko3gcocfM/J4MWPF7p1n7kX7V/Zv+2RjehxG4fIGbfkcAnBoOWRaZlgnfeROZyqOFsSytKPatRhY5WY5MqTsQtBFJroAjPdv8rCqLBOmjPLaOk/opOWZatgJIqR3YhG0THv1JX8Cfv5TmOeDMB9xqWxLPHLHxR8wG1r28iESbJhIg49fwrX9rboC6RdtvTqjqLtXgOljAnLwAKPEzI7LP1wBJkX4X/+X1hETZngSy/uBo78OmkpnknKuYc3L0LIeOZUiikkbfHH/CaTkwFuTmcyrFRRFJl1sIbQJkXaqygK5U0oD14YcEJOnZx/K4dpB2rkgwutlxtnc0J5BbnnvL2/8lftWwr3YBy4XKDbIHPG3x2wWTxzZugkV3ertusX0xj0k7QMUCX/XcmPYNWIBguYqC0KQhXb39VfKrT4XqSnTf6vADQd9t1pWP/3H481IpEFUM/1T9efJEmcpwfGLO1H3O7b1swdANJC3KY38oTiVXhlctVC+jnvXDY5O3oh4Xx7h+Dx7/yJBFSlP1f0M995+oyEBMJTlbU/hNfCmAAdhlOB8PepvL1nyGc/nDXpKTI6jlxh0wBBgsv+Nb19RcAQIhX3neqz9H3VQidTaNl2PIlNrDG82BzM5D3r++rXzS3FdCVK/lPyIox6Bgys32KA +9/5O4pF 9t3SjEp7CmBeonNUK7wUfkxTQKwAjP4KB4P8qItghu7q0xW6ooOWT0be/W2jRc/5ddJL7HsZ3rysrdy0VOxU7NYRivX8nURI9nXZViBZ+lmO1PCUwvP1NZFYtfJV+WaESTQlqNqtR+W9GDRM0QGL6mW/ymLcXfEf/DAsN4ef4iot8PKCD/zPl8EJLcMavdaiL6sfs/lZIWcR73lPCfb/zWIHRhGeuC6ct7/9BLa+T0zJJleXjnG5LSgxkQA== 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: Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. tmpfs only requires the FS_MGTIME flag. Signed-off-by: Jeff Layton --- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index ff7c756a7d02..d650f48444e0 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4653,7 +4653,7 @@ static struct file_system_type shmem_fs_type = { .parameters = shmem_fs_parameters, #endif .kill_sb = kill_litter_super, - .fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP, + .fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP | FS_MGTIME, }; void __init shmem_init(void)