From patchwork Sat Sep 14 17:07:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13804441 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 B67BFC021A8 for ; Sat, 14 Sep 2024 17:07:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D6BF6B0082; Sat, 14 Sep 2024 13:07:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 185C66B0083; Sat, 14 Sep 2024 13:07:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0261E6B0088; Sat, 14 Sep 2024 13:07:27 -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 DEA536B0082 for ; Sat, 14 Sep 2024 13:07:27 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 576DCC213C for ; Sat, 14 Sep 2024 17:07:27 +0000 (UTC) X-FDA: 82563974934.19.5E40E51 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf27.hostedemail.com (Postfix) with ESMTP id 8D04F4000A for ; Sat, 14 Sep 2024 17:07:25 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="qgrESo/2"; spf=pass (imf27.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726333615; 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=odZkZJo7zbTgSpD61JoTnbkExErPRRGlLKPRz32iL48=; b=k4DECgLF9WrJumbyo2MUyL2TTUuboUv+zvX+6RIqc81V7+Vn8gn+z/bDsyTQuVqi8AOU/m dnIMs9dUz3ZdH0pK5PuXKXboDLWONmfi2etXPVZXw+aB9EidUlUSOwKFXHGkdzr9sTPEwj DbI84K9/UQaAabOKLvzHb/LB7KJuiUM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="qgrESo/2"; spf=pass (imf27.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726333615; a=rsa-sha256; cv=none; b=wVlG1auQDjbHHDd6tIjX99J49xCvznF2EtAGPtzD//K2U7/fKegNyrhGsiw8Q6kMPeMSoy 4uzkD8JLaIIP3OIrEkbUz7l0SE7A4LfAFH1OJwi5Nwjd41jtfBPZhBsVxK5MuF46/2lXdM VVC5A1BZXD5jXIn7sGehXalsqjd1ohM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 22637A401E9; Sat, 14 Sep 2024 17:07:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08B09C4CECE; Sat, 14 Sep 2024 17:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726333644; bh=I9/47O7qo7bvUG1tGenasxTgf1bKbVz1h75bJIuETII=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qgrESo/2dKlnGWdwdJt4WBacgChSPGID4vFllkaU0ksLvfh8W0/erR8TcsEd20YuZ qy7LG7yQaw1+e/hwVRstO2c5SRLjUDVSP/ai1Epg+DZnh8JrRgfa5TP41U31y2xz/7 +080vYTYI1+3AEo46MOZstgKVgoVQmbrOFSFzlkobnc00Vjxiieldhagjt4wBVp973 XWYxtSPcLauiLWBgbApL12W40KgS+mjYM9Rf0aPgs+ds4DZXA4+rRSTEnRWVCNll2X J3CCfCt44JNNKu6dnZep+GyBvY2msx2KWB6EgyIY2/rZe6t72Qcb7qRfabSY4kKAsr o+N7Q0cpT2x6w== From: Jeff Layton Date: Sat, 14 Sep 2024 13:07:14 -0400 Subject: [PATCH v8 01/11] timekeeping: move multigrain timestamp floor handling into timekeeper MIME-Version: 1.0 Message-Id: <20240914-mgtime-v8-1-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> In-Reply-To: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5475; i=jlayton@kernel.org; h=from:subject:message-id; bh=I9/47O7qo7bvUG1tGenasxTgf1bKbVz1h75bJIuETII=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm5cLFY6lXZvZm8RxN6kOFAGtO8JT2riURAMDHv 52tncP7VVSJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZuXCxQAKCRAADmhBGVaC FVmqD/42vnYgXZg5mzwCTj8STzoscinyiV3K/zfYJZXBKlhsahthN4ivhC4Pb/lyArui3/IxAQq EWZuccCCsliVOR5fGIXxBnGCyGUE/NFyJcgQVEdAjlz/lglEXC0qzAgFyqnBFXLjHIO/vEBN9A+ 3YgW/1rz3+jDt7H0Kfaszw9349+fGDmnzIlYg0fLqOG1l9LIdTFY7d1tCWtOxFJOhGeP+m5EUna +jv01w18PUKFWAnYS5w3rpbXPSkmQt/sw6EeN19nRR3QwlkumZck7VVgKrkWPzk1k1fY1omGGeN uu8YXrAhrI48XJ65fOyuUw4jBALv+ImDZwQGejRRPsguzETloqOXZI7HFDS+gpo52sMT22HwmgI XrpgwBa1uVZVVqf02ZnjHftQRwVpHryUcccG4KCDzFW1ZkTKyIjUxpqhXcEAp6jR8/Roa58umQ1 qXMl1cHM2aIpIjH7vLxInGCDw/RpXZMST+q5+QwCvBnKs4WeJBuaI0XLBsBMmbfQhhqiKf3L+HF 7xIK1uDDqzl9gZXVjuD8xpxGxLyhcf6BoT+dbv1E7KV5V8C8OJtRfPiuB/r6fbvaeqXDQLdlNxv vHj65OVIB+mRWvY0NEVU9WSQgxeWZ24UWiflRgY4sxq6+zKOkdbJNn9cAkfgQhI/GS1tqCKU3Mq e6rjZuBfD33jY/w== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Stat-Signature: aujqfbcn7hkbjhrh5a594rbd3uda5rwt X-Rspamd-Queue-Id: 8D04F4000A X-Rspamd-Server: rspam11 X-HE-Tag: 1726333645-532210 X-HE-Meta: U2FsdGVkX1/HQHdd6opPqcyV3qxyfvTKh2EN6+XQjVkMUvKHno7zy0yZGcgGed75iPGlKSkhUddNklQ/vxVOQIh6pdhqlDUO/aJhYl4eUpOH/jjQROjaP+AkctlkPp3gH/ceZNtTh6Hcm8YDNf1jyzHVZhUfO/jgAem14kI5TH9OkIINEEKHgGliGyWlTzZ/n2rFWRA3GL4R2qyNptNMMNlyGrqSwyK9EKfpwcYvKFesGgDy21gp4KJ2042G4P4AOuE61RPhNGd+HcXuVt4fY54MAiNhQmoX/7utH7lo2zWDM6m9PV1ACdFw8XV8TmbutFYoS/vZP8k4RnC89JqalkAUrIFNsIJzEmEvwcXJi6ax+KdHzB1McuMwL6TCN1p15sIfvkiEqxz1f12Ws+LWm0QIVJgl2itP3c3jnt42fEJ5A3GhYIiyBZuYzY4ZA03BjRVBOiVpEXhgubL5ju8tjNjS3kuOvjGvmiBGVA9WlXLWZ0nhfXvaX6w587CD/PAoldUlyAoxtocC1C2W0TAhwR4MtjdOC8BlVTvQyQqnVAoG11Ua+/IaNkPex78pSUF9n3dqfZnNWScOWHMCZGkTOizOeQGpctArGDUBLX7+Vk9CONEAL5YcX468wibWxVqAcD949LxM8SiAyg5xifvQEDy6B0IzNNCRiqXKNh/eaOJ4Hnf4VSZG6W80sgDkPNnejJQF/x3ejZ8Ot0lsDDp3m+lJMiFEHDdQ5FVmgCJQ0IoeYhUPVwJCfxR/IwUoC0XWX/el9mIqAZ5oMUcbsYCC4Dygi6yAf6ulfNaJRalAMyE3CuicNVU/1ICTR1r4zfOmkp473TCTLDHSSaDORIR+PQNNOmcUG4tfOedoFe/WD0Ul4JPTloauXJDtHCo/F3dro2dXsq2CzcPglhecNMCsHQVPvvhnSf03XQ/Xx9bBjDQNMUM9pnkU+oGQ8zreGnz46rmVmNt4t+m8dnvMQEt 90zLxei6 p+icBekep44hJZHqcNkDhfd4wwhO8JSCL22yh4fzyDIgzTz52vqBtMLFfECkpln2zcch/fpXdsB9RBKQbHaIm7CHRdYr65qFRy5exm5IBhDo2p2GMmXUU2nR4nybNJ3QaB7ieDa7yQESuXNfXQlGnoX/hgAY4icRDMew0vC4FgkJGgDL3HCqYw05XclNYSqU1LspFJf+uRex/mAQrYM0MsCDNU2usjeDsJDpfxG/L4ghEr1vbQ8ubQi6b0g== 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: For multigrain timestamps, we must keep track of the latest timestamp that has ever been handed out, and never hand out a coarse time below that value. Add a static singleton atomic64_t into timekeeper.c that we can use to keep track of the latest fine-grained time ever handed out. This is tracked as a monotonic ktime_t value to ensure that it isn't affected by clock jumps. Add two new public interfaces: - ktime_get_coarse_real_ts64_mg() fills a timespec64 with the later of the coarse-grained clock and the floor time - ktime_get_real_ts64_mg() gets the fine-grained clock value, and tries to swap it into the floor. A timespec64 is filled with the result. Since the floor is global, we take great pains to avoid updating it unless it's absolutely necessary. If we do the cmpxchg and find that the value has been updated since we fetched it, then we discard the fine-grained time that was fetched in favor of the recent update. To maximize the window of this occurring when multiple tasks are racing to update the floor, ktime_get_coarse_real_ts64_mg returns a cookie value that represents the state of the floor tracking word, and ktime_get_real_ts64_mg accepts a cookie value that it uses as the "old" value when calling cmpxchg(). Signed-off-by: Jeff Layton --- include/linux/timekeeping.h | 4 +++ kernel/time/timekeeping.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index fc12a9ba2c88..7aa85246c183 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -45,6 +45,10 @@ extern void ktime_get_real_ts64(struct timespec64 *tv); extern void ktime_get_coarse_ts64(struct timespec64 *ts); extern void ktime_get_coarse_real_ts64(struct timespec64 *ts); +/* Multigrain timestamp interfaces */ +extern void ktime_get_coarse_real_ts64_mg(struct timespec64 *ts); +extern void ktime_get_real_ts64_mg(struct timespec64 *ts); + void getboottime64(struct timespec64 *ts); /* diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 5391e4167d60..16937242b904 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -114,6 +114,13 @@ static struct tk_fast tk_fast_raw ____cacheline_aligned = { .base[1] = FAST_TK_INIT, }; +/* + * This represents the latest fine-grained time that we have handed out as a + * timestamp on the system. Tracked as a monotonic ktime_t, and converted to the + * realtime clock on an as-needed basis. + */ +static __cacheline_aligned_in_smp atomic64_t mg_floor; + static inline void tk_normalize_xtime(struct timekeeper *tk) { while (tk->tkr_mono.xtime_nsec >= ((u64)NSEC_PER_SEC << tk->tkr_mono.shift)) { @@ -2394,6 +2401,81 @@ void ktime_get_coarse_real_ts64(struct timespec64 *ts) } EXPORT_SYMBOL(ktime_get_coarse_real_ts64); +/** + * ktime_get_coarse_real_ts64_mg - get later of coarse grained time or floor + * @ts: timespec64 to be filled + * + * Adjust floor to realtime and compare it to the coarse time. Fill + * @ts with the latest one. Note that this is a filesystem-specific + * interface and should be avoided outside of that context. + */ +void ktime_get_coarse_real_ts64_mg(struct timespec64 *ts) +{ + struct timekeeper *tk = &tk_core.timekeeper; + u64 floor = atomic64_read(&mg_floor); + ktime_t f_real, offset, coarse; + unsigned int seq; + + WARN_ON(timekeeping_suspended); + + do { + seq = read_seqcount_begin(&tk_core.seq); + *ts = tk_xtime(tk); + offset = *offsets[TK_OFFS_REAL]; + } while (read_seqcount_retry(&tk_core.seq, seq)); + + coarse = timespec64_to_ktime(*ts); + f_real = ktime_add(floor, offset); + if (ktime_after(f_real, coarse)) + *ts = ktime_to_timespec64(f_real); +} +EXPORT_SYMBOL_GPL(ktime_get_coarse_real_ts64_mg); + +/** + * ktime_get_real_ts64_mg - attempt to update floor value and return result + * @ts: pointer to the timespec to be set + * + * Get a current monotonic fine-grained time value and attempt to swap + * it into the floor. @ts will be filled with the resulting floor value, + * regardless of the outcome of the swap. Note that this is a filesystem + * specific interface and should be avoided outside of that context. + */ +void ktime_get_real_ts64_mg(struct timespec64 *ts, u64 cookie) +{ + struct timekeeper *tk = &tk_core.timekeeper; + ktime_t old = atomic64_read(&mg_floor); + ktime_t offset, mono; + unsigned int seq; + u64 nsecs; + + WARN_ON(timekeeping_suspended); + + do { + seq = read_seqcount_begin(&tk_core.seq); + + ts->tv_sec = tk->xtime_sec; + mono = tk->tkr_mono.base; + nsecs = timekeeping_get_ns(&tk->tkr_mono); + offset = *offsets[TK_OFFS_REAL]; + } while (read_seqcount_retry(&tk_core.seq, seq)); + + mono = ktime_add_ns(mono, nsecs); + + if (atomic64_try_cmpxchg(&mg_floor, &old, mono)) { + ts->tv_nsec = 0; + timespec64_add_ns(ts, nsecs); + } else { + /* + * Something has changed mg_floor since "old" was + * fetched. "old" has now been updated with the + * current value of mg_floor, so use that to return + * the current coarse floor value. + */ + *ts = ktime_to_timespec64(ktime_add(old, offset)); + } +} +EXPORT_SYMBOL_GPL(ktime_get_real_ts64_mg); + void ktime_get_coarse_ts64(struct timespec64 *ts) { struct timekeeper *tk = &tk_core.timekeeper; From patchwork Sat Sep 14 17:07:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13804442 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 9B454C021A7 for ; Sat, 14 Sep 2024 17:07:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E7166B0088; Sat, 14 Sep 2024 13:07:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2991C6B0089; Sat, 14 Sep 2024 13:07:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09B136B008A; Sat, 14 Sep 2024 13:07:31 -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 DAB0C6B0088 for ; Sat, 14 Sep 2024 13:07:30 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 52B5214045B for ; Sat, 14 Sep 2024 17:07:30 +0000 (UTC) X-FDA: 82563975060.25.390CA96 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf30.hostedemail.com (Postfix) with ESMTP id 8EAF38000E for ; Sat, 14 Sep 2024 17:07:28 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bqyCIWG0; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726333618; a=rsa-sha256; cv=none; b=g75eyCma72bWP01hGseT+TdU5DyBo+geaqHO9fQlKpDVdGw4kfZi/0pCySLwXjCzAbHo9X 39huNxilBtKXusetsd3j7FDkniFB9MhQhKgM4cIn+sp5p0XISe4N17I+hZTs/qzlK5cXWC DBoB2dbFGuRqGi4rEZyFapvxOTxGivg= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bqyCIWG0; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 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=1726333618; 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=8lTZ0TORdrIWlrkWkK1i8pOoA3P2Z8y+xp6XPilKlpY=; b=rU73BoqkV/416W2jI5pY1IobyB1AeJ+ZZu1xtmBrKTq1d5GUvxHCnXhOpqOqgv48sFY3lx 2TezYM6XL2jDcBF0bTiIZ8utcnS2C8Ou2OgYDDru026dQQSKpXNU6T5Ze1kmqY/k7AMtWe nwM0r4hyAQYEn2MsIIOjmPEBAibrIpw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 0A5BFA401B4; Sat, 14 Sep 2024 17:07:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D048FC4CEC0; Sat, 14 Sep 2024 17:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726333647; bh=6kb3F02fF3yC3FwnTxgN5Y4EQfLhA8JPkgEVySAXb5A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bqyCIWG02cE5/h88EEs6kuvJhlA+x+RPzR7r9exRHfe9fz3NpXdiY2wbiWYTVT8sQ GzFJqoPzpscQ03XwTQLvgu7O1wGfcWJlc0tU5tOv/8BEh/ylidITUVI7Vpz9hP54ot 5L4uiM1F8z5HLBAGcZdMob1Ad0wJZLcVzv4z39dPGhyiSti9bHyC1Tu8VgopKQ3ycD ziX+913EeD3y3nBF3XSAOcDyjx80QvsDw2SFTIdN4X6BcCB12bHBpmezUm2YKcLG0i kjfOQCQewIAY/21h2SwbIJ81nEUtelDZr02Dh/W84RPgQ6oCPVsyyRC9jUqHMYQLtX juVvj++9tQqjA== From: Jeff Layton Date: Sat, 14 Sep 2024 13:07:15 -0400 Subject: [PATCH v8 02/11] fs: add infrastructure for multigrain timestamps MIME-Version: 1.0 Message-Id: <20240914-mgtime-v8-2-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> In-Reply-To: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=13790; i=jlayton@kernel.org; h=from:subject:message-id; bh=6kb3F02fF3yC3FwnTxgN5Y4EQfLhA8JPkgEVySAXb5A=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm5cLFarm4u48HfsabqF5lelJTtzuDvkf47vB0k xXDWBJEVAOJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZuXCxQAKCRAADmhBGVaC FVTnD/9tiqxWQUOghhcwLETn1W5RSDVynLPbNaTtLiTsCGfB7rmh5vCKK753A9Ld4ONwdFdkMNj Knl3QMFTBH4SlyYSV2Pg9tqNYG42kjbbXYIr1uZTcCxUgQuca82sN7ECn6K/KqpBKnSBcUYuguJ 7cg0hdRSo7l5OtGWZbr7ly15ezibrezG2bMLn2WQT3m0J29KKwbVRpXxiT1JRo2tPrMBR0MSBGx rXq9PDpvqLU6l9kOYyKm2FkFLrYK4eZM6jqGfiP9ML6ywkqrMFdKGMrCl2LtQDoUSFICgQ9ofZu bVXce4cRe2T6jqFMrGLnGtLS6G55D7UldNwtS6tVpQb4kyX1QgKJKMS8QckHzgWLyl5ltYxaTeq IXlbnvznVuaQaQ9g+1SkTLNhL/HtM42Yuz0H+F12JuHcuLaSEf6fGNEbOdIE5NDNwuc2srynL82 ce0ryxnBKq9iV2qwyieK2l+PZPNXOhabuWbmTbiF7eLUisaYEdN0c7NFy3Q8lfW7eX73UVuRyWF ayU6DXUe4bqtI+L4iUMxqz7pAkDIheoDj5AMTX9hIgTEl0VNZ+k7MNB/If/hEB4l+3TbEV73/8e y4QQTjKXvIIEHA4zufUljPUsPKYWO2xorB8jE8WsZLyofLMYwOj55DNltfQ07VaajdxvVP1jVAa 2OaOsCYKSlEGsug== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Queue-Id: 8EAF38000E X-Rspamd-Server: rspam01 X-Stat-Signature: swt33q8h84ke4cc7g7hr7y3e4wdiw6is X-HE-Tag: 1726333648-500461 X-HE-Meta: U2FsdGVkX1+9ca+uzkG/dIcJYn7zDyedrLeyiMPGMAjJT4KodigYQ0ILoCQduSefYRwpFjXWuVh4E6PPvEuB4HbvfaMkIE3tIZ2YIfrCYO1jGbmpQcazYchaAVknrBhnFGLBEs1l3K4FFRaYG/AFlG9PBsdSZClCoLO0L2yb6V+7+rFbQx6ibJDc3GUDMLJ5xpGzDAnY3kesVbD4J12w04OmMabwqTihYT0oMIB2ceL5B6p9Ozgi/4grW3NGbXC+v7lO6x4Tg9F+cJJH2MByddb/7fTCHVR+IjI9dnszWidWGnuhNsq4tTZYT8Rsxw3YFyUm7ZUcT6ZC57w/zTs3MCwG/PqsWMSHsQLSYrer8bBIyTsd2tx5c67EVJCpea3+9k6qtOwMJWjuALDFHOOHE5h2pxvacH8yaOfZKtxx8R1ttl4AbcSqnkOjJYlvgplmDm2C/1x+a9Pfr9gJiRSgq/paq5AIpwy+YCownEGRBeNFS4vvsDHrnjHDZiAqoBsou4B7Wfq9IF7oblB/wlivmTEEntms+q+BIADQwj8cpSQzcCVbdow7DGOzl4R8vzAdpSNwy2S0WodVcpz9mW8otBUiUycVKkJxFttA95sc9t3L3imyRAZ2hJxcE4p3eyzxbxTSEtiOphCis7h5T9szFJ+ULd7LyV6PmtflwyxYX4+7UEDVfeRBaa68Ays4CdRU6oi0kjXtL61MpFLe+gMkW0cIqOw4vucpjoxcwlSquqECqYdn4lLhJljbH0X5Ab53bEdNWdRybCt9hVPVC3YJhwrYHl9X04Pa19VhRhpPip3+JYyTEtC8EW9xPQ6YVfcFOXNwMCjindhcKHjvpqx763sjDYDfjGa5oY9Cbma+2v1zbZFel9lgDdU87j4RA78KZmWxCG4MjGmaARHsKswDDTKvHlJitv8qyFhW6EzdxopHmmRsMuIgJKfVK2QPnxCrJ5Zkn8qqJNg5VXk2/ra PA7XTJK9 GqEFv2p3YyQo+v/X0VPTb4pBH48qitKxnzLeX+mke5ZYgH/UpW3d52M81J21aW13alJEC8JbbbYrd1ijYPSSN22pVBLttNasC92oHyboC+inHdZJekv0idr+DE0S3WtDGCa0rzUMFE0aYhGhQ6xygidSVMUxzo1djWtnyqTImZzZfPfoy3jbcCfyvLhVXNrvKWToB5G86o/zGPrJq+xIqReWZP/u3JJCLl+OwuX+UIpOl0sMpMZO5lCORyw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The VFS has always used coarse-grained timestamps when updating the ctime and mtime after a change. This has the benefit of allowing filesystems to optimize away a lot metadata updates, down to around 1 per jiffy, even when a file is under heavy writes. Unfortunately, this has always been an issue when we're exporting via NFSv3, which relies on timestamps to validate caches. A lot of changes can happen in a jiffy, so timestamps aren't sufficient to help the client decide when to invalidate the cache. Even with NFSv4, a lot of exported filesystems don't properly support a change attribute and are subject to the same problems with timestamp granularity. Other applications have similar issues with timestamps (e.g backup applications). If we were to always use fine-grained timestamps, that would improve the situation, but that becomes rather expensive, as the underlying filesystem would have to log a lot more metadata updates. What we need is a way to only use fine-grained timestamps when they are being actively queried. Use the (unused) top bit in inode->i_ctime_nsec as a flag that indicates whether the current timestamps have been queried via stat() or the like. When it's set, we allow the kernel to use a fine-grained timestamp iff it's necessary to make the ctime show a different value. This solves the problem of being able to distinguish the timestamp between updates, but introduces a new problem: it's now possible for a file being changed to get a fine-grained timestamp. A file that is altered just a bit later can then get a coarse-grained one that appears older than the earlier fine-grained time. This violates timestamp ordering guarantees. To remedy this, keep a global monotonic atomic64_t value that acts as a timestamp floor. When we go to stamp a file, we first get the latter of the current floor value and the current coarse-grained time. If the inode ctime hasn't been queried then we just attempt to stamp it with that value. If it has been queried, then first see whether the current coarse time is later than the existing ctime. If it is, then we accept that value. If it isn't, then we get a fine-grained timestamp. Filesystems can opt into this by setting the FS_MGTIME fstype flag. Others should be unaffected (other than being subject to the same floor value as multigrain filesystems). Signed-off-by: Jeff Layton --- fs/inode.c | 137 +++++++++++++++++++++++++++++++++++++++++++---------- fs/stat.c | 39 ++++++++++++++- include/linux/fs.h | 34 +++++++++---- 3 files changed, 175 insertions(+), 35 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 10c4619faeef..232b474218e6 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2172,19 +2172,58 @@ int file_remove_privs(struct file *file) } EXPORT_SYMBOL(file_remove_privs); +/** + * 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, but don't update + * the floor. + * + * For a multigrain inode, this is effectively an estimate of the timestamp + * that a file would receive. An actual update must go through + * inode_set_ctime_current(). + */ +struct timespec64 current_time(struct inode *inode) +{ + struct timespec64 now; + u32 cns; + + ktime_get_coarse_real_ts64_mg(&now); + + 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.tv_nsec == (cns & ~I_CTIME_QUERIED)) + ktime_get_real_ts64(&now); + } +out: + return timestamp_truncate(now, 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)) @@ -2562,6 +2601,15 @@ void inode_nohighmem(struct inode *inode) } EXPORT_SYMBOL(inode_nohighmem); +struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts) +{ + set_normalized_timespec64(&ts, ts.tv_sec, ts.tv_nsec); + inode->i_ctime_sec = ts.tv_sec; + inode->i_ctime_nsec = ts.tv_nsec; + return ts; +} +EXPORT_SYMBOL(inode_set_ctime_to_ts); + /** * timestamp_truncate - Truncate timespec to a granularity * @t: Timespec @@ -2594,36 +2642,75 @@ struct timespec64 timestamp_truncate(struct timespec64 t, struct inode *inode) EXPORT_SYMBOL(timestamp_truncate); /** - * current_time - Return FS time - * @inode: inode. + * inode_set_ctime_current - set the ctime to current_time + * @inode: inode * - * Return the current time truncated to the time granularity supported by - * the fs. + * 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 + * set it to the later of the coarse time and floor value. * - * Note that inode and inode->sb cannot be NULL. - * Otherwise, the function warns and returns time without truncation. + * 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 current_time(struct inode *inode) +struct timespec64 inode_set_ctime_current(struct inode *inode) { struct timespec64 now; + u32 cns, cur; - ktime_get_coarse_real_ts64(&now); - return timestamp_truncate(now, inode); -} -EXPORT_SYMBOL(current_time); + ktime_get_coarse_real_ts64_mg(&now); + now = timestamp_truncate(now, inode); -/** - * 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. - */ -struct timespec64 inode_set_ctime_current(struct inode *inode) -{ - struct timespec64 now = current_time(inode); + /* Just return that if this is not a multigrain fs */ + if (!is_mgtime(inode)) { + inode_set_ctime_to_ts(inode, now); + goto out; + } - inode_set_ctime_to_ts(inode, now); + /* + * 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) { + struct timespec64 ctime = { .tv_sec = inode->i_ctime_sec, + .tv_nsec = cns & ~I_CTIME_QUERIED }; + + if (timespec64_compare(&now, &ctime) <= 0) { + ktime_get_real_ts64_mg(&now); + now = timestamp_truncate(now, inode); + } + } + + /* No need to cmpxchg if it's exactly the same */ + if (cns == now.tv_nsec && inode->i_ctime_sec == now.tv_sec) + goto out; + cur = cns; +retry: + /* Try to swap the nsec value into place. */ + if (try_cmpxchg(&inode->i_ctime_nsec, &cur, now.tv_nsec)) { + /* If swap occurred, then we're (mostly) done */ + inode->i_ctime_sec = now.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.tv_sec = inode->i_ctime_sec; + now.tv_nsec = cur & ~I_CTIME_QUERIED; + } +out: return now; } EXPORT_SYMBOL(inode_set_ctime_current); diff --git a/fs/stat.c b/fs/stat.c index 89ce1be56310..a449626fd460 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -26,6 +26,35 @@ #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 (if not already) + * so the next write will record 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_read(pcn); + if (!(stat->ctime.tv_nsec & I_CTIME_QUERIED)) + stat->ctime.tv_nsec = ((u32)atomic_fetch_or(I_CTIME_QUERIED, pcn)); + stat->ctime.tv_nsec &= ~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 +87,14 @@ void generic_fillattr(struct mnt_idmap *idmap, u32 request_mask, stat->rdev = inode->i_rdev; stat->size = i_size_read(inode); stat->atime = inode_get_atime(inode); - stat->mtime = inode_get_mtime(inode); - stat->ctime = inode_get_ctime(inode); + + if (is_mgtime(inode)) { + fill_mg_cmtime(stat, request_mask, inode); + } else { + stat->ctime = inode_get_ctime(inode); + stat->mtime = inode_get_mtime(inode); + } + stat->blksize = i_blocksize(inode); stat->blocks = inode->i_blocks; diff --git a/include/linux/fs.h b/include/linux/fs.h index 6ca11e241a24..eff688e75f2f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1613,6 +1613,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; @@ -1620,7 +1631,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) @@ -1631,13 +1642,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 @@ -2500,6 +2505,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; @@ -2523,6 +2529,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)); @@ -3262,6 +3279,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); void generic_fill_statx_atomic_writes(struct kstat *stat, From patchwork Sat Sep 14 17:07:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13804443 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 88130C021A9 for ; Sat, 14 Sep 2024 17:07:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9779D6B008A; Sat, 14 Sep 2024 13:07:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FF1F6B008C; Sat, 14 Sep 2024 13:07:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 751846B0092; Sat, 14 Sep 2024 13:07:33 -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 542896B008A for ; Sat, 14 Sep 2024 13:07:33 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CF0711A0470 for ; Sat, 14 Sep 2024 17:07:32 +0000 (UTC) X-FDA: 82563975144.15.CDEE8A9 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf19.hostedemail.com (Postfix) with ESMTP id 12F5D1A0010 for ; Sat, 14 Sep 2024 17:07:30 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZCOpnIci; spf=pass (imf19.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726333543; 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=D1ojAc6klVsoiH5Op6GfluCcOgdtDcrJ6dSTmDLx0Ck=; b=r3ukyvZeqmSmpnbW1MfbgPkV2rzRFSKPepIpbc93jmkzPnpU5cVF5jzeeZjLm6q8a3Fnkc FUXnNvsF2hDrExY7CDG1Ug7zhU+S5bOgySBcXW9s7ZqHYx4LrB6i6eOFmOMhdxzgNHJhTM UTPd8KM6IV/ss68xlL8xzYhQcE8sOBw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726333543; a=rsa-sha256; cv=none; b=PMnXVt7EbYdqTLsZtjscAhX3xikJcD8MyVbamvtUnWEXd8Jq836g8pPlX0KYbGiXrXLa1R qdjD3prfT+zBgIJma9hUPhAVJBG6Sr6nmm6/Fy3UaDZl5hKqHSev8epXE3HlTklqOKh7zm plaDt5D+rKtO2OVmTSc/hIDojsz6fJA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZCOpnIci; spf=pass (imf19.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id BF343A40209; Sat, 14 Sep 2024 17:07:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A40BFC4CED2; Sat, 14 Sep 2024 17:07:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726333650; bh=9/XBaGHpEs7172AZ1LJbIYF77AkYkko2J3CyGkwFfPc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZCOpnIci9ttfjhsJzdlcwY1nYcNFUbiD1dipumSZt87w3MACEWPzaGdku7J58Ocut 7HnIhiMDQAIoUXSnyL904jY9IAOTXxIxiIR1LWhnuDUgwkupg8+oSupET1iJss0j6j 58zUooisPaBhdB4W13l3tpEKZ/zhOH9LDKDAINhpnCC8r6Ajx/nmf0AhEdr/uUo0Oc CjPVoNLSKEWHCQEGyvzxrzRJEqsldglkPe2BcUgUhDpbf1SwnPrBrDTtNubansxew5 /6dR/EZrDa8YIK8KYySDQSYx4czlItz8HflLG4e7RWbLXVLXgWgfxKuTUczpylZw1Y XmuT7q3oYEnbw== From: Jeff Layton Date: Sat, 14 Sep 2024 13:07:16 -0400 Subject: [PATCH v8 03/11] fs: have setattr_copy handle multigrain timestamps appropriately MIME-Version: 1.0 Message-Id: <20240914-mgtime-v8-3-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> In-Reply-To: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3540; i=jlayton@kernel.org; h=from:subject:message-id; bh=9/XBaGHpEs7172AZ1LJbIYF77AkYkko2J3CyGkwFfPc=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm5cLFOqolNl/xZsf6WUTQki64XUYvRpIiwgA6E 8I95y8GTEWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZuXCxQAKCRAADmhBGVaC FV3xEACKkDWRY2iDTOCIYD0Vc9W6MmuR9SEw96FMPF1lO+jbD26E8dxf0hrkhre9oBUikVhQVAK mso6eiHYIR5pTUeQadzyNEdK8QQwVDVIq95IG5F1sp5NZBdW+myoBZzaVbX6i42BeAmKBFm+EAR uc0WhyS1vxp/5G2TzkAGEot1iMRUtgptkCYA1ksBNkbAQuAUpc28ksyE7gtXE+XTYRjt1+h7lb8 cXQakAWWrU9Q6lvD5Eu3kI30Ml47tKa/aLFyPct/CMVP1wzQT79+5bCbUQeoa3EmPsYZG3i6tgS TXVg1FFqlViABoU1Khb1RT0U4PY2i8jCrcZbncFaS2IJqlBSy2X3Eq618IyGtKF2ZOLoZV80axd hJFet3BIa4P64HQ4Fwjedi/V4OdyKodhAbbAzinWTRT89vH6DMI6nNlFCRSayI4PGlcoqrD4gZK rDvvA59XFLCJ978lHKKngt2iaKf3f90k955si5r2iZahPIjkJNnt1y1GRg1hVrP8NwwI2cyrNxV q0N4yXSUlEdwbb42iJKH5aKp7AADnCwtFkCZ/W3qxfAyhlm3eVtV/60AuQS3lzjIXr+TYqy5CWC BFUrQdbfj9XMZMNWLwf4qTQqvZKxw+Pt2OUbDcndFIk5qB1yYq0dgaRpOrtgUPx9FAtsIGGKb+8 vkCknd986DS7deg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 12F5D1A0010 X-Stat-Signature: nyk5do5wbxw9ttf43r6y49gneowywm3k X-HE-Tag: 1726333650-362806 X-HE-Meta: U2FsdGVkX1/Nxj+uSRyvu1lEcXeZISho1TfUEWeGBQOORtNL5EapoCyHMBa4yISNgmuZXQFqBx9d6j0lrLnpKp9dW7Mg9y80ckhseL/2lFaGvQU2HGSyUYWadD127wrewWPfos+y6Vg4XeArErwYUeu/8bJBJiAHb2G2jXS0wr85HaS9UGoSxc3MP2AbJAVpzATxq5FdBA/EothRL9OcGTkB2JhWSoGONSg8jZ2ru+tVRI0MiEoP1WO/bB9K6v8a7uPVMK4m5/dk6Yr79lcU1tymu79VzAg9pLYiCw1cIoVtlQFgE/J88fEtfPg1rqam/iiPRoso+Ev28vJkkwa3dBUFtWLdeqBkz+p6DxDYyRKuWsgXHuJRUKh73hhjXBv0UR9yb6YOTTw9B/3wX13Ytwe8pa7VM2jxavGAzpzeHkUZ5k3xr+HEByLVm67FfidsAi7EF52DJg/Tzf304VMpbXNZN2dPlg7Q8v0HbDNMXv2mM/X4FZXZCh2Wc/7y2x3UOKTBva8+7d1d/7LlG/5gDbd0/YGmzbI2jhmi4O9i0oiASFSKr197ZJFL6MXXhSOohoHpU2z3QFcObukBwJXZ/5s2rca/l62R4WLdJu60lrbuC4ItHg2MO1nMVtyE5MGUVjcyGSRTbZQuDfCHb2eOnmbzjgrjCWypRjT+bTgTEAa7yKJcBkPwQ/IPSOoFO5qUHuEFYYkOUg1s6FnTLJJIpVBn+5uxCM3oM450kIhVGv0XRFxb/3brnL0rLvCU4xw84L8mk0KEoJgXt79wNIY/ecRau9jpLZ4oYI+2SVcCrarbDLyxVJv9jGxSHJwWAOTIxwDtfguEdpR2FZAW4GIq6MtTvriAU3dms6OSx8MFt8z7X/knkLPEz0/i7iZKJq94MKY5vxLL+lTYO2q6OLCEgdySv0kMt//QgZ1qtSkT62Vy8xTjSmQXtR1Lb83D6y7xF99KHmkocbqsAwTFev2 kA0HHCPm 1ciY0Lh9CAWW5k9X8K/id5LHq2xXLjIJCpB05sCt6e5XdTii2k0l8mAIvQ6Ez+4FalRuctTD4zbPF2Iv0Wou+ZtMdjiXX55QhrzFwlJZcE/vfDd6cmNBhP3B+QkAGyKaoHhSCDwzyqfBOvTJgps+IGZw5pfJMYG0MSfqZGyCTDILpf7tWUt6rj2B6PNwdZAR77DFPkz8DgU7rYzqgJd1PEbOzamWB7VfXlFC1nZ14vJ98Vz0VH7QxixU4o0lFPfD2SEEt7yXqOSWZOtMZCMAG0KCinJRi/M1BlR66fMtCHpA5S7Lmd47gw+OGknGfj9d79i2TGQ8WuqUBCrpplKjXZ6Fi9TVfe0yQQb2oEoLt73s9SnG+HbBwaUuctSV+/VneU4nxye/8WMvhqMSJ4GHwMd+LV3UEoT1RYQOIxM+WHd1YNKHZqG/+tIzzS/QsU+C/n9dyg3aK2DEyYnzxhq6f4ZLA8CtrOIwtPazF X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The setattr codepath is still using coarse-grained timestamps, even on multigrain filesystems. To fix this, we need to fetch the timestamp for ctime updates later, at the point where the assignment occurs in setattr_copy. On a multigrain inode, ignore the ia_ctime in the attrs, and always update the ctime to the current clock value. Update the atime and mtime with the same value (if needed) unless they are being set to other specific values, a'la utimes(). Note that we don't want to do this universally however, as some filesystems (e.g. most networked fs) want to do an explicit update elsewhere before updating the local inode. Reviewed-by: Darrick J. Wong Reviewed-by: Josef Bacik Reviewed-by: Jan Kara Signed-off-by: Jeff Layton --- fs/attr.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index c04d19b58f12..3bcbc45708a3 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 Sat Sep 14 17:07:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13804444 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 51D94C021A7 for ; Sat, 14 Sep 2024 17:07:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D74326B0092; Sat, 14 Sep 2024 13:07:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C810E6B0093; Sat, 14 Sep 2024 13:07:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFFA46B0095; Sat, 14 Sep 2024 13:07:36 -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 8A6FE6B0092 for ; Sat, 14 Sep 2024 13:07:36 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3F7E4A9B78 for ; Sat, 14 Sep 2024 17:07:36 +0000 (UTC) X-FDA: 82563975312.23.69D2D09 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 64600100004 for ; Sat, 14 Sep 2024 17:07:34 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Pl5qlkt/"; spf=pass (imf05.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726333600; 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=Uu/3uANHfluwJOT0sOVK+YFAiKxotPPufi8sl8a6/Aw=; b=rk4mo/P97dmPctBz/Rf8uCgjNZVr1h7Qv5ze+/2VhtoYVgCfHrQhKM0Nxu6Ul1+kWaFC6k JXCeoWY5yYZwxMo3r1acoF7ULh5tVgmeAkcWDI0h6rYjSWTUx8GhsXBvK+dz10bq0d2DaW Fn7kFGG0y31PXAMi15VH8r+VPib1GIc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="Pl5qlkt/"; spf=pass (imf05.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726333600; a=rsa-sha256; cv=none; b=SMnKWP5OsAOtuysTlOOC8CmVgRWMa8aklb1l3gC434t+fVKsMRh5gmPBqw1tMixC1s0wPg /GIb8ij9ktYXrybaOxdWh3EN5cpNTyHQpwS7Fez0ZxDfpPQ1WA1jZDkuvw+aHWnREae4Sl XkiabjmL+hZwcbIO9Fg7pQriOA+sMZg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B4CA25C5AC9; Sat, 14 Sep 2024 17:07:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78032C4CEC0; Sat, 14 Sep 2024 17:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726333653; bh=aSqbB0gVujzisU/y6FV03b+ti8yD2UZ7U4fMZl1YgTo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Pl5qlkt/VRPxlEcECODI0Xew6wnc+fSPdtKQp8YUJed8MYy0e5w2xaPwRcdMBgUEX EpB1GwVipSkYtzT4yrDLNRGOmaESeRR8m1tNAMSKO5hR4QqT1zGET+2Eou0MilSySI /62SgfKM/z80LwjQbkooyLyYx8/YcM4NEjijduCtIUi1nxOwqRJAvxDk0IGFVy489A IizzP7V2GujnZLllrWkxp4cKoqQkdRkijuNJJB3pofH9F6G2JmhIMFY7uTji5J0rxl osd1Y1rOrPAsGiKanTdIrtULRfkQUyOW9EY0W2vuNxYLQ3adHa0xSm1IFwWGFcOOoT 1Y1NG/JInOehw== From: Jeff Layton Date: Sat, 14 Sep 2024 13:07:17 -0400 Subject: [PATCH v8 04/11] fs: handle delegated timestamps in setattr_copy_mgtime MIME-Version: 1.0 Message-Id: <20240914-mgtime-v8-4-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> In-Reply-To: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=6206; i=jlayton@kernel.org; h=from:subject:message-id; bh=aSqbB0gVujzisU/y6FV03b+ti8yD2UZ7U4fMZl1YgTo=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm5cLFQ8HK1/W2OQTOc42uOSa7MYW8Wq+Whom2H gQ2acWJQ+SJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZuXCxQAKCRAADmhBGVaC Fc5vEADJP9NxRrVNDWeeviXY5a0IMlU18SPHOde4ugVGgDVCrzzVS05AkoXjAn2YVxLbwxN2ls2 Xt0ndOnQIzwg5/eJrvpZdUlgKhEzMwtV2nsiT6qdBMSK0yeQHxgbbeNb1CUF66GiuTafnxCFO9c sccqTqX75ub/SOPK/89OsWUfBPIJtKcBqOzMeOsgJE17qSOBkXRr0ItxwxbxWc0m4ryqmIvth3z NPeW+VHgfvWPnx/eEK0FKiYh/Bkyeb6GdebifCbkRUEtCIYww4s3QkE+jWy1rb8akDFPD94vooX 5sZ77ScCJaYnb0Jas54ze20L1jQI+XoYIo0MLqjUAIY2cKMIRrzCDXCpoEPPnucksVjxFRJTaj2 mGXAC1vlu/7x+xu9rS8qu3xSUaShw/WCDKAyWkL1WSrd9pNgWenfVdu8FSJBc/3cSxXT93VT5Fk 1LgzBtyh74/qerEJ6ie4twa+D+eVUGmNsLVEg2EnSX63Gk5BXeQTn1sdnf56tpqTz8K5QUhjPQV XPkOopyKtxqzlYrpF7CJyJr8AetoNK9xLXniUW5qwbuDR1Hjqr1vm1EBnXDGk8khK5T27zBmxUb LwkTcemBpaEbcbX/PGbRS3tr6NFaZdf4Koe6U0Mu+rN/k0srUBYIxZlJj/WWHmBlKMrRspT/g+j VIHjLzOS8yubbvg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 64600100004 X-Stat-Signature: wzj6pnzz1dnsfastwgojsn5m1ybspn65 X-HE-Tag: 1726333654-320783 X-HE-Meta: U2FsdGVkX1/2FJoKZj1LmIuR0fEMqljaJoGhnj9EsZCltkbv11eA3Ktl43pFCI0FbWseS1KO1Qmdo0SoWWWXE+LjOUDhjCM4Mo8OcflAnqWGGeRy/KxdYmXYFSituq0oEFHsmeIwFasaoPRKE1imiF3rqdpm9zp2IXRGnTiKg2swQSbJ2N8uKcRf/SB1nG2MvxFp6FEwtsPIyR8M3djaYy+l51wbiimcirphQPYMk7/gyRhSkdIr+Wk1viNSOsE+r53aQibPYlILlbMkWGmBU1uqdXIi58K3HrDPRaGREdinzb5Q1iYBY7kbrmA7VUeRqVVvOjQwhAkXKYRug1sSDsinvql9UdcLj/WIJ8109iQsw4ylUCx9F6AMrubBLzcVUskwj4ul8JJtGjkP79/0Ejw9zVDn0PU+4hy2exMmYhfzAVuihoZYTesjT+DLOGK1FSKMlT7w7fH9FPqrfQYaIiQBAhj5A8gZ1PcP8YM+2Zl4TU2ZnqyEaRCaxXX8P+fxCxm/jABFe0rSCFS4BZEa7K6EJzebbDlvikpAEdEhAmgqaRwC5ewaFDGDljZd/Qbf8xfFkdQOCQFuYEtKdDPZHsYKZCZCwF42JrIIaxOey6mx5fEi7uiglv++bPNpmCSH5uxzwHPxaphr8p8slZEnULmgCd0fKf09CAXDxid7bQ4P+Icnw4PspEZnLaV/SdG8SFhB6M/U3SOGB6jd37BHBDlDnGM+ByCHZJj0qDZhA0qtVNegERWcpC2zwA8LLKUr8w7Wn7hVTdn4IwMr64r0Cx+So0DIFu6JbGQIFctqbbOoXOS9rqSOHZVI4hwnJtEyjKhJI/2APmOQti2pNy3NzzyfnWFUxBcZuYqnmmxBF7Eq1h4OZoJtRNjKXZxxF1PFVq7cCi6QzHogj+qE4uEGGdAzyWZrpxh3FqIwzV//qGhZkaeZ1wF0AQ+4dJy+HRT5bnKxSivg3Z9T11qUSDA oevngFpk wIf2KsUFHxDt954KQLZysmDru9PKsO9f9XX9uBcHBxBp/9YCaTs9qNAtEPCVrcA0fi14neT/yH5wbzGG+ae9nbnIZFx2O03SfjDquaqHg77jquOD82sZQxqtEi/YREZhGAJON2mS1MnurvyZ4u1fsG6ipF0+HsJ/ktfqntHZp0oXJ9yPKvHZ6miIZVp3CZQSldTHbWc9cob/l3zXjh3F4j/0oqLORv6YfkGHAJ05dj3tDgOiNZN67dc3Evl57lOsNATMp+qKhfnaVe8SosApFVmYfIIezyFrHZUBa3kv0We5nBg676GFP/sazOlgtc50nAKoK8W17rTSorEzQ7IBPxQtd0fijMK59cTwCJoRcPv7DHl5Vfz+dm+1h0vU/jrbPnEDrBDA0dXFdtVXG8bgj70aH1iHgdUkKaNbOiV7MRQtnqdEFBTSobDfQ192J0QnBD7N5 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: When updating the ctime on an inode for a SETATTR with a multigrain filesystem, we usually want to take the latest time we can get for the ctime. The exception to this rule is when there is a nfsd write delegation and the server is proxying timestamps from the client. When nfsd gets a CB_GETATTR response, we want to update the timestamp value in the inode to the values that the client is tracking. The client doesn't send a ctime value (since that's always determined by the exported filesystem), but it can send a mtime value. In the case where it does, then we may need to update the ctime to a value commensurate with that instead of the current time. If ATTR_DELEG is set, then use ia_ctime value instead of setting the timestamp to the current time. With the addition of delegated timestamps we can also receive a request to update only the atime, but we may not need to set the ctime. Trust the ATTR_CTIME flag in the update and only update the ctime when it's set. Signed-off-by: Jeff Layton --- fs/attr.c | 28 +++++++++++++-------- fs/inode.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 2 ++ 3 files changed, 92 insertions(+), 10 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index 3bcbc45708a3..392eb62aa609 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -286,16 +286,20 @@ 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; + if (ia_valid & ATTR_CTIME) { + /* + * In the case of an update for a write delegation, we must respect + * the value in ia_ctime and not use the current time. + */ + if (ia_valid & ATTR_DELEG) + now = inode_set_ctime_deleg(inode, attr->ia_ctime); + else + now = inode_set_ctime_current(inode); + } else { + /* If ATTR_CTIME isn't set, then ATTR_MTIME shouldn't be either. */ + WARN_ON_ONCE(ia_valid & ATTR_MTIME); } - 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) @@ -354,8 +358,12 @@ void setattr_copy(struct mnt_idmap *idmap, struct inode *inode, 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_CTIME) { + if (ia_valid & ATTR_DELEG) + inode_set_ctime_deleg(inode, attr->ia_ctime); + else + inode_set_ctime_to_ts(inode, attr->ia_ctime); + } } EXPORT_SYMBOL(setattr_copy); diff --git a/fs/inode.c b/fs/inode.c index 232b474218e6..614d0402e9ad 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2715,6 +2715,78 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) } EXPORT_SYMBOL(inode_set_ctime_current); +/** + * inode_set_ctime_deleg - try to update the ctime on a delegated inode + * @inode: inode to update + * @update: timespec64 to set the ctime + * + * Attempt to atomically update the ctime on behalf of a delegation holder. + * + * The nfs server can call back the holder of a delegation to get updated + * inode attributes, including the mtime. When updating the mtime we may + * need to update the ctime to a value at least equal to that. + * + * This can race with concurrent updates to the inode, in which + * case we just don't do the update. + * + * Note that this works even when multigrain timestamps are not enabled, + * so use it in either case. + */ +struct timespec64 inode_set_ctime_deleg(struct inode *inode, struct timespec64 update) +{ + struct timespec64 now, cur_ts; + u32 cur, old; + + /* pairs with try_cmpxchg below */ + cur = smp_load_acquire(&inode->i_ctime_nsec); + cur_ts.tv_nsec = cur & ~I_CTIME_QUERIED; + cur_ts.tv_sec = inode->i_ctime_sec; + + /* If the update is older than the existing value, skip it. */ + if (timespec64_compare(&update, &cur_ts) <= 0) + return cur_ts; + + ktime_get_coarse_real_ts64_mg(&now); + + /* Clamp the update to "now" if it's in the future */ + if (timespec64_compare(&update, &now) > 0) + update = now; + + update = timestamp_truncate(update, inode); + + /* No need to update if the values are already the same */ + if (timespec64_equal(&update, &cur_ts)) + return cur_ts; + + /* + * Try to swap the nsec value into place. If it fails, that means + * we raced with an update due to a write or similar activity. That + * stamp takes precedence, so just skip the update. + */ +retry: + old = cur; + if (try_cmpxchg(&inode->i_ctime_nsec, &cur, update.tv_nsec)) { + inode->i_ctime_sec = update.tv_sec; + mgtime_counter_inc(mg_ctime_swaps); + return update; + } + + /* + * 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 (!(old & I_CTIME_QUERIED) && (cur == (old | I_CTIME_QUERIED))) + goto retry; + + /* Otherwise, it was a new timestamp. */ + cur_ts.tv_sec = inode->i_ctime_sec; + cur_ts.tv_nsec = cur & ~I_CTIME_QUERIED; + return cur_ts; +} +EXPORT_SYMBOL(inode_set_ctime_deleg); + /** * in_group_or_capable - check whether caller is CAP_FSETID privileged * @idmap: idmap of the mount @inode was found from diff --git a/include/linux/fs.h b/include/linux/fs.h index eff688e75f2f..ea7ed437d2b1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1544,6 +1544,8 @@ static inline bool fsuidgid_has_mapping(struct super_block *sb, struct timespec64 current_time(struct inode *inode); struct timespec64 inode_set_ctime_current(struct inode *inode); +struct timespec64 inode_set_ctime_deleg(struct inode *inode, + struct timespec64 update); static inline time64_t inode_get_atime_sec(const struct inode *inode) { From patchwork Sat Sep 14 17:07:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13804445 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 DE963C021A8 for ; Sat, 14 Sep 2024 17:07:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50CFA6B0095; Sat, 14 Sep 2024 13:07:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4BA636B0096; Sat, 14 Sep 2024 13:07:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E7096B0098; Sat, 14 Sep 2024 13:07:39 -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 0F9C16B0095 for ; Sat, 14 Sep 2024 13:07:39 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8E90480345 for ; Sat, 14 Sep 2024 17:07:38 +0000 (UTC) X-FDA: 82563975396.30.43433A2 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf16.hostedemail.com (Postfix) with ESMTP id D0394180004 for ; Sat, 14 Sep 2024 17:07:36 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VQYAuBes; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726333649; a=rsa-sha256; cv=none; b=GSgr2XlzG6sxk5vTekR8qW9Faki2nNYHEq5N8CUdB8Ocj3mgR1GM5XiUH4MYL3lR+QoeE8 3tCFK+JLWD5dgTGQng/nuKH+80J/AliTO3bhCAxQZ3xyMlUfA7xza8jkL7qrjFcUli4NhI tGU+VrDP3He+z/8wH/jOYtpdSlfsnVQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VQYAuBes; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 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=1726333649; 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=u1RALYhpZdRW0Rd8s8pxsrSUW3AL0efoUXL1ELbYrw4=; b=b3LRRtXoSCrJGpC7xctD1PQRhrDFyO4CDe03gKQyJx+naBWpKkU+ye3lUTy06SNgSaQ78U PzBMWXIDHTAAhd4Ei6gQBFNmN/baSzMLoc+80EjgxVDId5lVde+Ds7UGJzWYTwfV9qTB5A uLC/K2bYlYvEDEJQzYHnDXRlkfMlg5w= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 7D298A4015E; Sat, 14 Sep 2024 17:07:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BA65C4CECC; Sat, 14 Sep 2024 17:07:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726333655; bh=/dfE47m7K8nZA6bqMBlfXG7BPm8zSfwAyhiBp2lHZvM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VQYAuBesq56UQPycOVQYKukq5mJbQ9QK4E7WhdklLL7GlhgbMNKWmgah4QPT7IO2Z AHj8MRiXTcHSGOFaEZ7iTGLMQmiKQMcCJ86KBKkyLGFKQQqXeT3otFDPkGicHlZCfo 6OEyw4ujRtYlCEUbUxTjonLAIYcQHDNz13Rj0JyCKMxwsP6HtherPjsTMDVla2+XXJ lPRKe55XyWLGdPU+Bk6eFQOA4QiZiq4T6fmkCnH4HtdCn4nyCcxLQGNZaQewo01SHe Vtz+KmyeYvomaHHxZSNoNYLu6sM0gV0sVx8xgQCBQZvN4z2pl/A9Ab7LxHqDiznOHt VugKDAtQdg4uA== From: Jeff Layton Date: Sat, 14 Sep 2024 13:07:18 -0400 Subject: [PATCH v8 05/11] fs: tracepoints around multigrain timestamp events MIME-Version: 1.0 Message-Id: <20240914-mgtime-v8-5-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> In-Reply-To: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5947; i=jlayton@kernel.org; h=from:subject:message-id; bh=/dfE47m7K8nZA6bqMBlfXG7BPm8zSfwAyhiBp2lHZvM=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm5cLG5tHz6yHM6q5mnvpj1Gu54/Dx+ejg8C/Lo OL6Yjyr7tSJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZuXCxgAKCRAADmhBGVaC FSzSD/9C2MjL8co2O/piD/TweFTojMnHgr0m/BmN/ofQm9TCW/y8BD7awkt7HUezkDb1iYLdyB/ mH1mvdLoddXhzME0s6tZBboBr8tuz/5mdiAewdqeMI3/Y/f2Z7wpdfHIOKHTrOXiD16vaWUlFfd feaAqdR8hjYXciuRBcRJzcJwyvkISuZUJz03+s/w73WvTASj1Iev39akcCFpJg8XN5Tfyt8S8nR xjb2fSfXNYCBu79VlQ7RzjhRLMqMfugbbnq+9SaqYRL4OaLZS5WZVHobfdGzmhAZI8IcP9cKuaY cZKdb5UCzcQtBkl1vKL2Dz4S3HCP0v5jG/1r+5mzJ6RVndUnowSWfi6+WIXoqtWPKSftX+/BtRt QxZNMb3zlh4PRtBuryOdhk1zJUJ/Q3oKglc2vERC23EJV4FN3l7CFYsQ6xYSvFNqcAIJ8PBBRAJ 0zT2vceH51lrHWOfc/H3fWN48m14JtgQfiWogDrV+Bww7I/k7hfjhRMhoBoCssKOH6E+XkTZXIk seUqqYcXooLcs7NaQdxeis5R2B75CBMNIDLJphZy1Ejjw3gD8OJ2Alj8pt5tXONZfYHcIrFqdog UTFuATPPICaN0K1m0yUB4WQzG4e9XQBNd4jbaBDSGxH861ChDaqx4Bi+8sNDxWYxWj3lYqvy5a/ icz9mM/v5aV35AA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Stat-Signature: npx191gp861zzgft1hjccjypfntpqci5 X-Rspamd-Queue-Id: D0394180004 X-Rspamd-Server: rspam02 X-HE-Tag: 1726333656-151423 X-HE-Meta: U2FsdGVkX1/Sg6joVafUbyiVDo6ZU498Vh6ne886zcz1GgIvfM6OG7FKIQTlpAI5w0i8WRjzbT3kN8/GdrInRVKgcKcn5OxSK6JrLQ3jZaWhm2eHt6J0PHvNcpzc7CEmo6DxUs0ch5PAa1EoByOB55DvcTjiISgYsmXx7l5Y2oKCGFubit1azUhCr/yWOJywoJ4vMP95zROULZqBnrVhBmq4Rd8vUIOGoZ1gWOPeIXuChN1jepmmK56hkCmq3f5qhX8pzrumPC6j2fmk2JUyTXIck3b9BuCKNr7T7mblqLQrVWv+xRw16P3m7Vdct/U0ECpdHRSe0LLzydNw3CLH0eBAAtASmWLr7aFc5A9u6wyfDOwPxmMg/dtS4XmQiyThFCeaZrslmI6SawioyU17WEPGrkHCLlsRIsqNlk8FKHmyXTAhVyfEpJXLlPA5U0mhXcicoiV5+JsoKO5YFh2pUNTDJEEf+jESYpxWJCnF25NYWHfUD/z0g4okfM0uWlNtCvxZo9dUfvVVWgyRBQQl5SjpM0Amnjifmnjcc/y0wr162qEp5mvctRJ/Tfksu97RCJZ3jEYVkGCMVKKze78qm63NsQyhTHb0V7149ADCczaFb12kfviw1V0TDZ4WSNzyJGo78lnKOETX8G1DKKlHKlSgjTfeFeNB9SsvKwisSGy3QwQZ3aF4TpUW4OR4IaZCHAUCey8WRw6NhG/kxLKOboe7Lw2gA/iWve2IabrVZM99PUAu4OAkBS/0MZ7HFS5GtEKSClbmW+IYMs/l39AJrBFRwY4oHaavXKN+KDF8gn+YkVEy1of1FvZWOImtwm9DR9+BPgcwRKWjOGF9XfeZjbw1VEj09uqjVXAvu3UGNVibyqTJoD591kv9QdfGjk+UkBaKutVmC4Bp2JaGwv3PyJycDjyfi5OBvENUdsWnLkmalHi3uptLY4rSmqFb/aIOxBcum+rrCrhIZflRdHA h/tabU3m FjR5QXakxzXnWquFf51G8fUthzI8bVsJVUEotq9L+r7QJRkTSPHHGSu04tm+jQo7um6XQO7vazFKe+Ofq89nWjrVMQWY+Cstq43yW6We5M2J7v0Qf61aKOXCwu+Js8AhWOsDXMWWLDSw2HfPQTT8EZtyy9C9kcwrBvu08d/4jFdh3zAP4IJ62n/ITZNk/MnSj9e1/HFmm71iV0ykeU7+1H0uGjOZ/52V74s8k41pJpTcCo+hBnzWzL2S3yyZ/W7ICwOYJaTWBfPsgMBoBZG2slRWF0vy3K7zwvMuRGjy//Xgx+J8FEKhPtdTr+g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add some tracepoints around various multigrain timestamp events. Reviewed-by: Josef Bacik Reviewed-by: Darrick J. Wong Reviewed-by: Jan Kara Signed-off-by: Jeff Layton Reviewed-by: Steven Rostedt (Google) --- fs/inode.c | 9 ++- fs/stat.c | 3 + include/trace/events/timestamp.h | 124 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index 614d0402e9ad..d7da9d06921f 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -22,6 +22,9 @@ #include #include #include +#define CREATE_TRACE_POINTS +#include + #include "internal.h" /* @@ -2603,6 +2606,7 @@ EXPORT_SYMBOL(inode_nohighmem); struct timespec64 inode_set_ctime_to_ts(struct inode *inode, struct timespec64 ts) { + trace_inode_set_ctime_to_ts(inode, &ts); set_normalized_timespec64(&ts, ts.tv_sec, ts.tv_nsec); inode->i_ctime_sec = ts.tv_sec; inode->i_ctime_nsec = ts.tv_nsec; @@ -2687,14 +2691,17 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) } /* No need to cmpxchg if it's exactly the same */ - if (cns == now.tv_nsec && inode->i_ctime_sec == now.tv_sec) + if (cns == now.tv_nsec && inode->i_ctime_sec == now.tv_sec) { + trace_ctime_xchg_skip(inode, &now); goto out; + } cur = cns; retry: /* Try to swap the nsec value into place. */ if (try_cmpxchg(&inode->i_ctime_nsec, &cur, now.tv_nsec)) { /* If swap occurred, then we're (mostly) done */ inode->i_ctime_sec = now.tv_sec; + trace_ctime_ns_xchg(inode, cns, now.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 a449626fd460..9eb6d9b2d010 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -23,6 +23,8 @@ #include #include +#include + #include "internal.h" #include "mount.h" @@ -52,6 +54,7 @@ void fill_mg_cmtime(struct kstat *stat, u32 request_mask, struct inode *inode) if (!(stat->ctime.tv_nsec & I_CTIME_QUERIED)) stat->ctime.tv_nsec = ((u32)atomic_fetch_or(I_CTIME_QUERIED, pcn)); stat->ctime.tv_nsec &= ~I_CTIME_QUERIED; + trace_fill_mg_cmtime(inode, &stat->ctime, &stat->mtime); } EXPORT_SYMBOL(fill_mg_cmtime); diff --git a/include/trace/events/timestamp.h b/include/trace/events/timestamp.h new file mode 100644 index 000000000000..c9e5ec930054 --- /dev/null +++ b/include/trace/events/timestamp.h @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM timestamp + +#if !defined(_TRACE_TIMESTAMP_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_TIMESTAMP_H + +#include +#include + +#define CTIME_QUERIED_FLAGS \ + { I_CTIME_QUERIED, "Q" } + +DECLARE_EVENT_CLASS(ctime, + TP_PROTO(struct inode *inode, + struct timespec64 *ctime), + + TP_ARGS(inode, ctime), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(time64_t, ctime_s) + __field(u32, ctime_ns) + __field(u32, gen) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->gen = inode->i_generation; + __entry->ctime_s = ctime->tv_sec; + __entry->ctime_ns = ctime->tv_nsec; + ), + + TP_printk("ino=%d:%d:%ld:%u ctime=%lld.%u", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, __entry->gen, + __entry->ctime_s, __entry->ctime_ns + ) +); + +DEFINE_EVENT(ctime, inode_set_ctime_to_ts, + TP_PROTO(struct inode *inode, + struct timespec64 *ctime), + TP_ARGS(inode, ctime)); + +DEFINE_EVENT(ctime, ctime_xchg_skip, + TP_PROTO(struct inode *inode, + struct timespec64 *ctime), + TP_ARGS(inode, ctime)); + +TRACE_EVENT(ctime_ns_xchg, + TP_PROTO(struct inode *inode, + u32 old, + u32 new, + u32 cur), + + TP_ARGS(inode, old, new, cur), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(u32, gen) + __field(u32, old) + __field(u32, new) + __field(u32, cur) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->gen = inode->i_generation; + __entry->old = old; + __entry->new = new; + __entry->cur = cur; + ), + + TP_printk("ino=%d:%d:%ld:%u old=%u:%s new=%u cur=%u:%s", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, __entry->gen, + __entry->old & ~I_CTIME_QUERIED, + __print_flags(__entry->old & I_CTIME_QUERIED, "|", CTIME_QUERIED_FLAGS), + __entry->new, + __entry->cur & ~I_CTIME_QUERIED, + __print_flags(__entry->cur & I_CTIME_QUERIED, "|", CTIME_QUERIED_FLAGS) + ) +); + +TRACE_EVENT(fill_mg_cmtime, + TP_PROTO(struct inode *inode, + struct timespec64 *ctime, + struct timespec64 *mtime), + + TP_ARGS(inode, ctime, mtime), + + TP_STRUCT__entry( + __field(dev_t, dev) + __field(ino_t, ino) + __field(time64_t, ctime_s) + __field(time64_t, mtime_s) + __field(u32, ctime_ns) + __field(u32, mtime_ns) + __field(u32, gen) + ), + + TP_fast_assign( + __entry->dev = inode->i_sb->s_dev; + __entry->ino = inode->i_ino; + __entry->gen = inode->i_generation; + __entry->ctime_s = ctime->tv_sec; + __entry->mtime_s = mtime->tv_sec; + __entry->ctime_ns = ctime->tv_nsec; + __entry->mtime_ns = mtime->tv_nsec; + ), + + TP_printk("ino=%d:%d:%ld:%u ctime=%lld.%u mtime=%lld.%u", + MAJOR(__entry->dev), MINOR(__entry->dev), __entry->ino, __entry->gen, + __entry->ctime_s, __entry->ctime_ns, + __entry->mtime_s, __entry->mtime_ns + ) +); +#endif /* _TRACE_TIMESTAMP_H */ + +/* This part must be outside protection */ +#include From patchwork Sat Sep 14 17:07:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13804446 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 CA2C2C021A8 for ; Sat, 14 Sep 2024 17:07:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 557A06B0098; Sat, 14 Sep 2024 13:07:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 50BC26B0099; Sat, 14 Sep 2024 13:07:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 382626B009A; Sat, 14 Sep 2024 13:07:42 -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 185E46B0098 for ; Sat, 14 Sep 2024 13:07:42 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BEC301202D7 for ; Sat, 14 Sep 2024 17:07:41 +0000 (UTC) X-FDA: 82563975522.06.AB3C238 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id E6F9518000B for ; Sat, 14 Sep 2024 17:07:39 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aD+iHFXG; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf06.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=1726333630; a=rsa-sha256; cv=none; b=A/IGId1KL8sgi5stzd2GX/4SiPIW3pEVY+MFyFZ61aDry4cKO8OdmE1xyBcmteASXd2BUA 02qKmRSb1peUCGfUKhbzcsV8fpcDuLOfJioDa1XbdPgrTuovtk6yPOta8dkJUqFjDo6qyG o4Ui5x5aQBToQnEGruLx3/9goicYIzo= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aD+iHFXG; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf06.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=1726333630; 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=ytTjWQabmXcqMZ1/WbM+DKTFn8B+g+FrlQgvzv/+fbY=; b=Bun7V69RmXpR7BJ06Ds2zRK5F+378KWLKMlZ88+dneWIrHGix9afGmHFpq1AmAITkZfbzZ WiZ/gMy7Df6KP3J78FSADyX5+eyn97VHOtCewJAu1AC/8CIRcPwkA4SMFnAkL37bhvTgTp LQCqvVKDHSre5r/DkvBefag9i/mMJ60= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 61A425C0714; Sat, 14 Sep 2024 17:07:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20F96C4CECF; Sat, 14 Sep 2024 17:07:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726333658; bh=+3a+MvaEmr8jlVEnfUS/6TeXNgPVOZEguly4I5T5qLo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aD+iHFXGqA5JgGaTYLcJ4FNvOcGWpB4PW6RtlVSPpR24jd5+bFiFM7Pxh4qJ7JBu/ dYIJMiQoz4IGBxFkWI0inRm2+leKVKhkQPUsfiEYkIMZnGasQL+JLA9x0dgds+ULSU 6UHnPiF4cgMAYIHYTD397RggIVocHkt1rqfLCKDYAdercMlwkBqOrPnh4rMnVH2tv9 i2lBH38WJTEteBvsFxDp6mzkxg6PJ3Z5ju7h/GBfzNQsaAwis4exfZKYq5TQvOO4kz 5RJaBkotGU4z1xjOjBeeY3gXWZ4yC4qeDlfubsn5Bu1zr3Mq4cPE1xE/CqXo+y/PwG uwtpVpVM9zK1g== From: Jeff Layton Date: Sat, 14 Sep 2024 13:07:19 -0400 Subject: [PATCH v8 06/11] fs: add percpu counters for significant multigrain timestamp events MIME-Version: 1.0 Message-Id: <20240914-mgtime-v8-6-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> In-Reply-To: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=7206; i=jlayton@kernel.org; h=from:subject:message-id; bh=+3a+MvaEmr8jlVEnfUS/6TeXNgPVOZEguly4I5T5qLo=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm5cLGQYo9QregMNCy/xaR7pG6H/Plnuv5MCrll yGT7FFAkm2JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZuXCxgAKCRAADmhBGVaC FY4dEACQ30o7dm6/X64AG7zaEOxgddb96T6gDj8TDTuCswZDN4BXXzgQQ3pmW+k7IGGXxgoZv1L Ah6te+pdJPDzaY3XkddSkrAAGklFh7bDRhwz8fN8W003zQIHSMLCDPT1jMdThh8U6VYDLvstq3J fY/+GyscMLHjaven87xQGU7DXJdWqWRdXfEmP4iJzBOEWti/U/YEECZ9XLSs6OMyHAGH0VV2zZM v3RDk5ivfmR4OiifBN+dR6ycULQFIjHh29mfYZQZPpNiYK2ud1uLkRmmoAznFTlt73zas407QZ2 4uiaN9PsVyHOwcraYMC5K0NeXzKPC4bm4fbnkTQ/7tLTUJ2aoNAt2tcV0aXnLNNwZQegh23JyDh HAAnq1W0uM6cjxXT21V03epzC8gmaprBda2pT2QpiNz5yMawOu+8d7M8DqN6HfBbWbCT3JMmSsi qlx05niBKzs0E1YgjmAcUG5S1RsxE+ma0nGcxRXSq9q0NziRwTw82xxPxihZ/yaF8OVPWGZ45B8 lQjwUDqgHSkbJ2XLa1YdE0CeJXhcCqpYQux5mgJw0aWJV2aa1lJOvRxWhoX2MkKyMV268AtM/gd Q8nadX2GchrFtBB7Oe906n/rM7CnD+U0z7G0xGfbbZVDWb+4AdPB5Olj+iI9A9YEG7axNm6KMBJ VObT+RUdyFXPSzA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Queue-Id: E6F9518000B X-Rspamd-Server: rspam01 X-Stat-Signature: jr6okbt9oumzhmb7f4bgfescdqdw4h49 X-HE-Tag: 1726333659-580857 X-HE-Meta: U2FsdGVkX19dsgUWcowlgKSrEvwWuJEfccLnLPOkAqGY1FCoCKx1ehbcvgoF07wKp3uUgzULYthgSWS6OOcyNOUu7JlVBpRspnNGeYOVdVv8wVtr7fmFzpRgoegDwWjCl/+4jaBijOGTgnAUp+2Js572NAKE22cTrMtqfRD+vJ4cMR9DLgNpl1VBoKhAwqsuL7ZxBIk27yc/1W2x8r9hvpZBoXDQoY2d9l7KTVGreeREtOuAa3mg1V3hLj/GIVxu4PldyN8WO3AF2vPsWeioY9QTBxdmDmwHr0kSUIMXdVCxbxafAsZTHmUWgjkRtzhDxd0EFd+pwV9jiWGg/QMne18kMMABwfyE15oR0c9hASfj4sqI32yWMETC0xOG5LnSQkLbqwLX1/iCDSAIq4PmxBeHsoASVFMvhVSRbvz8k87CVI5MRxh9phPEhgyS62PFyp7JADokhajtylqWvxja05WmcfK0fzU/FuX28bBRqPs0o3Qaxb5OopaxXaFVWzmcRJD81cDC07Kok5qbW8oCPMf57CMLDYlEFw6mBhBN5ppM9Ea90mXRP23IhaMTaQyB42rTQ/GlNUm9FvzaucrDFiFjflJfzM0j8p7cSh5mD48Np3A2apQxVl0QJJIiRGaR4L5jQnVxFcMkL9q1Pj9IBvI5iXa4SPZdpynmLNV1GjAxg5SOZc/AUdH9YqvDgx16TyY8Gq2yAAJM/4Ex3HrT+kbqlo8J9XWBelaBakBEHyTX6KA9nifQV8qP2USUVI4vr3VeVhyoTNA3Vg9G1ZnzdphKK+GhKZMzPQwlK1rUe0RD2fCQsNr54yPgnshzVi3EaxdB6WxhxX1AkIaoIXRTdvu+KdloDoAi7VfpKxM+5q6XcoJvCeWAozfuDFoTkzzRFm/BkU9ZCZMABJXZB6uLBk93Lz5hrDb605xhKw3+m5hIMsq6IoT5K86uUtktHICthjW+L14fi2bJN8BPKx7 pgYGCp44 GTTD9pRSRyfrk5QgMS+NRWaDIRCjuBkkg/kTOLCj7YqmgQPPKnzDvOqJ6le5AQVzifSj1cjbGODe1Ex3pX26UWpzAie8SUrFo3rqm9SIhWqfWqaygbn00n/JuMoAEpPC2HGNXFGYRPSLKCaJYu/EhmU6kCQRHeSyFS5NqVBqNtJP2n6K9umuTGOAC/+7ODK2ZKD2Wl/t0gWdzeA3mDIbzo8xt0z5XGhXAia4pvrWBByXzKs0/7Fadgy3ZVl7lzr3q8QOe+1oTRY+PGDPnY6gCcE8Gs4xoJLRwI+gLEOh0IZ4/fBy7Ec2NbxWZpg== 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: New percpu counters for counting various stats around mgtimes, and a new debugfs file for displaying them when CONFIG_DEBUG_FS is enabled: - number of attempted ctime updates - number of successful i_ctime_nsec swaps - number of fine-grained timestamp fetches - number of coarse-grained floor swaps Reviewed-by: Josef Bacik Reviewed-by: Darrick J. Wong Reviewed-by: Jan Kara Signed-off-by: Jeff Layton --- fs/inode.c | 76 ++++++++++++++++++++++++++++++++++++-- include/linux/timekeeping.h | 1 + kernel/time/timekeeping.c | 3 +- kernel/time/timekeeping_debug.c | 12 ++++++ kernel/time/timekeeping_internal.h | 3 ++ 5 files changed, 90 insertions(+), 5 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index d7da9d06921f..1f0487104c71 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #define CREATE_TRACE_POINTS #include @@ -101,6 +103,70 @@ long get_nr_dirty_inodes(void) return nr_dirty > 0 ? nr_dirty : 0; } +#ifdef CONFIG_DEBUG_FS +static DEFINE_PER_CPU(long, mg_ctime_updates); +static DEFINE_PER_CPU(long, mg_fine_stamps); +static DEFINE_PER_CPU(long, mg_ctime_swaps); + +static long get_mg_ctime_updates(void) +{ + int i; + long sum = 0; + + for_each_possible_cpu(i) + sum += per_cpu(mg_ctime_updates, i); + return sum < 0 ? 0 : sum; +} + +static long get_mg_fine_stamps(void) +{ + int i; + long sum = 0; + + for_each_possible_cpu(i) + sum += per_cpu(mg_fine_stamps, i); + return sum < 0 ? 0 : sum; +} + +static long get_mg_ctime_swaps(void) +{ + int i; + long sum = 0; + + for_each_possible_cpu(i) + sum += per_cpu(mg_ctime_swaps, i); + return sum < 0 ? 0 : sum; +} + +#define mgtime_counter_inc(__var) this_cpu_inc(__var) + +static int mgts_show(struct seq_file *s, void *p) +{ + long ctime_updates = get_mg_ctime_updates(); + long ctime_swaps = get_mg_ctime_swaps(); + long fine_stamps = get_mg_fine_stamps(); + long floor_swaps = get_mg_floor_swaps(); + + seq_printf(s, "%ld %ld %ld %ld\n", + ctime_updates, ctime_swaps, fine_stamps, floor_swaps); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(mgts); + +static int __init mg_debugfs_init(void) +{ + debugfs_create_file("multigrain_timestamps", S_IFREG | S_IRUGO, NULL, NULL, &mgts_fops); + return 0; +} +late_initcall(mg_debugfs_init); + +#else /* ! CONFIG_DEBUG_FS */ + +#define mgtime_counter_inc() do { } while (0) + +#endif /* CONFIG_DEBUG_FS */ + /* * Handle nr_inode sysctl */ @@ -2655,10 +2721,9 @@ EXPORT_SYMBOL(timestamp_truncate); * * 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. + * get a fine-grained timestamp, then do so. After that, we try to swap the new + * value into i_ctime_nsec. We take the resulting ctime, regardless of the + * outcome of the swap. */ struct timespec64 inode_set_ctime_current(struct inode *inode) { @@ -2687,8 +2752,10 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) if (timespec64_compare(&now, &ctime) <= 0) { ktime_get_real_ts64_mg(&now); now = timestamp_truncate(now, inode); + mgtime_counter_inc(mg_fine_stamps); } } + mgtime_counter_inc(mg_ctime_updates); /* No need to cmpxchg if it's exactly the same */ if (cns == now.tv_nsec && inode->i_ctime_sec == now.tv_sec) { @@ -2702,6 +2769,7 @@ struct timespec64 inode_set_ctime_current(struct inode *inode) /* If swap occurred, then we're (mostly) done */ inode->i_ctime_sec = now.tv_sec; trace_ctime_ns_xchg(inode, cns, now.tv_nsec, cur); + mgtime_counter_inc(mg_ctime_swaps); } else { /* * Was the change due to someone marking the old ctime QUERIED? diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 7aa85246c183..b9c8c597a073 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -48,6 +48,7 @@ extern void ktime_get_coarse_real_ts64(struct timespec64 *ts); /* Multigrain timestamp interfaces */ extern void ktime_get_coarse_real_ts64_mg(struct timespec64 *ts); extern void ktime_get_real_ts64_mg(struct timespec64 *ts); +extern long get_mg_floor_swaps(void); void getboottime64(struct timespec64 *ts); diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 16937242b904..94b0219955a2 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -2440,7 +2440,7 @@ EXPORT_SYMBOL_GPL(ktime_get_coarse_real_ts64_mg); * regardless of the outcome of the swap. Note that this is a filesystem * specific interface and should be avoided outside of that context. */ -void ktime_get_real_ts64_mg(struct timespec64 *ts, u64 cookie) +void ktime_get_real_ts64_mg(struct timespec64 *ts) { struct timekeeper *tk = &tk_core.timekeeper; ktime_t old = atomic64_read(&mg_floor); @@ -2464,6 +2464,7 @@ void ktime_get_real_ts64_mg(struct timespec64 *ts, u64 cookie) if (atomic64_try_cmpxchg(&mg_floor, &old, mono)) { ts->tv_nsec = 0; timespec64_add_ns(ts, nsecs); + mgtime_counter_inc(mg_floor_swaps); } else { /* * Something has changed mg_floor since "old" was diff --git a/kernel/time/timekeeping_debug.c b/kernel/time/timekeeping_debug.c index b73e8850e58d..9a3792072762 100644 --- a/kernel/time/timekeeping_debug.c +++ b/kernel/time/timekeeping_debug.c @@ -17,6 +17,9 @@ #define NUM_BINS 32 +/* incremented every time mg_floor is updated */ +DEFINE_PER_CPU(long, mg_floor_swaps); + static unsigned int sleep_time_bin[NUM_BINS] = {0}; static int tk_debug_sleep_time_show(struct seq_file *s, void *data) @@ -53,3 +56,12 @@ void tk_debug_account_sleep_time(const struct timespec64 *t) (s64)t->tv_sec, t->tv_nsec / NSEC_PER_MSEC); } +long get_mg_floor_swaps(void) +{ + int i; + long sum = 0; + + for_each_possible_cpu(i) + sum += per_cpu(mg_floor_swaps, i); + return sum < 0 ? 0 : sum; +} diff --git a/kernel/time/timekeeping_internal.h b/kernel/time/timekeeping_internal.h index 4ca2787d1642..2b49332b45a5 100644 --- a/kernel/time/timekeeping_internal.h +++ b/kernel/time/timekeeping_internal.h @@ -11,8 +11,11 @@ */ #ifdef CONFIG_DEBUG_FS extern void tk_debug_account_sleep_time(const struct timespec64 *t); +DECLARE_PER_CPU(long, mg_floor_swaps); +#define mgtime_counter_inc(__var) this_cpu_inc(__var) #else #define tk_debug_account_sleep_time(x) +#define mgtime_counter_inc() do { } while (0) #endif #ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE From patchwork Sat Sep 14 17:07:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13804447 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 81B91C021A7 for ; Sat, 14 Sep 2024 17:07:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D21636B009A; Sat, 14 Sep 2024 13:07:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA91C6B009B; Sat, 14 Sep 2024 13:07:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFDF66B009C; Sat, 14 Sep 2024 13:07:44 -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 88EE36B009A for ; Sat, 14 Sep 2024 13:07:44 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 45D65A0463 for ; Sat, 14 Sep 2024 17:07:44 +0000 (UTC) X-FDA: 82563975648.22.FFCA48A Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf17.hostedemail.com (Postfix) with ESMTP id 8C8EE40006 for ; Sat, 14 Sep 2024 17:07:42 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=I6jXlekN; spf=pass (imf17.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726333555; 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=SiQULGejP9nqJpsq7GnKaT/oTe870RFoP8vBoy4vdC8=; b=Ut3SYgZjkB57Y+UCLBL8IhV66W8GWlZTbhLxt9jQyfy3bEzdiLR/449zVbl6AlcJ7/KVG0 vms85Lhv1ikDQ7ZiGkg8Y79Mi8DgUJYbtUBawSka6riOmDM+9aqSOSvjFwe3briaSpISb8 ZClG+oV/h4+rz0NF+vMzuv98/bafRo0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726333555; a=rsa-sha256; cv=none; b=WbKDuZtCn64zORrhNuqxSOe2FXnMnZad9ZXpWnVvngjVd7Mq+NaauAlN5w2JI8MCaaXjc6 A8bnGL0eK4b5MMN7YkETse3eheFupCHTqnkJVZ3oK0OKWEXT6IqnKJi4dW8TlwtEsl08Jv Da/2vpPRWasrgTiRPrT/mrNXLcOB5WQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=I6jXlekN; spf=pass (imf17.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 1F056A40136; Sat, 14 Sep 2024 17:07:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB481C4CECE; Sat, 14 Sep 2024 17:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726333661; bh=/XcZHkK5gYpUwCSVg7s3+A6XUqyCAQD/OQvh4jjSlT8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=I6jXlekNuZGCsp5NBpRYP0R+xcXpVQbTNaK6HMUBUnTRSpt1zMlwP9l28+OQQsA35 qDoXUcSjO+bpgtb+5Fwv7gteU9Nn3R0dTcshB0a9pD2k3fNQQcCNyEnuNQAPrPXCmS 9EPY65VWshQzrPwqy8HHc2coX7lK5lfDWBwZO4fBj5XPwwC/irwcLnoxz9nT+Ceopb obf3x/9tQr5KsfITxF8pANIEFJblk2cNow6RtJQgL5OpANFICZK2eSs5HLhO3srtMS 82TGmM5omjLC8ZyXKmCqqtVN0z4DPt4tz+4+9qZgV/GdqjganAwnPl2l2av7XZxMN5 Emi4PP3ARb5eg== From: Jeff Layton Date: Sat, 14 Sep 2024 13:07:20 -0400 Subject: [PATCH v8 07/11] Documentation: add a new file documenting multigrain timestamps MIME-Version: 1.0 Message-Id: <20240914-mgtime-v8-7-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> In-Reply-To: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=6998; i=jlayton@kernel.org; h=from:subject:message-id; bh=/XcZHkK5gYpUwCSVg7s3+A6XUqyCAQD/OQvh4jjSlT8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm5cLGJuuSb1xltFHpW0q8a+qitvGMUmowicsfj Rg/e3AZpXiJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZuXCxgAKCRAADmhBGVaC FWVQEADCr1Ju8Vg4w9iEuJQYTT5m4eUvccIiH6Wxe4xu7Bjjl7Esfa5BErRe/5Jzro90FFNT424 rEz4iPtm6aigGIR/RWKMg+HHvguntKiMPVorNF2LSPWDdD323OJYfux0/lhljniTqzGjYNxEJDD AyTSwsd+qaP99+L8AtMBC8VbvyBAM9M2d8I+U82Omh/FxBpuybHvs2KUh8Zqnom/ICx7y3131gx BUbpZN4gCpoP8yyUoB1+I8XnGs3Q4e4xU/3f3VMmHve1xpMr47XZ9aEuEpVQZ/6dyKTSTEkr5pd BW9VllFp5Xq0daBkYHXOVTJVR+5xX+GPkraB/JNTcJBRl8FQXnUXzbXHFottzpRseuCGkLnlhR5 /Oy1FspdD6sUlKvnyALimjvBu6vKZzqJRuYOxHLNI0HYiY3mnBwq8UTouZR515qw64HylfuCHIh tfNxxCNnfr86gANN4QXomTNmAzzBzvWGfD+V48xHvhRE4ESBjfQ1B2NFJyinNOYkBQfrRtVUUXP aCHXIgF0oFoiDt2e0nCQym4YsEt0Wxh5aSNJDdcA0Zs6srKCiIjbA1U7TgGCF+UXQ9QhBLeeAaw iGt7V2f/qfXuyfXskvDFLtFTHw84eXq55hkiuqqgZJ+i4cvgaOQ6/d6+K8qD98nF0fWuHreU9yx EBLPusAlWUknZNQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 8C8EE40006 X-Stat-Signature: cpe6dogeoizw5nzk6oxauu5ho8g3e694 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1726333662-646241 X-HE-Meta: U2FsdGVkX19N6ticbrHvDTE/cYPNQzp9FqhLy4/wJnOFsfaUzzGTdZOulLQoEtcovgXpEds4Kq9c7hgKpVGsZxEjAz0Sq+rq5wdZrKS/u+O+YHQU7xnp+e8M/p75JkYion0csWzE+hZVGIVLIbgIWcdve1C4guTnPnGQsdiYoiiRpxHdXSET5oBMdLk0JE2cmlooEX576ccoTNx2Qs5sRZNIqAPwn6mkFvtuqOocMhUXl+joX3Sy+wnbSk20YzIl4v7sSAb/xURrMvipEBqi7PXA96OhxP+zfl/GUqw3Us2QGoTguwEibVREbULSJfPdZzNpRKMiShp/ObDaAYbt3J/VGU0DjgYoMBpPmBG4w/dGuzQBTqSLqxQjQjS9cuqvGw5qYRncQdPYm7+uHTVP6IU+KuB7ZjXxWUmociOPVQMU7ouydSGIcJZ6GJexeYahdpUE55uktW/WV+1sodNXGPe/U6cdygr2ZV9+RHc8aow9C9ZGNyKZYvDZahxPJvnmo+JH9Uhsm9ExXTVClxj9IxRpAnBKQKdinNzyVJWSyyVKfmvFZi+J48pXDmY10sLfAy3YwijwXY9GCqFohMua9GZn5SmA/FYjidB+3KPFrqZDpSmw5ZVDRWLRChpIPX8Cp5fXPR+qiQCMvsfGqW8cuBHvXZiC6EZyXbN/pfgh0PbRO6tZHP1roXS4O4SRH/2RuFb2QArxiULhAwWp4Q2CdlPvYrm0KEwHxNkcw1xhj/zKm50AFsrupq/tEppKtSL2rlwWnueuAOb0s7OjBr5dHSoybzeuL+0qy9FFG18ijtUZm5kFP9xqwx5MsHHQDMEv+AhpwC+/m2NnvpH+bhsQUaw+FsKyhHH9oNpDo9RU3SpQnaEKRfyv5yxrbKpLYSFaQP1A8sXspxVfn7RnGNwjH5qXQU6/iSiPvioS2n7usX4LJCPswtZIYKa5fCpX/LXHUr8kfaP5lBsyxUGrDsW Ykz/ZCQP +1x+EZYvauM4kQ6YhwHNNy7csvVT68jGvQgjFECYsbOqzIqvddfU6pXdhp5soDdAxYca5/YeMfMY9ABqd4BmvUvyx6WPsWsqxHEOODbIPtYjCvJZE49CGXGUMbnlR3fMXO9oT572Xw0SO9Fr4w26bBjtEP5CaZeMdPZkiRmHEVU0Z2TU4JzNbo6a/11KZhEYcmxcy8ttHzn1esgOM99LqCE15dve7rW8+m9AYek+rQGP1Mh3JEvdgjc/uQK/mSbgL1H51zxfKlFSeQ1B9Ym62ZwgMydFueoFyE2ZPeG+xvPN45Ye2asqVWTPGbR3SFURQ7Ont0rqQ3YvecwgUyspDgU1a0EjrSIkaIdRi9oJocPs2suB5p2Gg2QcyDajjnAeVaM9VgBFF9BsGCAUjbUXGCruydz/WLZCFkhhwPzdF3PP9vS9OyXPYO2V2+9/Cm0BzkTDsgnqwBiaNPSK0dKQywyBMRxG8jnPoS2HeRQyoQR7ITvw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a high-level document that describes how multigrain timestamps work, rationale for them, and some info about implementation and tradeoffs. Reviewed-by: Josef Bacik Reviewed-by: Darrick J. Wong Reviewed-by: Randy Dunlap Reviewed-by: Jan Kara Signed-off-by: Jeff Layton --- Documentation/filesystems/index.rst | 1 + Documentation/filesystems/multigrain-ts.rst | 121 ++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) diff --git a/Documentation/filesystems/index.rst b/Documentation/filesystems/index.rst index e8e496d23e1d..44e9e77ffe0d 100644 --- a/Documentation/filesystems/index.rst +++ b/Documentation/filesystems/index.rst @@ -29,6 +29,7 @@ algorithms work. fiemap files locks + multigrain-ts mount_api quota seq_file diff --git a/Documentation/filesystems/multigrain-ts.rst b/Documentation/filesystems/multigrain-ts.rst new file mode 100644 index 000000000000..97877ab3d933 --- /dev/null +++ b/Documentation/filesystems/multigrain-ts.rst @@ -0,0 +1,121 @@ +.. 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 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 Timestamp Implementation +=================================== +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. For setattr, it should use setattr_copy() to update the +timestamps, or otherwise mimic its behavior. From patchwork Sat Sep 14 17:07:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13804448 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 6BD87C021A9 for ; Sat, 14 Sep 2024 17:07:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B74026B009C; Sat, 14 Sep 2024 13:07:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B29C16B009D; Sat, 14 Sep 2024 13:07:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B0976B009E; Sat, 14 Sep 2024 13:07:47 -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 67D326B009C for ; Sat, 14 Sep 2024 13:07:47 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1DC1EA7E08 for ; Sat, 14 Sep 2024 17:07:47 +0000 (UTC) X-FDA: 82563975774.15.C6C85CC Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf27.hostedemail.com (Postfix) with ESMTP id 60D4A40015 for ; Sat, 14 Sep 2024 17:07:45 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WWxcOHhP; spf=pass (imf27.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726333610; a=rsa-sha256; cv=none; b=MNnRNhHNsf6EBldZRdNGEnCqX76XNxHu33p6mZFtZsOlfK6mM7uCtFHv9rtGdBMFHe4RM5 lHPDnQk3qzsgB9NpTWYW5khiZQQFrA3Vn5nh/9XeA4N1tXRpi8BT7HRZXJBg9cd9m9IydU HomgRtOMOost3CTuc2vKXzPxVqEa8ws= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WWxcOHhP; spf=pass (imf27.hostedemail.com: domain of jlayton@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726333610; 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=u0Vjbqo4iOeknMWhkuNlxJFkRlockym8GpRmEYWtsK0=; b=Xdv5f7/0M66K54KcF/SjUOR6nKRWt1E3ovWcZukyyy8Myhy+xR3tQWgj46y21J91f4xsnL knCz8tEgOMW06TX7/0NhB1DTyHYEQT+RaXqhMYJvL8SblXVUy4aU83WUnisFhrsQwVvqfl Xdfmtl3LlkgqC74Q4O9VGN+cNIi9X4w= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id E9381A401D3; Sat, 14 Sep 2024 17:07:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD957C4CECF; Sat, 14 Sep 2024 17:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726333664; bh=bIaGrKHNkJGKwsIp2/9hx+nM5n7ktsZpZECPjECvfD4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WWxcOHhPNBbvQOZoVEbWbSYGiCVIBwokWxYhCZncCHYiJQcTFpwERaEcR4Wh0Xbn2 3xgKHnCdve6t5zipyFCFIIBbKMWVFc9FsCdvQlwXt0VN1K59PGcfWb0gtf66zVh9ku 4gWzO/Exl3YH/sNl8Z55iJKZqKHzfWBD/8d75G3/rPfif7e0K/HOcWPYvxm/rvB6z7 ynGJN/c23nHNOBswZWBCa0GrR4QQylZNz9jykfRjCvUNB3lAR92/VFZcvrBWVHvkFG cgl7qUvXIQhMBLNMBiIOTqlN2+HOEptvI6n7QQwrcqDYZie6g2r0gfXk8R9Qa2FNtn LNjg2zn+ZKxEQ== From: Jeff Layton Date: Sat, 14 Sep 2024 13:07:21 -0400 Subject: [PATCH v8 08/11] xfs: switch to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240914-mgtime-v8-8-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> In-Reply-To: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2942; i=jlayton@kernel.org; h=from:subject:message-id; bh=bIaGrKHNkJGKwsIp2/9hx+nM5n7ktsZpZECPjECvfD4=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm5cLGuWV9a+ING+mQgmsUefPyvxOtCZHhgbDyr h3WPzWE+SWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZuXCxgAKCRAADmhBGVaC Ff0ID/9dUQxrrNbqHpnaVnHsEUNWAcwDvm/Uzqz8JRH/iN4YRdGjThpIu7yEpdW72rihVUgzhdp MDDhOlQO5YqQqkgHr2CFKMZk6mr8pRtn85S+8NTVanoaK5CcKu+J3cM9B8uAhojNlwwLA08TIEg GarAOa/asTvsuyly/mkIWdl+B86IGn5U069ELYgegsSia8FaUxhSDP2aMn0ZXoP7yKsKU3iEGnY OKDmWJaL4kfYP5m+nQQcjCvXkSJY9Ek9EIZIErc5POHxebkpCVmS2EYzTeC7jcJsCpY0mK4euhj 05JoZnB5tDPT+Ct7GxZMu+oFKFfHk9kOG7cpt4wbXXB0V/eTid0mZdkeFy3Q6hzrgRxg+GoIJML nS4LFtcRuOl/hBIkH+gAMvbPxqQMHWj5xvEiFoJGKo1X48NfNJwzOids5R/ru8ztisjIxOWUIQ8 loAuC5LGF8DixJKgHNRS9S7Pf5fC/zOAJwTWbHc1WsnJ8jCSraBKi6yhlJaY2ky5i0OSdZJ6KAK tWQg7IgZtrxbNJuibvrXaOj8KBKky232I5TcB9IwV28ZFZiflP8071Ut5Gt8VEuoMan75ri60n2 R+g/WaoBLU5fySDEGF02y91KTtNV09R9oXBtC6oLh2HAY++rt9IZ6JzLzFbgWZCMyyI8/yQJwzq yRfbZfa50FD1bMA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Stat-Signature: aktt3c6pe1d5qfs57qjx8x6spu4i4ard X-Rspamd-Queue-Id: 60D4A40015 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1726333665-630093 X-HE-Meta: U2FsdGVkX19Rg1N++LMxV/2YsbPucSO4FQgXMzfICLBvgrMW+7lPiv3KvRh1wyDLTdVDSfsw5GKWdFdcIs4CmkNKGcjKeh4hARzSSfOX2CbxMUTxkKY6espiWplem4/xNw59e85IbfY5MryULFmaNFcAXx1vRsOnzoiJxHD/SdzvFk1CTaZnoOxtIUw8asLn71azfntEffjoq9MatHVqzMoYNALpV+G/9eizKh0kKk3SWVm8DnpLVnLBa1USVOspuTjVgcLaSqohEyXI/d+VWXsIdxutBmXi5+FqVz3sokZGTvRS7RKHUe9wCBNt6UPmP1u0JprYxCpwOf3pfRE5mlcuzV0Tng7NFW9XC7nXHw1rLdnBbq33+dFoIMOrH6/s2t4mezMeRGSbE1pgb5iUaUXq+Kd4XcodmDnjIp1sAKb3JOCTrUbM8TeEjJRSkhDmVBsBoRH68X8vn6mLzNROe0AQsytJVb7pWlw2Ku0e9gNheBg8LJC3FnTBlqTkvB6BxyjuGTA1TWp3hIx+ztZz+VT+Jj6PBdfoSXwtblcr20Adqzxmq5R/o8Lcxb0d7A72AsE0lAX9+kvIl6nZ8Zez7gpnT7UTR+EvOORJ74gsmnu0Dm3aBmKIBDLbIgD5fOXMQ7n4ePUUW6Z71aL2ZT+DwnBIDJEkHBQjt1nZub4saAU+XYR1ZB+58MuUihfzgeTN5o5yrZsV3ADbFAUvKxGaSO9f+metKhxtP2ypznGJrSnZ2uiwxZfNo20YLXQZnaX6BCm96uFtbhv06mtyt7QQRfce1M/VjRfhK7wMiIQkanQg9gLYYHUG+zii1njaePJUpXPIqTVOLg/zq7LXAPt1gzZaTTKfce8nmL18YH6f6w1hkY+MdkbAD/okE3Y19v4Dd/B6xcDoaist67mcvG2yStJ7ICe0G8ZZY2kI/vgg0T5/6g4lCgSBqSJ58WsVoVIjUYfqv60iw8cjn2N6YW4 0FkU2svr GLaiuu4IQfGVlMBCeoAwUvmR7xEdih8nntq3PXrLw04BWRZtaE4B4EtE2UEZLqXApoUv+ZmuZd6pCIosEm01mnpRXh7UaFcuoBipShcwZ9indqkEn1EuSRAdP66aO4QseJBYMOFoExze+2uAcmFGWaQ6yfpSkDgE46UlZxjL0o/mCIIzQMm8gC66wkuLrKUf/ahWWIJDXtbrM59SCykoCukFCxvVsQ9iyFBMoXocOqe58F7Lx0vRuwTLnnZSzPI7Dlou/O9UuXLPhvrgW6+zdwvI+EIMOERgR8UBoOEO00qi3XLUnuwN5kO5exX8xLWQDE/TlCV1wZZWGY4v2Qthk9AqcHSQ7L0aztj1qB+Y7RxnqCtkWnPVUnfIsh+aPScu9mGFn7tCBd9/hYiQYazCKzCBsfKTFyMAAxqBltAvX1SG/So0KO3GshZP6/g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. Also, anytime the mtime changes, the ctime must also change, and those are now the only two options for xfs_trans_ichgtime. Have that function unconditionally bump the ctime, and ASSERT that XFS_ICHGTIME_CHG is always set. Finally, stop setting STATX_CHANGE_COOKIE in getattr, since the ctime should give us better semantics now. Reviewed-by: Josef Bacik Reviewed-by: Darrick J. Wong 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 3c40f37e82c7..c962ad64b0c1 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_ACCESS) inode_set_atime_to_ts(inode, tv); if (flags & XFS_ICHGTIME_CREATE) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 1cdc8034f54d..a1c4a350a6db 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -597,8 +597,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)) { @@ -608,11 +609,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 Sat Sep 14 17:07:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13804449 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 55A9BC021A7 for ; Sat, 14 Sep 2024 17:07:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 977E76B009E; Sat, 14 Sep 2024 13:07:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 928216B009F; Sat, 14 Sep 2024 13:07:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 753296B00A0; Sat, 14 Sep 2024 13:07:50 -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 4E9F26B009E for ; Sat, 14 Sep 2024 13:07:50 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0604CC214D for ; Sat, 14 Sep 2024 17:07:50 +0000 (UTC) X-FDA: 82563975900.19.69B9308 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf27.hostedemail.com (Postfix) with ESMTP id 4920E40010 for ; Sat, 14 Sep 2024 17:07:48 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lG7KWITq; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf27.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=1726333661; a=rsa-sha256; cv=none; b=Pf9b+Y2oJsEdegWoy8i4eJz8dgRlnGPZwvS6sYEcjwAnKeQHgHTZQQrvK69Qyrn3WPyGv6 uYHaU8yBDpGUYxWUPPGKPSdkeTfO8bnsrq8nvSCLy62fUxoDqkvnIPPq3O/JiKUcPPMCsZ XhsWORpUPvNAQQ0gp5IllJJzqbGsc4k= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lG7KWITq; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf27.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=1726333661; 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=hZe0kX/JIW4s+r5H/kQadEO92KTCyt9IERXyJM9rmpc=; b=Oi3XC6/sc1F3dA7NwNqr0wsVGMVcbA0VVl+Wx3f7aXhpokBEhJdy5jhWLirIF5hpZkXlgz bciczCoivGp4EN+OXx36DTkvzNAxWUL6f7xoX6ZZ4NJTChyt1k9v2qpmvKFFyBRZ8gbH4P as6WdsDTbuixJBwkAg9j2V0l6REHs70= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D3AB65C5AC2; Sat, 14 Sep 2024 17:07:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91458C4CECE; Sat, 14 Sep 2024 17:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726333667; bh=Fd5IxgHtKcN7b8Mow1VZm20amle3gCRV/bljD+jCFMs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lG7KWITqZ0JTULqD7K9VNOzVeIcKW5pDUATUsN0srkR/FaTU34rCalh4fQLd0NiDz ayuWAUjH/b0F6+2dSPyidYV2vGekaNEFlst+DGGLDZJp9KDjfwEp7fFvmRbLLGpgXQ VKp25sywWngfmZlWl3znmMEZJ2xwbKrYa3+nQL+VkAIDTbthpmqHHGPh0xozWOzWA3 tdQLKrY/X3SFm2oYyzfnF6oETy80+BgJ1JlbjHE2pKOJGAY5EBgFE2vN7/MpyNIKib DxwIgODNV99Racaj1tVRZSo5DgF94J49k5zNoIAj9ZI+9aj+TWw8u/SluzXG2HZjNI dCovHd/yHMRbA== From: Jeff Layton Date: Sat, 14 Sep 2024 13:07:22 -0400 Subject: [PATCH v8 09/11] ext4: switch to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240914-mgtime-v8-9-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> In-Reply-To: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=926; i=jlayton@kernel.org; h=from:subject:message-id; bh=Fd5IxgHtKcN7b8Mow1VZm20amle3gCRV/bljD+jCFMs=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm5cLGaLrdQdloS9SHdXwjs/lx9Z+m43owb/WYh Ced8DtcfP2JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZuXCxgAKCRAADmhBGVaC Fdf/D/43c/84XJBxc2MJzrsOgo8VKaf8OhXukqOqa4RnPa4E5mj1ttGDtErs8lIQmzt45brcimw cxGf4byRL5N91O6Cv5PFmSlZiKV/MGMucjoc+YCRT6PPP+L14YxaP0mnxjK7DSxNPiEXtPytkk/ pMnbw41G5nHWCvJXaZnH2iV628zZgovKt9rGi05T+YvxjfYZhRRxZBc2r5q5OHsFYRlvlCFWnYh Uiy4soYIg6KZNopRh28NC75kVeKzbJm9OjYuSO8Eklbhbn1ew6n1TEudO25zyMSL1gimXSzU28o WXRf+DYyfpaWR1ZSCFRhYUvhslFN+gJ23qo7BwI3R1HmQmObfhuRUFPQGRRGq3YWfZkWTRoL+h8 ktSVEFwBZZ8jJw3ZyF18d2WM5rUZXtQTYj6ZjBfLq0viDaj+whmVXP5WKcyjqHNc8+9tf3IjRNM QICRarciWhavol197vxmJ9xwMm/whTgX6Zn90+/2JwlxsNNey+3aFRKKTJLC4rVZcwNnfPaOTbD 8D9w21RW913ovXTTJz61yn+MWHnrTlcjJ1Q3nWPY/XbvNQyXJoT5xrMBZ6ew2mhamHbgTC+jZvi +ZzebH+GhoqU0MBAOmPVX6nNE3BiL1nAq1UPunG3Vivc/vxhkn/LxCuFW/8esGLfkACeXqVNf7X aVUfw8gUCfn5HNw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Stat-Signature: qof5wdosycdx55w6cumbkxxsgxsyzs9i X-Rspamd-Queue-Id: 4920E40010 X-Rspamd-Server: rspam02 X-HE-Tag: 1726333668-880244 X-HE-Meta: U2FsdGVkX18pZKWIVeX10+GtjBNmVPuftMgKAr9lF+1P42ShdNke5xqVznUDxxWIp+xyv07fxQLHVjs9Nw95Fo36YPgF0uuLSz4bNYaPfYVxwb1ScBxmFzpGtocR5QZdcEA1A/PW8ymc1Sqcimkw/9upzNIYsL5oGv0jO5uVgSJnjTLPG5nNF6VsibPhxIGM/8RkWLwWFaH3Dfb+YdSJupZzaOJFyPNdhpcEqu5SSxjGDjbWxjWwXik4n65dDS39A8tbj01QF9DORE8+AZsUgoJMDJ1jUD/cXcUXa6CrwWz0T56gJSltAU49qB6SkcZlaFcLPNJWTyt2QaEaW5RLXxWF+CDyh0OYZXbTUpyzPT5KWDVuvSNMAXePRt0OWSziin58zyzurdyV4pCZi0DorzPTjmt0SR65zuGfbjGsW5IlBHsExpc5wgcoQu+F3WiOtWSSLyj8zjD32/KOC2aLAL25nMALPX4it4MCwcAPEwkACqFajVVHMhaQhSbgwrBsD+OtPTRGGKZblrxVT9fPBIcSYD/LhkYVcCgdSuHA7FhEyBvqelbguhI88vjxzTGW5WQTuOHxdSWCrnIATx58CTKno6/lacj33V4xmbhkxV5XgJJBbf2+jLRYS9+pAEwrekzug6kRSWb1mzQcmdD6+XUiPCqtWpk2rybCM3gTk9z+P+QG/RNDZeKc/0br331fGEbMGWMFnZx4Z5soYVmAjXAWxr/OASTWtT6iDSt2bCCW9CZ6+tU+140qidqjW4X+kzZQihiNRR6ZnbVHsvauk8Ocasj4zQOEXXKW3KyOC0h72kkJ03I/wd7AqWsBDnBTgPFiLoqM+5XpKoCGgaxdHyIoxkAFusmoH+LMbdAOut6DmxdrtimrORhJzo5okAM8AAHYkCdppzw89zF//yuTrx9AFTSbHLRxA0gYy3qeEmFjczR4ESXFKOUEpuzvNne+78D6xZUM673OlPJOap/ 3hp2z9V+ BGvL345PhUvN0d9wK/S+vPPmoUo5G0/52oskwJHybKUfxr82FCdjc99Q1f67Ch3ZxKgtgBKxLF1tgw/Bq7K6stZONg5qbrql3O1sDZBiHMIWstwHX4w7ri/Bg2A70434wo66FgigDUk2kCbf06gDO7dRJGJuM4bvmbw5H/d/n0BoiqWw3wxC+fJ/oCCqzkcRvuW5hDgTw3+5xzbrGj2rkt2jolXILdmUeYlu3CmUHbdaA5W2y58pnFnuKwev8my4AgLVbPWqPEc6gMdP0UuWopI2/WAbuckhUHocU2G54sj6eebZ0huhj/m1bwjUnDnhGNKlvaAYydQqdei60rFBwVDrP8+dKIwfiWYkcD0y7bEa6DdZ0hZNa9uxRgu6/dX5D4FQz+3qaTO9QQlGfkic091L2xtLrrTcSA+HhtfhAOZW9tQ4Rzxr8De5XORVwL9BByuLm X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. For ext4, we only need to enable the FS_MGTIME flag. Reviewed-by: Josef Bacik Reviewed-by: Jan Kara 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 e72145c4ae5a..a125d9435b8a 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -7298,7 +7298,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 Sat Sep 14 17:07:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13804450 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 22B95C021A7 for ; Sat, 14 Sep 2024 17:07:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50B986B00A0; Sat, 14 Sep 2024 13:07:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 494956B00A2; Sat, 14 Sep 2024 13:07:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30CCC6B00A3; Sat, 14 Sep 2024 13:07:53 -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 0B7686B00A0 for ; Sat, 14 Sep 2024 13:07:53 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BEEDEA99C3 for ; Sat, 14 Sep 2024 17:07:52 +0000 (UTC) X-FDA: 82563975984.23.CA5E941 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 09BD71C0008 for ; Sat, 14 Sep 2024 17:07:50 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OnsaXc9Y; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf18.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=1726333591; a=rsa-sha256; cv=none; b=ACJXz2iXkKR99HRYWArKYXjle0hYJQTMwoeaHIav0fEvx3bTFVAz3VQPLRP6wazNtbsThA 1CY5DmsBLYYj8nPV2BRBWF3CeR3mMWWIToZX2OOf4SSts0Zlpa9I0kHjoXuP00Y0Hct3CY 8pGtuMLQ5T8gj6qIfXgV5fuJoyVnYuA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OnsaXc9Y; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf18.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=1726333591; 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=2H4/vlHZRyTOK6xofuc69OL+vSngUgFvaslFJHzZIMo=; b=bebyTqeqsdTJ60InTBGIqqcE8FYzKqfS9U/7KHnMfxCt771x1IMlj+JIxpCrUm70v+0C1l WEn+E2uniGTpMdgADwV6oq+Hm1rxbZV0d8Mvj3asWS4+A/3kjgqjN5JaRz2GZw+ezMigHV aehJ8Z2wQTMfaIgw1+UREBYVgSc4PsE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9D1C65C5ACD; Sat, 14 Sep 2024 17:07:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64294C4CECF; Sat, 14 Sep 2024 17:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726333670; bh=gD0wNq7Gu5j1JVptVjT60GA5HV2tmuyZD0KoREfuUWw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OnsaXc9Ymk3RYfHMoFlLfXvNdkNLPJT/nCCxRvBL04+CscVmYlVBuqxqN52CHdmZq rS++6tGhQj3jHFzyPbPjWZz60BE3gbH55x26rwO5tlfsF/Oy6ua//id7CsKu8XobYh XsyTGeKDPE9GQOa6pebLQ5hcvMqGTv743a/9EA7n6F578YF5ADhWllJWaCFs3ahd94 4G7wC+3BmpbRo179YYT9jFBP1j7K283dTrDdRUb8SKm+hEJdqDm9Iw7LZTIXza9b4Y Hy2/y7j2vFxVnXRqpTxnXQF3KFr34hNAELx6wKUpGn5vJFSPI1OcEq4FIAOYgFVVja DUQfrqF54ZGDw== From: Jeff Layton Date: Sat, 14 Sep 2024 13:07:23 -0400 Subject: [PATCH v8 10/11] btrfs: convert to multigrain timestamps MIME-Version: 1.0 Message-Id: <20240914-mgtime-v8-10-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> In-Reply-To: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2660; i=jlayton@kernel.org; h=from:subject:message-id; bh=gD0wNq7Gu5j1JVptVjT60GA5HV2tmuyZD0KoREfuUWw=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm5cLGDFBDcopNy/21OHrXrCajnq3tvWydZqq9f oWLLLJG7hyJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZuXCxgAKCRAADmhBGVaC FbCsEADDSDCuLOkoBu17JJLTtSg9T7tYQSu30N5o6tKAz5hfYb3oqONtgrosynqevuMTPya4ygi j2u7OXW8FNsPhJbFFfD7RYKB1bha7dDz9BXy1qJep8KB06FA4/ZZKqGo9Rtfo/S564yYOmrMtD1 LCCfM9ZMexmEjLRbE/6qQk9LKHL4RUkw/Uus8ZQw0m4pti5eQVEsZMvIyqDEKhzySyvg0Xgaqds k4SDLA4lRPxKpMm+kTdJ3nhEGNPL6AL8lzF0lzeT8rtq6HnV951MCwIbBPnAcGzXZH11GFmSwGh /r/HxQsBLNwqwXFzB+lqbp9403WElBb+E0J9Sj/6zQf7jA3CicYASW4ojXLpgxzzZGeSAfs2lkz RrQ8mEhezpMeVrn+HaorHAqEH7FzMvYSGJNE+Mxss0+hqBH/sJ7kja46tMW+5rzZ0SwjmNuue2W 1WyYbsohvdObP6z6hREpQ1OO7D9VQ6QoH0lOnOWGF4re20/p1yp7uclcGu7qe6UgMDtWCpjetRo 2DKRnag68WIlLO/hcUlJpg7HRhzU+kIB0YTG61GKnVdydjW2GQJScOLK8PxJJczGuWiesH9seJk hJB65WmjibjgT8/tq+g5CPdXoKRvGkyDBcSWcFPDeyO7uFLuDqqAFFH5S/OVgK9syKPrMNpx+te xeyJbodV8Mp6iSg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Queue-Id: 09BD71C0008 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: r8qygiw7nciujps66mxbogm6sexb3z4g X-HE-Tag: 1726333670-644287 X-HE-Meta: U2FsdGVkX1+4ijqra6C2YSztWUKV0W+e7hFwdUFOiTRubw62Xjyjl7aTeU5lJreHK6u3wmi31eloaF2vLBSRqK0N14RNZgUFktQN6nqoudIWr4meYDjL2AYDsSQ3uMuwWZNkrFJRPV9NC8Jnnfq5E1q9H/i+WrYNVCxuBdioeXRoBQDNHykgLwQLz3WHUxZ2y0WWFcT4KPrMbbqyQl7TGbXqYEi98lmHJm+NjhWJLT38nNRdRXSe/5kR5oLbJt1SRdfPHi0kflpSWs95evqrdc94yWEKlwhFdezLfhxOP0IS3hVEAfU7AESIZCtCSZjeyrllbVdysE8jxPwvIgvheuSSaGQe34rZKFm8Kbzej12Gi1BsnG+MC0y/UQ2V2pqqZ9vf+XpVp4rhooag9/tRpoG6L1hKVQF5Od0dzAqzl3caNqY6aXldhJPOKfLqyjRc/O7jgSVDMq3s3eSnUzA06I4rUDfUbBmxlNSPBgIzpsEDo8PisqEiCc6M06+gQV71oQ/XPuyWfHYloGB6Xny/IOz6U6uPtSP0IFcuFER889PsxjTZYPAPytQw41Iq8FqOLHX2kZ8+QzlFV5ySZ3Uep3k6RsH/rYERTg10/7pFkWOxLeKmnQkWhpX84NJ3BNhdnvx+grnun7UV+9Yxc15nS8hmGMS3w9xzzqySuBUQdNhVweXL60HtJuMW8fSADErLk5jVNpaY7s33b0sooDW+UQC3NlzCDMifobS5VlaA1q+do0HAgOh/k7IBF70F+OWyHjuFfl4fQAKr524dgExQovnNT6gKr0Ziv5e6rJqTaKc9fWXhJ6TlhxRFSQIjDxVMQnrTB4BPOR26SNWOk0Vihydbn4H1WbUi0CSvxZZXRA1kfxRRkGlgc1mtY7SK5L+j7Db2kwb7T6TNiqwHV7dANb2LrQU3Qmkw35O/9i9k0lJ4uSHdN28RhPsia5ep1dFGvY0PECWcHqRjq+NznFD BfGcJJNH LPxDBqv/Hu5el4nZikpKnJJCniR7OYD5dn03vmhuWrA/DQwdrUtxLOQCDeqh+WdibZ38Rlui+G3BQDOSSAxZr3tvt2t7eJAyUN3n4Z6mObNFFrq6XedfWvMFg/28Fs9VdJs591RUdLgpY7sxHzWmWuK8d3Xuavhxv8KM9L5YdjMMH+7e6moifUOtOt1iHf4POmD2AUqxbJmk/2wRfe+HhT4oq62J2we8+HLT8r0CI2DkHVkUF9DqD108rPfkrYFfgBucvBjHo+ZU1KCK4pQS7XxsRz6MwGY8ISfmEXBH5RPFAdLNfqk2wUu7YMZWluv18tuWYMKhW+Lq6uBfiGzeUZI2b6KMAObqO6xUFMnzj1iGqNETbAk80Tbo0TcSbdpZYJ7zU7ZLS6x2IaxNxizfdeI8at4M/6ZxTO+idU8NMlS2qrj65Txxo/VrzzQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. Beyond enabling the FS_MGTIME flag, this patch eliminates update_time_for_write, which goes to great pains to avoid in-memory stores. Just have it overwrite the timestamps unconditionally. Note that this also drops the IS_I_VERSION check and unconditionally bumps the change attribute, since SB_I_VERSION is always set on btrfs. Reviewed-by: Josef Bacik Signed-off-by: Jeff Layton --- fs/btrfs/file.c | 25 ++++--------------------- fs/btrfs/super.c | 3 ++- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 2aeb8116549c..1656ad7498b8 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); -} - int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from, size_t count) { struct file *file = iocb->ki_filp; @@ -1170,7 +1150,10 @@ int btrfs_write_check(struct kiocb *iocb, struct iov_iter *from, size_t count) * 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 98fa0f382480..d423acfe11d0 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2198,7 +2198,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 Sat Sep 14 17:07:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13804451 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 2355CC021A8 for ; Sat, 14 Sep 2024 17:07:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4986C6B00A3; Sat, 14 Sep 2024 13:07:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4546D6B00A5; Sat, 14 Sep 2024 13:07:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 297CB6B00A4; Sat, 14 Sep 2024 13:07:56 -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 022B76B00A2 for ; Sat, 14 Sep 2024 13:07:55 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C0E0512023C for ; Sat, 14 Sep 2024 17:07:55 +0000 (UTC) X-FDA: 82563976110.01.FFA9085 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 04E6C20004 for ; Sat, 14 Sep 2024 17:07:53 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=R0wkJ2rw; spf=pass (imf03.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726333566; 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=DT6ZIHMqhAU8MCEAijaXVoegBM9DDV7WLOJvWqNOc8o=; b=dqGDllxhwKO4H4MjI9aI665z31pMXzSdknGtR0bdbSPvIjgjD2TdMP441CGbeEmcX7PNlc D4n22M9bWv3088Hduc4LpnL9ZqtIRTz+NizcbFhl3XiwRk5BDCoQ69EQxsyHMGcGjhTMWY NSIaUF0uwTUXCHp24PcNYipzV7bnKxM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726333566; a=rsa-sha256; cv=none; b=I43aCpOJmubhFceIerFxqaciBguqRaa5r8yF8z22fjFPmKMtqY2a65ksh1FxyqSnyelP3r S8uOtdWpRQoeDt1JBosZ2D0h688EW0Euvb4YZY4mwH3UHegFb0vLERAopelj8XhlpZocwE pPuGbNAR0Hg1wt6h/sXrUYe9Jskr240= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=R0wkJ2rw; spf=pass (imf03.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) 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 735DB5C0714; Sat, 14 Sep 2024 17:07:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3738DC4CECC; Sat, 14 Sep 2024 17:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726333672; bh=gE8r0Qbj4D8u7V9shLCLoJR+0WYqh7zAXrVYnVeHWEs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=R0wkJ2rwtbowlAve1guhZzLO89JBiB6wfkUI9wk3bplGqMCoTw9HGM4KS8fTDOshB FuZWd67kwt4rXUsO6CyB2+Ab6PMhi1ARNtC/t9cutBzZelr/O7diYk1RtBKLvbXFwj tFYMT7EBiTl4wyF3ptzVe8+gBbE4nobdO7AjF3pR/1ftAychS6wsoIDxrRWGG/ajRJ 8El2g5E5XmxrAyULWb6SehvjQWXEmUzvBqZFIwqsSMLoOvY0obrig7U5h2VflcZRPB hRzANQMSzmpqk6mhxGQh3iMgVDaA7LDTb/Cp6c6d3nZNG5jhWPSAOkjEbJx7IVPYfx liPdJfoPZ6GWw== From: Jeff Layton Date: Sat, 14 Sep 2024 13:07:24 -0400 Subject: [PATCH v8 11/11] tmpfs: add support for multigrain timestamps MIME-Version: 1.0 Message-Id: <20240914-mgtime-v8-11-5bd872330bed@kernel.org> References: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> In-Reply-To: <20240914-mgtime-v8-0-5bd872330bed@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Chandan Babu R , "Darrick J. Wong" , Theodore Ts'o , Andreas Dilger , Chris Mason , Josef Bacik , David Sterba , Hugh Dickins , Andrew Morton , Chuck Lever , Vadim Fedorenko Cc: Randy Dunlap , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Jeff Layton X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=862; i=jlayton@kernel.org; h=from:subject:message-id; bh=gE8r0Qbj4D8u7V9shLCLoJR+0WYqh7zAXrVYnVeHWEs=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm5cLG77OZfuwOGAG5Ly687wn48EdQFM4UuCpjV SX1+Zqe5KSJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZuXCxgAKCRAADmhBGVaC FfuLEAC3RtpxYP6q0t0xpB+5OwE31ZZoYfdisPWuC6dQLRBf3JPHoqiJI1tM3i2ks/CU726MZIK hrROc4CQsVRZrxvfgB3tCcL+TZFHq1469dvPTsHpldJ9POculR2FqNZaK07nhswJGDtwXp9KryG TXSExFmSv3iZAZqDa4RNy6DAuOb4nMchTbC/v+BhHmGES71T+aZMSfGP5kpvjDeTdI9WcIRtbgX rC34F9nBnt5pGNWL8wyImBu/GKNQYb5N6eaq7Yyv8eNLqtOlwEc4NRsrqSGcnWOxt32FpzMkP3i 8vXlw7NOtTM/uv4uG3Dvq8Gatg8/6EsknseTHtcNd77XEDGCf6pqTzZ+vfkg1v9GuomVqwDubWI 9UUBtVq9VcF59teol7/FyZoXiOigJ7wj/mCK6vzRepGszlCjC7Bi+j500YArHMd+322IG9y5EXe O8t6skl5tsxmALcyf4FPYk/fLSj5Fkx/H7fFWygBTxXDCrCAfbNMcmCqbOYyIY6rpY8JueiwWXB TTaoMNYhE2yNiwQNLRUg+4lRgBX5G18vQaYIvFbIgMw0Bdg80zssmKfdd6v9hTOlgzD9IoJM+p2 mvIvWO/A2NlUe2C+lWB3tkbElYUryFmwB6RZZNxpBq/egGr6D3hSxNiFV8m497rAIxKwUeqzIz9 YmSBRVn00Sho7OQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 04E6C20004 X-Stat-Signature: 4mi4k5y98o3bkcien9girm5q9o8df5ry X-HE-Tag: 1726333673-858346 X-HE-Meta: U2FsdGVkX1+tQiJgRKLgFb+0uyzRFL/wqvxlm7bqAEy4wM+EnAipqTtUIpcRysDIgKJv/hLAVxD40r/cMUZlw/sgbwiF+fEjo7sc5J/R809yv1pFFltrBW/qFJ5tCnNxjGgyev6xP+NZZFzcRFnfbZVcJDIFZHgwmkhgFoPf8sgKwiLygdPmKeNLaA/3NaJFEwW0QXYwoGhSrG70IDZeeEfGyE+kqMZ7cQkNx9w174lP7V36z0HLBsTG/t3GHiQWYMqjr2TyvvaHEQ3ho+3gmb/PoIpsR7Wsk5qW0LeONC8UcPS+n7JaIbcCU3hV3JFAGtBv7FC3/nH3/2yidtmhGEGZ++MWFQMuL+gBlRy48ofC+MIVM335rYZ9XNlEw0zCcvABkoC6nPENavN6TMsJLGpyIH16LT6O8x/a8urlMzdCidz20b5Pjmq8w+0fz6LYZLdT9tXpPB2Q7gEexQhG6NmmtXEfxMw3akLZKzliv0ttwuD/kbEBnrEgqbPWAEz0mAGCbJFUToNa0t0I9EP5Xup1kq0MDNSFnF9JjWJzBq3EBzzz3w32Fhn+W7ya2+ZuHoR0iJLSzIg3hdzL5UZwbKjwXYQBrJlc8FzQ5hKFUvLTFoIP5oXtsVksqaQ7LVBK1kuJezr7N/03TN20DG9/M2y3x3kw3AIk12aVpTcsh+5NCVzP2a7mpHtJ2uBRuE8juE36LBE3IgVBJVwnLo6z7CB+iJPC8VSYGfwTdXnu2T9dg489ixu6X6DdGlVs4JZ0jOLPqhn3a/dIuCMrXuUKdjpQu8BrmHIfnLHACZkBV/Dj/qLTfEjnk2ZQGZARkHsFGlVU+RUmat+FeRdJK2jWU6tqow3OkzHhPBt4aGMSk4+XieXeomtsbE2Rcoe4xaB5UH06r8l8c23yZ3e6MegEn27cqWL18et1t+ajckNUSnpgDqSgoCoCPjvhiZArTGlHy0YEw84IjmDLgbvmAeX eyXuoOIl +r1djPuWl+3Ah/8tJyFaZ6Cbi9R7U4DtEymgz/W73lCTYMTeUUgV6hhhdOPjvZ0r8G9Qz+DGVfgSIuzeYwmDRJMGUwLGMvFr1ZU8KG9KcdKya/JoU9SAwRtHNOcjrO+RQUB048o6b2qmVLyS2mOY1KSaVov1y0KbbXclL3h8EY7dSWPLVMzFCpPpNdFhJCUYG/6YeBmVhvVWaXcAjpRy2S2kwht2qr/1GpoU/jOSsCzl73ZMMfvgQQE3OUbGfqt5C7xzfJ5zmFlTheG9pkCIZ4So8kpwduzIHLn2eTLWoKncKBZpKlfjwURTusqbyTrUFWKCWl7dpu7kIxGkk5WX1Gqak2S7AsKYBU7ItpV/bLgQHreTJ/8tmton1IWOzZGfYqQDKU21Mbwbg5FVUjV/CCI2anCumhwl095QQUaUoMKf2Def+xxOQCz0k3QK8HRTKvIC1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Enable multigrain timestamps, which should ensure that there is an apparent change to the timestamp whenever it has been written after being actively observed via getattr. tmpfs only requires the FS_MGTIME flag. Reviewed-by: Josef Bacik Reviewed-by: Jan Kara 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 5a77acf6ac6a..5f17eaaa32e2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4804,7 +4804,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)