From patchwork Thu Jul 11 11:08:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13730386 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 6DFF3C3DA4A for ; Thu, 11 Jul 2024 11:08:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C557F6B008C; Thu, 11 Jul 2024 07:08:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B8D306B0093; Thu, 11 Jul 2024 07:08:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 98F5A6B0092; Thu, 11 Jul 2024 07:08:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 741816B0089 for ; Thu, 11 Jul 2024 07:08:34 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 270B5120545 for ; Thu, 11 Jul 2024 11:08:34 +0000 (UTC) X-FDA: 82327198548.08.68ED932 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf27.hostedemail.com (Postfix) with ESMTP id B2B7640003 for ; Thu, 11 Jul 2024 11:08:31 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="VUBwPH/V"; spf=pass (imf27.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=1720696096; 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=UjAyV7RhwDaXCCoJs3dWHsOJCddwgyxl5wMpKyH676A=; b=0r1tkrBJ0rhgU02GqveYGaFyXoK8GaKY8eN2uqyEA/+SPN+2Q50KKOSwS/D08VIrIEulkZ 0W0ENNVCkAtwtAyiM8uXGqZOj4neKsLhWKcuPTzmoPNK+g4NqJu133RljpYX3D6b1fA/Nf fXG6kn8E3NNcKTnMQ42weCtKE49HbqM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="VUBwPH/V"; spf=pass (imf27.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=1720696096; a=rsa-sha256; cv=none; b=z7koXYqujIVhj342EW6xVXnzrFL58bc3wC0cuD27fWo1KI9SDTZmkpJJ/kylf03TgM/U/+ JdqH4Io5MHGQDe82wIiouoH9fPMO9CD+59QeykNJOuphf2Dl6oIFLXHQnAUH2iubEEthpz NKtgBbZOSZFfRf9vk6COZHlpo06xUPg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id ABF4CCE18AE; Thu, 11 Jul 2024 11:08:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08DAFC4AF0D; Thu, 11 Jul 2024 11:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720696107; bh=IxBI5x78cxV+TlUA9TXEi+rPKuXyv5wGl1bxdbx3V9Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VUBwPH/VC+0W+NWeJnYLSaqtZm3MOeNdGRJClNTEfpflrKoiGVMEY4sxW5ZtJ4T6Q ZP+n1zDk7wlSdhlgKHZReJGnlZhHelPoB9wf1tfb8Qh7SAbQ21tpD2lxjjaF5DxIma n6EqI75EoSQgKfBtTLXuGaWtaRFWdshpjskE5TXmw2s6OQ6zN0wZCuO5FaBdiuFg/5 pSd4Hw/1/MRzVPHYLCQ4J15YkxFS3jMLcqNQsrcoOSl6bzpCYyJoqdiVhxLTiqjA9E wIWLs1BW/jS8va5aMBOrTPzIV5XoVFTF1xuh9JJAbb8GeuyHorVJd+OB2BUhlSXJww oeBIGxI2rCldQ== From: Jeff Layton Date: Thu, 11 Jul 2024 07:08:05 -0400 Subject: [PATCH v5 1/9] fs: add infrastructure for multigrain timestamps MIME-Version: 1.0 Message-Id: <20240711-mgtime-v5-1-37bb5b465feb@kernel.org> References: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> In-Reply-To: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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=15228; i=jlayton@kernel.org; h=from:subject:message-id; bh=IxBI5x78cxV+TlUA9TXEi+rPKuXyv5wGl1bxdbx3V9Q=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmj70kb6ejazT61So4QBLkPJwXd+zBh5L6+1bhV F6m1VqHiX6JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZo+9JAAKCRAADmhBGVaC FY9YEACNQeF2qsweCizgVPk1zHMSP3qpEz+Ctu2PfuTZWlae42CfJIpJXteIFmB/V2GT6bK3KDT lf3h46fLEaLOmVAtLNOjJq8vgFOTYkjlq2G9wQoAgWzsKv94PLSGOct+UTK0sydH5O8aMq+cLy3 ZY7oEaeAw+iYAxN7A29s3MlV5iNhonXg7TeixvIyeWfW1gBODBrZYb7IszpHDB1uC3gJUJvG53i TxEa1sSxavCw7wiU9wY3771gaaigWThV/bLcCycOObU80/IUw5uCJlKp2FOcaxOnQkhi0Pg/CXe brY9Q2rC/Q6XJGeG/6yR7qpzIUrjhaT6UXTveTXUsSxUZfDyl0vy6J9kq/x7lq3we2tc4xn3iaw DNjIbB7/s671fuP4LAmD5arKIQ7ISo9WogViLnGi+IA8P1Nm1T5Mj7BXkJy/D3OUI5Xe6XVEquJ TsUIBMwVnCdvzUJj1/5MfxYOEUPpzlPuK8JIVBY5yXKbhA8sRvEdoe/GOcTlLYPkiUWuccIQw09 m3pEZcCa36FzNL90zyFOGwCyAWM79xk8RngeWIJktbXjMOanN+n9sZlTJbh98rykHHWgnMQcSQ4 9jyu6fcS24Lk3XSyi+qX92afuQ80r3MA6rkPEG66gkuZvEdlfNp3G6Jrh6bNGzqUTSP2QsIRnW7 b0Iv+QdDzBmmoOw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: B2B7640003 X-Stat-Signature: o8xuxeybbf5hssykezepftbisgf3zkey X-HE-Tag: 1720696111-322526 X-HE-Meta: U2FsdGVkX19TQ8aF27e549I8HOhwIubOC7f0m2ujtpPulPCQM74OxgljBGB73QZerjDNSh3mM2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ajCMWIAQPn3PjOs/SjWSd+bmq+fW/cFr0ipbdsR/R1OKWg/Ak8mEcqWGBJXXaGUGMGttb4clZOnbQ1qckOsphUUYJ8GoZm5iMIp/2yAOTKZARo4iq141UBEz+KBR5royH4WGZeHYo5EVMvWcsrXojW1TCn57P6or1yqBuAttpHyu4Mnrqtnbwo0= 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 Reviewed-by: Darrick J. Wong --- 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..2b5889ff7b36 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -60,6 +60,13 @@ static unsigned int i_hash_shift __ro_after_init; static struct hlist_head *inode_hashtable __ro_after_init; static __cacheline_aligned_in_smp DEFINE_SPINLOCK(inode_hash_lock); +/* + * This represents the latest fine-grained time that we have handed out as a + * timestamp on the system. Tracked as a monotonic value, and converted to the + * realtime clock on an as-needed basis. + */ +static __cacheline_aligned_in_smp atomic64_t ctime_floor; + /* * Empty aops. Can be used for the cases where the user does not * define any of the address_space operations. @@ -2127,19 +2134,72 @@ int file_remove_privs(struct file *file) } EXPORT_SYMBOL(file_remove_privs); +/** + * coarse_ctime - return the current coarse-grained time + * @floor: current (monotonic) ctime_floor value + * + * Get the coarse-grained time, and then determine whether to + * return it or the current floor value. Returns the later of the + * floor and coarse grained timestamps, converted to realtime + * clock value. + */ +static ktime_t coarse_ctime(ktime_t floor) +{ + ktime_t coarse = ktime_get_coarse(); + + /* If coarse time is already newer, return that */ + if (!ktime_after(floor, coarse)) + return ktime_get_coarse_real(); + return ktime_mono_to_real(floor); +} + +/** + * current_time - Return FS time (possibly fine-grained) + * @inode: inode. + * + * Return the current time truncated to the time granularity supported by + * the fs, as suitable for a ctime/mtime change. If the ctime is flagged + * as having been QUERIED, get a fine-grained timestamp. + */ +struct timespec64 current_time(struct inode *inode) +{ + ktime_t floor = atomic64_read(&ctime_floor); + ktime_t now = coarse_ctime(floor); + struct timespec64 now_ts = ktime_to_timespec64(now); + u32 cns; + + if (!is_mgtime(inode)) + goto out; + + /* If nothing has queried it, then coarse time is fine */ + cns = smp_load_acquire(&inode->i_ctime_nsec); + if (cns & I_CTIME_QUERIED) { + /* + * If there is no apparent change, then + * get a fine-grained timestamp. + */ + if (now_ts.tv_nsec == (cns & ~I_CTIME_QUERIED)) + ktime_get_real_ts64(&now_ts); + } +out: + return timestamp_truncate(now_ts, inode); +} +EXPORT_SYMBOL(current_time); + static int inode_needs_update_time(struct inode *inode) { + struct timespec64 now, ts; int sync_it = 0; - struct timespec64 now = current_time(inode); - struct timespec64 ts; /* First try to exhaust all avenues to not sync */ if (IS_NOCMTIME(inode)) return 0; + now = current_time(inode); + ts = inode_get_mtime(inode); if (!timespec64_equal(&ts, &now)) - sync_it = S_MTIME; + sync_it |= S_MTIME; ts = inode_get_ctime(inode); if (!timespec64_equal(&ts, &now)) @@ -2507,6 +2567,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 = atomic64_read(&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 = timestamp_truncate(ktime_to_timespec64(now), inode); + inode_set_ctime_to_ts(inode, now_ts); + goto out; + } + + /* + * We only need a fine-grained time if someone has queried it, + * and the current coarse grained time isn't later than what's + * already there. + */ + cns = smp_load_acquire(&inode->i_ctime_nsec); + if (cns & I_CTIME_QUERIED) { + ktime_t ctime = ktime_set(inode->i_ctime_sec, cns & ~I_CTIME_QUERIED); + + if (!ktime_after(now, ctime)) { + ktime_t old, fine; + + /* Get a fine-grained time */ + fine = ktime_get(); + + /* + * If the cmpxchg works, we take the new floor value. If + * not, then that means that someone else changed it after we + * fetched it but before we got here. That value is just + * as good, so keep it. + */ + old = floor; + if (!atomic64_try_cmpxchg(&ctime_floor, &old, fine)) + fine = old; + now = ktime_mono_to_real(fine); + } + } + now_ts = timestamp_truncate(ktime_to_timespec64(now), inode); + cur = cns; +retry: + /* Try to swap the nsec value into place. */ + if (try_cmpxchg(&inode->i_ctime_nsec, &cur, now_ts.tv_nsec)) { + /* If swap occurred, then we're (mostly) done */ + inode->i_ctime_sec = now_ts.tv_sec; + } else { + /* + * Was the change due to someone marking the old ctime QUERIED? + * If so then retry the swap. This can only happen once since + * the only way to clear I_CTIME_QUERIED is to stamp the inode + * with a new ctime. + */ + if (!(cns & I_CTIME_QUERIED) && (cns | I_CTIME_QUERIED) == cur) { + cns = cur; + goto retry; + } + /* Otherwise, keep the existing ctime */ + now_ts.tv_sec = inode->i_ctime_sec; + now_ts.tv_nsec = cur & ~I_CTIME_QUERIED; + } +out: + return now_ts; } EXPORT_SYMBOL(inode_set_ctime_current); diff --git a/fs/stat.c b/fs/stat.c index 6f65b3456cad..df7fdd3afed9 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -26,6 +26,32 @@ #include "internal.h" #include "mount.h" +/** + * fill_mg_cmtime - Fill in the mtime and ctime and flag ctime as QUERIED + * @stat: where to store the resulting values + * @request_mask: STATX_* values requested + * @inode: inode from which to grab the c/mtime + * + * Given @inode, grab the ctime and mtime out if it and store the result + * in @stat. When fetching the value, flag it as queried so the next write + * will ensure a distinct timestamp. + */ +void fill_mg_cmtime(struct kstat *stat, u32 request_mask, struct inode *inode) +{ + atomic_t *pcn = (atomic_t *)&inode->i_ctime_nsec; + + /* If neither time was requested, then don't report them */ + if (!(request_mask & (STATX_CTIME|STATX_MTIME))) { + stat->result_mask &= ~(STATX_CTIME|STATX_MTIME); + return; + } + + stat->mtime = inode_get_mtime(inode); + stat->ctime.tv_sec = inode->i_ctime_sec; + stat->ctime.tv_nsec = ((u32)atomic_fetch_or(I_CTIME_QUERIED, pcn)) & ~I_CTIME_QUERIED; +} +EXPORT_SYMBOL(fill_mg_cmtime); + /** * generic_fillattr - Fill in the basic attributes from the inode struct * @idmap: idmap of the mount the inode was found from @@ -58,8 +84,14 @@ void generic_fillattr(struct mnt_idmap *idmap, u32 request_mask, stat->rdev = inode->i_rdev; stat->size = i_size_read(inode); stat->atime = inode_get_atime(inode); - stat->mtime = inode_get_mtime(inode); - stat->ctime = inode_get_ctime(inode); + + if (is_mgtime(inode)) { + fill_mg_cmtime(stat, request_mask, inode); + } else { + stat->ctime = inode_get_ctime(inode); + stat->mtime = inode_get_mtime(inode); + } + stat->blksize = i_blocksize(inode); stat->blocks = inode->i_blocks; diff --git a/include/linux/fs.h b/include/linux/fs.h index dc9f9c4b2572..f873f6c58669 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1608,6 +1608,17 @@ static inline struct timespec64 inode_set_mtime(struct inode *inode, return inode_set_mtime_to_ts(inode, ts); } +/* + * Multigrain timestamps + * + * Conditionally use fine-grained ctime and mtime timestamps when there + * are users actively observing them via getattr. The primary use-case + * for this is NFS clients that use the ctime to distinguish between + * different states of the file, and that are often fooled by multiple + * operations that occur in the same coarse-grained timer tick. + */ +#define I_CTIME_QUERIED ((u32)BIT(31)) + static inline time64_t inode_get_ctime_sec(const struct inode *inode) { return inode->i_ctime_sec; @@ -1615,7 +1626,7 @@ static inline time64_t inode_get_ctime_sec(const struct inode *inode) static inline long inode_get_ctime_nsec(const struct inode *inode) { - return inode->i_ctime_nsec; + return inode->i_ctime_nsec & ~I_CTIME_QUERIED; } static inline struct timespec64 inode_get_ctime(const struct inode *inode) @@ -1626,13 +1637,7 @@ static inline struct timespec64 inode_get_ctime(const struct inode *inode) return ts; } -static inline struct timespec64 inode_set_ctime_to_ts(struct inode *inode, - struct timespec64 ts) -{ - inode->i_ctime_sec = ts.tv_sec; - inode->i_ctime_nsec = ts.tv_nsec; - return ts; -} +struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts); /** * inode_set_ctime - set the ctime in the inode @@ -2490,6 +2495,7 @@ struct file_system_type { #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ #define FS_DISALLOW_NOTIFY_PERM 16 /* Disable fanotify permission events */ #define FS_ALLOW_IDMAP 32 /* FS has been updated to handle vfs idmappings. */ +#define FS_MGTIME 64 /* FS uses multigrain timestamps */ #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ int (*init_fs_context)(struct fs_context *); const struct fs_parameter_spec *parameters; @@ -2513,6 +2519,17 @@ struct file_system_type { #define MODULE_ALIAS_FS(NAME) MODULE_ALIAS("fs-" NAME) +/** + * is_mgtime: is this inode using multigrain timestamps + * @inode: inode to test for multigrain timestamps + * + * Return true if the inode uses multigrain timestamps, false otherwise. + */ +static inline bool is_mgtime(const struct inode *inode) +{ + return inode->i_sb->s_type->fs_flags & FS_MGTIME; +} + extern struct dentry *mount_bdev(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, int (*fill_super)(struct super_block *, void *, int)); @@ -3252,6 +3269,7 @@ extern void page_put_link(void *); extern int page_symlink(struct inode *inode, const char *symname, int len); extern const struct inode_operations page_symlink_inode_operations; extern void kfree_link(void *); +void fill_mg_cmtime(struct kstat *stat, u32 request_mask, struct inode *inode); void generic_fillattr(struct mnt_idmap *, u32, struct inode *, struct kstat *); void generic_fill_statx_attr(struct inode *inode, struct kstat *stat); extern int vfs_getattr_nosec(const struct path *, struct kstat *, u32, unsigned int); From patchwork Thu Jul 11 11:08:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13730387 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 61DF3C3DA4B for ; Thu, 11 Jul 2024 11:08:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01D936B0089; Thu, 11 Jul 2024 07:08:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA1906B0092; Thu, 11 Jul 2024 07:08:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4FD46B008A; Thu, 11 Jul 2024 07:08:34 -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 833FC6B008A for ; Thu, 11 Jul 2024 07:08:34 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3F1771A052C for ; Thu, 11 Jul 2024 11:08:34 +0000 (UTC) X-FDA: 82327198548.24.67E0393 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 64A1780005 for ; Thu, 11 Jul 2024 11:08:32 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CLLmbufx; spf=pass (imf02.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=1720696080; 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=WVBLt75swVv5iMyyNNvSkcEY0JqTDn74BYiJHjE/vc8=; b=4O1zYDQri1frmGcx1caUX8JOtFrDJYYcX2cMc2WbavbeGmPRJLmwDNAYGuOEw2dQ5AE+Qq Rbh9fK47CuGsQpYKUxpqYCF06EZYdpTeznScCf+OlzmerdSwJSiRg0LGWi0OX64uLZw41j mHQ4crQSYzcUJcCJrbcW9orZzLHnk+c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720696080; a=rsa-sha256; cv=none; b=f0MTT2OaF2GcY7DMpogMkThb1TUbb6P1ROFkcFR5a/OecLy6VEd30p2mhNwS3JGfFpPZrG 1adNY7mnyu8vxR7iTjbzUW51TGyu8RznxbnMOoCQHGPCC7ZjgmsswBkiAIs5b8qokQc+/b MnZO4S+hhAh0GmP1gxvT3ElagFPDbuc= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=CLLmbufx; spf=pass (imf02.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 4357A61D0D; Thu, 11 Jul 2024 11:08:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28D80C4AF07; Thu, 11 Jul 2024 11:08:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720696111; bh=rFzpgz1HqOKOCLh7b0SiDnaZS+NN3RBwFhHtuP1qUx4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CLLmbufxrMwqRIxsj3EShlbrXkeTe6QolAUV6OjeFmXNDxMrS8FgaZD5fet1zUGYK EuTAGivoIefR/QittNO1F0NVIxe/dS51KBHibbHueFnUadb5ve6vJiRuNL2BMH5unO bLpDY+VzZFC8jCXRma6W6JQ8FpSb3gi5uf6XgsV7RdM829lo6SghJDd4296X49b5Gp LRQ2TDjlvJBkDsNpa9lfKHTLunLNPiPQi9eaelK17ZwAOtk9XL3AgFLnOraT72P6Z8 eL1ItkUDt2fNUTMY8+d2jrdYOaOqk9huYtOczCijmsagZL4hsS518H2PdT4GMoXDYL GB+1wxSKonsRA== From: Jeff Layton Date: Thu, 11 Jul 2024 07:08:06 -0400 Subject: [PATCH v5 2/9] fs: tracepoints around multigrain timestamp events MIME-Version: 1.0 Message-Id: <20240711-mgtime-v5-2-37bb5b465feb@kernel.org> References: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> In-Reply-To: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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=rFzpgz1HqOKOCLh7b0SiDnaZS+NN3RBwFhHtuP1qUx4=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmj70kIZqRBAr9twF69KZlGMkMn1TAN28mNNhTf ngIzrb7jvWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZo+9JAAKCRAADmhBGVaC FX5SD/9yMgo83hVnTouqwh7Wudzs0Jud5XixMFsw35LiO08WfJQztDhsi7MJ6lxuIejoTHfuqus zAkkVjU1NHU1aPGZM1LaW8NY+PM5Vm0rg1H3Tp8LWaxM4u/kapfjM0f6xep+yI75SHRBm2T00Yu I0nrE8Ymxm8IwMju/5dPeqZG4gWibKcorgyLgv4TAmwfmidRhjYRIALqhKMAN+Zc2OCBLG48VMS foedmx1f1jk/Kv5n9NDlIFT6BNGhZrGahDsqXM5UaTVTksmsnXUL/o/neOWINHggU6rvsjS72SL ygap7ep9ZUCBW7Lh8t3Zm/htJpqnwBw6c7NvDCjFa4JBYo4v+6Jqbxkgy1qO/A7rCLhmnfQE2sv /SnXaHKUznyFIl0sOa4xvOln1B14jAlfpxmcUE/e3NWkb6Bzb+TxMujcTXnuVFUrepr/WsCnsU7 gzVw9Q/HcugitbGMkQgmeWtGtGfYHKUmf+LPetEcK8lPO95Gq5Bk5KRgVfoPTN5hX9vX8vVq36J TFbun/sDhI9A7eWtnr7ZkYbo9D71S6Iq+FQGQf3WeWlWqx77ThDn/39obkMI2vV/2/95kFnM+hw G1nCZSOkBoc/K5bQqsbxktIJueJou5XmijV4ZvXD0O4dC9kciGPM5YYI3NrMs3YdqjZwhI9KyRG 9mD08b4tXRCD0fg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 64A1780005 X-Stat-Signature: ik3ein6r4685fexpkpf7i6ce111kfawz X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1720696112-526216 X-HE-Meta: U2FsdGVkX18LUbnzgA0KgAqLHVDl/T7MDUpOF2P4ZETWru363yu8N6QB2J3pkVwoTrZOTYZ3KeNxKJieJEohhgt6rj0zyLn/2lnu/v9TYf2HHLsFliWzWOl1GNeNNjHHuhkS9BFi+yjQiWbGrWCl+FPJadVVxhzoGt9Wk5iA99QCAsYlf4ljldYXKZfsJckN+us9gOu77yk5eEZDRq7+UxBZgl+mLM4/7dH/nB8m2bbhilFgC73OE0ncPuUxy9OakRaPAkWqOjR3qM7VESRXjheb+AHMgOH8iUUJHyrMoDK0qIwT6VefvZEpGmGOLpMREIFHu6BdY+5FMv62PiPa6d/eGgEKC3sCdrfZu9JpJRjDuq3A43K0MRa5bPZuXhdsg9vmQ8Udop8LpUfLE7gmdp7OlSd01UP9lQ1+Iq0uH0ovyQhfpdgbCHhP5unHTZ5X0QafejP/y8faM/CtV6wZkKyHa2eihUo61AFE2fAKveYejliAACJCDsx7DVR/H6b6wgc1ljdf5z/ZeWAuvoN9C9icWGWQOistcIQPSoVOdLcIA3M/UGgYHsmcaCpw4sbghXMvQa84DQbRKvBjEfl5vz5HbrQHnQ4XfH9k2T2nPW4gQhjx03cpIC+0BP/j4kBF8rCrF1CS7mRGmKTAW8bL04/yJRn9YKuSlGs3R1U17JikL9auEqQAdhH8TkAUKVRZEoM8v4gLZTUguey1V5Vi6KVR149TtAC6io7ioAc85tkf6WzNiqsSTM/s5PsR6TgFrhElAnjl22tacTNPYlemY5DVQez1kSxW4tl0KbiVblNUGkX+s0B8XujBwIwA6t6SFeuTx2rmSegbvaQpRmUGI7SvEkdJgYyL8K8FxIB/EAaRBMvG1QoYNOtbsEgeoUGePtOeoRJJTba4ow3INsPCSCQjczcxfq54zc9pgzz1J9mPoVPuT/vW5SnqwBGdgprXIhaaR0SVS8qM2RJ4ihE 9Hv1AdH7 4w+F2RaebQbhOTe6I6nhpoCogNVmnm8Zy0M40sKmm2yQcd7w19CmE0hBwcpJsausUKs0YNzlCPZYsYxjkXFi0AOfkOAtI2/o6UeInWi0obIok4dpCqZI1Tcd4LjD1ma7fV58ZekS9GN+PIN3jHkqcDZjoHiBpSXA4pk2WPb0K3icscZ9mIP2oVD+PO/X8Pg8JSNObnrHo5Dv4nmaRd6vT9AWkLL/m5QoMQS+lXZHu1EdV7EdbkfjrSIAs1+Zdn0GxM1RK 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 2b5889ff7b36..81b45e0a95a6 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 Thu Jul 11 11:08:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13730388 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 B926DC3DA4A for ; Thu, 11 Jul 2024 11:08:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 39E526B0093; Thu, 11 Jul 2024 07:08:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 350156B0095; Thu, 11 Jul 2024 07:08:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A0476B0096; Thu, 11 Jul 2024 07:08:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id ED09F6B0093 for ; Thu, 11 Jul 2024 07:08:39 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 673F8C0536 for ; Thu, 11 Jul 2024 11:08:39 +0000 (UTC) X-FDA: 82327198758.24.00A1503 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id 2AE6A40012 for ; Thu, 11 Jul 2024 11:08:36 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JNqlpCJQ; spf=pass (imf04.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=1720696085; 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=lO+vKeSv7uIVC2/ZKMhRQIH1J+OUbASrL8o+t3AQg7E=; b=zpi+QIXMHZHKTNJUYxOp6k4KGTEzjKi3R7vZalaYZM8twLebtMUzuaG7L+01TBaNmegY82 NbEBUFhdHyDTf/ySX9ImZ9KZcBf+4B+uzxPBvpBuVVrgoXt9eLSS2khmFrBO9TF3z/rYf7 2vAs4qt0Hi85WAUx0nl7HyvduiA9QC8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720696085; a=rsa-sha256; cv=none; b=HP6pg0dJjppKEOYegEGpa/17NAsFZC3SjgnCq6HabAkQySkyfK9vNTIRAAsN1yR5A+d+6y i/yqWjGu3O0ei0d7gtenYoQUo/hVvLVcwR8II6MVtSOd7eCEkrNxGWczGT5DnOdPoJt+kh 4BF/+eToO8g+Cew3gLQfA/UAnA4FS54= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JNqlpCJQ; spf=pass (imf04.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 4D48361D0F; Thu, 11 Jul 2024 11:08:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34BA0C32786; Thu, 11 Jul 2024 11:08:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720696114; bh=V0Y36Pam00rCiMQb26squSrDlnu7zkSekBYQGaNEp4g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JNqlpCJQnzaR4gPRF+/O7iGm2A36GRWO+KYPfgCzi+SSbIJ978sLXFTiY7DHW2bE+ eGFmiXzdEx7tdFvxZrS8DXqAwndXrA2C1o5/vvB9K8i68QH2Ewh29kC00nDEodVbE4 FGz+TV/F2NmCZueArvI+bsTRWDzQUzQvURwbYUXojZlDeJ4qb/uL2WLucfVPg8olqf 7s78U0dC7qDEidr4Hr1Xv4cO3CpxgpquMVzYVT1tTg9xPdewRFVqA7SLvfGnntJe5P rJDK7r5NSwVCzs4BrJ/5g8Wujp/7ggImfhB9jhhSY2N+Gxs07I1C/bCj5G5MBtTdAC 4mFINDf7SE5/w== From: Jeff Layton Date: Thu, 11 Jul 2024 07:08:07 -0400 Subject: [PATCH v5 3/9] fs: add percpu counters for significant multigrain timestamp events MIME-Version: 1.0 Message-Id: <20240711-mgtime-v5-3-37bb5b465feb@kernel.org> References: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> In-Reply-To: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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=3923; i=jlayton@kernel.org; h=from:subject:message-id; bh=V0Y36Pam00rCiMQb26squSrDlnu7zkSekBYQGaNEp4g=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmj70krkIlkGBeCvXUTXPhRsNRgPGJ/7YIxm4VL oKt1D2isCCJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZo+9JAAKCRAADmhBGVaC FW9aEACXcSFuqDDqkal+wDTNWITDuTTUB2w8mpenTaC/RQ3UZtBsS3UcX1Cx8QGaA/9P1j70Kpc b24dZI2nx8fs3w6Tdw+tosbB/bBOkwvgj6FdMTijoam8dSosicCguBmMSx5afItFNUeokv4BpZq fYTF7BCzFykIsuYa8XzhyDtFt5TpzJtbHjrFMhpCioS62H8q+jReo87cZThXZkAagQYFnFb7G2X yNacNVvoBPllyhx9PA0PdCv3+A5HDmtWKzFH/w+doHLJb3Umabh9NkkQNvf93F5jKFrpMD9jNxa odgFtZ7FVa08ZF5AoVNUUa7/TwwAYlsvMJt7eZsthrL2N5/zth9xDVzCJd1qVvgwrAjfKUzo2Co yKM5XS+ZmsTnpi1u6TesAh1lvQk+L3uX01nCXJEtyovW1FvVRTPBgFNvviObAKTj/cyd2ZHJno0 iaC79matLqywBRRBk7lkHD48raPWyTxIniS3Oo8dAzxF+sRZeMZFkMwgnuLXyJk/oghLI0NqlUf dXAA5OHTlY0zGAZWoVLrcnPu2NXMDt9074Qvn7BcbYsOs8KVGY9Wm3XyT+IX0c9FQX1O6bWT/J3 oTWjUmrPm+su1GqxnnelBFzr1W79r+m/y4xgRiiD9eJLqFBEx4O5EoSFC+o6wdeplizkl0ovYh/ /RbyRLwcUU9VYrw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 2AE6A40012 X-Stat-Signature: rj619nitnhgrdqu5aax1b9pnjddwumak X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1720696116-518939 X-HE-Meta: U2FsdGVkX1/d7Zf/J31adtlQ5zuzcqmuPYLzVCWUOtgNl43o/co/LZOUsjMlx2Msq5o8h2cjirJu9Xoh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fwTzbJaHTtK6TQFcio5ryLwMrXdwYLyrLR171lLWBs2cAxp/p3ALXCFazRBXFNy/4nfRJyaRKe3PYyk+DBGqKwXWIya2yR2htQ5f9UEWWR0eRNw105M6qUmxXjKaYZ5fJaHMD9Vh4TOsEz2lQ5Iu2kwegxzhmwdpAUFwjtbKw2UZgWVSyIdwCGWqKRlbGtf2Ke3/Gn5DEkD3Rh9nf/U5MusIR3E9OzJyGQw== 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 81b45e0a95a6..011148c82901 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 atomic64_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 (!atomic64_try_cmpxchg(&ctime_floor, &old, fine)) + if (atomic64_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 = timestamp_truncate(ktime_to_timespec64(now), inode); 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 Thu Jul 11 11:08:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13730389 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 7A598C3DA41 for ; Thu, 11 Jul 2024 11:08:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 461C86B0095; Thu, 11 Jul 2024 07:08:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 413FF6B0096; Thu, 11 Jul 2024 07:08:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23E0F6B0098; Thu, 11 Jul 2024 07:08:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id F3F4F6B0095 for ; Thu, 11 Jul 2024 07:08:40 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A2B3B80453 for ; Thu, 11 Jul 2024 11:08:40 +0000 (UTC) X-FDA: 82327198800.09.6E62C57 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id D348B14002E for ; Thu, 11 Jul 2024 11:08:38 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aM6rnkQn; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720696094; a=rsa-sha256; cv=none; b=yAWB+9xdnQZTvu6M8oLXmyjW5kSwOUrJny84Qa1D+aN/78lBbBR9mavX1+Rxhg/32HN9jN Hr4cITYzuWCnriZkIRlO877MgBlYwHD1HQarvRCXcbtQ5+0PMoAKj1RxWEaYURbzRHKZm+ QtuAKbBBRkq8HG/yTbj56w3gN8eEKu8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aM6rnkQn; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720696094; 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=2M6W6JZiruz4nySz6bD7RVoeM3AOko1bo9RHx9uB8p72DFsc4mL9KvGQ5T3o/woW9R1dWs HXrFQush+mrok+KXEpa3KcDznRWnqGvWJ7OQitBBSrS3JPMb8szKrFeUWBI/lg2vVx63fE 3qLk5htM4ft9SZnPQ+SomhXPtbTAiGY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 57C0261D0C; Thu, 11 Jul 2024 11:08:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3ED33C4AF0F; Thu, 11 Jul 2024 11:08:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720696117; bh=/g1ddIto05q7VUdUuGmHZRulUXiGWzaifPHAIEfpWmk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aM6rnkQnft67EwdDPveBEC+aLnbaz9Iw/J9cEyYCG3WskFlIH9k0egFU0+Qi2Q05c PGTgq5xVMimnrOH/NEwwdPJJxHGQC59lahoqxdR1589/Od69pfsq/S4P9rCm6EDfnE CCbH8QPfqjRO2bzt1m/KEINTRYYAeM41mPxo/nmz0cf7H3iakPlLS6s8HITwbeYPU+ i2/lDosNupJCDwHLlMu9LzEE4CucQJZFqhDTVII8U+QLk+uhFR97875JWbKdeb8kEY m6RUPbotcrmnFL7PG2S+dR12jKaQ79i/hUeM6l9cFRvMyW7Ub2xHxlN/HxyaaoQOIU tNrQX0xPxYWJw== From: Jeff Layton Date: Thu, 11 Jul 2024 07:08:08 -0400 Subject: [PATCH v5 4/9] fs: have setattr_copy handle multigrain timestamps appropriately MIME-Version: 1.0 Message-Id: <20240711-mgtime-v5-4-37bb5b465feb@kernel.org> References: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> In-Reply-To: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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/ZANAwAIAQAOaEEZVoIVAcsmYgBmj70l0tB8wkk1mE/fQzmfxmASsaLYnQ6xULsvM medg6N9UiyJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZo+9JQAKCRAADmhBGVaC FRj/D/9/qFMGv96YIkAUDVx329NA3lwGZlqp79bN1JG78zGjqY7RX8Uv8c805I25dhpqy2+jfBk VnWd2HCtg1ShenHgPEfnBAsQNjiSUqeF1uIuEVVrTwFaq8AsGY8LTu0QVyeuGImLKtdQomtuVwt FSmNefB0eXDRt6rmOFfnflJoXglp10hyeikatMaHGEr4ASXHDObg50snibOl81qye5cNJh6LbWT UZSgieB+TtqZzZfxAqwNVBRXLrT8QjDcSyfNuJoiB16Jnejn5qaFVEiGGqomR3//RmFSBozZ16y 1HwtgYp+Wn/io/r+6kKUrUeYHURFsR2sVu7s/XBzTb6gJ3yMjd8YTaCSg8Oy+yKNh32pf39Lhmh arf0zK8/W8lt2iOWSuLYJ2//NzoH8u/p12GqCm2dhWvmIWg1CD7YqW3cDGiWc8bltkudb+doVt7 JnP52FRHLAy8v3Sbp5QD9WLr/4lBVDEaE+ulNhzfxNjI6XIaMRQLWY83t1qsaNRRd9+l/QdIh4D w8GSkDpmq9M+iIPOmGLF2GndPggmO3X5p84sFpQHkNa9P8Nc+DBt0RnoIS+1FTm4LfAs3VrB9Se XHTcE4rfgHM0uGMDzvP3iybkgvcTipYHi9n9zPYC1UflB4CkmguObxvjJKWVAOuSCGxvMhtPjBt g4r/yhDL2VECz9A== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: D348B14002E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: tcbm5hatx3kj3he6i1pchwihmz3erxgz X-HE-Tag: 1720696118-327545 X-HE-Meta: U2FsdGVkX1+ebPAzswvSll4+skRnHsx9bj1LPUz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J8hjb431asFAyzdEN6aJPifo2cTZ2/iwOQHWq8hiHI9Risj6GfoFuXXVRSEN7iHqIzozZH4zXR88HCSxxql5LdOx/hRXjr60FFmTS6M4OxaugQCY20SUoJqw8D4rRQTEtLUm9ebSiwq9tbhZ2EkHMEAP5PpIO3GsBLrkn8Guqefv2n7p1+5KrmtAbP0bvF0og5adOtr8FM+KNGDCjqmKnR1g8HyOu7NjBhMXumRxclzHgBbEmjbIZhj0LMz9Z1gY3riqqin+k2D12N6D9f8vBDFJPwb/eNet 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 Reviewed-by: Darrick J. Wong --- fs/attr.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index 825007d5cda4..e03ea6951864 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -271,6 +271,42 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset) } EXPORT_SYMBOL(inode_newsize_ok); +/** + * setattr_copy_mgtime - update timestamps for mgtime inodes + * @inode: inode timestamps to be updated + * @attr: attrs for the update + * + * With multigrain timestamps, we need to take more care to prevent races + * when updating the ctime. Always update the ctime to the very latest + * using the standard mechanism, and use that to populate the atime and + * mtime appropriately (unless we're setting those to specific values). + */ +static void setattr_copy_mgtime(struct inode *inode, const struct iattr *attr) +{ + unsigned int ia_valid = attr->ia_valid; + struct timespec64 now; + + /* + * If the ctime isn't being updated then nothing else should be + * either. + */ + if (!(ia_valid & ATTR_CTIME)) { + WARN_ON_ONCE(ia_valid & (ATTR_ATIME|ATTR_MTIME)); + return; + } + + now = inode_set_ctime_current(inode); + if (ia_valid & ATTR_ATIME_SET) + inode_set_atime_to_ts(inode, attr->ia_atime); + else if (ia_valid & ATTR_ATIME) + inode_set_atime_to_ts(inode, now); + + if (ia_valid & ATTR_MTIME_SET) + inode_set_mtime_to_ts(inode, attr->ia_mtime); + else if (ia_valid & ATTR_MTIME) + inode_set_mtime_to_ts(inode, now); +} + /** * setattr_copy - copy simple metadata updates into the generic inode * @idmap: idmap of the mount the inode was found from @@ -303,12 +339,6 @@ void setattr_copy(struct mnt_idmap *idmap, struct inode *inode, i_uid_update(idmap, attr, inode); i_gid_update(idmap, attr, inode); - if (ia_valid & ATTR_ATIME) - inode_set_atime_to_ts(inode, attr->ia_atime); - if (ia_valid & ATTR_MTIME) - inode_set_mtime_to_ts(inode, attr->ia_mtime); - if (ia_valid & ATTR_CTIME) - inode_set_ctime_to_ts(inode, attr->ia_ctime); if (ia_valid & ATTR_MODE) { umode_t mode = attr->ia_mode; if (!in_group_or_capable(idmap, inode, @@ -316,6 +346,16 @@ void setattr_copy(struct mnt_idmap *idmap, struct inode *inode, mode &= ~S_ISGID; inode->i_mode = mode; } + + if (is_mgtime(inode)) + return setattr_copy_mgtime(inode, attr); + + if (ia_valid & ATTR_ATIME) + inode_set_atime_to_ts(inode, attr->ia_atime); + if (ia_valid & ATTR_MTIME) + inode_set_mtime_to_ts(inode, attr->ia_mtime); + if (ia_valid & ATTR_CTIME) + inode_set_ctime_to_ts(inode, attr->ia_ctime); } EXPORT_SYMBOL(setattr_copy); From patchwork Thu Jul 11 11:08:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13730390 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 6FD99C3DA4A for ; Thu, 11 Jul 2024 11:08:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E25286B009A; Thu, 11 Jul 2024 07:08:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD4FA6B0099; Thu, 11 Jul 2024 07:08:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4ED46B009A; Thu, 11 Jul 2024 07:08:46 -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 9FAF96B0098 for ; Thu, 11 Jul 2024 07:08:46 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5A01C1A053C for ; Thu, 11 Jul 2024 11:08:46 +0000 (UTC) X-FDA: 82327199052.22.561E976 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id C95F81C001F for ; Thu, 11 Jul 2024 11:08:43 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WCzTZU0J; spf=pass (imf18.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720696099; 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=R9ZSF8Ea0l/p209368BdF6Z+Bw1WhPjc55g0E7Z79qY=; b=UYOc8SOMfpfLBzSE+pymSQ0wme25R/BzGZZrlYqzwLm+9hE7bh8uTB7hf2KOaUmPnI5bWl hhN4ivMF5TZzTuk1mGU9gRetlHr9qKCSRFodXcG8OJOkssK2m1zajk0FYRMQHbOGvw4NSa k5ESERMFTt8OESLvhsnLvQX534uEiM8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WCzTZU0J; spf=pass (imf18.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720696099; a=rsa-sha256; cv=none; b=Nwa/aGwXap0qMM8x3kv0sXYVjy9PHUeRDaGOb7scYjCg79f3St+vbYpLww/zwTBQwdzSeU TV+ZV8ju9PCMuYZT92ajDt2oxzLFN7OcDaD3nCEc8xNovZ1zwTtlRySZ/nKcVxNrh6Cu3M Zh2qiKUlg/5xFY3lGRCYbaE68o5OyR0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 7ACF3CE18B0; Thu, 11 Jul 2024 11:08:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49D2CC4AF19; Thu, 11 Jul 2024 11:08:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720696120; bh=pW/jFkAPiF/HbV8e5Z5baq9Y5PvUD3bzN6ubPEHLIXQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WCzTZU0Jr3v43eG8Kx5I8d4s5hM4Nl+4vwkWWwhE05eXLo7V1b4+GWNCE/DgQpjrC I4wY2fE1b8a9AzJf6PqRGaVfDxSQpO6S3ESRLeYAxDf4sN3ZcBDuErjicZUkW1FKoY M4c//kk3Wv8DChNgGR1TK/cPTm4pLi0RY/GC28H1rN03MPSHbtbTWmshnlF/2ojlLH rYQX9W079Lr36VIK9vZSc31GuUnOLeQo/eC1jCmnLGOSp5kNr1x7yNIFj1fOPSkcq6 Z4fG0FH8w9I2wetEiPhdXL5lmwxvUNZCS8wfBrR8OE4yw4GerUFNinTLpSfH65X8Oa 1EeUzRbEQKY8w== From: Jeff Layton Date: Thu, 11 Jul 2024 07:08:09 -0400 Subject: [PATCH v5 5/9] Documentation: add a new file documenting multigrain timestamps MIME-Version: 1.0 Message-Id: <20240711-mgtime-v5-5-37bb5b465feb@kernel.org> References: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> In-Reply-To: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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=6283; i=jlayton@kernel.org; h=from:subject:message-id; bh=pW/jFkAPiF/HbV8e5Z5baq9Y5PvUD3bzN6ubPEHLIXQ=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmj70lBBUxl022ofr76yZVy6+CpmCaiGsVxhD3/ T3eOiMHVuuJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZo+9JQAKCRAADmhBGVaC FWpmD/9kRQrNGkdVPNBW8W7BmKOZt1X+58Y3KY4xzbfBqyo3Eg/XG6dQT717nBirvgi8SfDwtIO JW1PZ6ynlRUujLXq/frAtLhMkEZfbgiyqHQnwRnpwL7utKuPHgze9QZBYbEfp9T9AzxH0qOpcEN J8Suy3DPo+btdubYZPs5rkpxRXyI0SnmsTDoYU/JmIFvUeRguPCDNMGNHRDx9uOt/z0wcOUti1p e8g+jaKiQYw+NnOx24ynuurPOmfg97ad6Z1w7YkiVWSuvnSoLhssKAGQcdKzllDCDpJjwCHWvjQ voU3krCPd+4HXIxC+/pUvFcYTDRYODr1DY96YL4P0whozRIxX4OsSmWKYofSbPVyZww1jYja+Wj HgRGVktAXTXmlXCSb34KeQ7gpBiOTl+ggwqidK86S5ubl8bm3bQwqC/rYjxxRU5OpzjBtQphNeJ Rvqb+vtV9V94Fu1fEaMD5HgGvywWWhN3+VmQqRMsExvrwAlfZc+/AHeNvP1gQJf3JpFR5KirITv NMkZR/IhO1xaXfNoD3JyqkoT0+VE+PrnNsdNI5O7o6ahm2BozM9GBqQTlCA4NR6laYYmy9teQT7 hWgSpi5wdzG60pn4z5+cqXs3cEZu34bW3K/UDzxjHeqeHe04KHdAbmZ2Ykz1oJPd91MfaB3E9WD E+Lb3+lWAbLCPsg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: k7oe6iszuirzw5r1eezifam5duzsm4qu X-Rspam-User: X-Rspamd-Queue-Id: C95F81C001F X-Rspamd-Server: rspam02 X-HE-Tag: 1720696123-674941 X-HE-Meta: U2FsdGVkX18jJYu8zkUomkow/jvd/Ve3CguDr5TL/9jS5ZFhQFEEYwQjA87VI0rjdimLZ7OqyRlQ//r194uurOCx4KmvFysY/8KajW9eMiKY9aVtWRZdz89ykTTG1ri4XVgsSUqVZd8c/976l3RwvkJ0jlJsj5rCnTpMzZZvxuFsPV2rbBRhjhs17Ox2PPuoZmo6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aCdxsNJnrdytjO5zB/Un5cabSCiyu3puVFhvjjvHUf3D/kaCON/DSZYW6SvHe8oNj+9Nv+qKKUVs= 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..5cefc204ecec --- /dev/null +++ b/Documentation/filesystems/multigrain-ts.rst @@ -0,0 +1,120 @@ +.. SPDX-License-Identifier: GPL-2.0 + +===================== +Multigrain Timestamps +===================== + +Introduction +============ +Historically, the kernel has always used coarse time values to stamp +inodes. This value is updated on every jiffy, so any change that happens +within that jiffy will end up with the same timestamp. + +When the kernel goes to stamp an inode (due to a read or write), it first gets +the current time and then compares it to the existing timestamp(s) to see +whether anything will change. If nothing changed, then it can avoid updating +the inode's metadata. + +Coarse timestamps are therefore good from a performance standpoint, since they +reduce the need for metadata updates, but bad from the standpoint of +determining whether anything has changed, since a lot of things can happen in a +jiffy. + +They are particularly troublesome with NFSv3, where unchanging timestamps can +make it difficult to tell whether to invalidate caches. NFSv4 provides a +dedicated change attribute that should always show a visible change, but not +all filesystems implement this properly, causing the NFS server to substitute +the ctime in many cases. + +Multigrain timestamps aim to remedy this by selectively using fine-grained +timestamps when a file has had its timestamps queried recently, and the current +coarse-grained time does not cause a change. + +Inode Timestamps +================ +There are currently 3 timestamps in the inode that are updated to the current +wallclock time on different activity: + +ctime: + The inode change time. This is stamped with the current time whenever + the inode's metadata is changed. Note that this value is not settable + from userland. + +mtime: + The inode modification time. This is stamped with the current time + any time a file's contents change. + +atime: + The inode access time. This is stamped whenever an inode's contents are + read. Widely considered to be a terrible mistake. Usually avoided with + options like noatime or relatime. + +Updating the mtime always implies a change to the ctime, but updating the +atime due to a read request does not. + +Multigrain timestamps are only tracked for the ctime and the mtime. atimes are +not affected and always use the coarse-grained value (subject to the floor). + +Inode Timestamp Ordering +======================== + +In addition to just providing info about changes to individual files, file +timestamps also serve an important purpose in applications like "make". These +programs measure timestamps in order to determine whether source files might be +newer than cached objects. + +Userland applications like make can only determine ordering based on +operational boundaries. For a syscall those are the syscall entry and exit +points. For io_uring or nfsd operations, that's the request submission and +response. In the case of concurrent operations, userland can make no +determination about the order in which things will occur. + +For instance, if a single thread modifies one file, and then another file in +sequence, the second file must show an equal or later mtime than the first. The +same is true if two threads are issuing similar operations that do not overlap +in time. + +If however, two threads have racing syscalls that overlap in time, then there +is no such guarantee, and the second file may appear to have been modified +before, after or at the same time as the first, regardless of which one was +submitted first. + +Multigrain Timestamps +===================== +Multigrain timestamps are aimed at ensuring that changes to a single file are +always recognizable, without violating the ordering guarantees when multiple +different files are modified. This affects the mtime and the ctime, but the +atime will always use coarse-grained timestamps. + +It uses an unused bit in the i_ctime_nsec field to indicate whether the mtime +or ctime has been queried. If either or both have, then the kernel takes +special care to ensure the next timestamp update will display a visible change. +This ensures tight cache coherency for use-cases like NFS, without sacrificing +the benefits of reduced metadata updates when files aren't being watched. + +The Ctime Floor Value +===================== +It's not sufficient to simply use fine or coarse-grained timestamps based on +whether the mtime or ctime has been queried. A file could get a fine grained +timestamp, and then a second file modified later could get a coarse-grained one +that appears earlier than the first, which would break the kernel's timestamp +ordering guarantees. + +To mitigate this problem, we maintain a global floor value that ensures that +this can't happen. The two files in the above example may appear to have been +modified at the same time in such a case, but they will never show the reverse +order. To avoid problems with realtime clock jumps, the floor is managed as a +monotonic ktime_t, and the values are converted to realtime clock values as +needed. + +Implementation Notes +==================== +Multigrain timestamps are intended for use by local filesystems that get +ctime values from the local clock. This is in contrast to network filesystems +and the like that just mirror timestamp values from a server. + +For most filesystems, it's sufficient to just set the FS_MGTIME flag in the +fstype->fs_flags in order to opt-in, providing the ctime is only ever set via +inode_set_ctime_current(). If the filesystem has a ->getattr routine that +doesn't call generic_fillattr, then you should have it call fill_mg_cmtime to +fill those values. From patchwork Thu Jul 11 11:08:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13730391 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 0E9ADC3DA41 for ; Thu, 11 Jul 2024 11:08:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80BDA6B009C; Thu, 11 Jul 2024 07:08:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BD836B009D; Thu, 11 Jul 2024 07:08:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 634576B009E; Thu, 11 Jul 2024 07:08:50 -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 42F776B009C for ; Thu, 11 Jul 2024 07:08:50 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0B0951A0398 for ; Thu, 11 Jul 2024 11:08:50 +0000 (UTC) X-FDA: 82327199220.27.E0CB19F Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id 8265040012 for ; Thu, 11 Jul 2024 11:08:47 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OfcZxRI1; spf=pass (imf11.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720696095; 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=QtgomzbHR3KcjvS99m9ZDB68gqSVvAmjfQhMJPnFWPwuBExUejMDHUNYWugsRvoUTEyJJO F7NSVlLIhgjoahdG7iO35hUfaVsYeTUrOPrgSBSDuQJNLDkhuyW2jebCUVAv2Ih1xRMRwl 69+jCGxGeZ+TbDKM4PG1EiUnRaoKiRY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720696095; a=rsa-sha256; cv=none; b=ZoxPiRJ+2CxYRGkOK85m0GDOZADHpPM9y42uvKaj9jXNtmVjVFIdEHamO0ijJbOvsGnfHF uG9byYFNuQZyxMGbTfxNQWxKplRIPVypxIUn7FABkali6CMIpAJQxhe1JyqUuPfpn3RB7L XAZREeS7awJeC+EKm7yEg0/gZ7NjzWY= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OfcZxRI1; spf=pass (imf11.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id DA67DCE18BE; Thu, 11 Jul 2024 11:08:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57940C4AF0A; Thu, 11 Jul 2024 11:08:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720696123; bh=fHx/mgJgehSKKeWi0EcYG4swNcOzJbq5fDt162sYPoU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OfcZxRI1S61fYHl8qHzhI3AAeoHxhQ+TZqus8p3/jlXgd23s/5AvLeA/iHAMNu9dX 2Afrdk77c8F5kg5T9PUJKYDVh1AC8OyNV7YXK7vTTl447pU3OZ+thjT7wqgaoeLjAw xpoVoTBTgLt1nS8wwbbLjV4oNQY/TD3/gbbsmy21zkRUx8bSsOtRM/5LZiUaNlUMG6 3vHwisH4gHRWKGKfnSQa0bdXp8/EqBarQqYs0ZJTZQNsaUS40mn//uGzDipM8xMY/l Bbt4qp9y8ZRuuOPEZh4mPeb5azSLL0xI5JxQyZH5FMsxhe/cQd4MvO/WnvCVj0YeeW pleRtchZqlusA== From: Jeff Layton Date: Thu, 11 Jul 2024 07:08:10 -0400 Subject: [PATCH v5 6/9] xfs: switch to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240711-mgtime-v5-6-37bb5b465feb@kernel.org> References: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> In-Reply-To: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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/ZANAwAIAQAOaEEZVoIVAcsmYgBmj70lX4OEuE/qxmSz5H5yszC0h3kRUmqoeXVzO 9+ohuiXnomJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZo+9JQAKCRAADmhBGVaC FVKwD/4nUE2xnHwjBoFzgjJ5fD/kv/mS9yEN5YGF/355Lk7Ayx+lsUACghZYoPm2AU13LRQAg9Y axQhahdEmYPMVxmId6ETZe/uGV5uA55R1M5A8rVpkkElbzAXnB87ASBKfjkuIFNANnv4ZJcGklC 9QUuH02p7d7rBLpfUBLMG3H0ikQu5DgnEqba0KSBKJ8RvQrY7PSz4GRexOb6pwC7tEA3uSl6HPA bCa0E7/lcuiduqPeM89Q3fnU0cD39CzvaX9DbfD0Bz9JLc07PV6MR1g+9f4Gz/q0XaRj59OuCtv iS8Uu4MFDT4p/B6FP2I6As1Jr2SOBIf9RUqsl0fc3Fow45eZ346ALIuwXjmy2YAZbsdTy5g/kvn Kgz1YkcOU6ZTaN8edZD6GrgFT9+h9L7ewVPlFGCnMMVC4TKZBvvAh2g/d9Dw8ZBs0UiDxtU4OmO uAEzSy9lf3IRN2K+MgipP0l89f6yft5sdpnCHAimcdGuZN/AF7vRmEoW2+rCNgN5hZZ0KLJbtWq dsBKD7sbQKF7fMWaFdVgLTC8JtNAg+IIWXutwkOM1w92c69GW5nXNpbmZWa1wSr9u7fG8bu9ULp hI2I2Iz+KyK20ocK4rZgnBgII4Xa/hM/6tDuJrv/wohXYkTwD/uySqf+M8sepMhqgIhyFoczp4W X6W7CoD4lWXPXlw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8265040012 X-Stat-Signature: zexkfsixnm8jghx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RLZA1c4e7WXUw2HHYCgfjtB9d3Yd/CHdQmDTit8ziWGLl+ECorZg+k4DwkcqnO+7Ch24xsyxiOZFTfpKbKiYR7PAsPOKofTRCYE0g01MUvKOUGykznWRXb8UhrUdCU4+nt3qu5+A7Scg5TgjZvXwdd3RWigm08ZhDlDmXyET1V1k8QWE7/cYnIhg1AYWDVZFVAkQElw38rybYLFJdiGG+YLprkLcfh9TC5KL5hLz48f/h3Om1kvUUEyaAXEqCkxHw31DFS10FYU9tNcqhvqkqr9TPgzKAi69dZmHQD2vGbNyzTxFNanEZdj3kCfnYVqWAqgAaqeKag= 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 Thu Jul 11 11:08:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13730392 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 15AB7C3DA41 for ; Thu, 11 Jul 2024 11:08:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A7156B009D; Thu, 11 Jul 2024 07:08:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 856CC6B009E; Thu, 11 Jul 2024 07:08:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 634AB6B009F; Thu, 11 Jul 2024 07:08:53 -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 3E7E16B009D for ; Thu, 11 Jul 2024 07:08:53 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D1A51A0567 for ; Thu, 11 Jul 2024 11:08:52 +0000 (UTC) X-FDA: 82327199304.22.A0613B2 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf08.hostedemail.com (Postfix) with ESMTP id 560FA16002B for ; Thu, 11 Jul 2024 11:08:49 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=p3RoEDci; spf=pass (imf08.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=1720696114; a=rsa-sha256; cv=none; b=14g7QPaPwJ1jn9u8eyLkx6ST0fLUg3KcQEZAV1ru0UyMePbzgsjtCiI1zAWS4F6DV0xLXr gz9CHQ8+fDJGKQ7HVrvvhlJLXMJ4SrGkFRoK8GnXDQ9Tg4utxD5PirGLzuhJkss47B/TWN pBt307tKYvNbHL89inVn3fi1wMUjnA0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=p3RoEDci; spf=pass (imf08.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=1720696114; 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=DkNOpOMiAP/3vbCRtPFII2IdA/dbNq1DaHyy/lXYZFSFGBR3SDVEd+7y9BIJn/CZc8ssx8 HCEokECTTpBRI1yy9M0mF12H8WMQ+brTCQqzQyuN6UnGx9bJj8xAsOtpXjX1wQPYlTkOzX CePjSZJdgo+eb3NqlPaky38A9eC2FZg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id EDFD9CE18B3; Thu, 11 Jul 2024 11:08:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61540C4AF19; Thu, 11 Jul 2024 11:08:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720696126; bh=aIxGR7na/Qdc3ayjXzlWsssXh9j6/eXvzZW4Lz1mI/Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=p3RoEDciD+DzxXOQ4bkKEi/2XUp+heLaAS7X8Rk2SnsiE8e8X+bNY6DnQrWWaPCg8 vDT2+s2Xj2d05hRPt9U1h20xOMTqaC4iyDa9XL3ktuDcG4PfpGXLsckn6gM9Pz76vr 7tmNuLiIYwtH2KSw5EBteQInK93cspWsfKPf2CsBJWRSYtQGXc17pRkEFbbJ4XVyEj g0gBE7VDIKgTumvWLyAQHqK21u+zMeksCE0+4ZxsZF/zS0xNny2zd5DELfTBxS0IE0 3qJKTSkKQD3mdSNnbQxQ856Qipa1ntOZjZuwZcThGvzVEeTFW+SsAfTzXBGS0Nhn/R q+UiX+o4cfhtg== From: Jeff Layton Date: Thu, 11 Jul 2024 07:08:11 -0400 Subject: [PATCH v5 7/9] ext4: switch to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240711-mgtime-v5-7-37bb5b465feb@kernel.org> References: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> In-Reply-To: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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/ZANAwAIAQAOaEEZVoIVAcsmYgBmj70lLGwtVIH3fc84IqxhCflp0IWdNwkGUMG2A KdkQdY1RniJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZo+9JQAKCRAADmhBGVaC FS6uD/4iWWotu9rZZKKFv50AvekdwtGDtGPWRiHDnyK+Z4WsUIEm7Je//sOMkTYveYEOhKTwiw2 JKNOdXyMaZppvgpDkeNa4cv9LhdxnQCV1yGdeh/RorjGmeNAekQF6FEuvXnYZDjU/b6P07Jhbsf BD3rSONfp1FDpMNZryrsO40nWnTF3Jk4xpZ23j/5uVlj6otGJOQJTHR233i+gb7LSlKmYffo2kQ ynpKKfUFhGoIIYspBFefTrK3pEVBGuwY+mlpteZbQofFI5+pYXqiLj2PAgZMnRAja5y9Xww1E52 0gx8Cysjr06dcF1/CMrXF3hVDB+/NQzXV4a6EJDcmWL2ap13OLgV5LYfhpiSM0dLZDmSNK6+Vxo I1MJVA9Rnk3W49gq/rZD48IRm2M6ctw+raFZic5nKFC/qKSrNKp6znW9JPsQLbclpwn5s3BS0CU kTBWse7xWx83BQ4pbJl2np9CXPeprNQqup22HN/p5+jTqcaos8t9mN4bXfdA4xhnTMGcOfCY8QZ iGnLSJ7FaKQex+xK/q2E/1K2rvzPtmDJKFiVvSRgIUmpQ3b2/4v23Z671/UGCpCgT1MtYzzCYvU FbsAT67Wp8UNzXVatlzSKXwQvEDyRbXasYy1gEniN6W7uExCqQf/k0sA0ToW/ptxlQfb/z/EFd0 /NYocsP6uJA2FgQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: b8xqxthrxo5g13sfs8r5g19ur53dhcxb X-Rspamd-Queue-Id: 560FA16002B X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1720696129-618005 X-HE-Meta: U2FsdGVkX19ByPaXkcNyPGB/I+e/+eAf7V2hwowQUg+p41cuAokBqzoA3LaD3Peb23VYnV/Q/MdjAcFmcN844FouoIt+NrRYwXMS2rJ2ghT2MnXhDRK03+XtP6Z4XOadRdh3/g6hkLDEb6V7rpRy3ysdxMN244A+vcfSDdR66VwR8QxD0lFg8HyK/JxTVf92y5S3QZTv9RzbL5n7b5LHO5GvOmvlk0Bt6FOYj1sXJ0o6WVoncxtA70Qzwox+Gq0K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+kggtPep/I1yTdXfzCk9t8= 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 Thu Jul 11 11:08:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13730393 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 1DCE4C3DA41 for ; Thu, 11 Jul 2024 11:08:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7E156B009F; Thu, 11 Jul 2024 07:08:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A04EF6B00A1; Thu, 11 Jul 2024 07:08:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87FA26B00A2; Thu, 11 Jul 2024 07:08:55 -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 645406B009F for ; Thu, 11 Jul 2024 07:08:55 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1C96A1A053F for ; Thu, 11 Jul 2024 11:08:55 +0000 (UTC) X-FDA: 82327199430.25.F11CDFB Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf11.hostedemail.com (Postfix) with ESMTP id B39EF4002E for ; Thu, 11 Jul 2024 11:08:52 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PIYSBlDz; spf=pass (imf11.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720696116; a=rsa-sha256; cv=none; b=cEA2rLy6KuF/lKQjCI76VNc2Uaq40VF8Sa05+bOWACla/NHKMh5P/eckPIL1LhkUK5kDEH qRFH+d16I2EcJv2oqfW+p0sE4G2OpEbDmnZp2yEjDGMFi9zkVtUeNQMfQq1/DBGINt44yg WPlqzcvGC5HUAnRmrWzaeJnBAtnzKxM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PIYSBlDz; spf=pass (imf11.hostedemail.com: domain of jlayton@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720696116; 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=AxQhWOzxp4e+vfZTy0ZsZgVkGapDPiaEABto/QXCpKTb59l+ZHmdStHReQTWJy7SKgx0mW Gt0mbh+FVzIAhE59box3G552pjGDvi5jW0wyl4aMkJqZHM5IAIbEoGINgzj9vf9o+YGUW/ c4kZDDpOuvh/JPj7tQOm4pg25CEkw5k= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B9874CE18C1; Thu, 11 Jul 2024 11:08:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 690D2C4AF0A; Thu, 11 Jul 2024 11:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720696129; bh=xTk9IFiZeoZdqPbR7bcsVc6tPLRLkOIJYDVl81q/MME=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PIYSBlDzi3izlhhsIih/pyOcBS1LMKHlSVybt8iwDKMCT/KuB+uwW5ZH/4UDnvHt2 iQmqRu9FPZfscB4x1O8ANDwsFpStacAQn1MZcv3WRPTRtaX73PHMYQyQFGyYQGHiSD uVU0KS+6pKts00oAL3Oad3Sdrxu58b4u/W8mOZNypM4ig/boWOPsrXhK79SRxP+ror Vi0p96D0J6Xep6j+EXS9SFWrtblFyvbZV6WHVx8Rvyoiqw9M0WX/4w55T4qbJ/Ghkc ufKRaU4Ci/y52xxGlR2i1JJsMXG0lQDkq+SsEElni0wujfCUS4LA2B8yXhSG4Ifr2+ 70sfbdd2Cqs1Q== From: Jeff Layton Date: Thu, 11 Jul 2024 07:08:12 -0400 Subject: [PATCH v5 8/9] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240711-mgtime-v5-8-37bb5b465feb@kernel.org> References: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> In-Reply-To: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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/ZANAwAIAQAOaEEZVoIVAcsmYgBmj70lhNewWHh61CO1bt11704SMJNMRrO6Etw2W 30QskLPOVmJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZo+9JQAKCRAADmhBGVaC FWr4D/9/BKDDLNpeTxoxJKR9NnOB0Mj4UHHvSvM5FydPU9wm1TtZNljZG5FdmhRnlVA/EU3EXzh jf/KKNDLSi/SkxpUOyQcE/LCWROpGNQa8YBQVBIrykpJkAuUaTSB/x3HeDxG1iNhLnyZOP6wmv7 CKV77Ru+Ii2wwDEoVcJ5lK/s9p0eidSnOxpZhJLK+yjjY5n64i+NVh/Is5z0+bCWVJC/Wkm1RH+ tNa1TaLjw+meKTwcACY4E5sbvvFtJJAboc11Ga/shYG8MEikSL+PEnLXpy5qovDMn0a+o2f0Ym7 k64mPNcEDEbQA+pq0VFMER0k2zzjogtxHfVDP8CPHs44giEoqX+5QRMSB4qlvElDZJeYfOfNkCL h6CgItnEYUOg7obynfz1AKOmd5WeuEpHoH32KDvJGcr8u+wNqFW2bjON7JpfxXdiNQg67aOX3i7 cqM2H4I2b+Owt1/0khoFpTec36REaIYLbwYzuJl9I7knlouHgymKaeJNYKdKPQUrPgBa6h9PzRd r8gQtiz/H1OwqeSyKf7WhIqGVAa/TI7+AkAH4tyAEzG3AUdzNctz4o5MbhhGkRzOGJSTa3wkQiH iZ1RyliJcivTulNvI+EYYJoflW+3qIliMy3wtk5seaDzPMrlZJO7+uQTJBw7YAlp1Y8S9F7YbXU acGupOaNKLqwSnw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: mets8yoog7xginb7hwzmzegbq6bjdakq X-Rspamd-Queue-Id: B39EF4002E X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1720696132-399776 X-HE-Meta: U2FsdGVkX197ohIi4QYpy45OQV8ESFZOV+M6smh8CU9KJ6c8R9jt4sZU4YSz+QeODSE/5XK+YjYiSwjf1za0xBz0lEpQ4I9RWdUfg9li/rsgmKHzXBriStbSAVHKE2Rq2/aBrJMaRiykKxrImQlgFZJ5YWcYINvOAkOauuwWHkDY4wHmcw1RWl1nTt2TzCMy7pQdAmRw21/ZD7BiNQmruA4v5p8L5z4IOjYKiq8RCFacFAtWKzFmpsD7P5zK3DwHcHI54TRMLVAjpzQYUjSM0NuGdN9RrOMSYfaooIUqtpCfha34C6kF/HRAEghE9+kDgPkDOLr2e7z3k/648sJKBfmWG10hn6cTTfHfOXm9FijHWw6gFjRMDwDapBIZTlHj3MPuaRG2n9Za5tGuorPfrmOmQ53w6i0uYh+O/Ctg3C8BukvT1N3MRIXlBCP/VZNCZkXAvFU/egCfogpnSJZ4QjNF0Vlk1V4FnSv0kDF/UDoHdi0oW5Y1ZKO6km7qOZ3TvuB1VQDrViVn3vzPKW+Uh7Zs3TEWyjj7PrIqPzDANPeYonpmdwatdtdGr8w+vGizZtJ8kQFUoRzuyfL6sAHIWgLMECxbMM6hsbRntgVPBEV/XHi2yzjShMa7rMwjufmrZE7wwgPAXtIjfIH+ZIkdFLwamjLFKUxJlVRyS5QurYEGrg5lOAoVriYnxT6KQIfZ9ElD2SNH8ckrFOGiJI0cpW+izRUZ6pjjfc3r+yTweaAOzhmmG3/G/4KAHGFY8JuaFeir6sT/trbxHjraglWi1XXzhWvZgILY0NyaExGgX+ZUHcPrSrnt0GBt5Q1OnLdaEU+NOdCPHLOlyF7YTQikyuKa/8H/rSESKN0i2nx8hljexFYcYlECLTT4GHe/HjOHyH3GgPdvYYCnjchVfMlD/jQh5ARrsKibrt0P++AeHgimIdP8AkKTHvcT2k7jyyvKwzUqtnRfYrPXQeiyXKJ IyB2+yJ5 yc7IVVwC8e41Kgd5D8w8cFB5x8ebV//juLXRSCKRmVHB5NVOUwXQAPZJfho7gY8TLfomcfJbLLdK9z5sFLkSOHGOpMKkbK7rrDWJZEYuNuVrkACVRb17d2h5KBDfyq4YhoTWO7PpErgHiCWTV4tJaYp02qVNbnPQnh+LlThm/wYVCpDXpp6RHYLiz2Ef8AqBt0QBVsB3bUhWtdVhzy9NW+He0XZQEo1zwaimvuW9y++PWizPaCT+IBWU7jUlc9lAEOuFarmVHgZG9kGaTHdqYHVcK/iRk1J1T7T6HJUn3WZcmRZtI/iDpogWsqI4HC1aA8/Q7YhPJsXh2+88pRkexSkFnW3mKUxyVk55ocgEzaZFV6J8= 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 Thu Jul 11 11:08:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13730394 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 36A8EC3DA4B for ; Thu, 11 Jul 2024 11:09:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1B836B00A1; Thu, 11 Jul 2024 07:08:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AA3076B00A2; Thu, 11 Jul 2024 07:08:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 940FB6B00A3; Thu, 11 Jul 2024 07:08:57 -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 735EE6B00A1 for ; Thu, 11 Jul 2024 07:08:57 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E27E8804B6 for ; Thu, 11 Jul 2024 11:08:56 +0000 (UTC) X-FDA: 82327199472.11.B134810 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf08.hostedemail.com (Postfix) with ESMTP id 6B5C5160017 for ; Thu, 11 Jul 2024 11:08:54 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kZWlnKSt; spf=pass (imf08.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=1720696118; a=rsa-sha256; cv=none; b=vyozWUVE5jnqEOxQ0FoqAiyB4Nwlv0m1CrchyeJXPRQ/dPo1okMLYtDjJ/o/e6cQ8Qmnba 14g7iPuALp/aaSZUnHLje7V23R073aLlpfkph91RazyRXgAfLTwrR/Dmr5yW+QfPOkkkXi BaP0GjNamTnxaPMa9QpmpXt9NOTwuVE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=kZWlnKSt; spf=pass (imf08.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=1720696118; 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=WJWqiHj3XekHYx0VgwRhnJIhJTvqF8OvKgeylJHVcRE=; b=1WvLRYQxsFAMZT0BVd/ohj8ybXqv0VUpqJAiFt50p3+0Z6XgOKrb1rCypoVR16vnU+f769 pl+7wkbeTlXqJud9o+XncP10cJzPGp2EV+8eY1836Feb5202ed958QigSIQgm5v/A8k/o6 Wh9su7O+5VOKpIKUtx1rgUftLlLBqj4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id A2086CE18A7; Thu, 11 Jul 2024 11:08:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72C94C4AF0D; Thu, 11 Jul 2024 11:08:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720696132; bh=OTapqLUtOhOklsMt0JtGipDN7/MAEwqOBUQ+KnQBUIw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kZWlnKStTWj/I08Tl3NCNpksnVXMXWM9yXlhktX3p2YwFtK1kZcembFkaADm1ByML 2hqUuLfknzwwRWW8jz0tWvJZnTLio+NcpivJ7DKtiZzjradOKuHmkN/rEMucFiJoVD qrqSIY5CLhJuV+gEMUuHR4ZYrg39tcU+yG36QOb53fR2jfy+FtZv4VnGEX/i9um87T Hct1UhKTZePkdLV9+ldCeBWNs80da+df5Om6mWiOakKtFDt83ux9e+hcKRLH/jc+dO wb08v3rnt5ZOUgzIkWiy7lcUXUxtmHZ5Xyy9dCUoLkfwj8sgDCq5Us7mAzhTwXAyWR bhpic4mjWPRMQ== From: Jeff Layton Date: Thu, 11 Jul 2024 07:08:13 -0400 Subject: [PATCH v5 9/9] tmpfs: add support for multigrain timestamps MIME-Version: 1.0 Message-Id: <20240711-mgtime-v5-9-37bb5b465feb@kernel.org> References: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> In-Reply-To: <20240711-mgtime-v5-0-37bb5b465feb@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Jonathan Corbet Cc: Dave Chinner , Andi Kleen , Christoph Hellwig , Uros Bizjak , Kent Overstreet , Arnd Bergmann , Randy Dunlap , 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=OTapqLUtOhOklsMt0JtGipDN7/MAEwqOBUQ+KnQBUIw=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmj70l7ZnQeMlGHhjvFghMhoPkLSm0RtSQvRi/6 iYpytjkGrGJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZo+9JQAKCRAADmhBGVaC FZNfEADRHxrrM5sremg5UaJseVwuJj4hBX4wOg9PWhSGsvDhBSLnesYgeOMU7tABwVt/Z/8KcII E7FyeB7UeKZrk8KHbfDLrkFr4s2S/TsKPL0w538UEz8RtlzRM4BSv05QfJBJoRKpw3uBgJQA2St owelXYZBb5lXQeYVY3Xjg6yE03rw7iXm7Wu6v+u5+KVwkX9L5Cybg1j5UmqyA7WAs0lIqln/R+p wRjdQjL+3DK8MeqWiReYlmE9bBRLXa6DAseu3M4zC6xlaNGriEHoTWjFGbtyVwrPBailuJjRHrY wlIbkJBkkU72wY8rV4URo52g0iKX5b26BzHIzseEAqFJP6QHZGBVS6xFGsT/V4kw6EtPicdbsYN 7FlnO1dz1NWgv+TY02YEv5Gwd1Qxi3FeOHpJxt9o+5H5ASHjBGqlsdfjbp/hykirLGwFeBwQjAr vrz+47ffKte5ROyhV/V2djA/crlVqZq8xMxybO3ewVl5FymC+c4VbtWkTS60XsbXyFieFVR6Akb lnJcrsgvNEjeJoI01ocrq89wTYm9uYLYl6Z4W/Ffcp9WVS+BDgNe2Qk0r7JXbZ/aKZ8Jjm96txk +IdIydQLrUXuYBlPjpWI3oZp1xjrFddm/vOkQfR9dOD4JKH/hotMg3sRlNQzAo7lHreH0cGxP+Y TpESK6T5rsq7iwQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: nh55r3okigrdqz5d1dag6tq3o1uu4zxs X-Rspamd-Queue-Id: 6B5C5160017 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1720696134-901572 X-HE-Meta: U2FsdGVkX18teBUCPmQN04J+XbCSCMbR7ZKCt5FKYB3sgOQI/owvIVBnu8hXWaMDjsAL68t2O0X28jPgCQ5HXrtBeMxPuZ1ORCuqznj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dB1ArnmZP9ZWKXuBj++rgxcyV5qvXLOM0539Da0S5ZvRHPJP3HEPsj2RN/0Bbaa+Z8BAq5Uig7WeQr7pwYm8aUlqaC37/Hj7s+pWgCv5OR5HEulYOYCY3D2ExpJn3YH71W8rUffDpGELj40u7zs08SIQNwxYOAEcXs9qYeOe5MZT9CycoM= 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 7f2b609945a5..75a9a73a769f 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4660,7 +4660,7 @@ static struct file_system_type shmem_fs_type = { .parameters = shmem_fs_parameters, #endif .kill_sb = kill_litter_super, - .fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP, + .fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP | FS_MGTIME, }; void __init shmem_init(void)