From patchwork Wed Oct 2 18:49:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13820253 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 3CB98CEACF3 for ; Wed, 2 Oct 2024 18:50:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFE424401C8; Wed, 2 Oct 2024 14:50:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BAF354401B5; Wed, 2 Oct 2024 14:50:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A02EA4401C8; Wed, 2 Oct 2024 14:50:03 -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 6D9CC4401B5 for ; Wed, 2 Oct 2024 14:50:03 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B443DC0E7A for ; Wed, 2 Oct 2024 18:50:02 +0000 (UTC) X-FDA: 82629551844.05.67B23B7 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf04.hostedemail.com (Postfix) with ESMTP id ECDEE40012 for ; Wed, 2 Oct 2024 18:49:59 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iELSDJpT; spf=pass (imf04.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=1727894829; 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=EAwD0uRlnn0xgT0nc2go2NDFad9ZqMytYxmnawQNvW4=; b=PcJijLNHP49+q+ZCohjM3pIDmNWLSipA+KcXP5SQt/ReLBQQ5ZKplTTJG+y7yVlhHfGe1/ ktiWgVtY3dQ/j6HLOFVaCsaiI/dP0Y94FHrlkd3DFL1MY0Jc7ZcoCTyNv9ebsmLxojcqdJ b9hetYbBaeb6mJgKyel+tb3vQbKU6A4= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iELSDJpT; spf=pass (imf04.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=1727894829; a=rsa-sha256; cv=none; b=xiqM4NVtOkL8kSDJEPLE/P5RKTPzFwGKXPxLhhV1XgHkuz8uY45USIFYZlYK+apT/1n6lR klJ2ol5B8yRc24CF41yzVv8LA1xkYJJjEn77pePK32Bkd5EaXB06KeV7wrWkRXjGMXwOIT R01kf/Lsc5UrpqFW910MRhZ6TlS0b78= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 140E8A427CA; Wed, 2 Oct 2024 18:49:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85498C4CED3; Wed, 2 Oct 2024 18:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727894998; bh=lWIeTtPiI+ai6qKZudnjNZrxKOAsE771WcfrcaA6eA8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=iELSDJpTc38MeEvbtdl0OEwL5LvjWHdrYtI745f7k+JXAdmWTmsxrHr5hKXyok1RF wga5wjJHQI32nCM/7NZ2ispr34lXDRw1sUix05NzEahfxdKxQPUGT0z1p23swc0tEQ olLV9uBSYc1x1qA1kB2Pys5a2icT4FVmZXY8IIZVdbmcRQq5UYHNk1lbubMxStHc6y qMAt+5njhyLEDY6iONNK7Sif2lZAQILkPAlcHwbDlRNzHj3ZMx87TdfYbzGuwjkjQ6 o+GhIcCf8eZrv+NYVTQVwG60vX1cCiahkA2+GpRTirkguohjDff91V31QGhyzm1HZP b0qRmI34RcXHw== From: Jeff Layton Date: Wed, 02 Oct 2024 14:49:30 -0400 Subject: [PATCH v9 02/12] fs: add infrastructure for multigrain timestamps MIME-Version: 1.0 Message-Id: <20241002-mgtime-v9-2-77e2baad57ac@kernel.org> References: <20241002-mgtime-v9-0-77e2baad57ac@kernel.org> In-Reply-To: <20241002-mgtime-v9-0-77e2baad57ac@kernel.org> To: John Stultz , Thomas Gleixner , Stephen Boyd , Alexander Viro , Christian Brauner , Jan Kara , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Randy Dunlap , 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: 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=13570; i=jlayton@kernel.org; h=from:subject:message-id; bh=lWIeTtPiI+ai6qKZudnjNZrxKOAsE771WcfrcaA6eA8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBm/ZXL/47kzw0EDS05DGJsTs28j/X5WO+L1olmN G6MLBUypBmJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZv2VywAKCRAADmhBGVaC FY8sEADAyOjzBxqMnCAy2kT/rpD8kGgBDEcNMxvkbaIDu7fqC95/2KJPMkV1cDVIuBVIPrOjUtA VDbJLgGkLMO466oEkCLtFdCNrY9fpL1RpOQOAk2Cg2+HQgPEVNqisV65UMz6CZD3OIOKd3qoUQy 4vqisKxk7Z9oxi4wW6mrV4lsUJBskJgzNjaA8yHWTjsQTxLlG+UkfcY7dhvQf/o9EvTzPpBu107 pf6F7SGEAOQHBp0IBWnJQ6MZ84PLfTxaNzR8Gne8kQgDcTs/kBtaiv9C2zuMIGsDdtqiJVeYG2n 2fuSVtaSCjclrfjGVAQbkwNyPYgL2j4CYhrqCo8y29WXniF/j8MWRUxMfIZSw+VlkvGv3/Gxux0 pSiFMaARqdjpOBRUTEeDHtoC1stA7Dt6X7n2yHeBiy/GCF5bXk5FIcQ57Ai+d9z66FtXCauGK51 BMFEO/41B5L3Y4+nKhpE6rQ9MlRhwGew5Hed2C4zeDpFU06Od7yaSCsAFYszkTAwxa8ELPn5osx iHMIrlfs79Scv1OI7GA+bX3kg+EFFAX7UTODmG364vjLvTN6tEXJDGZJfnaCojs7Xrw69oJe+PZ FMqcq7AAFgY0Bfvx4OXsO37lbKUHz1WQ+0WHLlUUBYxIjay8FCHokK7i01zTXoDfOOWX/49JaKu 43nXChnM6wpquaw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: ECDEE40012 X-Stat-Signature: xwb6gtszh5q3yqw9x95dmd4oueh18mbx X-Rspam-User: X-HE-Tag: 1727894999-541122 X-HE-Meta: U2FsdGVkX19PiHuXVvDVaLTPERqb6PkIAzu9nc803DHB8gK1nL63YJlkEWNn6v4irRSpUjbVRtkGrU1QPWCk43s+ppq2zX9mr+/7vmWP6Cc2tPAKcSpXWH6pRWyv3prvPmHabi4jOzMYccWCgV/Pui0KlUskdi+4sD+d8rR02H4SW1UiMnaLnWg3+eFBEdUMPhunsCn63N5lrNAJNUaXOJVutu7yxpx8lLyE23m0DII2BVfwrH8jTKP3lgv0bTKUhi6b8Jzfh0i6qMZFE+uVqI1q6qWtscDXQtm4iJETXBVvxPFZPCB4TCuS1rz+bZFKf3nVzOYFw3DZS+36HiZHQ3oJPSwf3QBsSoYEmsUuKATrLOoKYlrtDWrn919Rq2YA/A5omi89k8pWVHhh6ODCmOkTyas69VMIzQmx9oWl3GT0+YYr/boeBTDp4cUm0cHlYty0L1ai0RCrabJQB0Uu0pLh89ejzZ4YLOXiATA/6B1sRnXQLkahx7agAlo0InMviTY/B/ouIT1XndP8MdgG81kuw72yAA5YXHApscuaMviE+QrSae+Vc1o1BEKjvM19yfCnJc54681iNy9U/tcG6+s1yxoRyfwDMT/RyUec8Wa86ffudCpiOa+valFXrjPim+ytdjrvGxg9w5nlWT7pcmSYelVHRBpNWU5mgWHCAl99cgDKbtpSLSa+iUpbwmGt2LRuZLiQMnPWckwVqnPtdYih6oB5yZbIGYxQKEADp3uLyj505LuartahZD//7/kW9lcB1OeSLgeO+yE1dM4BMua5kEXhlFUlE6TbaF98CliBvHmwRZ4GOo9ZGfy+pwvUXYixF95I8uW6zi88yOhD+a7XwxG2+s5jczCEdFH8eVCzwNQl4yStYGJ4V1Tz0G2IWkZf+grm/4jREfQY6HEiApRBFvYrdelHOb/pf5vaQhu7PGMzcsKUPjDIdGKhVex8obBlNXnLjbCf07pHEdd rO5h7Jdm 0lRcGOTvm8de+xnSq+9f8/9kA2zUjWbvE9CLDPizug0z+ff0yaEC5/Km/1yirEBx6OvNoCmeI5ZdUrTnoEJuOMBJHyfk7/qSu83uDHHESwaJ5yh6il08Eupxkj5iVC4Px8PwuRTbInX7CJNZ17qF9T1jaX/CRfQthliACBPPYhWWEPxCf7GaG76WSPGl1F1PPhAWMikrekVxm0zluLiEBrL4QElTs+P062aU/cSjqh9jCLZGKkCAC/6xgBfNyKAtKk9vfW4N6a1R71e27W5UQKfSJwZAsMhKpEdXgoUPUOaUoSJu6thyTMuwJDw== 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 fine-grained timestamps were always used, that would improve the situation, but that becomes rather expensive, as the underlying filesystem would have to log a lot more metadata updates. What is needed 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, allow the update to use a fine-grained timestamp iff it's necessary to make the ctime show a different value. If it has been queried, then first see whether the current coarse time is later than the existing ctime. If it is, accept that value. If it isn't, then get a fine-grained timestamp and attempt to stamp the inode ctime with that value. If that races with another concurrent stamp, then abandon the update and take the new value without retrying. 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). Tested-by: Randy Dunlap # documentation bits Reviewed-by: Jan Kara Signed-off-by: Jeff Layton --- fs/inode.c | 139 +++++++++++++++++++++++++++++++++++++++++++---------- fs/stat.c | 43 ++++++++++++++++- include/linux/fs.h | 34 ++++++++++--- 3 files changed, 181 insertions(+), 35 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 10c4619faeef..53f56f6e1ff2 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,77 @@ 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 is already there. If so, then use that. Otherwise, get a + * fine-grained timestamp. + * + * After that, try to swap the new value into i_ctime_nsec. Accept the + * resulting ctime, regardless of the outcome of the swap. If it has + * already been replaced, then that timestamp is later than the earlier + * unacceptable one, and is thus acceptable. */ -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); + /* + * A fine-grained time is only needed if someone has queried + * for timestamps, 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..dd480bf51a2a 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -26,6 +26,39 @@ #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. + * + * NB: The QUERIED flag is tracked in the ctime, but we set it there even + * if only the mtime was requested, as that ensures that the next mtime + * change will be distinct. + */ +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 +91,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,