From patchwork Mon Jul 15 12:48:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733438 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 9BCBCC3DA4B for ; Mon, 15 Jul 2024 12:49:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D1D26B008C; Mon, 15 Jul 2024 08:49:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 259326B0092; Mon, 15 Jul 2024 08:49:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D3626B0093; Mon, 15 Jul 2024 08:49:18 -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 DF7B76B008C for ; Mon, 15 Jul 2024 08:49:17 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 668AA1415BD for ; Mon, 15 Jul 2024 12:49:17 +0000 (UTC) X-FDA: 82341967554.23.CEB4454 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 94795180010 for ; Mon, 15 Jul 2024 12:49:14 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qYCKKiNb; spf=pass (imf06.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=1721047725; 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=AAloJPKDnTWFR/vOnPncq6tKSL/vTV3xbImIcICS+PA=; b=r7IFHvjIHfGXjLcBdhl7qFXPz7UXENeSiNjYvcbsjIng21mcjlglWCv6wcpVSBJMARaJML NJGNUccoszpYUVX2Lysvm30NqrYRl9BEKXJ6fI6ZCdxlH0yVk4BvsluIOTjWCs1Vp4Q7q4 hsBz7mWRdYOeUZqQNGXRXFb4oV6Igwk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qYCKKiNb; spf=pass (imf06.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=1721047725; a=rsa-sha256; cv=none; b=oRd8PqsOrzj6l7eusfghgPBRn1KkMpJdyWSrDaIegYx1ENzn5zfR+lnMt6HlybpAc81QMN vhMV6LdKM5jBEgZqtDb4iTXaZkjzYYSB6Y+eotU+4W2R4GdVy2FIs2QOWHjTmBTe+X71l2 Gc35jzMY5wm/1H79ZE6s4f/HmOZ26ho= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BB45360DBA; Mon, 15 Jul 2024 12:49:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D091CC4AF0C; Mon, 15 Jul 2024 12:49:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721047753; bh=6RYo72I5y5RcRdxKYi2v4wCnQYvk9YGbpl/t75l2w/8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qYCKKiNbmw8qJxTSl91sH55UoflXy7kmg5C3rmJRKKoK6l0iZn6igiowuHxR6GStS vmzK8X3wu7OhtJO8bJS+o6lJGgHolq5NCiwLJasqqD1zV5nR0+Lzu7OF9G89sOtFap gWF3+zBh54bx47eAhtS4G57pLiS61YeHt/PIva3iyL1xVbrCx7MbOT3bEH0AYgBBKl MwYWoBccADAdyQdIVUqsbzXx21EQJvXLysKApGOE51SQmDqGECESGlo0SIYY/GNnHa 9ggtthQPNEQB00R9H+ItDVqQmY+j1ZCPxfxFvC6B+/75+bpzQqfi2a/nyxVdRVL9Sm 8sIqTMf2Btyww== From: Jeff Layton Date: Mon, 15 Jul 2024 08:48:52 -0400 Subject: [PATCH v6 1/9] fs: add infrastructure for multigrain timestamps MIME-Version: 1.0 Message-Id: <20240715-mgtime-v6-1-48e5d34bd2ba@kernel.org> References: <20240715-mgtime-v6-0-48e5d34bd2ba@kernel.org> In-Reply-To: <20240715-mgtime-v6-0-48e5d34bd2ba@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 , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=15508; i=jlayton@kernel.org; h=from:subject:message-id; bh=6RYo72I5y5RcRdxKYi2v4wCnQYvk9YGbpl/t75l2w/8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlRrCsEsrn1gBjZlojfc55qZiw5ENu0CWwKCap gZvNtjpeKaJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpUawgAKCRAADmhBGVaC Fc0KD/9e7+cdNJn5WFxvtHizKo7QQt2+iq4QAJKr2bekcs14nlvK0IWVZ2siySQ89SUoGFSBhYg IHQVqFG+nE/yzXGsAdlNJf+/3sdsoaVrIZ1kx48WLZJTfrDdNQFNuzNXCOqvrriJo01TQyjzeuI RRUzr2TBiDhxUvqkr6ufdq+jV/KSBgBtjNOPCI9u+Y6gD5GnqJjb/XOfmN6uORidN6v5nXh8W8G 3j40oqYfZ8ZSdy9aYDWO21IgGuUW3P3XeO+ZaVjpYft1bxzAlX0j8G3W8AmE30guyFNM6Uknjzk WWvoc8EEGR2FiP7x6Al2CWA9yONOD67nVEBUxRjF+x4rnw2JKzJpYDMrFVUqToxpkn8ofLtVB16 Qb/UhvZcr4L86cQvXrWCuUCZo+fjEcS46gZmLG1KG60H6U9c6xymvCTP9a9ADffnCZEoNyhE3d7 KBsFoA/aqsjOQtXSXvCwPylKRZGzsxNaHng5cHvCt19y65OKAkb02jDuD9vlflpZ9Bs3FJCRc9h Ga8hH2z+rmj4nJIlc6CRB2NO4fGVeVuZjFTMq7Q61GOVCGE0Zyog6IGPWLkMLaSwjheNbm1TD01 5AbycQVeYPqR41uV7Yz70qlvOgDCuhPi194oyOtlMsBRUKv3AxUMe5sUoppi6eVS1nX2NXKhVvo 3FH6iYl14AX9umg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: xooxteh55kui4tcqxue3wxx3bj78mdpd X-Rspam-User: X-Rspamd-Queue-Id: 94795180010 X-Rspamd-Server: rspam02 X-HE-Tag: 1721047754-868848 X-HE-Meta: U2FsdGVkX19Jjze6m2nl18Kz+s//r8vMVtMb1JgmiQe97REMy4Wb654f5IRgVwjglDSEd3DUncl0ui8EcIgGdx0J1An/moyvT7Ehp2v62MNc8L1ZWCqkBg8fNSClacvaMvkqc9KbDYvF4cJJrb6rWwSfvnd2P8Z7MQQYbmR3DMuscTZx6c49n3ecuGeblD5SzPK2lJUjuMGF4KV3AvlOzhRNJXNppKzXsDDUEfNqg34LVH4Bbi8N3/XUiqQBGcyfdbyUSyGKqLLJZyd3+tRaTnv+PwVQS97G3SuGMoZ43VYwBXRyEjm7/rRSyjrhSUIX52URZ1cGSYOEW/RN37Kq+7md9vga57sayl79t/ekDpA+oEtbYyRlIeMAm3Gg1Jp9I/yZVdbnUK/Ti60NauNHf2FoThV6AEJmVETbbegaO1qdivLhcXERhstkUemRaAZa04fUg+crM/Tc4xSz9Bu9PObfzI14GlmKWUU+oJMKxU/+DCClL4EkueD6UyxzJQ66ulnHppTS3ZShdNCJk98GfVKojqeJQoYHEutMlVc/l2pqQG+PC9//xK9TPC3DTVOoNsscrvdXvpHmLsmQiEwzg7Ic5qP5Yip9uhZ+Dft/lXHxOwJOON4JyX874TcOIk36QOR23WngXEG/P3vpGqvRV6hWlPUyZWE806mMdVI47Aixq66gKBm4cOAVWDYA4LEYcC9ajbWVWnE0lXRwKYz03LnDlDpA0sNayjm7BUVwpPpUD3dzj/aSPDCY2ogtIxJjF/sHH71ZoCFxEg3XJwvtepOaLd+HIpl6y7PRJ2hSKD7lOctXBPtHkpPxNVyPTZyw266J48aP+gcQozWGaKWBgDcXi2THG78dTQh/yVfAt8koKwLrTVm66hDo5f5ysGwlVhPBt5JI3oNI9d99SnSPCoz5YdsDWCoxjHkwJ8NwKLb2eNhl1+e3bQTTcQcmMpUDBsUsg15jX8eQydTXWvS KS0/abuV rDYK8CWdO1T6/kVgC7/ykMIAdswg/R39gIrbNaoW2+HBSJ8uVoE1I6ySPE732vio8iRpwj1fbJhcyItmYKi576yoRqNUMFwRJelL94duSKwHmvwpOyBH4pYK1w1wyU2k+LUQVqKTxOOjZSInSd5TfVLw3igYSm8q9FpJD0lD3DkTxB9mM7B704NjQi7q+1w99ltFL+JHlt0sVAP0zAEzNl4+UxRHsJ+EyN9Rf+6MGn/m7M6eqmP4WnT9+aYuJCy/ZEHgI7pzFp/u0jy3iaWy+phqpZ5YdCylxqWtyj2fsJcp0mm7MVOgMjFEFpw== 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 has always used 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 when 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. Use the (unused) top bit in inode->i_ctime_nsec as a flag that indicates whether the current timestamps have been queried via stat() or the like. When it's set, we allow the kernel to use a fine-grained timestamp iff it's necessary to make the ctime show a different value. 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. A file that is altered just a bit later can then get a coarse-grained one that appears older than the earlier fine-grained time. This violates timestamp ordering guarantees. To remedy this, keep a global monotonic atomic64_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. If the inode ctime hasn't been queried then we just attempt to stamp it with that value. If it has been queried, then first see whether the current coarse time is later than the existing ctime. If it is, then we accept that value. If it isn'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, convert it to realtime and try to swap that into the ctime. We take the result of the ctime swap whether it succeeds or fails, since either is just as valid. Filesystems can opt into this by setting the FS_MGTIME fstype flag. Others should be unaffected (other than being subject to the same floor value as multigrain filesystems). Reviewed-by: Darrick J. Wong Reviewed-by: Josef Bacik Signed-off-by: Jeff Layton Reviewed-by: Jan Kara --- fs/inode.c | 176 +++++++++++++++++++++++++++++++++++++++++++++-------- fs/stat.c | 36 ++++++++++- include/linux/fs.h | 34 ++++++++--- 3 files changed, 209 insertions(+), 37 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index f356fe2ec2b6..417acbeabef3 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -60,6 +60,13 @@ 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); +/* + * This represents the latest fine-grained time that we have handed out as a + * timestamp on the system. Tracked as a monotonic value, and converted to the + * realtime clock on an as-needed basis. + */ +static __cacheline_aligned_in_smp atomic64_t ctime_floor; + /* * Empty aops. Can be used for the cases where the user does not * define any of the address_space operations. @@ -2127,19 +2134,72 @@ int file_remove_privs(struct file *file) } EXPORT_SYMBOL(file_remove_privs); +/** + * coarse_ctime - return the current coarse-grained time + * @floor: current (monotonic) 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 timestamps, converted to realtime + * clock value. + */ +static ktime_t coarse_ctime(ktime_t floor) +{ + ktime_t coarse = ktime_get_coarse(); + + /* If coarse time is already newer, return that */ + if (!ktime_after(floor, coarse)) + return ktime_get_coarse_real(); + return ktime_mono_to_real(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 floor = atomic64_read(&ctime_floor); + ktime_t now = coarse_ctime(floor); + struct timespec64 now_ts = ktime_to_timespec64(now); + u32 cns; + + if (!is_mgtime(inode)) + goto out; + + /* If nothing has queried it, then coarse time is fine */ + cns = smp_load_acquire(&inode->i_ctime_nsec); + if (cns & I_CTIME_QUERIED) { + /* + * If there is no apparent change, then + * get a fine-grained timestamp. + */ + if (now_ts.tv_nsec == (cns & ~I_CTIME_QUERIED)) + ktime_get_real_ts64(&now_ts); + } +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)) @@ -2507,6 +2567,15 @@ void inode_nohighmem(struct inode *inode) } EXPORT_SYMBOL(inode_nohighmem); +struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts) +{ + set_normalized_timespec64(&ts, ts.tv_sec, ts.tv_nsec); + inode->i_ctime_sec = ts.tv_sec; + inode->i_ctime_nsec = ts.tv_nsec; + return ts; +} +EXPORT_SYMBOL(inode_set_ctime_to_ts); + /** * timestamp_truncate - Truncate timespec to a granularity * @t: Timespec @@ -2538,38 +2607,91 @@ 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_set_ctime_current - set the ctime to current_time * @inode: inode * - * Set the inode->i_ctime to the current value for the inode. Returns - * the current value that was assigned to i_ctime. + * Set the inode's ctime to the current value for the inode. Returns the + * current value that was assigned. If this is not a multigrain inode, then we + * just set it to whatever the coarse_ctime 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_nsec. 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 now, floor = atomic64_read(&ctime_floor); + struct timespec64 now_ts; + u32 cns, cur; + + now = coarse_ctime(floor); + + /* Just return that if this is not a multigrain fs */ + if (!is_mgtime(inode)) { + now_ts = timestamp_truncate(ktime_to_timespec64(now), inode); + inode_set_ctime_to_ts(inode, now_ts); + 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. + */ + cns = smp_load_acquire(&inode->i_ctime_nsec); + if (cns & I_CTIME_QUERIED) { + ktime_t ctime = ktime_set(inode->i_ctime_sec, cns & ~I_CTIME_QUERIED); + + if (!ktime_after(now, ctime)) { + ktime_t old, fine; + + /* Get a fine-grained time */ + fine = ktime_get(); - inode_set_ctime_to_ts(inode, now); - return now; + /* + * 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 = floor; + if (!atomic64_try_cmpxchg(&ctime_floor, &old, fine)) + fine = old; + now = ktime_mono_to_real(fine); + } + } + now_ts = timestamp_truncate(ktime_to_timespec64(now), inode); + cur = cns; + + /* No need to cmpxchg if it's exactly the same */ + if (cns == now_ts.tv_nsec && inode->i_ctime_sec == now_ts.tv_sec) + goto out; +retry: + /* Try to swap the nsec value into place. */ + if (try_cmpxchg(&inode->i_ctime_nsec, &cur, now_ts.tv_nsec)) { + /* If swap occurred, then we're (mostly) done */ + inode->i_ctime_sec = now_ts.tv_sec; + } else { + /* + * 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 (!(cns & I_CTIME_QUERIED) && (cns | I_CTIME_QUERIED) == cur) { + cns = cur; + goto retry; + } + /* Otherwise, keep the existing ctime */ + now_ts.tv_sec = inode->i_ctime_sec; + now_ts.tv_nsec = cur & ~I_CTIME_QUERIED; + } +out: + return now_ts; } EXPORT_SYMBOL(inode_set_ctime_current); diff --git a/fs/stat.c b/fs/stat.c index 6f65b3456cad..df7fdd3afed9 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -26,6 +26,32 @@ #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_t *pcn = (atomic_t *)&inode->i_ctime_nsec; + + /* 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 = inode_get_mtime(inode); + stat->ctime.tv_sec = inode->i_ctime_sec; + stat->ctime.tv_nsec = ((u32)atomic_fetch_or(I_CTIME_QUERIED, pcn)) & ~I_CTIME_QUERIED; +} +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 +84,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 dc9f9c4b2572..f873f6c58669 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1608,6 +1608,17 @@ 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. + */ +#define I_CTIME_QUERIED ((u32)BIT(31)) + static inline time64_t inode_get_ctime_sec(const struct inode *inode) { return inode->i_ctime_sec; @@ -1615,7 +1626,7 @@ static inline time64_t inode_get_ctime_sec(const struct inode *inode) static inline long inode_get_ctime_nsec(const struct inode *inode) { - return inode->i_ctime_nsec; + return inode->i_ctime_nsec & ~I_CTIME_QUERIED; } static inline struct timespec64 inode_get_ctime(const struct inode *inode) @@ -1626,13 +1637,7 @@ static inline struct timespec64 inode_get_ctime(const struct inode *inode) return ts; } -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; - return ts; -} +struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts); /** * inode_set_ctime - set the ctime in the inode @@ -2490,6 +2495,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; @@ -2513,6 +2519,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)); @@ -3252,6 +3269,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); From patchwork Mon Jul 15 12:48:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733439 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 B8C14C3DA5D for ; Mon, 15 Jul 2024 12:49:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D0A46B0092; Mon, 15 Jul 2024 08:49:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2AB8C6B0093; Mon, 15 Jul 2024 08:49:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 086A46B0095; Mon, 15 Jul 2024 08:49:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DD2C36B0092 for ; Mon, 15 Jul 2024 08:49:19 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 73A93C1576 for ; Mon, 15 Jul 2024 12:49:19 +0000 (UTC) X-FDA: 82341967638.20.65C7DC2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id A3C9FC001C for ; Mon, 15 Jul 2024 12:49:17 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ur9LdRyA; spf=pass (imf22.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=1721047739; 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=Cd/jBsRAxquHh6M92Mm3t6t3MkIKhZpQhfKmmeqBbWU=; b=tnM0H80vx99xzP3IYZ0m0Lx4fUKA4kR/PGJVxUJg967NVur3rl60L1ZgAjM+8xcTFzKLDW 8q253AUQfFrXsEYdpsjaqm0Wpr7/k4U6InmclvBpqTUUInoM/42jS6fh8bYvrCc+ipZ1FD u5IGu3m31l/OVxFaJ9DNopY6FRYjEdY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ur9LdRyA; spf=pass (imf22.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=1721047739; a=rsa-sha256; cv=none; b=4G/LUDirCg1BMYNWqGNTKhOs9ro/liA27kVqXrvKK7wAD4rpj8+SwQ4gYdo1n/3F0rZu36 N3+CouriQxG7m9Z6lrSBWWMgVscrrNeJV815j86cMLT5xT9FTHnBAndd01yHBxU3F24oDx uK3LFA6cLAqJWbFUzaNUT/8XyBB0Nbw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C60916105A; Mon, 15 Jul 2024 12:49:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA9A6C4AF12; Mon, 15 Jul 2024 12:49:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721047756; bh=JF/UPK3ugqCOBOaDB3oltr4AnbnZLO/O9/Xo7V+dF+g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Ur9LdRyAvrQagDyjIWlEueNxPt9nz4/83/B6DD+X9AKi2i4/a5sMfqUVlz8RbBvcE Px7Gaj/Lm7MtFRRybgKxCT/6t6an+0CinXqzM5r/4Ddt/uWMtaXBjx19DXKcLlBPLZ Y2y1mYNlM6rQHHBhxXvFe527889tYnjdqlLtjyr1yUOS2DxQyXXi2+uD6DHbXOhX2b E1Ga4zCQj4fJNeyw/q+Zos3j3cyle2JETp8CEVD39WIJUhBxNHi+wy4R9D5GQyQC+O O4jzYdl07IPgm0A0EyuPEG2KANH9JzsGAuoOq9gQukqfxLMRVWW4uUrIcAHL1bjAlY KQC636ATizJXg== From: Jeff Layton Date: Mon, 15 Jul 2024 08:48:53 -0400 Subject: [PATCH v6 2/9] fs: tracepoints around multigrain timestamp events MIME-Version: 1.0 Message-Id: <20240715-mgtime-v6-2-48e5d34bd2ba@kernel.org> References: <20240715-mgtime-v6-0-48e5d34bd2ba@kernel.org> In-Reply-To: <20240715-mgtime-v6-0-48e5d34bd2ba@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 , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5888; i=jlayton@kernel.org; h=from:subject:message-id; bh=JF/UPK3ugqCOBOaDB3oltr4AnbnZLO/O9/Xo7V+dF+g=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlRrCSgUIIsCgXmn1E3IInVm5DrnlaLkzFW1Jw Q+FZkqs1YuJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpUawgAKCRAADmhBGVaC FeayD/4qqJuWDW34Qj9rLUQz1zDsDJLwxRBQatCJZuZzyADr4yvwLceGX6w1+FUvXEa67majQhJ e7oBwc+4hdgMiY3uolxhzopsEolZMhJ0iQqVJknfBn9+457EHEsVYbUv3lbZt2FUI0+z3F1CjZe tlBSFJ5YtE6qYdGbVLfp7t+6h9WeNhRCndTXKSM+Rhq62e+ECQyEVvkFCGD7Z2yWnn7X0TFZIFo F6t/iZwxyG4d7FNQFSXRBnHBX94VW4L5SdosG9r4N4o8OCTKSH0cEwAv/RRj6Bl6AsRTAoC486f 5JooGyoWoUxLj4BTmVYknjinuTvdD8CNaua5BvXftYb6NZfx8wM4vjlxsosIH2ag4AvP4B+loSY fBhiNsjn6oFZ9R/y3yiLqXD4hKHs0B6TSYjPZUKOnF+IOIdt7wnaJJPoUpJ5XcR7cvAsvg35Q5G q4YzxTeFXs4B37EfoEHKXJNRP53TC7Exzv1Gkg3z9dV5iqep1Yr6tCCcXYz4qRmYPCQegvTkSDe rrQB5mVJ/qWQ/uhYcF+1tDw6JhZcVIDgS9Ux4kYW2sYVA0znjt4RwDhTvZB7HOhaDDU/+u232Sy 5UDpuVg1mOk5Sp9DpgFxvvqL+Ft0vVIgua2aXNn8v5w7PfPa476R4sLaUcfUXlMt0QCw/jFVIOV D1//ICt1f739Nfg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: A3C9FC001C X-Stat-Signature: 9xc5wrkn8bj85ewi4puicyynacqwp5xn X-HE-Tag: 1721047757-238060 X-HE-Meta: U2FsdGVkX19i1C4buEoL0bo9AvTutsj8n6Vxyt0caUKa1cyWLoL9mMCjkYb0ArVLkd1zXVDY/8bd2s+oqwl+MS3S3dd+eIUI1kd+/8+Q0xTrZz8IQvDJ4OzJR/HuZDBkzV9yRsKbd+bj4JnP4iM8I/oy28OYKxsCsN+PwcilnqzERFWLzDbnNG+nJAw7oq8jekBV/GYRDM3l1mKDMnsiuYjsRIo00cKntrx6m5e0et7bN8jSWxRpwAprRv+dMu/NnaGYIGWHuf/pGsM5hJ34w7JScRIAXQjZUXeH1vjqwpFUWrJ3NSIGBBeGwkBsS4IxX9v2v84fkB1FFETd1HtEH8yETuEmlH6O1/J+OYF9SKsYryblrXxtP7b2FpFJF43IzziqcrZ4GVqTmXAUwwv9bf4MfL3G0ZtBsZ4TueuQbK8rfH7hlH6jn+k4AkzCVJd7OvvnUuQbBDizLbgTHU/pZYMMO8fyHi7SjknevgWFoSV+P3UwreBkf4fwYKfCOZVRJzfsK0olRVQ5XqY+4T6lJd5N6xBOBHSajeZ0R7f3dwlvkQ13FngCiP1OzxnXQs3TEA8XUvn9OFwlA4csr1kUhllD4jH4ofT2398wAE0KcJegEC+G/5UZQ7xBU2qBYGzUxjhj6Bl26CsYUPiL3qqOEWEIuLAVf9CNT+yAc2+wjRj4AFL5zrQ6lc0/jmHuTGaoV/lUhtPDupLDflXkmxpnhHgUvhZpkgN/lX/sc0HwljsTVIk9Cl6OpYSFKOuUjxPk815U5oi8lMJBrxIT6HePvZnvV/lkfIzMefDkRYYezdie0QtOMRbALXQqce62Qo1FcQg8OxCljoxCBh+TgvaH5g9rZ7KvQmPFCKlaWOd7eKgC5sMkIFmgPUs4kynjx4zRqrr4nS4mgIiwRal+OK1B5LU4N1AWgah+u+MpFCUD4WWPe31pwtlvpqCnFyedxRGmxyBQ/+R92IiCtL1yn3+ aP0D2CRp e77e5I+WxLO2JuOQ5D4Ecu57Umud5qK+UMwGLIMg590p8FYMNDhVY0KLsKQ4VrLOa+8Nq9ht+IgRnPgTiu37SeVAsTCG/Dy4ceTabXLl2N/vhsLMmI4kudH9O5FKg7SoSyAmZT2TEaP9UqovQK6bhntdaYJ3XSPe8J/zjaIF8wNtKwmyE+DRLq7ELC37Bnb+mQBqkn6TSsEn0Mvj/QFI1HtDzlujBiDhW4n9fePhdyhLZoVtNnukNRMtuCn5qMphqJlI4TD9JXwaCRpsbEWbnI8JnLofxtckZl+2khKBB32haISCjC1yIBRuELA== 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 some tracepoints around various multigrain timestamp events. Reviewed-by: Josef Bacik Signed-off-by: Jeff Layton Reviewed-by: Darrick J. Wong Reviewed-by: Jan Kara --- fs/inode.c | 9 ++- fs/stat.c | 3 + include/trace/events/timestamp.h | 124 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index 417acbeabef3..869994285e87 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -22,6 +22,9 @@ #include #include #include +#define CREATE_TRACE_POINTS +#include + #include "internal.h" /* @@ -2569,6 +2572,7 @@ EXPORT_SYMBOL(inode_nohighmem); struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts) { + trace_inode_set_ctime_to_ts(inode, &ts); set_normalized_timespec64(&ts, ts.tv_sec, ts.tv_nsec); inode->i_ctime_sec = ts.tv_sec; inode->i_ctime_nsec = ts.tv_nsec; @@ -2668,13 +2672,16 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) cur = cns; /* No need to cmpxchg if it's exactly the same */ - if (cns == now_ts.tv_nsec && inode->i_ctime_sec == now_ts.tv_sec) + if (cns == now_ts.tv_nsec && inode->i_ctime_sec == now_ts.tv_sec) { + trace_ctime_xchg_skip(inode, &now_ts); goto out; + } retry: /* Try to swap the nsec value into place. */ if (try_cmpxchg(&inode->i_ctime_nsec, &cur, now_ts.tv_nsec)) { /* If swap occurred, then we're (mostly) done */ inode->i_ctime_sec = now_ts.tv_sec; + trace_ctime_ns_xchg(inode, cns, now_ts.tv_nsec, cur); } else { /* * Was the change due to someone marking the old ctime QUERIED? diff --git a/fs/stat.c b/fs/stat.c index df7fdd3afed9..552dfd67688b 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -23,6 +23,8 @@ #include #include +#include + #include "internal.h" #include "mount.h" @@ -49,6 +51,7 @@ void fill_mg_cmtime(struct kstat *stat, u32 request_mask, struct inode *inode) stat->mtime = inode_get_mtime(inode); stat->ctime.tv_sec = inode->i_ctime_sec; stat->ctime.tv_nsec = ((u32)atomic_fetch_or(I_CTIME_QUERIED, pcn)) & ~I_CTIME_QUERIED; + trace_fill_mg_cmtime(inode, &stat->ctime, &stat->mtime); } EXPORT_SYMBOL(fill_mg_cmtime); diff --git a/include/trace/events/timestamp.h b/include/trace/events/timestamp.h new file mode 100644 index 000000000000..c9e5ec930054 --- /dev/null +++ b/include/trace/events/timestamp.h @@ -0,0 +1,124 @@ +/* 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 + +#define CTIME_QUERIED_FLAGS \ + { I_CTIME_QUERIED, "Q" } + +DECLARE_EVENT_CLASS(ctime, + TP_PROTO(struct inode *inode, + struct timespec64 *ctime), + + TP_ARGS(inode, ctime), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(time64_t, ctime_s) + __field(u32, ctime_ns) + __field(u32, gen) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->gen = inode->i_generation; + __entry->ctime_s = ctime->tv_sec; + __entry->ctime_ns = ctime->tv_nsec; + ), + + TP_printk("ino=%d:%d:%ld:%u ctime=%lld.%u", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, __entry->gen, + __entry->ctime_s, __entry->ctime_ns + ) +); + +DEFINE_EVENT(ctime, inode_set_ctime_to_ts, + TP_PROTO(struct inode *inode, + struct timespec64 *ctime), + TP_ARGS(inode, ctime)); + +DEFINE_EVENT(ctime, ctime_xchg_skip, + TP_PROTO(struct inode *inode, + struct timespec64 *ctime), + TP_ARGS(inode, ctime)); + +TRACE_EVENT(ctime_ns_xchg, + TP_PROTO(struct inode *inode, + u32 old, + u32 new, + u32 cur), + + TP_ARGS(inode, old, new, cur), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(u32, gen) + __field(u32, old) + __field(u32, new) + __field(u32, cur) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->gen = inode->i_generation; + __entry->old = old; + __entry->new = new; + __entry->cur = cur; + ), + + TP_printk("ino=%d:%d:%ld:%u old=%u:%s new=%u cur=%u:%s", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, __entry->gen, + __entry->old & ~I_CTIME_QUERIED, + __print_flags(__entry->old & I_CTIME_QUERIED, "|", CTIME_QUERIED_FLAGS), + __entry->new, + __entry->cur & ~I_CTIME_QUERIED, + __print_flags(__entry->cur & I_CTIME_QUERIED, "|", CTIME_QUERIED_FLAGS) + ) +); + +TRACE_EVENT(fill_mg_cmtime, + TP_PROTO(struct inode *inode, + struct timespec64 *ctime, + struct timespec64 *mtime), + + TP_ARGS(inode, ctime, mtime), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(time64_t, ctime_s) + __field(time64_t, mtime_s) + __field(u32, ctime_ns) + __field(u32, mtime_ns) + __field(u32, gen) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->gen = inode->i_generation; + __entry->ctime_s = ctime->tv_sec; + __entry->mtime_s = mtime->tv_sec; + __entry->ctime_ns = ctime->tv_nsec; + __entry->mtime_ns = mtime->tv_nsec; + ), + + TP_printk("ino=%d:%d:%ld:%u ctime=%lld.%u mtime=%lld.%u", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, __entry->gen, + __entry->ctime_s, __entry->ctime_ns, + __entry->mtime_s, __entry->mtime_ns + ) +); +#endif /* _TRACE_TIMESTAMP_H */ + +/* This part must be outside protection */ +#include From patchwork Mon Jul 15 12:48:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733440 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 205EFC3DA59 for ; Mon, 15 Jul 2024 12:49:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EF686B0095; Mon, 15 Jul 2024 08:49:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89C8F6B0096; Mon, 15 Jul 2024 08:49:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 714A26B0098; Mon, 15 Jul 2024 08:49:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4910C6B0095 for ; Mon, 15 Jul 2024 08:49:23 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 10C771A168D for ; Mon, 15 Jul 2024 12:49:23 +0000 (UTC) X-FDA: 82341967806.03.EA68E7E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 4D5EDC0016 for ; Mon, 15 Jul 2024 12:49:20 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gTkc25ss; spf=pass (imf22.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=1721047741; a=rsa-sha256; cv=none; b=PrzKQbPyZtqZd9lQXPhDTdrV+w5paHOJw0keNYXhU505R2NUxcHWsJRUmFC8S3w/L6t3Y2 Bl49oKEb6Yp/IAx9UUxI3SfzpX/IADpJS3qxtnM3np+cQ2c3HzyPZDFN+mpkv2vbXgu843 F9vw72r71aQv5RWbnSmj9TI4HAXi390= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gTkc25ss; spf=pass (imf22.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=1721047741; 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=VTMfzdrp27uG47UaiooorN5rUMq6f5kc/ISsASb0PyQ=; b=eka80/7EpFOl7mO24Q6EVmxWhxumR81wep2sfHEC0vjfL/mKqyLzfcUkHWHsoXK/hqv27N L6DC63Qkjfmj05GAdl6/1Ysyvl9LdJaADCZPjKxy8Ny26r4WmbU/qGob/DWXLjBRSBpaph 7tmLV1LB6Xsy2os9+S+aNSdtz+Y2L8g= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9B3D9610A2; Mon, 15 Jul 2024 12:49:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9369C4AF0F; Mon, 15 Jul 2024 12:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721047759; bh=HU6vitpuM/kW1drnmaJbobayjjiX3I313g5+a5XkSf4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gTkc25ssg6JIYDP5yx56GycmMYuUfPA/FzBDPYtSausd5bgyrigtG6xODVb8OFUDc W55GGEX8O4LsV/vWIWiJXaEW57ho7kAdFYc7OntI/7DGEEG+UzzuKwUgoTgXmVHr0D nskM2bOoF9umr01Z2oPfDiJh31unMRdMxVeWkCddFmP5YTNa9cufjicwUcxSdODguS x/ocBfBFbu7LbPcwHdrStZ3DkRPrwj281kjkwLf2LxHJWPf+PfUse8dL0zznuS0lL/ BhOIYPIVsO7NG9BM274kgSdWSBGLKQn3Azf6ARWdsZ/uEBb4sVuN+Qrt/08zmgfGyr Zgy/6fN8dnQHA== From: Jeff Layton Date: Mon, 15 Jul 2024 08:48:54 -0400 Subject: [PATCH v6 3/9] fs: add percpu counters for significant multigrain timestamp events MIME-Version: 1.0 Message-Id: <20240715-mgtime-v6-3-48e5d34bd2ba@kernel.org> References: <20240715-mgtime-v6-0-48e5d34bd2ba@kernel.org> In-Reply-To: <20240715-mgtime-v6-0-48e5d34bd2ba@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 , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4074; i=jlayton@kernel.org; h=from:subject:message-id; bh=HU6vitpuM/kW1drnmaJbobayjjiX3I313g5+a5XkSf4=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlRrCYPk7Gycow3R8t8u9VHqvaLk0qL2DGj/tC M6baL/u3SKJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpUawgAKCRAADmhBGVaC FfCpD/wO35AVGJ7f4oBU8BPuQpqmK72PLEFjcoUJMSz/9hbuLYnDFxXNGdedZya7sbm3a82unkI OR0VZkAsVmwdUxJJHMEiHejznHsftKsq6O28bDsrH314esp9WXHHaOIbgT9Yv95jifbccGodejm On3SY90Jyi46TF+2jQMGpUlKJXM+FITar4aDAy9UEpPvArFZJRuAkOLijiyecK06u0PvTGzzBEp /0p/+3JwbXJOSNoVNVWXsClCMRKsoxvuc+dT0G22ktyL1aX9linfibZk8ck1bk0PhCVsi/gIm8Y 3P2pe7OkT3F6o9zDCFAr7F3XxetyoRxK7Fu5jPkE5iOR69hCGbmFXEJoya5GVNicwxqRdrRhdVn QjbFyIuJs1lgklHTHQK0qVdTwziVMashfL9yjxes92pMj6QKJGI3GjBsg4v8Q+BmQW6IftmEbOP zu757yUqHCzSRlHe0y1yf1nSY6erGn/S1Rvj41iulKcFd+96hIVbrKjZh5rF/r2wfJczzwAmsRy b8LgQ5p20q0H4h2GElvxGQAxGZqkU8f/uGDY1NwoCqK1dxcftLZUgbJ9HkPZ+AOnkGwGNTZ+viO +CzeoUQIrSpVhPYFFuzrzRvDqU/1xRLqMBMdqEf0c3dUGuE2xoWnhopq8VpLQuMBJX4RgroiKWP P3pBhVgyKiiwuqw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: 5qnoo16jr35itsf38egcprug68yk6ymj X-Rspamd-Queue-Id: 4D5EDC0016 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1721047760-277036 X-HE-Meta: U2FsdGVkX1/+qpjeytVkEaKl2gAdNkMhpcrkOix4zuLOKLT8WYt0pijCyQuOramdqBQbo+u5NbyspTZjqrHQsQd2qRtkHXmiqPmSSdVaz5FrLjU4DYUythc9svyYyIOq3+4K0AKLRSVCYgNPehYObmvBZ1pynMaA5U1xrp0Uh9SQnRDgoMBU+GCHLQKTSvcxWoTUZrckR8V59Lgoun3HL4QidfebWJWttj+07O3TMrlxZ92dNZou3d0SIhHoq+C9mTYWmAFgHUHs2y6G5suPPIOj/NA+e/82Lz9XhIe8r0esVi3+UirfHNmDrDJSyi6oU34R2wQHN2zPLuNUw4q9gVTnOWYPVjCMqAkSXA+ovlG4HapSIfh9XiqI7KspBtvX9+d0TLaJmsiYFl413ee2iH0LMDK+HIkjuKeQ8eRy4bo7oDXLo2uHTlCM5lYNz3JLj+DUI1p9+Y3xZ7lhu4+JDR6jxYHzzhS5oQZzf0fN4t/vlnfPLXBfC+qn4b6c/tgKyebF+3oLBxOvLjIEqiyc+7psuPTmMNaK4HJkq2AaESEODEcwP/ustOmCJn90emnyv1r/o0WC5r3vhlp7zF2srQBVU/jpNcUe8Gxc1m+t6jytqn/dJDNjGznjANZBCRz9lyvDsdDE/uYmLoHn0lXEydpu0JDXJLvEqfH7RdFPC6Xll9zMQW+tHMx1oynni2F6t/7dHcpIJTiGqWjUPFPWe1DxC5H23k8wJfr3tawEoaW/BaMi7zyiE1z2dq+Alr7kf23VHGppp1i6QLNAKp2IF366KeK3oBAgWjWf7qo64leGmjt/PoCrpKkLmlDR+oZWrVU2qRfFFo+Co+4vigj/wDWA2d3gWGfFs8b/FBmx/hSsHuKnEC1Te0IDkdpeaYcTW+WCIUFpN4NKlOUrK3sog/J2ZVMwE84fM5rHtS2vcV0xtlnRgio+1UzqujnOV+wfdgBaN0GOFQs4KFeIEAb rNRwhKNa fIAam+tsjG3DZrD/VC9SInUqEnsnKWm1v7vpB8ZBftRtUAjWSNdUW6E/Uxp/cuttiC1Vh3rUB54a/7W71+FSTPDGlGxxFqXHDsmYxnqWOMtNzSxxfULDhkuJyW5zXNUyV7uvRFKEEOJ7WqDSRSvT+VJ0u1XMSDFqAvEGIxZpFXgHr6oJrDNY309qjPda6rBD9/I5f09wcVPk4EO4NkvQnjFP7F13aHIgWjljbvXHlcWAqyNaOdtX+1sM+UsRs2ydkQ37FGcF/fiSVJwnBvVC8FRVWsDya0weaBcvJg93CRuRh6S2gTJij/wLTGQ== 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: Four percpu counters for counting various stats around mgtimes, and a new debugfs file for displaying them: - number of attempted ctime updates - number of successful i_ctime_nsec swaps - number of fine-grained timestamp fetches - number of floor value swaps Reviewed-by: Josef Bacik Signed-off-by: Jeff Layton Reviewed-by: Darrick J. Wong Reviewed-by: Jan Kara --- fs/inode.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index 869994285e87..fff844345c35 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #define CREATE_TRACE_POINTS #include @@ -80,6 +82,10 @@ EXPORT_SYMBOL(empty_aops); static DEFINE_PER_CPU(unsigned long, nr_inodes); static DEFINE_PER_CPU(unsigned long, nr_unused); +static DEFINE_PER_CPU(unsigned long, mg_ctime_updates); +static DEFINE_PER_CPU(unsigned long, mg_fine_stamps); +static DEFINE_PER_CPU(unsigned long, mg_floor_swaps); +static DEFINE_PER_CPU(unsigned long, mg_ctime_swaps); static struct kmem_cache *inode_cachep __ro_after_init; @@ -101,6 +107,42 @@ static inline long get_nr_inodes_unused(void) return sum < 0 ? 0 : sum; } +static long get_mg_ctime_updates(void) +{ + int i; + long sum = 0; + for_each_possible_cpu(i) + sum += per_cpu(mg_ctime_updates, i); + return sum < 0 ? 0 : sum; +} + +static long get_mg_fine_stamps(void) +{ + int i; + long sum = 0; + for_each_possible_cpu(i) + sum += per_cpu(mg_fine_stamps, i); + return sum < 0 ? 0 : sum; +} + +static long get_mg_floor_swaps(void) +{ + int i; + long sum = 0; + for_each_possible_cpu(i) + sum += per_cpu(mg_floor_swaps, i); + return sum < 0 ? 0 : sum; +} + +static long get_mg_ctime_swaps(void) +{ + int i; + long sum = 0; + for_each_possible_cpu(i) + sum += per_cpu(mg_ctime_swaps, i); + return sum < 0 ? 0 : sum; +} + long get_nr_dirty_inodes(void) { /* not actually dirty inodes, but a wild approximation */ @@ -2655,6 +2697,7 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) /* Get a fine-grained time */ fine = ktime_get(); + this_cpu_inc(mg_fine_stamps); /* * If the cmpxchg works, we take the new floor value. If @@ -2663,11 +2706,14 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) * as good, so keep it. */ old = floor; - if (!atomic64_try_cmpxchg(&ctime_floor, &old, fine)) + if (atomic64_try_cmpxchg(&ctime_floor, &old, fine)) + this_cpu_inc(mg_floor_swaps); + else fine = old; now = ktime_mono_to_real(fine); } } + this_cpu_inc(mg_ctime_updates); now_ts = timestamp_truncate(ktime_to_timespec64(now), inode); cur = cns; @@ -2682,6 +2728,7 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) /* If swap occurred, then we're (mostly) done */ inode->i_ctime_sec = now_ts.tv_sec; trace_ctime_ns_xchg(inode, cns, now_ts.tv_nsec, cur); + this_cpu_inc(mg_ctime_swaps); } else { /* * Was the change due to someone marking the old ctime QUERIED? @@ -2751,3 +2798,24 @@ 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) +{ + long ctime_updates = get_mg_ctime_updates(); + long ctime_swaps = get_mg_ctime_swaps(); + long fine_stamps = get_mg_fine_stamps(); + long floor_swaps = get_mg_floor_swaps(); + + seq_printf(s, "%lu %lu %lu %lu\n", + ctime_updates, ctime_swaps, fine_stamps, floor_swaps); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(mgts); + +static int __init mg_debugfs_init(void) +{ + debugfs_create_file("multigrain_timestamps", S_IFREG | S_IRUGO, NULL, NULL, &mgts_fops); + return 0; +} +late_initcall(mg_debugfs_init); From patchwork Mon Jul 15 12:48:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733441 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 E444CC3DA4B for ; Mon, 15 Jul 2024 12:49:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B101C6B0098; Mon, 15 Jul 2024 08:49:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A96836B0099; Mon, 15 Jul 2024 08:49:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C4126B009A; Mon, 15 Jul 2024 08:49:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 64FA56B0098 for ; Mon, 15 Jul 2024 08:49:25 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2CD301A15CF for ; Mon, 15 Jul 2024 12:49:25 +0000 (UTC) X-FDA: 82341967890.29.F058921 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id 64147140013 for ; Mon, 15 Jul 2024 12:49:23 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GiWQXcYj; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf26.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=1721047735; a=rsa-sha256; cv=none; b=dVsldKwq3ye3Q/36xTWenfMNKoY7YcjeTg1Yu/d690RnZ9Wv9b+l3d7GHxzLA3J9j16eUG +5yodFJPk5/VbaKaJApLjGLu88iU7LnNJ99R7XwSYIITqRFpQXpCPYG7NeP61GIMKWb/mb eMYdDjwBxI1i3ZIRTdJ8DCrEo8FUllQ= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GiWQXcYj; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf26.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=1721047735; 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=VtMJfkimg5Ssr9JPagx2sf6tC2jf6PpiLuy7lmXdaTY=; b=EsMaZtGKCcQGhB46mHBNxS3RuhMZs5zKapEwYLKBi5urNAPLXdBX4htfn9FxDtczww6x88 VXvQvRPRpTI96jwF3T+qiVGzLXO3B+yi6+zWMAQ4dZZc8Mb+9K0J+CxYcMR+g8qBdf71v8 Qij4XVOUt8EUuhcbb6sTSk9qIX/OzXo= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8696E61087; Mon, 15 Jul 2024 12:49:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB26DC4AF0E; Mon, 15 Jul 2024 12:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721047762; bh=QeVccJxIIqw839FMAslwYN0cCtumM5RGorsmI4f3Ba8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GiWQXcYj1to6dm4zqB3WZcP047jHZ6ztSMtTi+WxEaaMYw+niVkY9vKzScQredr+L OvHfw134L8C7mHiOMPXDdO0VZiYVW34o6XUZAONLlvhtC4N5fPTgckq8KgS2iO6BmQ zkfHj7wkaflVGgU4Jgpu3lhmTzfasIAtVteUGf9cgKR/Cc05mBM9z5kzj9GCiLb71/ C4bUPXIS6p1E/ZaQx7MUg0mdkuHVcCPzEAFMCE7HxyzaHJK7vKlYy3HmERyREnj/sB egfTLiRvHuyGjPIGvm2Qpzy8c7O4wLLogMgKEJvzvlpBC9CwslWSvDuhzRRJQn/nVG 9/Kipe3dKWfAA== From: Jeff Layton Date: Mon, 15 Jul 2024 08:48:55 -0400 Subject: [PATCH v6 4/9] fs: have setattr_copy handle multigrain timestamps appropriately MIME-Version: 1.0 Message-Id: <20240715-mgtime-v6-4-48e5d34bd2ba@kernel.org> References: <20240715-mgtime-v6-0-48e5d34bd2ba@kernel.org> In-Reply-To: <20240715-mgtime-v6-0-48e5d34bd2ba@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 , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3502; i=jlayton@kernel.org; h=from:subject:message-id; bh=QeVccJxIIqw839FMAslwYN0cCtumM5RGorsmI4f3Ba8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlRrCv6y9K94MS/Va6IMTGYStbxE7qbrcFZ0Ck ktMIQhcUj+JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpUawgAKCRAADmhBGVaC FXaTD/4+907j6epNme39/Jvo42T2sVT8Gr4WtDO44maokkPWgfEq/tA5OdSZsLRKdQnyuOtxDZa KCzRZScbuIWev9UWubIT11gAkcf2at6Wu20ez7swsPIwbw8+BHd8+2cjjN1XFbuTEaQ2QMW1Ruo 6MQEsCv+EgExV27/ORkA6sizkDMDb2m8dtxZ5YXpZnp9WOiF1QKDAJBU5JtgYklvKnxacG13xgd Wws5jbg+9FxOokzjJ5G2DHUGC5/JxmiJAx5Zf1OIqOhIEUrYzaQv/3Yo36AeskCYUqbA2q2MqH9 j5of3fjIixxU7GHEkmq3+CdclNooG7OAIpnb7lGEHj56qewVRnxrbZBRK1z159RcXYicVi6qF65 i1mTSjcgcz4fJ/BG1oNHRxR1S3ivBPlycHN3Y5AHr6WApq6eK9wU1sQ6X+pGdi8TttQg1K9AHOE Zq2mBVjy3m/YcpxJgUiYnrwiVwgq3/MQ1yOLfrczrXzkGon/hUelkp8pB96JI6yE/UsNc0eYlXM OA69o9g7LUH+JN5sfl0/r5jwABDL3lm5ZJXtIZXjaDklDWQUT1r2RNcjcwS4pdgRXKyhT4HZ+Hs Z1h74eWkZ/uHYdiWIEwtzOBFNHRHIn1eNloZ2T05WWNowSmDtEJAerXDjpCNdDrLdHvZMo7zxVC 0Vy0lk5VKnmahgA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 64147140013 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ahs84j8t7rfpjwjohga7g6p5onminjdf X-HE-Tag: 1721047763-389517 X-HE-Meta: U2FsdGVkX18U6PkYY5/2K4/DNwYSnSmEc/gUtVlHsEQla1phaxVJF0NhMd1yopEU0CXHbAs0xw9XK1hOvh3+3mZ4ZpYbYSp6pg9kbTf1EsBuDKH8PSP2GWAvn3BmBSt5P1PwjHA2tQrSIVXx0sYH3DrllO55gtf7yMDHob4+aVaO/t3hcza7SqyZPC7vLsICM1XzJAMGt1Dwlm7JX6Vv3tVBCJkQOs7/v00L2/Lw8gWns+bV/a4Ihkpk5E5yp5pjSaMyDJ5KLBADMsuSf3EwSHTYmFqoFGwgb1yV/4k0y2f+UKjkWNbOYqcOsL+BK2uQa4YwFI7MSNyNoeSy8kq7ulMeMKfVNn5wMSLsOjHvFlAuFVPPx2cpNjfj8JggpIUtVfXHLrkrhI+Fn+etoSYqsU8hncAfuSGIWACaISqlzd1w4HLqgPT2PuOxqPiqmJJil88DLq72s6V7U2CsN59493EhB8YHJO0qx8tCrwd7GZSId43xT+GNdm+iJNr3noOvoq/rSeHbMc/xIZ+7GS0wRssIxNbkgDkATFWsUM64/QJSgOLY+CiNTUSeAg1StC3dGZ+j0uPcbsjNeDjLLhGNwPxX899wvrhBLWfo9oNuGz3QPaCluSq1Tzu0B0oidvr6gKVGZpSdcw5p7eZ6LkRr1vTknIaFE6CL4lcrOcjMyj/X+mqU+hNnSe9tSSddSqPAPUverL8xjbbGyEbu4EscULBBeUzgHmhbClQum4QtBlo4J8MDx8DFj5JBlBCMh0JSV2YJHxovwkEEk38MQ1o7pmIFabgavg2ouZYn9L9Ux3YfjnI3jhgVh+Amm4GTRCTFHRaPRS0TSK+ADOQjQb+6sOPI2NnaWbfu4G/gAaycgAXcTkFzOQnDGx6em3auKlLmoVLSjyZ9e7ksIxREOR2WIm0BGju66/adz94IwcDF8x+RTva204JSGvyCDuwloiaviRzdpOlZrOVI1fqtbX6 5jLFDcYY ZMoxSQR59dQSUVhQfjyjiJDEMuun3c4EEmYfIZBtt0TAZcbqUBg2PMkghJ1GMdt4pKoUJ7BtGmvGGIkmXIWe9sruf0sofxECXxI6PFm1qmO6/KI2x8Qp+ElQSW8uQeef4AmTkah6BlGVK91QnV6RXLOPbi0AO+QRkr68DbLwfHZBgwfwMK3Q2vHalKGMCIZHNvWw8YQTVsGIf0o0SIqdU6LZ9JR68uCM6x/qILaV63F/ADE1AsHKQNKWVzqvmy5hkbWVDapRhRXXYtFO0uhsvc9JLUVwFKjMdQ/tvXoBBYkROI+Nvp+Gl1hIvUC6/+b1YwjEdPd8nDcmTehNdUI/y5rQcBTLizfVKjbrY 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. Reviewed-by: Darrick J. Wong Reviewed-by: Josef Bacik Signed-off-by: Jeff Layton Reviewed-by: Jan Kara --- 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 Mon Jul 15 12:48:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733443 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 DA49FC3DA59 for ; Mon, 15 Jul 2024 12:49:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DAFD6B009E; Mon, 15 Jul 2024 08:49:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 910C16B00A0; Mon, 15 Jul 2024 08:49:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FA836B009F; Mon, 15 Jul 2024 08:49:35 -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 3C6176B009C for ; Mon, 15 Jul 2024 08:49:35 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E382E12161E for ; Mon, 15 Jul 2024 12:49:34 +0000 (UTC) X-FDA: 82341968268.15.A0B003A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf07.hostedemail.com (Postfix) with ESMTP id 850FB4002D for ; Mon, 15 Jul 2024 12:49:32 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z5Orqeh8; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.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=1721047731; 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=ofgP9nmBDlCXsH4UIVzu2VUwgNgOG2mQ3+tiyTUSNgs=; b=BIr6DGXkIooYeU4RtJCMHqWDJVmxs58r/TEjuzEVJUg3Rses4AmA3WocOgB+aUBkbgH1Rx BJOXNyt2N1LAtB5QnxyfNzPeqaGZUsY9+GpZKDhCujROYw/AF4hMIvjP/QIJMnOMENyXav h7ZGepReTbOqR5+04uEnT3dQm0Ffd2I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721047731; a=rsa-sha256; cv=none; b=ApXig1SHXT61N+OjZCe6HSfnpJlBHTtkCFV11xt0LHtgjECVhp71P9pJzKwyBCWFPLE3LX LtbpeOZP+TDaaa2np1clM9re6qifzDiiIochhvn7kEB+g1ni0umVRBAETXmuGVXdV2znE2 AVmuWc/Nt9OBgS8+X3FKl1+RneYFyx8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z5Orqeh8; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf07.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 09DA0CE0FAF; Mon, 15 Jul 2024 12:49:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 964E4C4AF0A; Mon, 15 Jul 2024 12:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721047765; bh=iWqOXrOqIjnZmnolg+NEkEq3Yoj/1L10uHjOuc/xylw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Z5Orqeh8dgUc1gNrWO3awvIvearNO9jL/GLYnPiI9DfmGf76A0FSclTsiydvsVdLX P9z9VAeoZuqzFgOvQPhpA2BmMpvnmyZsI9Kd2ynTkH+ZcZtfjNVVAEzpA6RgAWof3c o/N6/gadf6s382d4wQ4m1FNp7Xh/uQuQUuzrqwZukVlT8q9iTq+jarW+dGVMu8szFE bisYIjh7qxk/bJfUKxkw3afk+G7/sb/xtgcW3wCgyi8K7lvffpoyAt35E8jC1SxieU 1MsnZzgZhKv9hABIDSRl7acGfYIcVREvZ9L0J3uu5d5S59ku7A7lpsvDWx/2JWOQo/ EEodhM1YL0B6A== From: Jeff Layton Date: Mon, 15 Jul 2024 08:48:56 -0400 Subject: [PATCH v6 5/9] Documentation: add a new file documenting multigrain timestamps MIME-Version: 1.0 Message-Id: <20240715-mgtime-v6-5-48e5d34bd2ba@kernel.org> References: <20240715-mgtime-v6-0-48e5d34bd2ba@kernel.org> In-Reply-To: <20240715-mgtime-v6-0-48e5d34bd2ba@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 , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6332; i=jlayton@kernel.org; h=from:subject:message-id; bh=iWqOXrOqIjnZmnolg+NEkEq3Yoj/1L10uHjOuc/xylw=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlRrD1XVGZ1c8cCIJmwfS2YZ77i/n0JY0rvv7g EETniwfzleJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpUawwAKCRAADmhBGVaC FQDbEACwh6VmE4qLcnqitmCqk2O7mVTzebx37UKl9uS8FvZaSKi7BdWNZFzrWhFsOOo9nzQ2J7P EqhJd5AIWZUsRNsgRnWS+LPusCZkJ9r6EpGPCg8hCzqMJH3YFaOJyt7s2qn3/UxF4zUQ+G2T1r/ VdlV60RJVEb6Qs7Nr/5oxiN0TSy92wa+Ghd3Fj0BNLCrY3LvOft1bl7wd7wRAnTcBT5hhdhkaLo j30lZHe8lEr4UkWtY9pEx/v17SxSJjfm0CB1fxn08pvNYczGPGRgsEQj5jyZZqMOTb50zZINVIw UOt6gLE6BvayN94BfnnRzzCs+EErUWMY/3g8ef1Axz71mdyfAs+xebNeTulyC6ZRqPbJRjBMhgc J7iGxT9m95TeJEmmvX+9/IL21XPs37yDNx35L9jPy2xZy/0TuROcmu+ev5JqSD4NnXJ/Crkp3JL fGi5gHVxrzVS6gCxkWaVYkybLQMz9KL9ni/aVdPdlWVdCps+lNuhIHtwcyQi/5rh1Vzwn8XR7ru 0aOuBIuitYqxg5TMVk4IGrT1gYV11D06hQSs90iPER8bf2rT9bbuahH4SjgL4d8yGNJf3ZyBvh4 cR9+fivitdTWSR5mpTSQ6bSqDDpt+zzYtLglpl+Gg2gHblc26C72aVc6yXyHbfHYomie/n2H+9q a2O0O4lkIL9NCJQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 850FB4002D X-Stat-Signature: oe5bctbsca3tuomq61utxtmtiuaw4x4s X-Rspam-User: X-HE-Tag: 1721047772-549838 X-HE-Meta: U2FsdGVkX19BsRtUoRnZLBb2bvCy3ywIR7x5bwgYxRG98b5F0N0CjWzDWpCFSyO/c23hwWVCIt5kqrktXegDp1gFEZLRnpsH1PHlYum39qRBxGyW2nFYAHyLWA3UExX/ozYK31GxQxyKK1cM/TUMdQTD+kHlWuKvoeFZlDdLMVWz3HCok13cdNsLIVt0ZTQouzzyTnnDbcV4qy6DmzwtkH9fcHIgXIFuPE8/GObOrCaNyHFWXvs4utee5QpB3Tu7rD9kn4A4S7obIETyL7tbnUu/K9riUfs4bcmDvdM1Lmy0e2VCs4zhmK4H101xmyZbeyUEd9QNXs4A3sPIezrxmhzz/6zel1KfE75wcNUtarPZhueazLQhS+ZRX66ypVT2Z7LbZsQ0kwlt1bpfqmKbA0iUbPKKSBkAJTdsFynnpKb92eUK6n1qyL0ByVUB8XpkNMfb5jvmzuVNmm0wbQ3AiMv7nxxSLV3XeGAoQwfkV+nkso8voqTi0fh6ubTEeBbTfm36w0mghfHErpbZTPPgx6Su+3JGYhousDCwl+pfvXbHXDvWHl0EX7WpB9GJr6BOrYINYyVbftiYGcJFa7IjSVhoG8BmMc8vtr5VDH0rYBj4k9O0/RgM+PJcXlK5ZARDTRZufcQezr2aA0IB+Ebd8GU0n41MFlUlHkfZw02uGHGhAtsuZV7R9SDADQg8o0/eHLqBogdHYCgAvHtgGGfZVm7baGdWOPnfT67xAraRZSc8qdJvgZIPD/220VIEjPPcIALq3Ydtm6O4W7B2ZXTAaS8+IbGPCVG1qKzIznhQOAV9kyyL1bCvQWSGdrnocQZ5CxG071QOMkwHIz1582sGhyougJZIyYZOkgD52bZjixwDEpffAz8nVLTUiRjBSxbAv6krTcu0j9WJC+xTP1kf7WzD1Q3EIwTIvqlg42LWNm5zIBeo0ew04nKzBhKVw/njk9f2gT1vWITlhT+PomD 8DE9Npyh JtLz1j8TUwu5rkey/HFqtuyH+tM9iPs+2kAsI4OxLRGt1ffUfwX9EmfokBCzgFwfFVpuc1NpIwX/bG2+p5QHuS+abyZXRhAimrcXjA41odASepJEvqCFqhAiGWf7CHIWejS8VqJ2mPNticY61JrWyeiI5UjyTqpDXJkmMez3NEy95quZB7DpuKuNuJ0Zx0IlRU3xYxLwRMPh2kfZvac76lP8+1drC1SVy4IvmBf0gKNbZn+QeVrBIpTP9C3W8164aK8d2f21FNxidCrfNSs1A2fCQgcBTX4+aDLXP5yl17X5s2Q+WQ628qXWM2Q== 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 high-level document that describes how multigrain timestamps work, rationale for them, and some info about implementation and tradeoffs. Reviewed-by: Josef Bacik Signed-off-by: Jeff Layton Reviewed-by: Darrick J. Wong Reviewed-by: Randy Dunlap Reviewed-by: Jan Kara --- Documentation/filesystems/multigrain-ts.rst | 120 ++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/Documentation/filesystems/multigrain-ts.rst b/Documentation/filesystems/multigrain-ts.rst new file mode 100644 index 000000000000..5cefc204ecec --- /dev/null +++ b/Documentation/filesystems/multigrain-ts.rst @@ -0,0 +1,120 @@ +.. SPDX-License-Identifier: GPL-2.0 + +===================== +Multigrain Timestamps +===================== + +Introduction +============ +Historically, the kernel has always used coarse time values to stamp +inodes. This value is updated on every jiffy, so any change that happens +within that jiffy will end up with the same timestamp. + +When the kernel goes to stamp an inode (due to a read or write), it first gets +the current time and then compares it to the existing timestamp(s) to see +whether anything will change. If nothing changed, then it can avoid updating +the inode's metadata. + +Coarse timestamps are therefore good from a performance standpoint, since they +reduce the need for metadata updates, but bad from the standpoint of +determining whether anything has changed, since a lot of things can happen in a +jiffy. + +They are particularly troublesome with NFSv3, where unchanging timestamps can +make it difficult to tell whether to invalidate caches. NFSv4 provides a +dedicated change attribute that should always show a visible change, but not +all filesystems implement this properly, causing the NFS server to substitute +the ctime in many cases. + +Multigrain timestamps aim to remedy this by selectively using fine-grained +timestamps when a file has had its timestamps queried recently, and the current +coarse-grained time does not cause a change. + +Inode Timestamps +================ +There are currently 3 timestamps in the inode that are updated to the current +wallclock time on different activity: + +ctime: + The inode change time. This is stamped with the current time whenever + the inode's metadata is changed. Note that this value is not settable + from userland. + +mtime: + The inode modification time. This is stamped with the current time + any time a file's contents change. + +atime: + The inode access time. This is stamped whenever an inode's contents are + read. Widely considered to be a terrible mistake. Usually avoided with + options like noatime or relatime. + +Updating the mtime always implies a change to the ctime, but updating the +atime due to a read request does not. + +Multigrain timestamps are only tracked for the ctime and the mtime. atimes are +not affected and always use the coarse-grained value (subject to the floor). + +Inode Timestamp Ordering +======================== + +In addition to just providing info about changes to individual files, file +timestamps also serve an important purpose in applications like "make". These +programs measure timestamps in order to determine whether source files might be +newer than cached objects. + +Userland applications like make can only determine ordering based on +operational boundaries. For a syscall those are the syscall entry and exit +points. For io_uring or nfsd operations, that's the request submission and +response. In the case of concurrent operations, userland can make no +determination about the order in which things will occur. + +For instance, if a single thread modifies one file, and then another file in +sequence, the second file must show an equal or later mtime than the first. The +same is true if two threads are issuing similar operations that do not overlap +in time. + +If however, two threads have racing syscalls that overlap in time, then there +is no such guarantee, and the second file may appear to have been modified +before, after or at the same time as the first, regardless of which one was +submitted first. + +Multigrain Timestamps +===================== +Multigrain timestamps are aimed at ensuring that changes to a single file are +always recognizable, without violating the ordering guarantees when multiple +different files are modified. This affects the mtime and the ctime, but the +atime will always use coarse-grained timestamps. + +It uses an unused bit in the i_ctime_nsec field to indicate whether the mtime +or ctime has been queried. If either or both have, then the kernel takes +special care to ensure the next timestamp update will display a visible change. +This ensures tight cache coherency for use-cases like NFS, without sacrificing +the benefits of reduced metadata updates when files aren't being watched. + +The Ctime Floor Value +===================== +It's not sufficient to simply use fine or coarse-grained timestamps based on +whether the mtime or ctime has been queried. A file could get a fine grained +timestamp, and then a second file modified later could get a coarse-grained one +that appears earlier than the first, which would break the kernel's timestamp +ordering guarantees. + +To mitigate this problem, we maintain a global floor value that ensures that +this can't happen. The two files in the above example may appear to have been +modified at the same time in such a case, but they will never show the reverse +order. To avoid problems with realtime clock jumps, the floor is managed as a +monotonic ktime_t, and the values are converted to realtime clock values as +needed. + +Implementation Notes +==================== +Multigrain timestamps are intended for use by local filesystems that get +ctime values from the local clock. This is in contrast to network filesystems +and the like that just mirror timestamp values from a server. + +For most filesystems, it's sufficient to just set the FS_MGTIME flag in the +fstype->fs_flags in order to opt-in, providing the ctime is only ever set via +inode_set_ctime_current(). If the filesystem has a ->getattr routine that +doesn't call generic_fillattr, then you should have it call fill_mg_cmtime to +fill those values. From patchwork Mon Jul 15 12:48:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733444 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 CAE55C3DA4B for ; Mon, 15 Jul 2024 12:49:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB91A6B009C; Mon, 15 Jul 2024 08:49:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E41CD6B009F; Mon, 15 Jul 2024 08:49:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D3CD6B009D; Mon, 15 Jul 2024 08:49:35 -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 670546B009E for ; Mon, 15 Jul 2024 08:49:35 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 162FC4158B for ; Mon, 15 Jul 2024 12:49:35 +0000 (UTC) X-FDA: 82341968310.02.46A7A22 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf23.hostedemail.com (Postfix) with ESMTP id 9BBB714001D for ; Mon, 15 Jul 2024 12:49:32 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MsgBtdWJ; spf=pass (imf23.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=1721047754; a=rsa-sha256; cv=none; b=ygNoLxb6LJFt8EfAakW6f91oS8mUgUTidecU9ZxmefAxwRjCZuxGGE4Q9L0vNs8EYflans UJ8aI0tbQ+zzE4d5p3g8/k9hZhLPqh1fvmoKpE00RLXWSpP+SgsGbTy46JB9cbzk7g9l+u TA9B43Tg3rXUR/D9XqdIMXENQ+lGu3s= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MsgBtdWJ; spf=pass (imf23.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=1721047754; 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=7IlQM8X+w9Jbpz3qGtMT07Pt20M62nSEruGY4bQqXpQ=; b=imCvGCKYUrlYjma0rRtf6ACv5/3RV+0ii4bnIaXCWQe8MjwVUDCFnFN9RL1J6foMDBQsfU PWPug0KEdxtsfJONFUJ30gn3igtkWF6q5rWgVKQe8sr+dY6OoSfj7unvhUm6GH0ThhJcvi u1AvJCMLFPx405Nb7068VqRaUSkdfq8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E3C47CE0FCA; Mon, 15 Jul 2024 12:49:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D220C4AF0C; Mon, 15 Jul 2024 12:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721047768; bh=Za4x1Iy/d7H0eflkTicTt1UaefhIWQ90YwrfG99Zd/s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MsgBtdWJCSqIckHd8N/sLkK2H3UIksWen4AFqt0e1Vqov1QXoqSeqhnEyiEBfk0KI zj0dYtnefpLl+FmWTb6ufRTO1eLgUOQTtZsF3BZ2+dtqqeUn0cEVv3TvDGMR7c6Sem ZNRa6hMxaIqS/T0hzOUpgdNgTHHbIWxGSrfEgbTQOFeTgCDhc9xcUkD0aYgu1yu8e8 Qy2ZLRQn9sHe2ibmplFUdcKXFpNVMxxBTark2MPod1F/4YMoyURrYbO3xf/7YBGTRZ lZBi7Hg2xzw2XFivw95Cxm3vfGotZmDsB291SEKV/5Plyr5C8JMBdUihn6s8uWXqEi SNVMxc/c4ocbQ== From: Jeff Layton Date: Mon, 15 Jul 2024 08:48:57 -0400 Subject: [PATCH v6 6/9] xfs: switch to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240715-mgtime-v6-6-48e5d34bd2ba@kernel.org> References: <20240715-mgtime-v6-0-48e5d34bd2ba@kernel.org> In-Reply-To: <20240715-mgtime-v6-0-48e5d34bd2ba@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 , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2845; i=jlayton@kernel.org; h=from:subject:message-id; bh=Za4x1Iy/d7H0eflkTicTt1UaefhIWQ90YwrfG99Zd/s=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlRrDU4nWQP3Re9QBLBdg/iDcdaRe20/HAbh5B Sh/ulM1S0yJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpUawwAKCRAADmhBGVaC FZu2EAC2wyQqv9ZanaKX0NuqQvQl2qcPF6diqtykkUObkhXK0jRkoEC+iEJPmSWECO54qgYrEMf aVXeh4ZR7BDbS3icu8iCATQzL7ICRAOfLPkM3ZFag4JsScuSM4JKijVGPIGAfR7zG6913stH+Pk aFE1lCE+eOyTUpo6XxYvMk2Oer15sWj8b5ZL2HO3Pwg3uofMhramJ9jxwAElIkoHuVA9JKxrLam Bp6j3uDOGbdZxecYvRzCD0Iprz9ZCVQblK4MEyISVe5XzHyNlWlmkKoRODyhnfV3pz5j6bvW/61 96K62l0sABrGRf+4lw4K2xekAP+pB9jgeup/7knviQJye8w68hj1kcwKSX6ckZkxS4CzZwTROQm 1VOBCYWGI4cbJ+V/ILEQTzNqkS67R5BCc9XRXgElutxcMXOMBtU8yQoQUs6z9HC5SQldvs/Bcgs IwvYbzhFvmyynv3B0vX1Q9mV9OkAdYHbfH27HtzXCqfPxfCpFwrWiTZTy9wKbYC36tgVy9nGH6S PNInEiAel+lNAF5n697sbRIQfTDDMbTjkB6sAjUQQTNzVPCPr/OL6Fnhzl50Ju8H+Ihzs9u8Ehf lTfaqd9QL5Z2kzDmkUkCXLkf1P+oDoD99tlMutYBCdj3NC7p8r6eZUrtoUa3pwVj+YyDWbe5R8y 0wRft36HqyrPZyA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: hk19ohtyfg6wwgriu1ux8mij1xaypnqn X-Rspamd-Queue-Id: 9BBB714001D X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1721047772-560865 X-HE-Meta: U2FsdGVkX18bRU+klPlNke23K3yRfn2mWO/eC2xjVtEa1bKWkneX9GhS8dEdXJFuUc7HjLehnsk8re3vqw7dxlDzY6DsXQC9RhF6984LWe/XKeobbUgbEgC336MSqKMjsXFk/3Jvk98E5TtCZdJHQBHuK8Oh4tEI9yrh4fXmuVDYC9Uu3Hgfe2DAwu4Efzs4XMiafLHcDnW0zUjdC9vpeyjpxOLamNiMn05+OKCDQWcuRunKaY0S7aXQHLq3rAPJ8WhMZ4hPHDtYHS+/2V2ag7uYaHfOs8VK9UT0yIaaBAt3q/FIcOReYHbCOVjmQ6wP4VxLKrIM516Vr3u3piFZhTrPQhb8/wqbtK02Y/rY3CtFsJhFOHXxhbRzrb529VzusbicQW9yKrZe6T0mEBEQ7IUtz/xDyJM+ztswxXwkCYQIDnGp0svnttaS3D2RMK81MYZkPzbpGFkm7oisQVj8qDbVTd7MsAm9vem3ZjBL7Me4m1syHrl5kdn9gR8OyvRc4s4q4yRr6wsVcitkwv3XOsXYXrx6YrVJ1WLSyz52nbL7ESoGfamKJNXqfW+53I0Z9sLP+2Xjn0Dji7c3qAjCotUPFIF6ugI7fcIeEDg++YU+kGfuoRik5lAnBJ7vF/OR4cOMoQXx/WAzToUwMoZKhgPaYIfAEkzbk2i3UHLYHMEgc0R5G3u8FbfbbyhVBXtWAK3nigLTSQiosHX3wPSViDRwlDwcODO1jzKhKqBmhV79DLF82MC0jKMfNgOGxHJBB0eiBBsZN7RWYZyfbU3nn6gBDPeBASLtaMJ3g+2t3T2SUQ4rTwR6/3mAjVLn0zuuOytNfgkURH2TmJmGenKMf08vhpwLWz8Vl+encVLJH1/XAHIECRX9gftFqNEiB9/3o2b9JX4XVcHSnHIIKu5kNoeFglMTPfwEmVZRf6TOApT5TKLxXHGWJAReVc9+wcA4Lu2Wfze6cbBZ2vV0yL2 5y03tRac abqspVIX/cK3NDL7gBe8jypQwHTEllTggPalxBQq2/aHiE0DbBfzdgaSIjyCPElPu/CquGWkvSWTMfbLNZPJY4DnSf8SStrrgvBcINGRAKbYHCVN7vpoQnmBVzYbuQ0UX/KsDqG32JQ3qkSbEJlp6Cf4n3yobYqGY7UZny6wt90C77rLwrm+HyR19jR3q75XlG7MwcSeTRQsBsIHZAOCgoGtYBdp6TckgubfzHDfePic1nV7AQx0Vu4HuprWliShyVQVtV4iAgEIqpW3hANOWn1FfLmgUqalsU/wkkEJqsU3cGP9p8GGmORjQiQ== 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. Finally, stop setting STATX_CHANGE_COOKIE in getattr, since the ctime should give us better semantics now. Reviewed-by: Josef Bacik Signed-off-by: Jeff Layton Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_trans_inode.c | 6 +++--- fs/xfs/xfs_iops.c | 10 +++------- fs/xfs/xfs_super.c | 2 +- 3 files changed, 7 insertions(+), 11 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 a00dcbc77e12..d25872f818fa 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -592,8 +592,9 @@ 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)) { @@ -603,11 +604,6 @@ xfs_vn_getattr( } } - if ((request_mask & STATX_CHANGE_COOKIE) && IS_I_VERSION(inode)) { - stat->change_cookie = inode_query_iversion(inode); - stat->result_mask |= STATX_CHANGE_COOKIE; - } - /* * Note: If you add another clause to set an attribute flag, please * update attributes_mask below. 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 Mon Jul 15 12:48:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733442 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 209A5C3DA4B for ; Mon, 15 Jul 2024 12:49:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A98926B009B; Mon, 15 Jul 2024 08:49:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A22076B009C; Mon, 15 Jul 2024 08:49:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84F816B009D; Mon, 15 Jul 2024 08:49:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 58CBD6B009B for ; Mon, 15 Jul 2024 08:49:34 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0D5271215C6 for ; Mon, 15 Jul 2024 12:49:34 +0000 (UTC) X-FDA: 82341968268.01.F028105 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 2ACD0180015 for ; Mon, 15 Jul 2024 12:49:31 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dRAlerJu; spf=pass (imf06.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=1721047735; 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=EHs4D0kT9Ln5IH67Fu/9x3vf6R+s9xrfUc6y8hjV8cM=; b=3pUqowSCcKppogEk+njF7WvHRtJPja/xCx9J78ntv6qfAkydvI+U7V3Naxo7uDeZCMrByf yUx+EYPPdMxx3Ao2J+PB+qwL0Xt5I7k7loVZsrVbpaoNA5Bf01R/pxIDZ1G703qwjFd+Nu WSRg+F3t2EJBfKdWIClo5Ra7g48E0BU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721047735; a=rsa-sha256; cv=none; b=FyJVXzl2Nwkm9zLwWM+gjsYdY9CBLL3C9UecgJHGfp28gv7xuqTvK4ymVsirDVzbr/YEWH /PidUda/VJ8D7Tz14AXql/i816asTx/MlD1bSItnosI2gCuuAgfh99W/hMXgqumVnUrc6p l+inUURgxztJ+/RMD0/jod9qedd0g+I= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dRAlerJu; spf=pass (imf06.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 57AB761072; Mon, 15 Jul 2024 12:49:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63B49C4AF13; Mon, 15 Jul 2024 12:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721047771; bh=o+gyYbKvXkNExYjsuAJ8m7WMS8PZUinH23WSH2Xu+Mk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dRAlerJuBd8JkM9VU84MlAHiMeZsxsf5H+2iDx8okusCUrns1bfvO0zdGul5dcknF sUqrcyt5LPwrDZLTCazlsNLaZIGKgXgxUvZeTbQFYc18YKukJQpwMJjvbDCMc9VHW4 mYhgD/hePs6YdNdqNN8is+NjLcevZBaupiE8wiqAPjyMH1t9ae8WG23eKmp7YhcJJn olDHXS8PqdS0eMKgH+2OqBfejhVSOdvmCX8lPd08AzjITxV+1375oAgz3ZJ/bXNq2f HU/m9MgJ7kEvT0Q6SH1MHYwtIlWi32QJxYF9Z0AzefTrXou3tHk4wznS1XrSHc4Zua 6xUwhfdAHh1Pg== From: Jeff Layton Date: Mon, 15 Jul 2024 08:48:58 -0400 Subject: [PATCH v6 7/9] ext4: switch to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240715-mgtime-v6-7-48e5d34bd2ba@kernel.org> References: <20240715-mgtime-v6-0-48e5d34bd2ba@kernel.org> In-Reply-To: <20240715-mgtime-v6-0-48e5d34bd2ba@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 , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=888; i=jlayton@kernel.org; h=from:subject:message-id; bh=o+gyYbKvXkNExYjsuAJ8m7WMS8PZUinH23WSH2Xu+Mk=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlRrDVHNMl9hO9HTihB98s1BA9SAsORNuI5QNF B0qYkAQuMGJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpUawwAKCRAADmhBGVaC FQo8EACcB1c4yRYITKFx6X7py1QtR4U1d1NUafTeKADoWBjerJPN9fsm6ZpaaCtQbtKA4W1iXUv kpcrsxM8gVi+PTn7Xx8/2ehSVovURyGJnPiHesoWN1DMF3wklKzBb+p+NAJH+ur+LxQjSc8zvdG MObZZHN91O7WhIcM/FOXYHusZ/q5rmKog9G83gjv1kosz19oxzdVTU38iC1pgRoMpmrlNIWV2+q J8bQZDAm1Kf1h/+ZN5TtfknFpBDJW+XyLUWL4wwGCTMQMKSM4aJ1dVnvDF3Mf6M9FwcoMUEssCN +lDwW0hFcHrX5QBhbU3dzC/4M6Czi3YMz/cWz92a/mGv1+Odh1rV5lUmtZEY9MafBvN8Z79H/BI p00YDvjO81Mr14q+LSG4V2rT91AJlEoFYDWw+lbJb6UnTHRCzX2gP4N+HlDcdHz0q67r/pBEiFY URwwNnnSmogqs1l1onFf3Ea2HRACisOBllB/MQf+OorxBz/tisk9LkGBMeFJJCUH5lND2wE8jBQ Imzp4daiSeYfk4qX/8JN2iV3tvEBiEqQ/Ucr+AKZkm9/QYLXI2zufG9ZCwHgw69vQN5BTdQsR9B YjJl9/SQQz/+pqO6h3/oEvnZvO1XYn46KHM8rb754N/szjYamIA30H3k/BQHQGuK4y04RrI38N4 PGkLTg+1A4pF3lQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 2ACD0180015 X-Stat-Signature: ykw5sra4odkf65k7gzqrjf3soobacn3m X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721047771-71697 X-HE-Meta: U2FsdGVkX18+f8CErUie+9ulVPu4MBAnGnPz1eeMLLuwcEs34Z3pSeMyMlM6r1Bh+ED9Zg08ZuHPr2KXF/UJVZRIJiVwrWJPVRQLSQVjjDFxVb2fEXansOEBapaNE0zt+KgY6feprClVsVt/BrLlTLXoqa/0zFuQXBwIkFqq2rzZDCHsSpiDeIGwvKxMzYYawhYvp7zMr9DBWJlT2b6ig4bzehQgh4H+zOnWBHYFdWq/AvT2tkdjfjfd880txj1ca7wxXwImH0UBDulr25GkRph+UKWx0XhNwgAlck/BewlFjE2yfUFBWKmKur796Yv8sV6rha4Tbv6HxDqQZbEAoEjkucELQZh+0mPekETSGqCrH+HcJzGd/OfK442gNO0z4JS+dmdgtD4buM58+zxBTLdZnXshGygbfeZVt+3Ctr3xhK8Bap622fITsTTUAdWYvkuRlWkd/tXdWEov3JXUMTM6ePTpOq6tCfAnbXpvyk9W8YWOEnZZyG6WIIFsZpLclrNyiN1Iv2GcKzJF6HQ9Wcdyz2DkFYTFrGcQ0y9IG9qu/fwSZfXcfGd8YR0g4yi/1BI2Olt5PYuSogikQYR5dI9MlOM+roBwj+7Glvivyl8OL6RrZ0EW9snnmMfn0WjMBdqZPomOh7wpk9tdierUJsu8O3ZTNdONoG9dXTZLQ3wulgenhi25/Jcu6apFU8EXDZY5kaSpsJwa8E4kg2ls79vjDTqKHettxphO+OFfWFHGVSboglrfLp5t1xcBUjVkDxVRrBxEbMgsOc3ykZALibp8stxcykVC7mfXHDnTSO7tZr20n47BmZXooJfLBkvpkaUs16iI1ie4mTBmBD7eX0e1zMx+VFApt6oSs2WLXtcJBkDxHLma1SRphyZGXGnpRKU4rp772LryHt/fchCzInmq2FTZfztehB022wuhacZtY0koCSVq1G2LCIhcrpYpNgXWlpg8D7EzODGqDEc RBnsPPQW 7ADXK9AK8xDtMmAm7xpzVHT11cxolxM9cV2Xb2YRH14M5QOQqmS0dZabnbgTatrPnI1LO+xuak03a4GGiDJHi/A//JjdDaZog5yYduim7MK4tkfbHN/w8FlgbiGaLRxG1Ed51dlpFHVzfy/J0CrfebztF/eR9neEhu2132KFxs/Fd5bQnKOxDWm24Ygw16jU74E/aT+S0XjzNFioOZjVOnw9jEIqVrsXRoe4jATMEmJ24m7G6hqPhI3pF8oPerLLUvMWKdaORvET+QtVNI/QqmIzbwh26ewZfpcqoyYfVERsRdOn/plamvtRlWw== 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. Reviewed-by: Josef Bacik Signed-off-by: Jeff Layton Reviewed-by: Jan Kara --- 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 eb899628e121..95d4d7c0957a 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -7294,7 +7294,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 Mon Jul 15 12:48:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733446 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 E4450C3DA4B for ; Mon, 15 Jul 2024 12:49:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08A256B00A1; Mon, 15 Jul 2024 08:49:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0126F6B00A2; Mon, 15 Jul 2024 08:49:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE4346B00A3; Mon, 15 Jul 2024 08:49:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A44186B00A1 for ; Mon, 15 Jul 2024 08:49:40 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5EA0F4158B for ; Mon, 15 Jul 2024 12:49:40 +0000 (UTC) X-FDA: 82341968520.21.09A82F7 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id B5D0E40007 for ; Mon, 15 Jul 2024 12:49:37 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZtyYbWAd; spf=pass (imf11.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=1721047760; 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=6d3DRy+gZjm2SuuQV7XmALdMkOXObiYYdBFF2l5gQ34=; b=8NkTN2QBNL59fCHBm80cW1jkGrd5GFKBph2PCPZceOrDdS07SMHsgk5LCdOehWcEjN6tMD YrZkcRJJExig2HTDy+xQGonanLYKgcG8bWoSDdK9QQjzhEbnKdn91+fA2zli5RuHh/hevz dtykvALEv7nnclWMM/+TX4ETK7O9rus= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZtyYbWAd; spf=pass (imf11.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=1721047760; a=rsa-sha256; cv=none; b=E9e4Hogfo94l22nfSUnyvaWpYx0D/mFdT5OONjbCSmth4ZoTMPs34clxTXS7Z5sfFRuKsO 3NvxQo+D6B54wL3amqhJ9GZPiEtXzyXhwiYiBUoK+DIIj9ufvIhJAJ1Bq33APBt049xd3t cKuOf1kEI/+OwsD16owK6In8sfffLHA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B311ECE0C68; Mon, 15 Jul 2024 12:49:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AA12C4AF0C; Mon, 15 Jul 2024 12:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721047773; bh=n/GBFDubJ9Ek68qv1catP2lBxJ/9I9EY6EzBmvQbZCE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZtyYbWAdVGt+M9geIi9nq1XjNNQKoMnt4VvhJB4ByJb93S22H8PaeX8D+elBcZmA8 impfQEW14muDzQ8mqnKoESrz8Gr10uGPLm63I+ch9I+zWCDY92DOYLcnHznRSfIEz5 x/nUQ7EWPdrA/coYjsXKG0S6bIk4DgwnzLIkDZiZlfyt+lexFtIlTZE+/erPHt6QaK 0eM3Pnc3hhcq91YNFO/cFAiRBaYJpg5tpZc+04sECOGNuL3RAY9OYACGN8vPxWKGbZ poCwkG8HsUOnrBLgRdLZtcnNdU667lJj9uPt/n3SS3h0OKujpuh9GXE/MRP4ajdBjV sXgXQH2/rqp0g== From: Jeff Layton Date: Mon, 15 Jul 2024 08:48:59 -0400 Subject: [PATCH v6 8/9] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240715-mgtime-v6-8-48e5d34bd2ba@kernel.org> References: <20240715-mgtime-v6-0-48e5d34bd2ba@kernel.org> In-Reply-To: <20240715-mgtime-v6-0-48e5d34bd2ba@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 , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2632; i=jlayton@kernel.org; h=from:subject:message-id; bh=n/GBFDubJ9Ek68qv1catP2lBxJ/9I9EY6EzBmvQbZCE=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlRrD197rYggBbmtQ+Pjfq0t5urOGWrOjhcCqL H+PDb1PlFKJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpUawwAKCRAADmhBGVaC FWPPD/98OrTQhimjzIjdpNE2OeuExL1hLuo1FcAxjnPSODQMEGaEHQrTD1UnX5t+mb6vf7Fkhu5 4/Z4EkWwtnFXTrw7dWpDzmqHAMT7jYXa89Ga0TYbI2wx1q8tAuYvBzEQQ6z1E/pcmNQ1dJqOh/l ZDznTDp1mPTy9iE2jum19TBePEDngLxLqGiyqRE95/lJOwuaddhd4MvHdFWjSVPpdjYKE9KYope zyr90O9njRTaqFQlbSPHrd5XdE0NrF35opH85Yocwm/eGFHcN+SrKAMsbApMomPEaKSiFbC1RlN kLd4iYUx7PNDV+XvVGdTGXYbqSgsV7CL2bOxpOK+CYqU6RSKX15uZSqAnMv4Owpee3gZgAllHYU OHiyNZllPfZEOo72mqw3OgahIaEUKKrcWAFzvoyKbCazaMaqFP3d9XUFqOdYWn/iALgO3ZdUq8o VO3MyzVxCOZDjdISoPM5/cgfWc7wBJNLnudOnaQp2X6gH7vIuy3V78Q6SF7P2rezMSTgMepE/8s 7GkW31uEiZYJcpiE+aF0V33DllQqUoca2q+Eg9he4tHp4Nm05N/SXsadR2wgzOZ63OB15CgDJBn ip0syOwO653BxgR8VkjvdOHXxF+Zra0Ky9CCbWqDZWf49I1BJeeYTWCNNOyFrxFjKrVYOBlYtq3 Eh1fhvKxogJPFdw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: B5D0E40007 X-Stat-Signature: bkrpipmap1bc5wpr47ehq3xi1qh39pp8 X-HE-Tag: 1721047777-702795 X-HE-Meta: U2FsdGVkX1/4tHpSOLdLgSm8PqZBRPLx3fuZvYLxf3GTG7Pf0GXajKqACzV9XrjRQ17ezmahyY/A7b1Em0Z9MDLZdXeC6ZWNnI4Fk0aUYtUvhTbrZ6q+Mo7lepIQbFZNqwLZr7afmsBcIGDU8XJoLWqfP0w7rn0LQ4j6oaDfQsi8Bf8RDYcbWQtQEwtVuQY8fNkkuBZ+QSpj0j56v8f70GRoNkIaYG2RhM8N1FABQOy+OpJt2ZLV29ZbCGeunozzAmNve/FGsd+jTXpVv/XKZjEqaVexSWj7ZSkOOZuLDHM5++yr6fJ84llO2mJgrt8yk1ni44xebjUgoJUZ10GzYDUzS/W8P6g1U6ZOvP1AZ2QWKYw1kmlyn/lDuq7QBTxqTJQgpLCMpb7uDWvpK9J9iW561iUoW9oOw04TygSL9lM9cUUEJ053mEuAk+Sf1Acg1HTuejnVRDAI9meYmXEadpxrhCGUQPstjmagKUbyUmKb8apxqh5uh5XwQkE5XsJ+qwpNSQITLh7+ncBn+pp8RpRYOVAE2iO7rq7Ig+aQM0gEOTYzTUA07HjaI1YcMkaTkdjKBVQVE4/KUw4nLbIDq6fgSO0fd0cRV8NfLkHOY3jOzMb0gZVEi3YRHGaw6c6BeipniSeZVQ1Ma2oNkCPR3TB6KVkT1DzD5Yd6tw4VxwCtoaVsMn6jsK3PoZrd9WUn89cmbK6Kd/9/GD8UpNmx/JPPJnhZuUIP2lDXMoqh8tTxm5xSyX2xLN07ivjghjIMsL648bf6hbyUJYYhmVo+zoKxx58GrndEsv4P5GY78OjgSYuAVfuZAjn+zA7K7oWLo9yRX8A+VFBa0+Sg90cIaB3GM1ujOeuk+qcNNVO6kscPTuayRohgArV33Rveycnq5hwzvqpCRzQaIYB8uip06qlrSPiHIa29zlDKC63n0OfEP/h/4b4huT+ziSJ+lsP0skJEOu00dlqJIG9/eb4 Topi/YK1 pCUcUVFTMvX+8OqWI28wjwj6lrL15M3QmJlD0ncniZ6zLT6AOYZPzPxlg+720TFwdRI7jJKOQxhDtpZ0nDIwrPeG9eDhlkn3zoM6gSZdWBVgfxMQq53IkpK63oIpWugoN3pZJvwH2RH8DxC2Q+Lw2FDM8rXbu3WX+3aNwuwnCa9YggjcuoOSDGUFlygkmq1w1/mVzLcXHNi7Bc7+eNQxZT6GBBjpZ2MUAogTXYX2QCkekcxW0gec9WvtNpmuwLZQw5++0C+6mONgwvlZnJWYQAQwWXnW4gwmMoN2dbb5TmfKhrVvG56c09ft7Bg== 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. Note that this also drops the IS_I_VERSION check and unconditionally bumps the change attribute, since SB_I_VERSION is always set on btrfs. Reviewed-by: Josef Bacik 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 d90138683a0a..409628c0c3cc 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 Mon Jul 15 12:49:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733445 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 E186BC3DA4B for ; Mon, 15 Jul 2024 12:49:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56C776B00A0; Mon, 15 Jul 2024 08:49:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CCBD6B00A2; Mon, 15 Jul 2024 08:49:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 320666B00A1; Mon, 15 Jul 2024 08:49:40 -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 101B96B009F for ; Mon, 15 Jul 2024 08:49:40 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BDD051615E5 for ; Mon, 15 Jul 2024 12:49:39 +0000 (UTC) X-FDA: 82341968478.16.6EEA983 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id E405540029 for ; Mon, 15 Jul 2024 12:49:37 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Op5sWagJ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.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=1721047747; a=rsa-sha256; cv=none; b=SVS0zLB+WfTKt63RVs3nUfiYTRElHvE8dhKHsqq+PVdPJI//fSFCEJfJQH0TID/a+c4QCM 6Rvn2JcTNErd0uBXX/8d3DQH9d3pIhQPFPWocQoYxHJ7bZgphOqq7BLvgAYNb7X5m/avdh T5FoxKICYaDJNnFsIvV2Djr+vgwx5JI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Op5sWagJ; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.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=1721047747; 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=qagxqLPuudnrlm9Bg3Nt6HjUOYRMaiI760lNHqKZZaA=; b=jFrxnZwdsZWsxG3dVMyQ67oFjGLrXQhfy8YQXR3LhgVloqBen4uLCPu2ja86oRaOtU3l5m vgEWkxHs49ZeUiW9jgQIx7X7FHzeNAwYSuD1od6WC4PSckIk9A46MlU17kWrxBJYkwKOU7 JLQeqpwiB8+WZISYLuQvrDssyozWuA4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 25B2A61086; Mon, 15 Jul 2024 12:49:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 312FFC4AF0A; Mon, 15 Jul 2024 12:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721047776; bh=EGo15KA9RzWejobFOdJXVIKVsZGyPzCyG1uwa3tZn1I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Op5sWagJjl+DaoEpT6U6Roz5G+OZlHnYlPX1GVRhRCs1ph5A4POU7AelkpSydaFE1 0S/6XZ5jrsy1l+pU8jT0i8xNz7C46rPcqZFpDt+RZwciCR30kKbKz24evOTitf1+Vr FzJPtBPOU5iclZk+mYyMWcBFe2aGVnk/Rn4MMAL/btOLEN7TC8VvQMsoRlssdnUhcZ RS8B6yYf90rMB3TbhzRrgFQYyqfAqu/Tv/l74Z/8C5XrCGsIXk7l2nSGlPXuk9Pf3/ YnBJu+MnFdqez9L3jJ10joq8GI/5b45+aubtvZlH8RUDpFYLgxThEgXVu7Ys1oCnQc YomcYnBGoWouQ== From: Jeff Layton Date: Mon, 15 Jul 2024 08:49:00 -0400 Subject: [PATCH v6 9/9] tmpfs: add support for multigrain timestamps MIME-Version: 1.0 Message-Id: <20240715-mgtime-v6-9-48e5d34bd2ba@kernel.org> References: <20240715-mgtime-v6-0-48e5d34bd2ba@kernel.org> In-Reply-To: <20240715-mgtime-v6-0-48e5d34bd2ba@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 , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=824; i=jlayton@kernel.org; h=from:subject:message-id; bh=EGo15KA9RzWejobFOdJXVIKVsZGyPzCyG1uwa3tZn1I=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlRrD4m6AcCbQEbB3V0ipLp+HPBka/5rUVsmDG +UI6LP4LSyJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpUawwAKCRAADmhBGVaC FehwEACB/2bL0lHsL7x+6a2mF1cA08ExumwGUUpjqhfW/iUJDZW8NksCANkEjZy3jkVO2UFom9k MsZ5dg106pC96JwTEgOw+Wz+KchU1EDu+k20LB4uv5tnPDvb/ET5ncKyvxJ5+wX90wtxidCfK4h TWJwKVyQsBqdLsZ9w4OXei8HGv99hsDxrY/rhQ1KaOY6CEdzPcQOpCJbSKZ0n3rRR4X3KCEm0A4 vJv7X1XCzEgq0XUFHxamtkbmLAiGeaDng0kVnJQntBpaoFWUvbE8nUnCKwO42rKF9RgKHFMFhr9 Hr5D7G1iySVSJQ2BR5sJDVgMk5HGd1iyI2pVyeFVC6McOAbLpkl2Q5lHCE8kJkxFjd8KLcIwiVW o50Xzk8xJyxBuopmF8fzBrgaXB7Vsova2nDppB4/gexJo9H/PagYElk6p9zsOndkBubvDxLfP3h EJ+mL8K/MHCwpTOt1Ef72Y4QbrbvjsKee5N/8O7YTpBbai8Df1rRFhQrunoWqFh94wkmlSaFm7q bvYRMax6wvvOUL4sKAulaMdnh/m92gAeta1TxcYbI7XC5LI0f/7NQjMaSTQW+lXe6+Um8SHiZvY H5DVd1+vLNraR6/Ry+rSfK0uCHPXRyQadKt9ly2ZbezoPAN3Fslo6ewd+azr8Y3pyp9SvkpysRm d24+EIjmNvSAjGw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: E405540029 X-Stat-Signature: 8zyoyh6b6uew958udu7azmtbf5xrusxq X-Rspam-User: X-HE-Tag: 1721047777-982405 X-HE-Meta: U2FsdGVkX185lZeQ8oKg2bx2srUG4zs4UV/cTwi9yPOtmYzou+wnxltd8Gm9jXSZXLKz1oxQEqMgn7H6N//iAVbEED+4zmnfKZjUzG6Kx0XVCEnoD35Y3b87RCaT3bSEe2kTPeKN6udBZ6Li0NDR/AAKiMUxPtomPkWEpulrImOZuGCl/KsdC93n5VCu/SG/0lTMPNdmCuPUc+DtvrFcr/DwiSFqoTkdboC6rCd9tNxIPBPWNFFG4fP4KTOXgn7k9OP0mvjjqUQhXfEbiLgMLKbxfSG6vlCYO7awi8jFwN9JQx4KZznNJ9LZ3RGUFY/ic4e37o0BQ1Q/ClEWzLKSQWGY6Tz9/OGgAzyjDzaigxwQzda/phmyZh00vHE1XrVOsXydmW0fxKYGY+tR8Oj6BO068xdaFirnxMKPTFHynotTlhhCWNj7pnO635HTd7lK04uVXOTLmQuDPRB52MmlTutmA4p46lU2EJiPhvIlvIZr1ExMfcnVdbNWZ0600xYRFbWQzlunDJJVV17pkP0cJbVB0IRkM8SwpJr0xPycoAFywHDW6XdzgeIFyxyGKmNMCs3+TAPdmIDM33WudR94mpQsPI5ytX+wEXAe2LC6lxbnDpEjTR059MZEB1yxeXZjS2YH6nZ4FgI33p6JLhPzLFK4zB1CoK2bSNcUBxiZP6Bnba6C7Z4cMHYmTXy46WYnC9IWUIrv4UznbIIwCEv2kcXiJ3idDImrGi78DWT6fXaCHG4ITKfQGJtLTiCPN592fdnKURBgLFGdmd/S3Kflgc+HcLMNGoHwXbZyNugpcQUdcNXNTD1sUnuJZ1oOTvnciR4fhASTvZseLjIz5XvIRz6XUBG1mANhEg9uIK5+Fhnl16T9fKR8Maw2yDYhl40R3ml0lcQAxHX7sMlGrIJVHP+ctwcEkdLsgq7jzSVTac6zOldAUO/qwLwH74SkI8PFeZaSVBMJW51HLIvZqtC o/DoRP3T XbcHWRY7VU5I/hVpOx22atm2UgLTwnHSCFaLAbn00FBZLoCExIPkujaSS5x1Gd7O3fEpa+2IG5R7+zsFBDof6hktBJ/uY21FaApc1K+F9n6Qt+nBNl9OfuwxZ99fnh5XpkZ6t25Ao8GwclAkD4ei40pkJ6dFYN8fr0bgJ2PNswsIIjozCnrRHcQE1T19/Cwm2YMxGtqgapp5WqsEhWyoP0SCMY8a4l7aSlU+PRPRgZmmWososbldF2n3mGOBBDF3zsBnXvyxJghPl554GPYz+2xISDc/0TK4q5Z7TTZS7zjQkHNvfBDfT4kT+QA== 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. Reviewed-by: Josef Bacik Signed-off-by: Jeff Layton Reviewed-by: Jan Kara --- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 7f2b609945a5..75a9a73a769f 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4660,7 +4660,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)