From patchwork Mon Jul 8 15:53:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13726770 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 D0AF4C3DA42 for ; Mon, 8 Jul 2024 15:53:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 595076B0089; Mon, 8 Jul 2024 11:53:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 543AE6B008C; Mon, 8 Jul 2024 11:53:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4325A6B0093; Mon, 8 Jul 2024 11:53:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 201866B0089 for ; Mon, 8 Jul 2024 11:53:50 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BE652413D1 for ; Mon, 8 Jul 2024 15:53:49 +0000 (UTC) X-FDA: 82317030978.19.452DDBE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id DC3B740015 for ; Mon, 8 Jul 2024 15:53:47 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fGvmmYvA; spf=pass (imf07.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=1720453998; 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=tQw6kls5zW4WWmw5t8bLP1klgiQSykqW9Q1KIftrgxM=; b=7Ta2/T/6sSk4wD6knviWAMzq6DfU8ZTtVkiPlmmsnAs5rnevAQqZPBTI6svP6to/fW2sdo 0VnQdplaKWldtE/Fbi7ZvnrOMu0M2T9w2GrT5/1m20Q2+70cwpsZumc3+QAQ5dObunt88b 843jqNSIseh4vwqNL1hdZx5w+mXzp6M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720453998; a=rsa-sha256; cv=none; b=IXNBTgSGqLXxjQAS2yQ7VGyhdrnAPbbISoTHYChlQK5Mpl1BkJZXyu75Mlqs2jqroxC7mt zFHu3Acy2qLf5oBTrTpbSL6QEqC23rtPF8pYkqilu3+ivlKqHnXIWuPoNJaOZLns3Uaari D609AJ7G1rqp4dWH0GfVOnUaw1b25Cs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fGvmmYvA; spf=pass (imf07.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 B36E660E83; Mon, 8 Jul 2024 15:53:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFDD1C4AF0F; Mon, 8 Jul 2024 15:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720454026; bh=c7BMWt590urBGIVwPnQtK2Pi/1H2yhOGpHklWywGiww=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fGvmmYvAdlKi5erHtNfB9uhRYfgGzq4ysCbklA87aldjcBam3iFDSjgo3xC4kUOfH +pNS9rUedIvTGuJ5SvfisaFiO1I17wfsvs70hoJdFeOpyo/ZCeVvZPt8o7kKk+9W31 fo5eCrYlQBijxo6CNas5x4QNchgZK3v1nE4nSESsjMdjJpf2a20Vx4/XPnbkvBfvwu Zrcad6K+YVIvveTAgiT2pyfokup1R9xTl79a84uO8swZGzKfe4BQN105ANXzAscT+0 oq5QIQqgVOBI9IKvc1dg4sziyLiqWMevHl1suzBBw4NczRGnP0Ka66TvgrI18S2Irx +ZOROSsGRnJBw== From: Jeff Layton Date: Mon, 08 Jul 2024 11:53:34 -0400 Subject: [PATCH v4 1/9] fs: add infrastructure for multigrain timestamps MIME-Version: 1.0 Message-Id: <20240708-mgtime-v4-1-a0f3c6fb57f3@kernel.org> References: <20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org> In-Reply-To: <20240708-mgtime-v4-0-a0f3c6fb57f3@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 , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=15198; i=jlayton@kernel.org; h=from:subject:message-id; bh=c7BMWt590urBGIVwPnQtK2Pi/1H2yhOGpHklWywGiww=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmjAuDiBG5mmbWinvOrmsHhBzRa0kBNM9+nLR+2 nlGGG58+duJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZowLgwAKCRAADmhBGVaC FYGoD/4lWhqviccrE7tR8iU1WzxBCuOmX+n3MePoJo1RytO/HL6untK1u2BH3m9BM5p7oOStUb8 rMThhTbheFqVzRdmkTfoOw4IJeQgTt35W1Eycg3TV/YxwZSwAumTYGmcZR2hPNjDB3vHTqY/mp2 /N2Cd0f1pw/sRRHRlOodkDUvkjaYw7j2xi02y+lj0OirAWlR1qjSuuvtxNZrrfbKJ0Phm8tws8K /9f+TRuURSW5gMo75+PsXte8Dd/MTPV808cfX1gu1UC3r23oHAe+pggvj7FLbwN5qGC1SxHyx9d lc3gbSpgbume4LUjmoro2jXkrVT9TIDpgyenypiWkK0CNHHxt9YlZ4khbINVYyPMpJu373aRCa+ Y10CCenLt4syoQ6Ha6Pz/j5siRJ0gbIAZWuYCKnXSOI0YfPnvbk1PuKB6vHxZ3hcKK/q9ynhRxp 6M4iPP4aDkSAGM/V535dfN8ZsV6HHrwb8R7MabR54DTR5wcnOqOwJpn0QqJef9QJ12TnWuzlhmk a4BlKHeK5jMw9hJkMKkdY3FjjnYzfcCXGy/nbULibKzVWMFAxDAfwp0I2M05zYwgqhki1+3tX5p V0v8+/JwDqyIdpX9bH6WDwq2QqaHYusdynNqFkRwiN/Yj68aKYII4tg7DbhkRqC1cTjpAgen7En 0MumamLE6dGuSrA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: DC3B740015 X-Stat-Signature: bzgag9tquxo7ujbs879rxek8brawx73q X-HE-Tag: 1720454027-180725 X-HE-Meta: U2FsdGVkX1/fqCNB98jQEeh/j6q/GXPKmTJ0mFesy4+3a6pzA5xDZkQ9qJIzMiUCbQh9i1kmwai110cMsa8IBJpTWrQnkds1A168LM7XjZM1dIHuAfKdA+oVDk3rCXPsOjDDi4EfPJpjMFSfjlPIvwy2Qsr0IYVQSkmVqJoGl30ZgwBtN8j6QgxC8fGm62NBOfgvZIOSqUEbUKc5MDoIXpOn5tVnmO0SCaXca+NKK3VJUSdxvsPcWb9ZrbZ3QooWPvUzHf8xCeyamsUlObONoMq8x5C/DGAvX3uLFgKVI8KiMeAdVu8XzcI9FY1mJrZMUjkqZJNYE+xGpS9OeoJjOaJYtWVEzsYvL/qBLaq4WgApsD3I6e396TawHnkxc1c+rK+eb5L4ysP5o3/N+FcoyxSqTJ3uEw5udhXw0bwS9WsmBFEs/1vnW+UxVtpq3eRySFkVY73QN4VLAAv3vc3zMLRzcsXG0YxgC8qUVMAygojUgXvgQgSntNnY7sEcAqcx7lbZ0yNzgiAd8aXLCgUcwpm8ndksrvYEvg/qZ6cTOZ0UgeBZBFGEcs0lWVsm13L8vm0YXuaJNbcXCAy7Eh3OlAEtZoCCG8BQIlnH202184npVUhE69wyqv6XGVC3SkcH3IBE61F/C+VjobmPrj5lENxMHAY1kRL4q8KwNni2FvaDVmcHHo6CdVoy9ASMZE1qJAejS8K5gFBrvaU8RIj9ZRKNdR9GvdtmFGrSSgf4EYmyMEQ72bkYCprXm4mvv8SPlKRznDjDpoTG/cMibfFB5jJtVfReWPmgwPsV615etZAbGcv8eDtlvtZe3/Pu/iigSpe6clzy9H28vRHRX/wcoOZvKF/Godoz4BUKV2V4rcdXMyLqnrsZgNde881LzJzs62tqGXgLfZOKCeyb4M6LsV4GeLxrPgUW4tWt2Z5OjYwWzmPIzWFtKYWOr868XItxTv2dpsoAs9cMuC0eqmk EOSr50ZS ugkAlQI3noili8DDiH/Y6syYjR+xU0vdTC7MCUbZs5fzhVCyYoow19JK+OzFts+TD+p5G7mZdaU/PwQaVAE39iHKrt9tlVTDNKp3ZMTfFGKcYwZl6+6rMXnXmiLuH73/HO3Ia8EbsbeHUb2lpxb/xYSQlgQEz12mZu4N8eh6AsO31Lk1yfMyWBGteycb55jSqv7QQZE26nLxGFZna9wYt/0tddXu7nA/sfHsbdQVclFGSuEE2nCWRltE/7A== 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 ktime_t value that acts as a timestamp floor. When we go to stamp a file, we first get the latter of the current floor value and the current coarse-grained time. 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). Signed-off-by: Jeff Layton --- fs/inode.c | 171 ++++++++++++++++++++++++++++++++++++++++++++--------- fs/stat.c | 36 ++++++++++- include/linux/fs.h | 34 ++++++++--- 3 files changed, 204 insertions(+), 37 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index f356fe2ec2b6..10ed1d3d9b52 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 ktime_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_mono_to_real(coarse); + 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 = smp_load_acquire(&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,14 @@ void inode_nohighmem(struct inode *inode) } EXPORT_SYMBOL(inode_nohighmem); +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 & ~I_CTIME_QUERIED; + return ts; +} +EXPORT_SYMBOL(inode_set_ctime_to_ts); + /** * timestamp_truncate - Truncate timespec to a granularity * @t: Timespec @@ -2538,38 +2606,87 @@ 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 = smp_load_acquire(&ctime_floor); + struct timespec64 now_ts; + u32 cns, cur; + + now = coarse_ctime(floor); - inode_set_ctime_to_ts(inode, now); - return now; + /* Just return that if this is not a multigrain fs */ + if (!is_mgtime(inode)) { + now_ts = ktime_to_timespec64(now); + 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(); + + /* + * 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 (!try_cmpxchg(&ctime_floor, &old, fine)) + fine = old; + now = ktime_mono_to_real(fine); + } + } + now_ts = ktime_to_timespec64(now); + cur = cns; +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 timestamp_truncate(now_ts, inode); } 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 8 15:53:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13726771 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 60926C3271E for ; Mon, 8 Jul 2024 15:53:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DACAF6B0093; Mon, 8 Jul 2024 11:53:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D33856B0095; Mon, 8 Jul 2024 11:53:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAD7A6B0096; Mon, 8 Jul 2024 11:53:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9C0146B0093 for ; Mon, 8 Jul 2024 11:53:52 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4A5861C29B6 for ; Mon, 8 Jul 2024 15:53:52 +0000 (UTC) X-FDA: 82317031104.04.5574489 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 7493640017 for ; Mon, 8 Jul 2024 15:53:50 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tqeurhHn; spf=pass (imf11.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=1720454001; 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=lIu4TkVod6GJlBVaD+AliSChtUpW+4t0bn+3EXem/Qk=; b=09h2sB+bCp/Rj364FEL0wJmbYq6W+UYXN0OUus0DHc1qJHEeoqvObE35cGZrxVR0c2ytHC sUEN0dizFZI3lB+kkLiThqYFmz7TjjVYhlXhZvv5OjM7IQJ7jWf/c9+2Kcyo3QeI+i4uKy GzqrG4g1jhFYg03+qTY5d2RpEUZseHc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720454001; a=rsa-sha256; cv=none; b=a07moRJAp87ZlUaMaR4DbfUN5hG6VXyDse2vFyHetEc/pytKbuAEGiZJtxWg4Xw9i0MA6J 8cN08VnnX20/DttGZVlGhTKFfMhLeuYBcl1Apc0EFoqHd1u3A376BjUxdc84UFmbvTSJBP Z8L6Y1rubkEbia6spJlGc/sAvpfaK94= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tqeurhHn; spf=pass (imf11.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 920FA60F2F; Mon, 8 Jul 2024 15:53:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1CB4C4AF0C; Mon, 8 Jul 2024 15:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720454029; bh=RGBdixLVMnvZSpnnXMBVJzXQ79WBOeu5zDQit4Vflmo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tqeurhHnKiHcm2GAMReCaD6QM2ypo/Gf/JZXf7C+JwFyAD4IMO2Mn7ryFxbwuNTO9 U7mXBDlo9IExDjK+eFXmJtquMvI2Q8IHsTB1XOcRIbBRQZpDFgUDj1dBKSTS7Axgwh WYOgBD7UkhQ2IBlVzaN3ML2PooKPoausb3ZczaK3GA737F/kGhyVul/2hdM1zfBeRM LkAlR68snx6yW+QmIj7kmZW65+7XpJN4bDHSOA7suaoQP1shx1NnWoIztABE7hgG1c t5vQW3jD+b7u53tzNpocQny56UPO4RfbgDvaHzdnF72kAM/P53s2PZE49Dd3YnKZU3 KQkuwg/y91bZQ== From: Jeff Layton Date: Mon, 08 Jul 2024 11:53:35 -0400 Subject: [PATCH v4 2/9] fs: tracepoints around multigrain timestamp events MIME-Version: 1.0 Message-Id: <20240708-mgtime-v4-2-a0f3c6fb57f3@kernel.org> References: <20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org> In-Reply-To: <20240708-mgtime-v4-0-a0f3c6fb57f3@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 , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5096; i=jlayton@kernel.org; h=from:subject:message-id; bh=RGBdixLVMnvZSpnnXMBVJzXQ79WBOeu5zDQit4Vflmo=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmjAuDdpNxbcmlwD+lX7dRs+zrqonu2h14Q/J+v Oup+OtpHtWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZowLgwAKCRAADmhBGVaC FSEVD/9sP/3W2ybSXNwIlKJEMoJIDNa7UF6wAAPhxhIK7AGH4bfW60+p1e3IvJREC6NgxDUFFx5 aMgG+AFMjN/h5J3/NvH+kbxgHfJciF4QiOfUGZtfPD0rMmiJhBJPLSr7c1kYC2RCuZz3pFpDbZO /qMOYme/u0KMqnMaZm7RyOSwfLhVlZxYX7DJl/Lmv2MuCLzqNjYim+B7K8thvoM12SdQH7U322Y +dYYjoLtEsJ1rqQsxPKmdk/NHK3010L2Inmkrgg33uRl5rQ4OnPTiwB1/XHB3mUnnzfiBGA9T8s UsekKVbV/lmVQjP08b3mpBxnaUKxBWB+H3tb8ZUDKm2+V1zJYxEXiwtsEF5lFZgiofF5FJhdwFR JHZbaMiXY/Mk51jYZRaerbqrot5jS/I5CUMbpy91Z/7qfjU/aL5Ud36zk6YEe7Ke+ZcQvIKr8qQ 52tPrawcLxLZvwQ5CJlNBsVuhR0INfwSUfIWL7jlWGwff87RKUHbOsUgo1EjqAPshTOzsIhNaUf 8XB7TaJCq0iJGWUPQHu8ndPilDUG5QqIbIhgmJ0A//UsXJlzeS6qmHYGtrfJ3PcjcnAwYEGe1bs KtAzvgsas7CXfNeWez8LkLC3b77EQecrzVI9HPK1CtRusGN+9L9rBfsZvXFzhgee1c2iJrYNb/+ vGEJaQHT5jQbLCg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 7493640017 X-Stat-Signature: 7wsgk1fisskjc9caokmwcz1y9bqj93pr X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1720454030-585711 X-HE-Meta: U2FsdGVkX19/0dd9Cf4E88PiR4qma2HRXLkqjwo0urQsAhXngMnz4ohl0hadVcE3dAI5NB/pn9BU9PFFLpo/kQzoU9MUTbHaKYJM9/dB/cg5i0eZH7ImWj0PIXZZxJ2Wm1XBPrKq61U6n76FpUtVmtnq61vUxZb6Pvo0JdojhLsQm5kp7Cr06K8DS4NanqgNo6vLb2Go8/Mz924/LH5pb98hho1OPEeshqC9mwKwuxLn0ypfFqw7Glh+/9POg478AICoz/bw1iW/d8mY6TrlpeOWeNSjwd1yKDy+t6Dv14D8p70zIldmyYFfbSsmDZebUYC+uJLgt1e5r0Hw/z1i2BPT+LYlO+qtmVooBv2ISY/6nlVIhYN5Ynx4+ucehMMK0hMgffcLJegjy6opO1cDnSXV8v2YOcKHf/kju73SAeN7IHHJHYmdNwTIt4BNoXJL1SXPPUtNnKYM5Z9phcN7OHqVtSyJN6O5iNolJIdRhW4zMOlvlhNZCLleetEpqXGcYmwKhAmd7D8KSIEZxiGSH4aeOWkzDBlti/jlze3/N58AVtMlDUEpC3vsIcgCMYossRWukBrNvQvGIgCzCJiA2VxYnrM9KM5cnqUdmtJeFjgW7sQj61APGkxkP+I1lE3Qm/HMSSvdOBl1JG95T7PfrcgvB3uqqMkTn1DErdA9h3PUk11RYt15Rzuwmyjz/+lWOmNwRBG4ZTsmiMZGqAarGfVO4e2UnqXHHdVCrU9eETgovpm+xOlUxhBEj01/3b8RRl64zn1+w69G284x2l972URGalDQXLN8shEDR3yLDhhmr7EO/UDpfD7FeC4dZGD815wSWhHvTfhsyhrw2dqHMHNABCsAvBFmLmwRHJ2Z12Uu9qJo4DC9Ddf55jloeKJFz8B85qvug2RYjYK2UxCYP1ILFZgZ1bL5bM7kKdczxEYU5qqgqHG6jaiZf5+ZjUaF/Ly+zcME7gh25S/l2SS RyOvqcju TGDuZ1fZqdMFPLhbD93YYDqU/zCnSy2kwntwGxLvjXj2zKju98ZNtIIzY4lFJGWH2INC1u0qqXEjIPEwoNsVgq+Zpanj60WRSLqujapW4bTCOvdOtwo9NH1KwN/vC2cZgVQMZyi4sOE0zmmlHyvKyXO+WoczLbDBrmlJDVjWQ9TsaaLzL6M+shKyXWPRcyAVP8ww3Q7GTmb7F27CiVr7PRmrLX536XsVkH+OnR9b9jQ6wt5LKGOP18j10Mg== 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. Signed-off-by: Jeff Layton --- fs/inode.c | 5 ++ fs/stat.c | 3 ++ include/trace/events/timestamp.h | 109 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) diff --git a/fs/inode.c b/fs/inode.c index 10ed1d3d9b52..b2ff309a400a 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -22,6 +22,9 @@ #include #include #include +#define CREATE_TRACE_POINTS +#include + #include "internal.h" /* @@ -2571,6 +2574,7 @@ struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 t { inode->i_ctime_sec = ts.tv_sec; inode->i_ctime_nsec = ts.tv_nsec & ~I_CTIME_QUERIED; + trace_inode_set_ctime_to_ts(inode, &ts); return ts; } EXPORT_SYMBOL(inode_set_ctime_to_ts); @@ -2670,6 +2674,7 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) 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..3a603190b46c --- /dev/null +++ b/include/trace/events/timestamp.h @@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM timestamp + +#if !defined(_TRACE_TIMESTAMP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_TIMESTAMP_H + +#include +#include + +TRACE_EVENT(inode_set_ctime_to_ts, + 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 + ) +); + +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:%c new=%u cur=%u:%c", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, __entry->gen, + __entry->old & ~I_CTIME_QUERIED, __entry->old & I_CTIME_QUERIED ? 'Q' : '-', + __entry->new, + __entry->cur & ~I_CTIME_QUERIED, __entry->cur & I_CTIME_QUERIED ? 'Q' : '-' + ) +); + +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 8 15:53:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13726773 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 A0A90C3271E for ; Mon, 8 Jul 2024 15:53:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0F2C6B0096; Mon, 8 Jul 2024 11:53:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CBDEB6B0098; Mon, 8 Jul 2024 11:53:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B13A06B0099; Mon, 8 Jul 2024 11:53:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 849616B0096 for ; Mon, 8 Jul 2024 11:53:55 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 067621613E3 for ; Mon, 8 Jul 2024 15:53:55 +0000 (UTC) X-FDA: 82317031230.03.545EF0E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 43059C0010 for ; Mon, 8 Jul 2024 15:53:53 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZK+m74Ln; 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=1720453994; 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=0+mTfA4rU1po8svyzP43M8jQDf2DxwWnMP8MnaYJ8h0=; b=NTCoGXRuH54uA3iwUGFEyEhaAUvWkhbAtv8jT7t5nWQFlI4VJVnP4R5RlfgPkYzyOnhKrI BciuiPDIwRZCXYLKJ0vCvettteRj8fNL51FP2XXTFQk30Yf2QCW0HYfNEBHmSJmr3Ihxp3 AjqKCWsMBqviUjRIrZddO1D9naKQ+eg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZK+m74Ln; 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=1720453994; a=rsa-sha256; cv=none; b=6B5pagc/Az22OO/8oYgM6BSjFkB6lUQDRW3f9Wm97BHLm7NeaPeTn5Dkmq+cTzYKEIwzx/ nmiW2bp+BTFhiA1slCiaZm15C0Nx+q5PnbzIMqxsFe0j1qaZF4JdWaXJpYHc42pKWncjc+ zAxSnlDUGaZjf9KzMG1MLEdBCof72Eg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 706AD60E03; Mon, 8 Jul 2024 15:53:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A013CC4AF0D; Mon, 8 Jul 2024 15:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720454032; bh=3Lbwoi1OsUrhgHdGPKIfY5gAyrpedRUJApKASCysnEY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZK+m74LnLYmP4hKfEEcqImJ2WWsRHzZh8aQS2kRZGkex1opFTkUCiiYOFpMJP7NN9 C+xzCJa17mVivTegTyPfkpvrSabc7XuOrKZy8hm5P5CFEniVLhvKlvb45MexFsgWWM fErZ+I3DuJeHvAZdMxnyFH/dGPWM1jgyYweg5qr2jLXuk7+6o0dsJl3tem3MrIxo0q q3SQRCFGMSKU86GPjjS+TE4ZL/Fcg9sn3y8raEHC2szPsIQsSk8jQyW7S037K/3dty cKmeWH6QdtXNzBK++SHOJJtGDBQ1x9qUkwyM4uTQPIYjsf/vKZmU1CQiRNGuK7o+1S FsG+vxtXTW8Lw== From: Jeff Layton Date: Mon, 08 Jul 2024 11:53:36 -0400 Subject: [PATCH v4 3/9] fs: add percpu counters for significant multigrain timestamp events MIME-Version: 1.0 Message-Id: <20240708-mgtime-v4-3-a0f3c6fb57f3@kernel.org> References: <20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org> In-Reply-To: <20240708-mgtime-v4-0-a0f3c6fb57f3@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 , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3875; i=jlayton@kernel.org; h=from:subject:message-id; bh=3Lbwoi1OsUrhgHdGPKIfY5gAyrpedRUJApKASCysnEY=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmjAuDCTkX86wQZxt/FexePHG2g2qXIymEXEO5D zP/7w+C29GJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZowLgwAKCRAADmhBGVaC FfVVEACRsXJxxH7+xhMllN37rUAlU4nCqFXZe9HjP1jSGjrbBm11+KznLCamc/MioFvpOSKHatn ux0gbVneJuEOw0SRtqvfdyvpcIeA3tr//bDyUEE6iFIfYQs3Ti/jroUTL0ByKzCv/Gk+VhxNJeA pLwbZgxJmDPjbq3COlkop/rp5Phdfwof3sI/q9IvlJ+NyemoRN2SNmMgSM0nuoYoht2I4n9twAb C8FiR+a7Eumi5eynE8zj4EnvuxZ+Hgo0/wI6ob+vV9720GGQYzNjddDkeb3tq1LHdrE630uxnGT A4wx3CDkxBATrZFdCGwwZP1Hu4PZCAg2H6//4T3VihPP/s9TBa6hIyCyA3QIxP9CYhhrckj6ILr mVOH5ZTbJQCEWThtzT6n2CcjoGnNjYSQwNWrNpw2lLpONd5EKdz7BC89OCEFIsYKjixhce4URO1 nUelqVu6pI8wlUzh972tX+6J6qUJlVzwP9kVDaY93iILZOEZQKjhr3umIqtkZzqNZhLL1w3IvCl FdNKQPT6DUOCpVGSXU7SavEbux6lnmq/f9TdrrmzcHKN/zfys7Fz/GIoQYjVVP87eelAXPPFCc3 /oz5euHbjCPt+3nY8JTmpDCn7sFZTcZNpMd+619k/41SELlbrvgeMU0JeSdNzEiSFtsbCb1JG3h ZAi75SeocmkMcSA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 43059C0010 X-Stat-Signature: smkrjgc99hocc3o498znizgjzko91m1o X-Rspam-User: X-HE-Tag: 1720454033-334237 X-HE-Meta: U2FsdGVkX1+MXS+r63FI3l1nTTxQI0xhQmpV20ekrZ6Q4YuO1+bCY97bNKwANFfy9k9bf+f8foZOgDflVAp+9ETfTqRolZHJwBhC+fuF34TEUBDTIbgxwvNPzwr2Z7HLdfB1jjJWu4vwsjr2R+RIjv07VjBEG6t8xcCuBRvupnoYoprFoWqKKjdZ7o1f4362xpN/dxb1YUp9pvJuQopNx2yj2sOlC29LLoxwM7OoUEihJIOmoHB17sMZQWWNue432njEc3YBVyUEG8HZOcy4a0XWbX5SkrlAiHSdunuj9gsGWD4VAgbNsi/hBZciQV4i1wtaict9YEwlqgFoOkFPvyke/UEVn+Li4mvy+g47VC29LkiKY+jzT2WzpQJIhjDK7rkr2zgZjq1Ft9c0CoDIIvXYoOR3dYCnk3CwD342+wLtHKH02ESqHs1pgGgYKLGd2+JHef5qTa4suwki/8R9er4xzgTpo8Foe9lKW6N6obC/FGv2Zcl29f260LuOLTjmkFPTCOlPefS0B2UyhOxwttuJkdZhDV5wjbplaLridhy6pC7DMQZgwFPvSBKQgzbLw51a6NzJU2oVAo9z0pbpW898JqZbPE8jHg6iewktA4gn0/giwKwLwB1AyMNv+YCs0UoaHEs/ETNsG0Ojivp2ePRky1lqFw4dam7GoY5QfI4F+7oioQn0UnsCQ1vCazaOpGWW9AHrME/8wX54gxR2dtM3CPFrMdJwkEj9yKth70dYTyLybYVW2PMsSVaCBQc46+Jvxl3DCycUmVgmCnFfnhxisEVTLX4K/wXQGDDJK8lTdv68gNrKAnUrCCKhUMids3SWmqIrjmU3HnNWgDqQlLjoDhecWZ8S8RvuSR+Bux1Z9X3lLWhbf1C4MBFLvUXgqPErfExJLz1D6Myu3AFPxjQFTkERL60Yla3X1MMKSHhvfMFsi/zO4z9624QL1FMEOFI0ylDcs67TqqUpkXi PB/3r3Wl R/FNdyeeZkW+KgHvBMAnqSzqQgC5KfSLuQV0ku5rhtd6CJtQcKohB0OfiWiCpT0giSyX+QoeyF4B47pIfbUXGy2BPR0XNXZIiIsq7W3mPemTNub6A4IAfujyQaYi7WnKv3idgcXgnAtvnHxILKVUizx1wyjCq9fHg3jF3TSTBY7UNtONYV6eOm8PlT6Vc5MGBmGlQAlZClgnLhF2If9KP7zG8M2b4rrvpkIX4VhCc2AnxE/ZnEprvii09gosHP7aDQaeZSI/DawCJVOGaex7Q0maQ+we5U3uGF+yZ 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 Signed-off-by: Jeff Layton --- fs/inode.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index b2ff309a400a..9b93d0a47e55 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #define CREATE_TRACE_POINTS #include @@ -70,6 +72,11 @@ static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock); */ static __cacheline_aligned_in_smp ktime_t ctime_floor; +static struct percpu_counter mg_ctime_updates; +static struct percpu_counter mg_floor_swaps; +static struct percpu_counter mg_ctime_swaps; +static struct percpu_counter mg_fine_stamps; + /* * Empty aops. Can be used for the cases where the user does not * define any of the address_space operations. @@ -2654,6 +2661,7 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) /* Get a fine-grained time */ fine = ktime_get(); + percpu_counter_inc(&mg_fine_stamps); /* * If the cmpxchg works, we take the new floor value. If @@ -2662,11 +2670,14 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) * as good, so keep it. */ old = floor; - if (!try_cmpxchg(&ctime_floor, &old, fine)) + if (try_cmpxchg(&ctime_floor, &old, fine)) + percpu_counter_inc(&mg_floor_swaps); + else fine = old; now = ktime_mono_to_real(fine); } } + percpu_counter_inc(&mg_ctime_updates); now_ts = ktime_to_timespec64(now); cur = cns; retry: @@ -2675,6 +2686,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); + percpu_counter_inc(&mg_ctime_swaps); } else { /* * Was the change due to someone marking the old ctime QUERIED? @@ -2744,3 +2756,49 @@ umode_t mode_strip_sgid(struct mnt_idmap *idmap, return mode & ~S_ISGID; } EXPORT_SYMBOL(mode_strip_sgid); + +static int mgts_show(struct seq_file *s, void *p) +{ + u64 ctime_updates = percpu_counter_sum(&mg_ctime_updates); + u64 ctime_swaps = percpu_counter_sum(&mg_ctime_swaps); + u64 fine_stamps = percpu_counter_sum(&mg_fine_stamps); + u64 floor_swaps = percpu_counter_sum(&mg_floor_swaps); + + seq_printf(s, "%llu %llu %llu %llu\n", + ctime_updates, ctime_swaps, fine_stamps, floor_swaps); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(mgts); + +static int __init mg_debugfs_init(void) +{ + int ret = percpu_counter_init(&mg_ctime_updates, 0, GFP_KERNEL); + + if (ret) + return ret; + + ret = percpu_counter_init(&mg_floor_swaps, 0, GFP_KERNEL); + if (ret) { + percpu_counter_destroy(&mg_ctime_updates); + return ret; + } + + ret = percpu_counter_init(&mg_ctime_swaps, 0, GFP_KERNEL); + if (ret) { + percpu_counter_destroy(&mg_floor_swaps); + percpu_counter_destroy(&mg_ctime_updates); + return ret; + } + + ret = percpu_counter_init(&mg_fine_stamps, 0, GFP_KERNEL); + if (ret) { + percpu_counter_destroy(&mg_floor_swaps); + percpu_counter_destroy(&mg_ctime_updates); + percpu_counter_destroy(&mg_ctime_swaps); + return ret; + } + debugfs_create_file("multigrain_timestamps", S_IFREG | S_IRUGO, NULL, NULL, &mgts_fops); + return 0; +} +late_initcall(mg_debugfs_init); From patchwork Mon Jul 8 15:53:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13726774 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 53C3BC3271E for ; Mon, 8 Jul 2024 15:54:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BC296B0098; Mon, 8 Jul 2024 11:53:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7697C6B009A; Mon, 8 Jul 2024 11:53:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 595456B009B; Mon, 8 Jul 2024 11:53:58 -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 39CD46B0098 for ; Mon, 8 Jul 2024 11:53:58 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E035E813F5 for ; Mon, 8 Jul 2024 15:53:57 +0000 (UTC) X-FDA: 82317031314.06.0EA27BE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 263D0100004 for ; Mon, 8 Jul 2024 15:53:55 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=snEZEZZY; spf=pass (imf05.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=1720454021; a=rsa-sha256; cv=none; b=ul4oMONIOn2omk+wJN+N9Qu6wWHpewQdsbKusjNbQKbzJ9ZqFxxCLcBJF0qmi5Z7PzrAMw MoaihbsQUqFnrk41iBAdCIYG2CEOIUBUoHsf5VDe+o3aRfFWf9aLPiJUOVXd+WN3lEK8q8 8yQMQXNl3bEQCIP/8xxrvzCMNR2GK/Y= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=snEZEZZY; spf=pass (imf05.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=1720454021; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bJddfqUYKfPkL5IaapNTI+DPloFTuokezQWldk1boEE=; b=y5PvMoiPGIzEUwjPCE8pHnzXYguSlpgbUNxBIQ3N0M5NG+eMtAMXCw1k92S4eoajLPtxWl fFgMMeYLBV3pRDTerjZFTAVP/hlUhK2Yhfqg454d74x783a9FsDvrz6FaTKe/A/3p8h1zB yd5ARhrs2clvTCWGRL0CQNjR+pxp4Ug= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5033960EE4; Mon, 8 Jul 2024 15:53:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E048C116B1; Mon, 8 Jul 2024 15:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720454035; bh=/g1ddIto05q7VUdUuGmHZRulUXiGWzaifPHAIEfpWmk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=snEZEZZYYlDIZjMeR0Td2Px4FknQRH3fmM4PTBqA1d7M6RXOxjxczgJGVuJ3P4GRQ ysSySTtnx+quYylWaidML4XGNklkrRMjIqpIe8UeFAh6fHMNYp3pCuNa5yheh/2xqi +wsTLz1ey0cfjW3yrcN2MAki2ZIhVRIpvH072F1MiLO26e12C+CH8eYH7dvEyYAibA aGbLq7+A1yYlyWQNzJKsppiAyNwSDcqZ+OcaCwOF4QVX1prMyLtbRPInAiBxLEaiUo DdtmLzKbMUTY5kdzF5nSR+HLmMMhK7doBtBaiLTyGCtcwMOFVonevbVz8SqbrjWqSc evKhj7yKOb6Ag== From: Jeff Layton Date: Mon, 08 Jul 2024 11:53:37 -0400 Subject: [PATCH v4 4/9] fs: have setattr_copy handle multigrain timestamps appropriately MIME-Version: 1.0 Message-Id: <20240708-mgtime-v4-4-a0f3c6fb57f3@kernel.org> References: <20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org> In-Reply-To: <20240708-mgtime-v4-0-a0f3c6fb57f3@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 , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3403; i=jlayton@kernel.org; h=from:subject:message-id; bh=/g1ddIto05q7VUdUuGmHZRulUXiGWzaifPHAIEfpWmk=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmjAuEL4klBEgs/SfbfKR94rLthGFfhBSMCDbIG o5m14n1BsCJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZowLhAAKCRAADmhBGVaC FUjqD/45ex7zNf19dNV4LHtGLYWtZ70YPvkdUMIkEdLkrKjWeWdIIKpGP1kG8D1U+0QY/cVdZQG /9dg3txWF9kkA7P5ghcdrHIk+gP7qVfFEqlBwTxtnLOjaiWbO06hgl9ii52/I2z1ndnTd2O8Xrx n24iowjJq3gdx8wfi8LqmlBCsvZVWPUf6OmUscBEtdcwEWTPCZMEUrl15JJ8MAJGRLDLjesvoE6 snCuGvaKcDXizPA7X+YpZBYoMtL1HWE61qQfvskO4F2Nkvxj2cCKAZTcSyaGx36j5MROw3XH0y4 4Mw/YCUcJ5OoZiqAZg79fS+AicFIykbZXLERNZ58tf8y6ESylFZsI+uFV4ydKW/IXNbB3I21EG8 RNv6agbK8HNsPvQLJMr6IhghR0QPI0KTEyw4dpVCMFiYoF8671jwrq+O7SfVGJRpY8Bi7G6SOpA UZ8izyjrGP/lkbGicScFy7QkJ3AZwvePIFh5JcT6j9mjykJ90V0cTg/7VDFEwFM7b+ptXN7GBZp zBjWzxR8CGq1293ZOBFGuk0a4mCqBmjD2yZifaP01mBzmnHZFeHpeQPAZwsI3i3fLi94Ct6CyZU 9FXumDSEBy/akWO9HZWy+HQGzR/Pe9fTc2kyWC93w3fSqfRlXMsRj7DCU7viYe3L4qk0ZYzgFJV G8Tql0DRGFseNHw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: 8z4jf13rexcnximdr98orecccnz5fezy X-Rspamd-Queue-Id: 263D0100004 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1720454035-828363 X-HE-Meta: U2FsdGVkX19OMTsDdDHbDIoQvbzpJFmcATbvEw8tNj669via7jDbkPx2iLEXuDkxDzT3kUz5tmX2cEuIWRYLXNx+Ox+FWzTiUJ/vaYbCXeAcWKBT6hC75YnzN6ZbsRzRFfzkYOMZTCXWedORDS9wL7uSOmJDPO3gEov8mLp4Ii/31swd4gLBimeK30etxz/EYYfH+xjCjVsHWEV82Anzu6EyoiUwV7GD+VW1MuMeSeU1eC97MvuYZcqzw8H9+jXtJpP3Z5yw0tWR2hDZhvXSVKv73XB4y7Ld6ca7tGoX2Kgy7F/IU74TIxKYScgyZCaDjG5N1P5ZsF9wL0g7Jhh3xHvNMWv17eOcv4x/cqKNSPmcaZDR0kDrWzXzFir4NxZ5h0c0bpbHvzyq6RwGq0HDqgFv9Fu/SIItFBC7ObG7aoyGvPC+G4+JEd5lVeOAa0ZRuJZEd/j8UATpaMJjzlxLhnNPqGYf89Xa39dEl5qubOp+5dcIcoTxsyPbhV1fWBSZ/ETySnlGhKVyP22HCHkVJrqdN5r+yRYxpWXBRZ4T2ngWmmWfb1F2MKo8Ot6mfddvF3DHutWtaALQ5xNbVk6IkW1R5KlNAdMMuqpz9DSUXP09/op/QayfF5vC0pgn8kgM8jYyH73aiCDWXpD3/b5mhqr6s4bC2EjXFLu4lpRrzriMFlCPfYfxn5MMNruWctBjESxLO4t/dCLpNAZXqnwo4FaHm+SzB5IUfvf/lC1xNGhxRJfv3QsB8QECXDyaL5QtN0lAq8Nnf7VDXpebjvCSiYnN+1f8TwGBor0/7DTTu3iPuRgDWaFSQv8tCsecGVyC1I8qefMsgU9p2k1UQYhV5ubR69TngnUFMpXdbT3W07e9LORaDiD3n1zrc8MdJlQQA2Kup6wS0TKF1QxCZm+18t3eFtaWQsD/k1yHSWaYk7SbHaKVzUV7qneu46YRomU9aCV6tEGT8juAnrn5oTR JnoLESEj TmJK41xQHudjwvN7LnibjMLf5KrCGjde7MAXOC5IWduvNlo81copifMVC8VMIGdggLmlXWYhfTCaoLfiawRJUdbgc6P8oJlF763Iw7uqVP1PH29SsKvqS99zSfTltRXjjVgEoiRksO49ylVa13lvuFZfMe6LfCol79uFhXsaKR6fFb1tQjP2QtmKOVMrAAxXoeTEf02FaN9bhyhbCj+LvBRpb3XWvVM7Wo/Fv1qfhz/Sc/QZEyrniRG0jPB3L6prwREkpJsLFYJjbwW3gYVmw4D37m7WWICSMzRIhnPPm8z+FKD6Rt4aC+3CIe0Mahh+miMm9aeJiPnfmVWSvWfgEy8ajF4XC8nUsEybqs7d47UZnY2rK7GEq58w9dwTCPFpr0d9vIgPu53jDWT7b/UhSc2VzvqAJuPORHQwf X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The setattr codepath is still using coarse-grained timestamps, even on multigrain filesystems. To fix this, we need to fetch the timestamp for ctime updates later, at the point where the assignment occurs in setattr_copy. On a multigrain inode, ignore the ia_ctime in the attrs, and always update the ctime to the current clock value. Update the atime and mtime with the same value (if needed) unless they are being set to other specific values, a'la utimes(). Note that we don't want to do this universally however, as some filesystems (e.g. most networked fs) want to do an explicit update elsewhere before updating the local inode. Signed-off-by: Jeff Layton --- fs/attr.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index 825007d5cda4..e03ea6951864 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -271,6 +271,42 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset) } EXPORT_SYMBOL(inode_newsize_ok); +/** + * setattr_copy_mgtime - update timestamps for mgtime inodes + * @inode: inode timestamps to be updated + * @attr: attrs for the update + * + * With multigrain timestamps, we need to take more care to prevent races + * when updating the ctime. Always update the ctime to the very latest + * using the standard mechanism, and use that to populate the atime and + * mtime appropriately (unless we're setting those to specific values). + */ +static void setattr_copy_mgtime(struct inode *inode, const struct iattr *attr) +{ + unsigned int ia_valid = attr->ia_valid; + struct timespec64 now; + + /* + * If the ctime isn't being updated then nothing else should be + * either. + */ + if (!(ia_valid & ATTR_CTIME)) { + WARN_ON_ONCE(ia_valid & (ATTR_ATIME|ATTR_MTIME)); + return; + } + + now = inode_set_ctime_current(inode); + if (ia_valid & ATTR_ATIME_SET) + inode_set_atime_to_ts(inode, attr->ia_atime); + else if (ia_valid & ATTR_ATIME) + inode_set_atime_to_ts(inode, now); + + if (ia_valid & ATTR_MTIME_SET) + inode_set_mtime_to_ts(inode, attr->ia_mtime); + else if (ia_valid & ATTR_MTIME) + inode_set_mtime_to_ts(inode, now); +} + /** * setattr_copy - copy simple metadata updates into the generic inode * @idmap: idmap of the mount the inode was found from @@ -303,12 +339,6 @@ void setattr_copy(struct mnt_idmap *idmap, struct inode *inode, i_uid_update(idmap, attr, inode); i_gid_update(idmap, attr, inode); - if (ia_valid & ATTR_ATIME) - inode_set_atime_to_ts(inode, attr->ia_atime); - if (ia_valid & ATTR_MTIME) - inode_set_mtime_to_ts(inode, attr->ia_mtime); - if (ia_valid & ATTR_CTIME) - inode_set_ctime_to_ts(inode, attr->ia_ctime); if (ia_valid & ATTR_MODE) { umode_t mode = attr->ia_mode; if (!in_group_or_capable(idmap, inode, @@ -316,6 +346,16 @@ void setattr_copy(struct mnt_idmap *idmap, struct inode *inode, mode &= ~S_ISGID; inode->i_mode = mode; } + + if (is_mgtime(inode)) + return setattr_copy_mgtime(inode, attr); + + if (ia_valid & ATTR_ATIME) + inode_set_atime_to_ts(inode, attr->ia_atime); + if (ia_valid & ATTR_MTIME) + inode_set_mtime_to_ts(inode, attr->ia_mtime); + if (ia_valid & ATTR_CTIME) + inode_set_ctime_to_ts(inode, attr->ia_ctime); } EXPORT_SYMBOL(setattr_copy); From patchwork Mon Jul 8 15:53:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13726775 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 458AAC3271E for ; Mon, 8 Jul 2024 15:54:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 549456B009B; Mon, 8 Jul 2024 11:54:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CEF36B009C; Mon, 8 Jul 2024 11:54:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34A566B009D; Mon, 8 Jul 2024 11:54:02 -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 13C8A6B009B for ; Mon, 8 Jul 2024 11:54:02 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8F604A458F for ; Mon, 8 Jul 2024 15:54:01 +0000 (UTC) X-FDA: 82317031482.17.E26EC4A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id 87D6F10001C for ; Mon, 8 Jul 2024 15:53:59 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="AX/xL3fF"; spf=pass (imf14.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=1720454024; 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=XZrdp0bNDFvi8wiEFlMR9pPqfGnh+LwGxLU56c6fuI4=; b=q1r3N8bWza4i2uXIu2DVXIw7q1Hx2NaLIcxWXqMJUhtjYxtZxpkTZiNi4gS+hXcFwYNiNG JB+klmVh9TYNDnIUO8gM6c6NPiMzpKHTqXyVaTgafHPiSSID3Ks+X4+tFk1iEhMnMKybvp 0xSSde/YNxML6WQeNqAw4PM7ZM1tJ2s= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="AX/xL3fF"; spf=pass (imf14.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=1720454024; a=rsa-sha256; cv=none; b=Mu2pwIJNK4O4Ce2wI9Xg3mwUGCPflx6HFuPr2ZKPXWTOlA/dWUmJ1kHgVAwrJ5syyipYCt queOcRioCDaF18I4dYW0rhnysx11Vtf3kjsSBU0w0Ljr7MVXr3OtQ3R3wbNSu8oQdxNth+ hKaqLGQ8FaOfDo6lHF2soBKS/s0FONY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9C5E960E93; Mon, 8 Jul 2024 15:53:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C387C4AF0C; Mon, 8 Jul 2024 15:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720454038; bh=3kjkEi2lp3qDJyH5rtduUEdM10TvHoB9LhQ8/+GSXaA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AX/xL3fFvU92GisiPs6Zc+adSfi3GyzRCVxVZfJpqtiEvLxdhhF7U10nvmJ4UtyQR fM37bQQPjdiwtSTcbdYn6LMjRFST5q5kd+Ew8F5fFLpiXChImlHCy0ELww42G7Y6RH wAgMYrnoci9J+K2MPrLa3Ic22crAXJNDM+0W9xIzuRdAOgkRJg69GTE27Jij+j1EEB yX7574tzzeUnnYY0aGKe7t0GaAJIpw6+NmA+fQIQl4zWPSileA0i8ZKGlYlonX//zw osAZqb3+Zf2gTgvnVKUJho0qMxzZGfuCK4hOzfoNv3qEKgZVs+fKLTCIeHVSwA2RE5 XtVMN76HRT3Xw== From: Jeff Layton Date: Mon, 08 Jul 2024 11:53:38 -0400 Subject: [PATCH v4 5/9] Documentation: add a new file documenting multigrain timestamps MIME-Version: 1.0 Message-Id: <20240708-mgtime-v4-5-a0f3c6fb57f3@kernel.org> References: <20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org> In-Reply-To: <20240708-mgtime-v4-0-a0f3c6fb57f3@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 , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6280; i=jlayton@kernel.org; h=from:subject:message-id; bh=3kjkEi2lp3qDJyH5rtduUEdM10TvHoB9LhQ8/+GSXaA=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmjAuEvMLYjCZyHKB07a0DIX65Yy1lyjMtPYQsB p/ppuqsUWWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZowLhAAKCRAADmhBGVaC FbyGEACt5Is1KDr6nFAsnXhrK6hwHEq1NOHCSrSYTx0zl7StwaPcSBLXI3etbY+cCyHngFD1G2V wXXrArzYHOXmX2fDCkftgwk9nXB3Exz9eK+6UO2RGTxxYCFxNN8ihq49HApbfn9eFa2+P8x3Rh3 uXzX61hR4Vz4awjOxZixbhwCpV5sK+2e1WmZvH1TpsQgC1e8GW45irlUQmj19a7h41VG2ybmKw8 5JxJxJtnUIHo+7vhwIuLthwH4Mvmt52xiv7J8mJIHyYvdqk5SteVn6EE6tZW0jDN6isXwsVRdwh fWxuaYgXleqLfteDUy6bBwR43NMH8kjN52cXIyG9xNX9a3gWDUdGgwmuXivtr3+ZJ8rnLvlJwnb +efX02rU0puyV+QosluzdLooCovCu64XnDZ6vrxqRPj06EUWjDL68SkPKHQ3ekNwYX1GA+APb0G sxrG54P7Ef8l5JNWVN4rpgMVaoyNGmYLO70Nn/BBt/GoOcxPrR0T8VoFOFZmPe0ECBnmpvsVQCR sdjqsbNhIaNfMgOUwXF/YJzLsA1lzR0V+SDo9v1FyoQFqCXvwEkqDpeZoPZnHz2k+7ejgtkAvh8 L6rxBrlqeM/1xx0J0fCFF54mCTJkZoD0x+DiGdTVzm3bjX6w7AQua19EFBoGTb25W6PQFSqmq3z mdHDbimn5AsAdIw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 87D6F10001C X-Stat-Signature: weqqw6u1gqqfi67pyywowwxgq4opri47 X-Rspam-User: X-HE-Tag: 1720454039-352803 X-HE-Meta: U2FsdGVkX18LOkWONecKqdGDsfgfQx2TKYJ45GrKHznyWIZSdNOOcUMo8BtUmh50Z62GV+VMJmg/U9C9QZwr7e5gCIKpK/i/LSSchceJukenpbPltnv4Ykh7qJcCXI6XeOyTBo3rvUVVbKZtAuAc8DyToE+ctR3UH+GhZTXutG9rwYOJY8Wn48NQAcPasnanJ4sSxaC3mdwVvl4R6NuF1S3im8A9eTwchvsrDwfEfx0OopG2BFv0bOZFWCNZFWmG1mChG/gI5p1G4iLeAFsFmSPC4XPWcJ48psURBoVHnz58UscFkGvZKPuWLHmCyFa8yclYlO+a8CudMxX0c5aRXDV/lDw5aXr/xd6vTegUUZEWquzgseUYB2krRtudX1nrH3UmVEbGT1OhLotUa8o6MQNQq/xJn94qfgT0Sa6RlC3/25aC5kTf1STThW/rLZ0xEXBf1/dTYzY9tbKyoAwsS7nTm/SdeJdheSTSTQhMsNTdEkwXxh5SRbeHB4ZLAJJFNFFDD7WtcnR84BAdb72wKB6KgCJ0gRYsxpkL4r0fPg4qXLFADZPqSJ8XTC7/raj9CZA2W5mU+PuYOq4CBWCyX7QRkMzsPRwJl+NbLn7rtXIWT6sna6gEhlUdsYHzOB7feK1PDto5++KLrYv7QNzbzFwn/RnkzzeRNOjXG7CNxWzxo2U5Qx5Z+xaU6Yn3gvg63uMDrvU8AMbBTakT8PyGIc41ee9H2p/Z2jNT6OhLiyrhRKfUpCOcWjV/qRQpefgiUw8hW9mNtVEDDddj5KBfGChnapUSOSMIoENQRwA/IQZmLvewoOVX3rovFR1yVrsscJA49gUcXw+5P+nwk1NIQvxuX0tIKr+eRj+xmPywmGFA3jdOHu7kPEz/44XVDr43SqytuMNqrMNigRzh23yniknPaUWsD5py9jlTXxac4l6h0iY/taqfZJvVPe75hyUNX9FQDkkrRVskk81/w6E YWyq2lHf NfrwyrMBA2qzgPA1dIAKNU2VRaR29ma9DAPLYLQvzpC0s8SbWp6es3BoEUychRaUVREdEvD0TGjbJ75Z591sL4eLCDJNbwireunqi4H1Vchodq6k1qsxLYvF/DxjRjIF8xJOyJdmKUhR4d0AJKgEFzDlICY9ncDUvX+iKuq9RQfYdIHfMHLpnw5jrmRDvVVlwxIs7/QtjH+/CQYpvoEIrbYXYZJx6rgD4GKTFINkPbJ/z12GpbTKQDIMDHbL34v1stzDsjMwvGHZVlSL/Fk+C5DglufSdR+LQnRJTIxIuH7eXvioaODeVcvmJxlCMvVdDkZKyg1M9rXcrko3lgqLZUMRLefbewlBoKYjhclJN9DLJOSDR/ZWIHkz1dA== 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. Signed-off-by: Jeff Layton --- 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..e4f52a9e3c51 --- /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 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 8 15:53:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13726776 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 5AA7AC3DA42 for ; Mon, 8 Jul 2024 15:54:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E203C6B009E; Mon, 8 Jul 2024 11:54:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD0606B009F; Mon, 8 Jul 2024 11:54:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4A2E6B00A0; Mon, 8 Jul 2024 11:54:07 -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 A58986B009E for ; Mon, 8 Jul 2024 11:54:07 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 25CBA413AF for ; Mon, 8 Jul 2024 15:54:07 +0000 (UTC) X-FDA: 82317031734.28.4AEE543 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf15.hostedemail.com (Postfix) with ESMTP id A0F03A0028 for ; Mon, 8 Jul 2024 15:54:04 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="EXc8Q6z/"; spf=pass (imf15.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=1720454030; a=rsa-sha256; cv=none; b=HrgH1gYCkCSrthnVFoIg3zRsCKmpHlde1EzWTUm+IJAQTMnJj/ry4ARHgILCV+ytpuJwsZ gsS0zUlXWpbNLRrcNL8PaiwNOIL/eneYjqxPLwxav967pkEsgclWI/qJUAyRVuT5zXNERx l7gzTPevbKdjasyLNz4eV6xXeIxFOGU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="EXc8Q6z/"; spf=pass (imf15.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=1720454030; 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=3Jh+/RkL/JMZmQsliXtD8/KiOzj+g0LqxKDnzgwCyRQ=; b=2Yw74NGczsTTRvfOOTxusPw5KT5vCJjV28igTB8XlfOSuPmp9jHdqS7mCFxIgBU1Ii0ytu 7Eae7r8HZ7YCG4NljxR+NqZNlNTOEifqrGOWHzmMQF/LixqA66Oh5v3gn0IRL9uV0DAQit 4T2g06UyJo7H0OtQwSGr3jQs4wTo7UI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 8A0FACE0E1E; Mon, 8 Jul 2024 15:54:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CAF8C116B1; Mon, 8 Jul 2024 15:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720454040; bh=fHx/mgJgehSKKeWi0EcYG4swNcOzJbq5fDt162sYPoU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EXc8Q6z/aA2iTbREyS3/WYORlttsAC9FwB+JrPR10EM/hOgWC3OmmPTatPQ7d5ZBK kUaYZpsX/6HPobJ4W/+IWz3lQRfBIhUqrC711O6DOSp//+rx8t+N6q+uwoPffBnRsY 0kfEB/LKf/3wlX3DOUKRz7m79YYVSaYkPbvPNQykmKrSy40XI+TvAA61vXTM7rY8l0 0XAtOI15t2eU02duhM8H2AD/8ivNp38watuSC449U1tQYed6ZzsmoAuOL9KDrI8sbV I/4vbT3RgYKakJu5l1YLmpI8ryXYoKzVvNOmFKSMjn8T27D5hx7aAVF47h5/k83RlA uAaL9ZTAMWzbQ== From: Jeff Layton Date: Mon, 08 Jul 2024 11:53:39 -0400 Subject: [PATCH v4 6/9] xfs: switch to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240708-mgtime-v4-6-a0f3c6fb57f3@kernel.org> References: <20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org> In-Reply-To: <20240708-mgtime-v4-0-a0f3c6fb57f3@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 , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2796; i=jlayton@kernel.org; h=from:subject:message-id; bh=fHx/mgJgehSKKeWi0EcYG4swNcOzJbq5fDt162sYPoU=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmjAuEMx+U894kzOliT8PIHuyLbuEhBDG/6A47f TNcoicTlx2JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZowLhAAKCRAADmhBGVaC FW32EACrJh37KQ3iCcP1FmPHSbhmc3lsquIR/ezsNSLqPcIYhcO6b9Vji3XCEokY8WXsfjZAZS8 R9/+Nnm6TSKeljPkYd+yPMpxp3T0jxCZkvYRyED/848A9fnnKx6OeAi4SzryA45leaHiEDRVQCX J9PNYkvOrJfs15fqhqL8nqcLhztTzgYMwkCn3n24dTD+XFq05JTkLQaEFCmqIdnfyZoOp5Aj9D9 paE+DUcx3iSah3f8GTFvejGBO+Q+WDqiiyeB4sMTFdyQ4tyZqjyaDmFaF2lSPMVPiNxtIAFP0f8 FRuiDB5CmvAuClW/3zBlLB3y8m8UWxME46t6vY/qCskxnnJDiV5wUCpEqfRzrgAfX3tBlS+WhOo 5BvmR6xrJoVht0jwBuaK7T0zoCHWETivxG73i+V3aGxLQYgmmGIHej7twpu31xi3l1aMcgrSi8B SS04qjk84jJYZ6VcN5OdQBr+Ol5ERg8nMNrIroer/1TZH34Gws3pLYcLBCiuYRPm4aaGSz8f0CA Nl4yZxGznM04yrrOSc6UZGA3z/cjiTfbo+I2W1pHGlFogwZglJkcgrLwGcsnpSVbHAspi/ONUAk 3dVo8oTmiJCSEQ9+rVTAHNKlHWvqEsqGr2WU1deWTKbhAptpG9VJm4ocBvFjV3t5AAfuZfiCfIe ABq16uwiRuXRIZw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: jjsxjt678jgpxmy1gf6omjwp1zzcpbuc X-Rspamd-Queue-Id: A0F03A0028 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1720454044-569514 X-HE-Meta: U2FsdGVkX19L6IU6bCyaeHWIuZ82eVuK9LJCiNcT/3tpgcbR8u1dNJN3YGWwBEzxJYoJYXybme29pVj5OLaAUUpv47Qg0vec9J75HbFUJzRdQ97idtBDOPch1oF6bdowYoEPYDI1D6dp5+d5iQjAYYZvuOYaztJrC49XjYFxk8uLzF0yEg1V6x9F8DM+joBRcKZdY1VwJz/+blciQxoBUUkO/0t1GSDviy+5WwkLs9w7uIfiq9xNRcYN7XWhEqobGmvDfiJZ4XWDG1h2q9RNuCYfBIDYJcD+7XT6iv8WiL8zmf7lIG3CR5WIzUTVqW25gW3HDVmLNZlCArsx9Ze9uXYKwyRy4T1M3g+M8jpG8j4GwovUdExwgn51SLSfZZOFYMzAZGsVwvrOD6o8Y58+W4lheuGn3cz8BY/tgis+At9tluJeThoGCfDlaOI1LHmIVPjwOOgzUc8dGziwPEUfZgeRnWtNKwy9Q9JtGNXwCNofRA1gfDS7iLP9qrZK1oVMVYb3RNRVaFjswUPt2Mo8EwJyNZpuHYbUWtQoTYya1J6bQl02U7uldm8bceZXPODnuNMjbbjDKKavigEcC7HE8ViQ01tt4u70xleqdRQOkNiy+2SfMWDH/MR5Y8yOiIenBpvUug6tioxxNNMqaQLtQTjeGpLMOvRZdva/eqhFfVKDLlhInG8B+8LTPjTcCyQ0Y66LYgY72r7wH1p+rw7NCtJQZ3cszpKZwCcPSCbWrTfe2SwNCV9dX0JQd4S73c0QGoZHRaHpC1gmvHOhMmU6fqWMzJFlPZdwaCZMi4OLChy8fxfOoULuIeM1HTvMID5gVm7ibf68tQl/JU4caGQk5JrQ/Aczpy6qY3pSn0EdgXfV1YqIN/ZsufoBr6RZqbA9V+aoaWamYp590ksf2coRzoyBS53VvOBAkCOcTMLD2hcseNdxe9tc2hZwvdKoqObsUWw/5ffLuLrPMqzaDUe SmYCDZdA mBt8o+TJo7tmuBVUOk/D8+uJw4FKMxJSRT1mtiGlbIPZOKlSC0WrYsh8KDIu8CDYQaRS+z9SUPx3qRazL5mEyPiu0YpYlxSVPNCSqdMf35ejDm5vqU5nRVN7Kv7ymfRPmZPF9fsFxEKHcHHVEbRMXujJYvNjLWksRnybEwM9+0RGIy+yg71XlX1SnPVgrP6eJA4LYwjNv3twlG3FHZXU7iCdkcF6VqW334D3bL2w2xYAXMfKD4BOVTtMgyxG2pQUkIZgvqzb/PVjTYXpkzLbedKfUAKM8rQKbfR4kQ4Tgeuye52ay4GZUZIx7rzHP5EvCLEGhTbyXkECc0eX/7RKPi4HLWB8Jy0eSLO3WHm/ra5Jvyb0= 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. Signed-off-by: Jeff Layton --- 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 8 15:53:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13726778 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 55307C3271E for ; Mon, 8 Jul 2024 15:54:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4593E6B00A0; Mon, 8 Jul 2024 11:54:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C17A6B00A3; Mon, 8 Jul 2024 11:54:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19CAA6B00A0; Mon, 8 Jul 2024 11:54:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DAE7C6B00A1 for ; Mon, 8 Jul 2024 11:54:09 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9682DA14A5 for ; Mon, 8 Jul 2024 15:54:09 +0000 (UTC) X-FDA: 82317031818.10.08C1EEB Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf07.hostedemail.com (Postfix) with ESMTP id 2FD7440015 for ; Mon, 8 Jul 2024 15:54:06 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WdZmqhZE; spf=pass (imf07.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720454032; 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=jrWDUNAfjQEDxgT+s5m3Xpc+SMUbJLWr2UGjE6OBm2Q=; b=UIfaata7o9pc6KW59UVzgzhcLWb4AZ+GtE38PDbRjX9ru5WKZSCKUTqTZoTlnHcs9gy2HY 469wiPHPdU2HODzPIYxEIEJS6sEHbcazEEs8SVMrfiqPWm8wybp1/FGymphqHLdsTJWABU e9PrIiswyp/HK/v6YvZ0EsXfHs4AlG4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WdZmqhZE; spf=pass (imf07.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720454032; a=rsa-sha256; cv=none; b=RhHti68AsIMYriCg7N+J0KYSkExzR4BjhGGKyIlPtQghMfhhs7VjlnT8QodcO54+k7BPhm exrIdgqRj8Rgwkd6vQ5x4Bizw+vfHeX7jkstoz1CUW7usKJNjggx0FOe89Sd0wSyz8ltdX 6+mkszdV3yIKepwkIQ5QjqQYE5uricU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 68EC5CE0E5C; Mon, 8 Jul 2024 15:54:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B02DC4AF0F; Mon, 8 Jul 2024 15:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720454043; bh=aIxGR7na/Qdc3ayjXzlWsssXh9j6/eXvzZW4Lz1mI/Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WdZmqhZEKcdRor0xeRZQ1AMbtjW8CCS6wtr9O5WYow4WRp4uGqcoWspFWu9aOgxk/ 05tMfHGKk+jbx4L5sjDmCtp37o3pHA/E3ErO+DjPywyV7S9VxEDTgypzb2c/IgpNbZ ZtaLocdM76/fWP/DNQD2TZjUMfKZcfr70nMP0S7IUdcv755TKcYHTmTEQPEU3wGDkZ X3n2VKVCnCOtvaoqnFx83g5WFH/bOJeKHGmA1A00nqffpV4NGLpFSFWWkmSv1ovx0L 4de01hkrsGxPUOXTdsG7AiOLqm0l3pEyU5WwhAE7CZCRkeuIsiefmeENFR6jx6/xAi FjxZUnHiiE7SQ== From: Jeff Layton Date: Mon, 08 Jul 2024 11:53:40 -0400 Subject: [PATCH v4 7/9] ext4: switch to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240708-mgtime-v4-7-a0f3c6fb57f3@kernel.org> References: <20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org> In-Reply-To: <20240708-mgtime-v4-0-a0f3c6fb57f3@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 , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=839; i=jlayton@kernel.org; h=from:subject:message-id; bh=aIxGR7na/Qdc3ayjXzlWsssXh9j6/eXvzZW4Lz1mI/Q=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmjAuEhXGg7q/ZSXYWrlObmN4kWG5CFpkeFLGJL BloJF+qTcyJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZowLhAAKCRAADmhBGVaC FWd2D/4nrrrq9qnRRkHaEtLBNuSn/vN9DMXD7XETJ5F+WVPpSdvHtM7RvXEvUR188K+EDnmqFa7 o7+7pTjzyn+uIzpSE0j9ZEBO482oLUFDAgItrDGhJeXZUfEQHKYdukxSKgarTD5nYbYC/i4TjDM RXka9WXpUFUIsCqd98h1XZ+S5W3AT88rUp/jv1LD0P+yF/Lp3FGcORSuAF95AU1GrjLSoKL2X5q mBf4nBLDpSmvRAdTGSSScut5LJdrMYO9jg6gJf8Cb4Mc3bDRPGo+oGd2nL1kTG+WyrErLM3IfqR 9H7jH8QQqXyvoso0FNo8KN3SCsgwXxMLq0qEv1iWFONDAyMYbmy5udOw6BEzIGBaYGMvPg9G1I7 nRUJUZPDWBdr7unHL2np3W4PFAT/l2nh7cZkxSkTk8z0pIQVG6udI1wTxdGpuC/zptSfzJpWzXB fRwotHXbhtA5mXZhu3gwUW8jNFYAy389DNBbYcPp66G2Mff8KECeoEJz0lRK5nzAaV43OCaOqPQ 2YuwPX57BH6wGkn+gvPZ0Fa6/0wMNEaZsZqNsf11YevvL/5srjIMlSr/luKwInTOD9YjtkP1HZR K08XctFRkt5sYW9WLrcZufyxUtPXnoe86WEOj3V8UMjB/HtQg4qUvpljpL1fhq+HiBfjzwrJ7ve tRYcHqYUd5VvbRA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 2FD7440015 X-Stat-Signature: k41bwog316x6d9dsi98zhrprf9t18gqw X-Rspam-User: X-HE-Tag: 1720454046-56688 X-HE-Meta: U2FsdGVkX1+byjKQhfux0P8JiOfoNsAPn0m1lUBoELNyIBCyp+tIG62ksp+H70QYW+8v6ScTzl2oZtVQE6WR5nbyD403eav4NP2eOmzrnA88hDJhfinIANPP6pQKDINZXHZbbUxqYkYbCSQMFbObF//7XqKTnzbZ2Hzg9pJmexEETZ8mBtMT/GkBEZZlhff5c/z89KqTTkHRmwyfxNmWp3PiGeFVjjmyK3nUYGO132pGE7tIZ0T3/45j7ng1tQoTr9D/otUFbAwUy0cHHuVhVa5C0VQQnwmnogCeNMe0UIvb45R0s+FJoZDcJu2KeWpRrFkiYNaNloAKfg5AfimErn0tLvMQg4zEqupOhESErlSI2pM2Ia626kUlLf4eEz9tqko2tM7oxId+U04y2c+Wj4i20YzFF+0XDW6Ifgl1BgWM8spzDS9FMuZoU70U9viaMs8Zs9QD8jVwLH/i+BC888uPMWvS2UwvH8YoyGZRBQD93Ov3h7IBUywe9CV6zhCCQ7sV9xPKhm6cFt71JrJoiG3rqggYg4rx+1QnlWrnTEjwl02gRUx1BBLB1MyJypdUT+9vmRtMgvPKVa+XdAcHc/Hb5xh7ZA48zm0yXTmsmxAgSs5bCTTRV4/rabeH5vWLxuzTrA+ZZl6e+Vnp8cYDlY2aZ2eCzH6nFAy9U+n+tyHnDowW6S/1EJtgjx5nGbP/l0zq38oTpSUQLbHHkapE51iV3ugtmpbgvJgSYsbhjMieWFRUHJHyzoTCgePzC1VE+r5ynF8CgusswAkt5KBm7Qv1s+L5zfR/yAvyRH6kLmzT5QdpS4TLmfQN+MNpV5WrR95wgyPLGSSqVKRJKfG5SeaNfizix/1pyWzvH9pby2h3ydWE+7eQYGkF6B5rliLcTeNkHbqrJT/RKIa1HF+72+HR05msc5Y4l+pR/pQLJTlbxpih/bLVbj3P+gnk2WqQ1dAMCTyqDs4wYDWH8UG dYUj7bLX 8mhebwqcD36veYR38zf3Hqtr3iMGxsW8rpPZZcSgdVZ1QouF/8Zvwe5apY9/S63G751EmCH2wVlLrASASfbjaHaBsXYn2eXfPxQpLPJ5i/ESNoeMTf60hYTOa9qLGcjOby0u7Q49/Hth0Q+JaSXR3wpIwKBBKjfG5TEi5YJV4JlPYu3jy1wOiKCvOxr7dYYChzFfYEbow8qQQZRiwWM+HRbTWg7DnxkBZUtQ850ggnqFdbRYFfo8C23sUMOWkdqzR4MV7GqGz433CyMfILu5r+TlCH39qFkET5/Ph7VJIJNTu20sxL4jUshHzVdtWJkF3pxUm9e+4UPWCUuX1ZOvIpgMJlP+KAWIae1Y7JwDIgs8E1Qw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. For ext4, we only need to enable the FS_MGTIME flag. Signed-off-by: Jeff Layton --- fs/ext4/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 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 8 15:53:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13726777 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 9355DC3271E for ; Mon, 8 Jul 2024 15:54:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1A1976B00A1; Mon, 8 Jul 2024 11:54:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 100D86B00A4; Mon, 8 Jul 2024 11:54:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E47606B00A3; Mon, 8 Jul 2024 11:54:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BBC7D6B00A0 for ; Mon, 8 Jul 2024 11:54:09 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 74D4E1413BC for ; Mon, 8 Jul 2024 15:54:09 +0000 (UTC) X-FDA: 82317031818.23.D6FC1E9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id AA6A9C0019 for ; Mon, 8 Jul 2024 15:54:07 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GB5rZu5h; spf=pass (imf28.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=1720454024; 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=5vMS/3B7M9AXRjhPTEbSrlkhwACcn/9XxJJqb8Ng0DE=; b=5ZpchYqKvsUoFymfFitdoS3v4pGePp9SjDFQrPl3wsjzr2kGuapEvZeIYYc9HkQ6aaOKv1 P6hvNct8pGOvqwtZIiPL+T1wW4yQtfqocaeHdCYpGqx+BCiSvLxxLqu/x9PqYfbrX+vzRf 3xhsro4Cb0/SsYWrun3thVdVLeyQG9I= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GB5rZu5h; spf=pass (imf28.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=1720454024; a=rsa-sha256; cv=none; b=N0EYlbpMrAtW7AM4ooLqSzQ1/DKD0j9XPTNrDtOZOforKGIeLo2Yo+JZ9eSLCQ0c7NF15C pCc/mGBVOpykRQLCRhqi3ymcn5H748282+CXY0ncmwFB/LRjyNnjl5yygGMeSZMB+LQKA5 ppa05t6YfgBru8zivP4ohIQj7PLnp7U= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DA19B60F37; Mon, 8 Jul 2024 15:54:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC349C32786; Mon, 8 Jul 2024 15:54:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720454046; bh=xTk9IFiZeoZdqPbR7bcsVc6tPLRLkOIJYDVl81q/MME=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GB5rZu5hMI15U2ylbFQqX0YhfA8/WrZ8rZu496zGgZ1UwskaiAWieirmiSY0606Ko urLNop+Q2sDgfXPdUj3B4pokqaMGp2zG/BgyDqswpThDrMg6TR8F0s3XyzG4Rhrnxt gj9l8puIj8+p5UQXYSaVy3m/FS0pW4uRf1cbPf0WM/228SQ9GMeCXMXbtNKQHaEB3S p5m166bxxxSjGzzp9F8ptC7hSXR0mn+kMh8kngD7wDi+o2q3CeM4hcV4onWPTe6Ir7 +od04Ic0bl594sgUqHvEifuuUvN4eu7LTD09AUXSBdxyTNOYX6vZpAN5stpmnakOO4 d0nsnczxdXYvg== From: Jeff Layton Date: Mon, 08 Jul 2024 11:53:41 -0400 Subject: [PATCH v4 8/9] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240708-mgtime-v4-8-a0f3c6fb57f3@kernel.org> References: <20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org> In-Reply-To: <20240708-mgtime-v4-0-a0f3c6fb57f3@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 , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2583; i=jlayton@kernel.org; h=from:subject:message-id; bh=xTk9IFiZeoZdqPbR7bcsVc6tPLRLkOIJYDVl81q/MME=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmjAuE92mfSh6NfDlCWQlKkv2+4U1n3snVlNA2V SIuSR9NXhSJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZowLhAAKCRAADmhBGVaC FYEqD/92ncQwLqYy4hgPbZpX9lkjOfRdvTeYjwgy6RHJ5WXvt9CL15LHhKRu9iCWGuT55UOEBDX BxpZp2takntEWAPpNyLuEe2UKXwe8XL2b8LCGEa0Av4jG2uxZoAdY3Puhf4NH+hTXMPPDxKlPb1 tOcJh/u1gTH+mrkLnSFyfEl4vNmLJ6Fs1yyJVTuRTraPqrLHlv1hmP0SVMu6YFCOE3VL94akxSK 84eEUH9VmtvOH/9SHnwfo2RehVlOZaaubcI9f2Yz5x5u3rBbgT9kpvoTD4MzCUx2Hcgtkd+MTAU 125popAe3xibLBc+r5YOn3MqbW2lS2Qr8TLoQq4LCuWOjeQjuSOSaBjmV7ti/snS8YoMuKPTsaO ZSgOq0MJfDIR409jaE5qswYGInM0lkM3BYy+S84yt5BfpE72bMj4IVud/q2ght+ZFnKepMaoJUb yDdKcmHieDoWAlojT+oEXOPecqzo4qXkZkTBl4HVQw0eKS0IMml38kJib/k2e2lxWJN5plXChKb 0UFQrExJjjC2LAa738FQtlDlESCaVfvPXjPV/jtlFCJavsLPD6ys+/WfdgN1Qreo+w3pwtrxDwv 9PcKml3SHYHCNXt1t9AcqlopfNjRHzLQRKk9MWxU8U3cy+KzH1MbnT/OXQB9Bai0hjLcsRKIBIA HwEogG0gM1mAx2A== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: grhbierudkp19xr5749zoxejy7tk7fub X-Rspam-User: X-Rspamd-Queue-Id: AA6A9C0019 X-Rspamd-Server: rspam02 X-HE-Tag: 1720454047-141040 X-HE-Meta: U2FsdGVkX1+kE+LVvhnc+TS2tPqSBVNobby70QrHXWiRjRwTB6+Bv2jtbRUROrFdREwpM87xyaPH2RkW1OeQwQcHLB7vV3cbeQpnZus3yZ5Ih58YyTumso4BxQKd01q+Nkmm1dehQTnCL1KNQlfgTkrRtu4buQxMQzhwImKs6ybpYn6CzskTq+zwE8MIPGxTboUouDpFqOlrGk0FmeM8PG5X3fJmIEVkSbe3H+Y3XZ/PLHRnFqFITMV4zCI/DimJN558VoxH74iY+D+0b2+2JLgr+rrBeBTwJAAs938DTVBz+Wrg07lGtKmKohZqKr90IqLOkTigRgCiZJnTqfEYxH5XJzwM26rfouqU5PK966/bEtnQFzYuWFRv47ZCm2DwcClyRk62/dlhnQklrHoilT2ed6fwoe3l35SfzBSG/p6XH3R1KViHwA/ruo4Qy3lQ03Oql3KoxYpMfwZs178H4aADT4kaj5EWjCnCitDviOpmP/wy95FksP2yoag7mVi+fdyr48TCQeeP7kCgZTEUFHqdq5NfStYh1eifkwg6oyzko+414bXdbHNX6q4vKB+TZFuCxgtEHzrD28YOaynX7nE+rhqdAML9db52ZzJBxSAWNSP1v8+WEWnpMy0Lj713ofHJicvA+WP+yt22hEkKBd4ZarbNC7/U+4qF4DFo3szB+z1PGMp1noCwzVs5DajAukmma9mSQhQFawtR+yKyj3oPqysX7ZaTDlf3fEP8fyy2IIZjp0Cu1TakqfgqIu2hzefG6MWKom8Bhx6dyr9mc9fa6+eH3dyVxbG/a/Yz1hn9IqdA7PeeTh3W/UGJlhQ+92vH+fCagZoLagHam7kNiIMjc3jUEJSW6WsmTCT+v6XyG4gWXXCsORF/qhrYnugG+dTXFKP3aIA3/KczFuIXbNfnTua1NHzrDCIBViVMpwIs+G5df4bLy8GYi+hqaqujiGsFwNqIZHDHrFCZAqN fj5bSky1 Nc933lQvUMuO480V2s++0zsHKT3COMb23m5HmeQcmGNyaFZVrSD3phT78yX2LpChSWu317hfZpOpXRtqKrzwSXk5HsYgHBFLqVSQnbbZ9Aa7eZNqpX9e8brhchvqv94Kuu9pMRG03ji7j2g8JmLAHve51LhFXuN5jpBX2viw3TwovAqkp+T4lusJqv3ssZuC//rTHlVkOvQxA7eINIKuB9pouv/Pk3B1Azcc1fLla4qJK4vLqz2+uPck9Wk2nDhuwVo/QNMKOSluhN7a1+Owukzib2dRCzdOfBsSogiH178vESWEFSzsN831avaRVPl4pmBtC90h4vONwte0Cfqz4AqdNeG0+JDwcI7Eu/8K2v5F5PsE= 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. 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 8 15:53:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13726779 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 AF81BC3271E for ; Mon, 8 Jul 2024 15:54:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EBDD6B00A4; Mon, 8 Jul 2024 11:54:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 176736B00A5; Mon, 8 Jul 2024 11:54:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6D3F6B00A6; Mon, 8 Jul 2024 11:54:15 -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 C219B6B00A4 for ; Mon, 8 Jul 2024 11:54:15 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 79142C12BD for ; Mon, 8 Jul 2024 15:54:15 +0000 (UTC) X-FDA: 82317032070.30.E51B755 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf15.hostedemail.com (Postfix) with ESMTP id 06D64A0011 for ; Mon, 8 Jul 2024 15:54:12 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="UKGmbJG/"; spf=pass (imf15.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=1720454038; 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=PNGkN9dLVo+0nGPIxzzuphPsGytnlYGvMkhwTj5uE18=; b=OfI7dUM+sbQuxBSV5zGbYAcadCIr6PiW3WJUiCGTcmXXXrJpqozqBbsaGSbvwhhyD31yZE oKvZeraxrAurgr+ZJUOlkeWss4QYSsMN5TF4QgxXYjEerKjhCKVuhyzWd4ZNt4Ge3El9xq r7Zwrl5/36Wxrm9XOLT7noq2ok1o5Pk= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="UKGmbJG/"; spf=pass (imf15.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=1720454038; a=rsa-sha256; cv=none; b=4+D65TGcNOLtKSNbkM5uL8Y84KCr1jRwZNrtpz42JHRj3dhK+YWfGQQnH/Ueso6XmUoHE9 hURN5nFJLwmAgdTEcQiQAMJR49I/zBhRBxGM25flRjzCDiYf+d0DItHfzMaX8mSl8jQwCD ybIaTzGgA+l4ciWYjPQ+JTr7SlGHZ/0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 2D249CE0E54; Mon, 8 Jul 2024 15:54:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB567C116B1; Mon, 8 Jul 2024 15:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720454049; bh=pHEQop1T1fiyamd9jcpDhT/4UZTaEZSdDGTRt6fHlCQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UKGmbJG/7ixB3W/bGJpEZHxm4Uec9QfxZrgFj7++PEuKgl87p3bp8kWMv6leWLkSL SVE0ZwRWnyuoBKzcBAsY3hxdEa0X62Miv77RfoVOdaXSkuwwXlhguWYSVRCWyNSR8w UqoXJK6nxT/+k+DVz/Gl3FaKt6L25Cz9EQCL5H/2V/kCaXMFeFETwv0moyo4jhoEX4 t/GJxOCYUspDoZ2uG4F5c2jWw9oAwJGe+MWpZhRyY2YBRCjpOE3bHMVzXy3RGvcUua XA3VRpPMWHL8cD2MZY1fzsiDd6vNFGncezD7lV3qig4l7B5Ga6JVX4VgJuYhxQ3ZER Zj6EIUg8C99vQ== From: Jeff Layton Date: Mon, 08 Jul 2024 11:53:42 -0400 Subject: [PATCH v4 9/9] tmpfs: add support for multigrain timestamps MIME-Version: 1.0 Message-Id: <20240708-mgtime-v4-9-a0f3c6fb57f3@kernel.org> References: <20240708-mgtime-v4-0-a0f3c6fb57f3@kernel.org> In-Reply-To: <20240708-mgtime-v4-0-a0f3c6fb57f3@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 , kernel-team@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-doc@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=775; i=jlayton@kernel.org; h=from:subject:message-id; bh=pHEQop1T1fiyamd9jcpDhT/4UZTaEZSdDGTRt6fHlCQ=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmjAuElSf4XFk52fOEHI6qnk5nkcaimuSsPCsyx xjkO5P9aUmJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZowLhAAKCRAADmhBGVaC FesvEADXYZRR3EQySwlhPXaMFRM3Jq6pfSUAjqchFJ5ZK46/YfRIrrnfJ4JbxYnbmshpJcBbFpR 0/5Av6Pr9UhcqUkFzuoN+lTegRgHwDiMg9lrS8JZ+RlrxJ/mI1jSkec7pdJeCA1o+uEspCwJlVV l2Cm9Wm5OJidm0vx4cGXlLZzmA4IHAdkNfWh2OXgnzFFtS0l40kW+3PF0/WGTPKccPdHhD862y6 aGl4SZcQo2KyHwKsueuBZ4tdmXuTa0JkEAbMT4bH3FxqToAIDJA4U0MF44gKItQuNoJ2ZaL2Q80 a3i190J0Loaigui6n9Cpypmy9nDd74qzubrfpMJbIqFWEwRZmDlHfRnv7nbY871QEYQ4xpJ3ili ceNhjnXNEO+drx5Re8ocxYDKT6KguzKI/aKc2WahemLhWKP7yaspe4q9VcpmjmlwAgf5tUCteyd vL0qw+tr6LTcIURjivpx/9GIxekvsxkhqUC8fzHzoPesyDiTUDc40q83qFeo7qhD1gSz4BEHkE9 0xREDDycM33VqUVh2mPB/yAqqTCv4QDPuSl6S7UbBkaTsKVuI4Ib3fx3f0H3D85+gcTUpsfJwua sVJEZzud7NP7tgknaFzBM7ymq8J2fUaKNM/KfI0Xna2HmKe/3idcid7UzQ8mWcD7n4ta6cF7NGN kEUJE/n2ZdSh2Sg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 06D64A0011 X-Stat-Signature: aah1q3w4tmhxbjxw7s3qscpc81uxmxum X-Rspam-User: X-HE-Tag: 1720454052-639023 X-HE-Meta: U2FsdGVkX18lF74GVcAYOS6K0jxgx3qH/Rd0qgV+eOSAnyJ5yDomF6F2Tk52m0aoRyF93MVjRIQv21tOTK5HtglSZUQbXn9eaPhWPLppQYeupKlrGq0rbrEbQR/H08+/NZGUZosv6pMevzuQdkY8DXKWXEvf1A37ocSYSAgquvR00AI8gkf+GVvs5lX/Ojhq1gNtCIkkip8E4eS0d3BygvPaUeYQNuI7/nw2ft0XgT15CTUgQlhoiUqOw0cD3JFZ0oPGB8z+IQ21vxn5nf56lS9fgBblnzGeRibWGThERaVBHhWNVGb4Bz+oiIMD0t6PCPomFL4BbcS6jk6W6Rxy2iCKQO9w3o228cvVpE1krL+sBP3MUPAkNfkHZ7oGquQik90K0N4zjT543m7FGFkv9iyXGr0hcWAIHi2KOyTV1f4pm+oyB0RyVY9fzBCQflel4Wi3rP3OUo5XJJYOXIegI4bekh02YTGL5Xf6vQ9t88g2vcSVo2EwIWvPpvixWE+qPaw9RS5gCCa6O7E+Llw3J9I1b0AtZtOVeH7jWJpbQWm8Ft7Dwwu6Om9CGqXOQaQJzOKKkWM38a2Vs1K3BZrXS8944x8qribRZHVI6uGc4A5nGCggK+62Ok/aqc2wVpdYNGWJ6AeRTBRDN3bAe/UUXqQl0YliOtIVYW6EXyhCCbZXJpvHh4KeTEQKj80bc7WRvr+Y/XvpR4JAVL8sDR9icqUGPAkrLnx3X7rlsIbz7MWXjXQmtNl89fLvh2S0uoDqHh+ShhzMUjZE5jouXBHFQnhNg1QFAog0kOEefK8Own2A44b5eTsX+2JomVKGeWhOEkQr4Z3Y6P6cGS4btNCAg40u2I4Ibij12aLDHH0Ig/e6UEASw/CAz8ZolJfC/wEOhg2ffpYCJxq5rkkZkBb/twcINlWN3VjmTJJi0fJUKHkiJWzBaX0Dd8i/IglWsESVXeQ9n5puvlpstg5AMPa zGj9PMkB Fq5ShkgeFkqSJHKWf1xpmzy/I53t0eCEJbmLfrMK+/7Ygv6GmYtNE27ezZyf+B9SYfd6r28xP3NvoQiTSWoQbLbC9GKOv3gmuQ1MqQ1yFCn6fZmCu6XJSy3erDkPScGX8PktMay7fTahFxz4A4y/9c1qAhFZJmOb/oLp2uaYmrHXXeV0y2SRtlOvcZkpkZRX0BM27tKrZgYaxI66SadrYFtvf8VCTt79IlyfSz1tLHaCq5/nqiFZXzTbaaSqmkseH3SWSy0sx7bsgT/TXBDNYaHG884Y2dTJE54LxSYMUs+xTe97/aXFztshEVjuruk79Eu7FztxgRUjZFxQwujetQ/RRyHklEUGIIpyCAOQ6lwIfLqY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. tmpfs only requires the FS_MGTIME flag. Signed-off-by: Jeff Layton --- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 440e2a9d8726..6dc817064140 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4649,7 +4649,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)