From patchwork Mon Apr 24 15:11:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13222303 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 C92A2C7EE20 for ; Mon, 24 Apr 2023 15:11:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDA526B0078; Mon, 24 Apr 2023 11:11:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B8AE06B007B; Mon, 24 Apr 2023 11:11:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2B196B007D; Mon, 24 Apr 2023 11:11:13 -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 9463C6B0078 for ; Mon, 24 Apr 2023 11:11:13 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 52B30A021C for ; Mon, 24 Apr 2023 15:11:13 +0000 (UTC) X-FDA: 80716622826.16.27A4AE6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 803354001E for ; Mon, 24 Apr 2023 15:11:11 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WbwjTOXj; spf=pass (imf01.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682349071; a=rsa-sha256; cv=none; b=SE7xns6Vd/d+39QB0sginCGBBlCdnk3evjo8+ocYmoMHfSc+PkD2Zvcmza+JJjTksy1RXN OW0R2Cu2htfWm8EhiBt6Ww8Kbbqw4/9OlCPlZ7aGKSwSHxaAawcuP0QSaaOItawWTly10Y koWP8tVjzM3eDTGGMHwL+u5II4F7G00= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WbwjTOXj; spf=pass (imf01.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682349071; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ubwlZTjWTEeqVjwTayO8O7kiOSnXxkyzeoSdvY797h0=; b=zUf5hZMMjSVKe81RfSJtwE1nRvxr9WIuiOKb3ewVLa8QgUrQVZYw7XDQkufG1uMtK+dFJQ SsQwjjCo+3D7nW6tp91ffAdp0QzaURaawWe/1ZA4y0E2C7tCJ2imqNlEBMWG3eKbfx4AdF jpoRMNlVIfYViATp9hERxZR6lJqhqV8= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 89860625CE; Mon, 24 Apr 2023 15:11:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4925C4339E; Mon, 24 Apr 2023 15:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682349070; bh=k2M9LEh7K33YqmYAvjSmt43fwT9vNRnPkHEMYoESVrw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WbwjTOXj6j4Z7IqqgUcwKWBEe7se7BityaoL5n8kCONOQFyyhdJLFsCkPnH/4aCll 8/v9P24+5T7yNJ85v7xY76DVsj1hZHjqtHagJ54P0ND4HN7kzhiZxUm64vTQJxZD/V 8O09xaRNauYkJvyCoQ8FEpxFFM3Rx6RAb0sEYgHCLu0Nj+oYHLIkXnbWaGOyH17Hz6 7ZCtWBvUgA6xS/vKAzS2qN6p4ir+qsMBRuqBgR01PmNrG/6BDpG3S9FzCfjdw8+hns +hJ8yDWXQnKXnkwver8+8m70uhn7KtYkdoFZiRmb+f6CZZfZ/i+ymETygYCQmTe0fS QHGW1lNmMZzTA== From: Jeff Layton To: Alexander Viro , Christian Brauner , "Darrick J. Wong" , Hugh Dickins , Andrew Morton , Dave Chinner , Chuck Lever Cc: Jan Kara , Amir Goldstein , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org Subject: [PATCH v2 1/3] fs: add infrastructure for multigrain inode i_m/ctime Date: Mon, 24 Apr 2023 11:11:02 -0400 Message-Id: <20230424151104.175456-2-jlayton@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230424151104.175456-1-jlayton@kernel.org> References: <20230424151104.175456-1-jlayton@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 803354001E X-Rspamd-Server: rspam01 X-Stat-Signature: f571u4ds38pnuxdttbhqoinjxni3kghc X-HE-Tag: 1682349071-90946 X-HE-Meta: U2FsdGVkX1847N9riu4nTCnoExrjfyPfgFdlRLLcTF5FkSDNSYcif2VS11JpHPrVMCirQXNKe9I2qK5dMlYzicv4cam3qWLNupYgg3cQocjq/7VkzgjJwmM1FzxWwdkqLjSa7Wa8Kg7YKHrShgzZr2SKbU6zIURHNSxiJjQj6x0mxJ2uJ797fC1uTglW0tAcKt194YT97Xit6G3fSXJtcdxU/qRPX/3lKp7N6oWUM3aMADip3PY0GSntua8xS6GDgZVae9cWv6mEyIZtdoOgnmQhYdVXzKZEQF56FRmO6UMxn5F8szLBGn5b2W6DIQEOsLJtlQriAL1kp3xATceQ0L5MUeqWXH6BEgX1EqGWea+3f/1OdspRG85HuShfJhIwfgAepIV5zSAgn8cYcfLxE6VlVd1lL8p2Ljn+2kyU9CZJhOX7/usxTYfr4kbIAt7F9yfyCPytFCVEsTjEGz4ns3ViM2979gR+iqOfuhPP8vPKla38lXFmOcBUgkGCYhlkESoLiYhHrk9DcQyEHFlS+3cwlkfOppNHd46ySvVAC0EUd0HWCRZe0GA9INnVG8viM7/GI++siiQ/oXlaiPBDMTE2DPKi+bOSyjIxeAa6yxP0RUZ0EFke/4zCJe+Pn8E758MbtBut8Fcl8Yv7FHFXBXCIGaJ83A4XWFLVtoe0CqwAodOmqveuRWIUetD6oMvRDPRyiYmROiqS/0ZGAi2hDU8JI06Y00cpl69DIrzjy19aYl7K8fVVJMv8L9IoTf4Bjn5hMsgekCQ+AdfBz+DR82I0eqzZy947fFoiMS5St3/IwX4hG3aFIrNYN+LfDYnIfoH8LiqV9O88xLDayElw87Z23KHzG/BJXv1vRY+Z9bX1Sj2+2nxPRrNC6Db8L9tn3swJRRpcpRvEhGUCtDXNfz8H/6HtRhtjEu6wqBCAaon1ufMO7gEPjtUzpgNh1LVF2UPSC0CXjTAPrWVvzmm s+HRvLME /YfsPjgzxsAzzDaFYQeMhVqIFq/ihtmu0vYy5FNPyEJZnzHb0slgzjR2xcX/PCFjHnulc7uDEBr1mvU7fSYAHZdVjckZKyOOsvtIRiD+lDgnF+smvC4lcrvux9t1ueYJgZtoT6GBAlMJdSBcrEKT7SxzlvAU6Q2e2i9BNeJOHkWMqyjknlj7E1RlXqW7uVqsr4O7wLbw3FTUnMS5PmhsLxahiRgmxBSXaUa3Mx9AgEmu0k64HobY4eK1GS8i5aX/Kci5y4L1rXGQWeS1C5AKAktfBCM62Fl32ZCk5FkAzUWY4QyO9mELqYUY2t0L0R8sCAU2MQNYfsAua6S/kqqmnY3eKXEUEzrHqts/ALx9PzXaozqJhGAPkSC+8TPrMwzJnqxv9 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: The VFS always uses coarse-grained timestamp updates for filling out the ctime and mtime after a change. This has the benefit of allowing filesystems to optimize away a lot metaupdates, to around once 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. 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 (e.g backup applications). Switching to always using fine-grained timestamps would improve the situation for NFS, but that becomes rather expensive, as the underlying filesystem will 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: Whenever the mtime changes, the ctime must also change since we're changing the metadata. When a superblock has a s_time_gran >1, we can use the lowest-order bit of the inode->i_ctime as a flag to indicate that the value has been queried. Then on the next write, we'll fetch a fine-grained timestamp instead of the usual coarse-grained one. We could enable this for any filesystem that has a s_time_gran >1, but for now, this patch adds a new SB_MULTIGRAIN_TS flag to allow filesystems to opt-in to this behavior. It then adds a new current_ctime function that acts like the current_time helper, but will conditionally grab fine-grained timestamps when the flag is set in the current ctime. Also, there is a new generic_fill_multigrain_cmtime for grabbing the c/mtime out of the inode and atomically marking the ctime as queried. Later patches will convert filesystems over to this new scheme. Signed-off-by: Jeff Layton --- fs/inode.c | 57 +++++++++++++++++++++++++++++++++++++++--- fs/stat.c | 24 ++++++++++++++++++ include/linux/fs.h | 62 ++++++++++++++++++++++++++++++++-------------- 3 files changed, 121 insertions(+), 22 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 4558dc2f1355..4bd11bdb46d4 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2030,6 +2030,7 @@ EXPORT_SYMBOL(file_remove_privs); static int inode_needs_update_time(struct inode *inode, struct timespec64 *now) { int sync_it = 0; + struct timespec64 ctime = inode->i_ctime; /* First try to exhaust all avenues to not sync */ if (IS_NOCMTIME(inode)) @@ -2038,7 +2039,9 @@ static int inode_needs_update_time(struct inode *inode, struct timespec64 *now) if (!timespec64_equal(&inode->i_mtime, now)) sync_it = S_MTIME; - if (!timespec64_equal(&inode->i_ctime, now)) + if (is_multigrain_ts(inode)) + ctime.tv_nsec &= ~I_CTIME_QUERIED; + if (!timespec64_equal(&ctime, now)) sync_it |= S_CTIME; if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode)) @@ -2062,6 +2065,50 @@ static int __file_update_time(struct file *file, struct timespec64 *now, return ret; } +/** + * current_ctime - Return FS time (possibly high-res) + * @inode: inode. + * + * Return the current time truncated to the time granularity supported by + * the fs, as suitable for a ctime/mtime change. + * + * For a multigrain timestamp, if the timestamp is flagged as having been + * QUERIED, then get a fine-grained timestamp. + */ +struct timespec64 current_ctime(struct inode *inode) +{ + struct timespec64 now; + long nsec = 0; + bool multigrain = is_multigrain_ts(inode); + + if (multigrain) { + atomic_long_t *pnsec = (atomic_long_t *)&inode->i_ctime.tv_nsec; + + nsec = atomic_long_fetch_and(~I_CTIME_QUERIED, pnsec); + } + + if (nsec & I_CTIME_QUERIED) { + ktime_get_real_ts64(&now); + } else { + ktime_get_coarse_real_ts64(&now); + + if (multigrain) { + /* + * If we've recently fetched a fine-grained timestamp + * then the coarse-grained one may be earlier than the + * existing one. Just keep the existing ctime if so. + */ + struct timespec64 ctime = inode->i_ctime; + + if (timespec64_compare(&ctime, &now) > 0) + now = ctime; + } + } + + return timestamp_truncate(now, inode); +} +EXPORT_SYMBOL(current_ctime); + /** * file_update_time - update mtime and ctime time * @file: file accessed @@ -2080,7 +2127,7 @@ int file_update_time(struct file *file) { int ret; struct inode *inode = file_inode(file); - struct timespec64 now = current_time(inode); + struct timespec64 now = current_ctime(inode); ret = inode_needs_update_time(inode, &now); if (ret <= 0) @@ -2109,7 +2156,7 @@ static int file_modified_flags(struct file *file, int flags) { int ret; struct inode *inode = file_inode(file); - struct timespec64 now = current_time(inode); + struct timespec64 now = current_ctime(inode); /* * Clear the security bits if the process is not being run by root. @@ -2419,9 +2466,11 @@ struct timespec64 timestamp_truncate(struct timespec64 t, struct inode *inode) if (unlikely(t.tv_sec == sb->s_time_max || t.tv_sec == sb->s_time_min)) t.tv_nsec = 0; - /* Avoid division in the common cases 1 ns and 1 s. */ + /* Avoid division in the common cases 1 ns, 2 ns and 1 s. */ if (gran == 1) ; /* nothing */ + else if (gran == 2) + t.tv_nsec &= ~1L; else if (gran == NSEC_PER_SEC) t.tv_nsec = 0; else if (gran > 1 && gran < NSEC_PER_SEC) diff --git a/fs/stat.c b/fs/stat.c index 7c238da22ef0..67b56daf9663 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -26,6 +26,30 @@ #include "internal.h" #include "mount.h" +/** + * generic_fill_multigrain_cmtime - Fill in the mtime and ctime and flag ctime as QUERIED + * @inode: inode from which to grab the c/mtime + * @stat: where to store the resulting values + * + * Given @inode, grab the ctime and mtime out if it and store the result + * in @stat. When fetching the value, flag it as queried so the next write + * will use a fine-grained timestamp. + */ +void generic_fill_multigrain_cmtime(struct inode *inode, struct kstat *stat) +{ + atomic_long_t *pnsec = (atomic_long_t *)&inode->i_ctime.tv_nsec; + + stat->mtime = inode->i_mtime; + stat->ctime.tv_sec = inode->i_ctime.tv_sec; + /* + * Atomically set the QUERIED flag and fetch the new value with + * the flag masked off. + */ + stat->ctime.tv_nsec = atomic_long_fetch_or(I_CTIME_QUERIED, pnsec) + & ~I_CTIME_QUERIED; +} +EXPORT_SYMBOL(generic_fill_multigrain_cmtime); + /** * generic_fillattr - Fill in the basic attributes from the inode struct * @idmap: idmap of the mount the inode was found from diff --git a/include/linux/fs.h b/include/linux/fs.h index c85916e9f7db..e6dd3ce051ef 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1059,21 +1059,22 @@ extern int send_sigurg(struct fown_struct *fown); * sb->s_flags. Note that these mirror the equivalent MS_* flags where * represented in both. */ -#define SB_RDONLY 1 /* Mount read-only */ -#define SB_NOSUID 2 /* Ignore suid and sgid bits */ -#define SB_NODEV 4 /* Disallow access to device special files */ -#define SB_NOEXEC 8 /* Disallow program execution */ -#define SB_SYNCHRONOUS 16 /* Writes are synced at once */ -#define SB_MANDLOCK 64 /* Allow mandatory locks on an FS */ -#define SB_DIRSYNC 128 /* Directory modifications are synchronous */ -#define SB_NOATIME 1024 /* Do not update access times. */ -#define SB_NODIRATIME 2048 /* Do not update directory access times */ -#define SB_SILENT 32768 -#define SB_POSIXACL (1<<16) /* VFS does not apply the umask */ -#define SB_INLINECRYPT (1<<17) /* Use blk-crypto for encrypted files */ -#define SB_KERNMOUNT (1<<22) /* this is a kern_mount call */ -#define SB_I_VERSION (1<<23) /* Update inode I_version field */ -#define SB_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */ +#define SB_RDONLY (1<<0) /* Mount read-only */ +#define SB_NOSUID (1<<1) /* Ignore suid and sgid bits */ +#define SB_NODEV (1<<2) /* Disallow access to device special files */ +#define SB_NOEXEC (1<<3) /* Disallow program execution */ +#define SB_SYNCHRONOUS (1<<4) /* Writes are synced at once */ +#define SB_MANDLOCK (1<<6) /* Allow mandatory locks on an FS */ +#define SB_DIRSYNC (1<<7) /* Directory modifications are synchronous */ +#define SB_NOATIME (1<<10) /* Do not update access times. */ +#define SB_NODIRATIME (1<<11) /* Do not update directory access times */ +#define SB_SILENT (1<<15) +#define SB_POSIXACL (1<<16) /* VFS does not apply the umask */ +#define SB_INLINECRYPT (1<<17) /* Use blk-crypto for encrypted files */ +#define SB_KERNMOUNT (1<<22) /* this is a kern_mount call */ +#define SB_I_VERSION (1<<23) /* Update inode I_version field */ +#define SB_MULTIGRAIN_TS (1<<24) /* Use multigrain c/mtimes */ +#define SB_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */ /* These sb flags are internal to the kernel */ #define SB_SUBMOUNT (1<<26) @@ -1457,7 +1458,8 @@ static inline bool fsuidgid_has_mapping(struct super_block *sb, kgid_has_mapping(fs_userns, kgid); } -extern struct timespec64 current_time(struct inode *inode); +struct timespec64 current_time(struct inode *inode); +struct timespec64 current_ctime(struct inode *inode); /* * Snapshotting support. @@ -2171,8 +2173,31 @@ enum file_time_flags { S_VERSION = 8, }; -extern bool atime_needs_update(const struct path *, struct inode *); -extern void touch_atime(const struct path *); +/* + * Multigrain timestamps + * + * Conditionally use fine-grained ctime and mtime timestamps + * + * When s_time_gran is >1, and SB_MULTIGRAIN_TS is set, use the lowest-order bit + * in the tv_nsec field as a flag to indicate that the value was recently queried + * and that the next update should use a fine-grained timestamp. + */ +#define I_CTIME_QUERIED 1L + +static inline bool is_multigrain_ts(struct inode *inode) +{ + struct super_block *sb = inode->i_sb; + + /* + * Warn if someone sets SB_MULTIGRAIN_TS, but doesn't turn down the ts + * granularity. + */ + return (sb->s_flags & SB_MULTIGRAIN_TS) && + !WARN_ON_ONCE(sb->s_time_gran == 1); +} + +bool atime_needs_update(const struct path *, struct inode *); +void touch_atime(const struct path *); int inode_update_time(struct inode *inode, struct timespec64 *time, int flags); static inline void file_accessed(struct file *file) @@ -2838,6 +2863,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 generic_fill_multigrain_cmtime(struct inode *inode, struct kstat *stat); void generic_fillattr(struct mnt_idmap *, struct inode *, struct kstat *); void generic_fill_statx_attr(struct inode *inode, struct kstat *stat); extern int vfs_getattr_nosec(const struct path *, struct kstat *, u32, unsigned int); From patchwork Mon Apr 24 15:11:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13222304 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 91F57C7EE22 for ; Mon, 24 Apr 2023 15:11:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54C556B007E; Mon, 24 Apr 2023 11:11:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FAA56B0080; Mon, 24 Apr 2023 11:11:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34EDE6B0081; Mon, 24 Apr 2023 11:11:15 -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 2114C6B007E for ; Mon, 24 Apr 2023 11:11:15 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D612B140255 for ; Mon, 24 Apr 2023 15:11:14 +0000 (UTC) X-FDA: 80716622868.24.F5A67E3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 0C0B314000B for ; Mon, 24 Apr 2023 15:11:12 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RCcnsNKq; spf=pass (imf09.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682349073; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Kbo9ZNiAf7/tMT1LpoE5F98CTclJG4BltSH6n6+BASw=; b=svrKsQgAiKmqF3KjaxB+RWQtU4ZFRpFvTKauuHKtmfAtF8XuSvZEzKSnV+ulcPqaLvV18x w7+uYqnyhb+1P3tjMYjlsjhwF3FMvmppD7TzPJa/hElU/ulzeZ8fLx+qaKV6wu9Hh5qew8 dO+eEytOeaEA1cOSLbf77V7X7a9l3+s= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RCcnsNKq; spf=pass (imf09.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682349073; a=rsa-sha256; cv=none; b=Nlh3kHn/98khHUOCtPGB5mCyEdRVQLLRMbc09ONFW6yUzfCt4QvRuAZhAvR6nAi648EZsp IKCXfeFaCaymVGY8F18OgN821wTY/B1OnlbniNM3SISypwK9UUimyVRNsqctImpeYraWSh jETfu3Z+x84o3DShvtVJazNbTWo5SSY= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 17ADB60F04; Mon, 24 Apr 2023 15:11:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39C69C4339C; Mon, 24 Apr 2023 15:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682349071; bh=LE5Eh9ovFKUm6KJZ5P5kcewXFLQQROg06eiUbScjjvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RCcnsNKq9Vn2vd/wl6VSl9MN7DxhyK8G1mY+jWZnjnryRrlkS0rhMKHuTSC3ri9t9 GQxDuTIz2MuB+V5MI3ipC9bH4+AGx2c73mWtBY3yRK/GVGUEa2PmUYLaTTj2lMw8SG j0jPJBWLWSDPqmUE3BOP/x7uSu+VcN1L+3xK3hRWQFrWYmXXhh3+oKPNOZKZLVgTIo xK2gVP60nWvtSHf9lcm4va0zxcLYoEm5MFZwe4cIDhVmMyyB85kQTwC+G9afH/AbHc PgGqDaBcW/XRkDUMVrLtsb2JXP2GhN+Gy7p1oLA2GH4Po1aVbgKCOcPtBY1C2nQ/nO C5bqLSvFz9HtQ== From: Jeff Layton To: Alexander Viro , Christian Brauner , "Darrick J. Wong" , Hugh Dickins , Andrew Morton , Dave Chinner , Chuck Lever Cc: Jan Kara , Amir Goldstein , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org Subject: [PATCH v2 2/3] shmem: mark for high-res timestamps on next update after getattr Date: Mon, 24 Apr 2023 11:11:03 -0400 Message-Id: <20230424151104.175456-3-jlayton@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230424151104.175456-1-jlayton@kernel.org> References: <20230424151104.175456-1-jlayton@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 9c6p6o7sh76ouskn7mk9wuh7hqmrbxw3 X-Rspam-User: X-Rspamd-Queue-Id: 0C0B314000B X-Rspamd-Server: rspam06 X-HE-Tag: 1682349072-421697 X-HE-Meta: U2FsdGVkX1/5u3xWgqzZwhslZE0lHzVKg0/s5exxEOaMZNo/2aJqjC+qfsxy1mhl+bg57kNRNIg7Sx4pq6z/+TgAtdcl2+a6t5lgMnZ09bqp23/X7ZrtNmgKlXdy/URINOAG8No0k8531gVhCfO8GndjvrtfXdXYZwL0Iqily2XPr6TOIsL0DxNmg3iGAvWPgfqRseS1yJFVs2YUmaCVzKW53WR5RW55DnoWgdbmgZepcwDRE76c85DenFYO60JOqjFV8jP/8GNbUeFGC1nypqLBn3CfWWaPQUAspFp2mXCqhhcgJCRyN1xavowe0ZwfIBXmRZGdZGg4zqsNXvPL3FFY27Q4ZEW+ifmO2wTZHdzx2c4b1v0SOrV3OW8HqxqZvor50sIzkNAux+JiYynISzBCJ/rfUDS+8SIPDLPdSe0cg3Kli23OOyagGHDCOvdu8vw3MKNBa52R2oTVHeshtthc/dX53qJjUgr3d/G58BBUrUOEksyJRdoJjgXfl7YLF2t+dj85TFghIJzpCRPTTivRiUhvc34os0N99dj1t3skRbK1iSLsOgKUa+JOoUpofpA0h/P0fYcj+JnUQUrjx9jAzHjdKj8ekxXycIov8fOKwC6rXg/sf7kk+j6grdgw39S0/xHiKVzy1lQ49O6qJK7x/188zLFAX3ehNzstLawe+k3yvekFr211RrTOIx0od43O8aqJzKDzFzuhDtuhdJUfvIp/ySxIg4cjjGBujYE0Yn7UE+tSst96I8LgK5you0UYT7P4qESp+yQu3cNrfEuG/Sdb4SptyJnE0cy0rp7Hu/lVskdyQz1JO67Fpvvkn4bXsiRPH1DxvkPpK5RIzX1R7b5j5b3RyJJg3a0BY4kd0fQ8kM5205Dtw50a55b009zrXb+ezPsKUTq+70KpAP6VkyzUrHOMEcs+roZyiluJ88CrC0EvWB0pYPJfJO5MYsb/rUuJIlhiE3LFNst LRn2xDqu VTtO2sSMyoNwRWVHb9K7a0I8CdOisSP4iygKMkGMYpkQN/CwGA9fKxT19rwrtWojlMYLCojciJt4vFcXEPIzUS4WADrXte3vc7cCPnsvKDRre1M1OLpwP+wVUPfmCk4X4IpQeQjL/EQJvVpwxKyeh4EXMpbjVw1gn2yZ/m0MKxwPuOVZOhUoaBTFCQcvG7uW7jgpHGl3c3vqD3Wofkx9FKwgbxq5sT7G/huS/HYvH8wlIGWtzR9CMLrByXYk+CtN/s7A9Y64W3EyAHYQQbuTisPUofsAlmxwAF3yqchmrwwWVLx8bDmRGP1/dSSUt7ELJaGBXHXRA1ETHCZcPMnTVBl+AoQ== 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: Change the s_time_gran for tmpfs to 2, to make it eligible to use the low order bit as a flag. Switch to the current_ctime helper instead of current_time. Signed-off-by: Jeff Layton --- mm/shmem.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 448f393d8ab2..497ffa29d172 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1039,7 +1039,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) { shmem_undo_range(inode, lstart, lend, false); - inode->i_ctime = inode->i_mtime = current_time(inode); + inode->i_ctime = inode->i_mtime = current_ctime(inode); inode_inc_iversion(inode); } EXPORT_SYMBOL_GPL(shmem_truncate_range); @@ -1070,6 +1070,11 @@ static int shmem_getattr(struct mnt_idmap *idmap, if (shmem_is_huge(inode, 0, false, NULL, 0)) stat->blksize = HPAGE_PMD_SIZE; + if (request_mask & (STATX_CTIME|STATX_MTIME)) + generic_fill_multigrain_cmtime(inode, stat); + else + stat->result_mask &= ~(STATX_CTIME|STATX_MTIME); + if (request_mask & STATX_BTIME) { stat->result_mask |= STATX_BTIME; stat->btime.tv_sec = info->i_crtime.tv_sec; @@ -1136,7 +1141,7 @@ static int shmem_setattr(struct mnt_idmap *idmap, if (attr->ia_valid & ATTR_MODE) error = posix_acl_chmod(idmap, dentry, inode->i_mode); if (!error && update_ctime) { - inode->i_ctime = current_time(inode); + inode->i_ctime = current_ctime(inode); if (update_mtime) inode->i_mtime = inode->i_ctime; inode_inc_iversion(inode); @@ -2361,7 +2366,7 @@ static struct inode *shmem_get_inode(struct mnt_idmap *idmap, struct super_block inode->i_ino = ino; inode_init_owner(idmap, inode, dir, mode); inode->i_blocks = 0; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); + inode->i_atime = inode->i_mtime = inode->i_ctime = current_ctime(inode); inode->i_generation = get_random_u32(); info = SHMEM_I(inode); memset(info, 0, (char *)inode - (char *)info); @@ -2940,7 +2945,7 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir, error = 0; dir->i_size += BOGO_DIRENT_SIZE; - dir->i_ctime = dir->i_mtime = current_time(dir); + dir->i_ctime = dir->i_mtime = current_ctime(dir); inode_inc_iversion(dir); d_instantiate(dentry, inode); dget(dentry); /* Extra count - pin the dentry in core */ @@ -3016,7 +3021,7 @@ static int shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentr } dir->i_size += BOGO_DIRENT_SIZE; - inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode); + inode->i_ctime = dir->i_ctime = dir->i_mtime = current_ctime(inode); inode_inc_iversion(dir); inc_nlink(inode); ihold(inode); /* New dentry reference */ @@ -3034,7 +3039,7 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry) shmem_free_inode(inode->i_sb); dir->i_size -= BOGO_DIRENT_SIZE; - inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode); + inode->i_ctime = dir->i_ctime = dir->i_mtime = current_ctime(inode); inode_inc_iversion(dir); drop_nlink(inode); dput(dentry); /* Undo the count from "create" - this does all the work */ @@ -3124,7 +3129,7 @@ static int shmem_rename2(struct mnt_idmap *idmap, new_dir->i_size += BOGO_DIRENT_SIZE; old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime = new_dir->i_mtime = - inode->i_ctime = current_time(old_dir); + inode->i_ctime = current_ctime(old_dir); inode_inc_iversion(old_dir); inode_inc_iversion(new_dir); return 0; @@ -3178,7 +3183,7 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir, folio_put(folio); } dir->i_size += BOGO_DIRENT_SIZE; - dir->i_ctime = dir->i_mtime = current_time(dir); + dir->i_ctime = dir->i_mtime = current_ctime(dir); inode_inc_iversion(dir); d_instantiate(dentry, inode); dget(dentry); @@ -3250,7 +3255,7 @@ static int shmem_fileattr_set(struct mnt_idmap *idmap, (fa->flags & SHMEM_FL_USER_MODIFIABLE); shmem_set_inode_flags(inode, info->fsflags); - inode->i_ctime = current_time(inode); + inode->i_ctime = current_ctime(inode); inode_inc_iversion(inode); return 0; } @@ -3320,7 +3325,7 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler, name = xattr_full_name(handler, name); err = simple_xattr_set(&info->xattrs, name, value, size, flags, NULL); if (!err) { - inode->i_ctime = current_time(inode); + inode->i_ctime = current_ctime(inode); inode_inc_iversion(inode); } return err; @@ -3786,7 +3791,7 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_flags |= SB_NOUSER; } sb->s_export_op = &shmem_export_ops; - sb->s_flags |= SB_NOSEC | SB_I_VERSION; + sb->s_flags |= SB_NOSEC | SB_I_VERSION | SB_MULTIGRAIN_TS; #else sb->s_flags |= SB_NOUSER; #endif @@ -3816,7 +3821,7 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_blocksize_bits = PAGE_SHIFT; sb->s_magic = TMPFS_MAGIC; sb->s_op = &shmem_ops; - sb->s_time_gran = 1; + sb->s_time_gran = 2; #ifdef CONFIG_TMPFS_XATTR sb->s_xattr = shmem_xattr_handlers; #endif From patchwork Mon Apr 24 15:11:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13222305 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 74A31C7EE25 for ; Mon, 24 Apr 2023 15:11:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E996E6B0080; Mon, 24 Apr 2023 11:11:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E49896B0081; Mon, 24 Apr 2023 11:11:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D124C6B0082; Mon, 24 Apr 2023 11:11:16 -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 B61B96B0080 for ; Mon, 24 Apr 2023 11:11:16 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8C9BBC0179 for ; Mon, 24 Apr 2023 15:11:16 +0000 (UTC) X-FDA: 80716622952.07.7DAF175 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 79AC940019 for ; Mon, 24 Apr 2023 15:11:14 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eGQWsqzI; spf=pass (imf12.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682349074; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TzgYZ8cOSbq7+L6azrtV8whYNwTMqPS5DBrD2YtmQs8=; b=yhif6md4j2BylQOgZfGzlcE4GRoIEcchvjsxvfePnAph5AK2JWyYWhtvNvQ50zNGeERZyg JPt0jnJDmIF8ZF5KH3SuJKq4ietry0fDOhrQacw7hneRtU0v85rRUpQ0cnVSRSiEfPWkbw O/gogQZRYqf8cBB3XwUw+lE9s0J3R2A= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eGQWsqzI; spf=pass (imf12.hostedemail.com: domain of jlayton@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682349074; a=rsa-sha256; cv=none; b=PklnnTJhruPiQ3RlHkVWJ/eJtpoa3JPdxeUKFHEiprqY+D3zzZs47gJMcmbnoDNnUrSxEI Lnyqe/4rpX4tkcDOesYi65onEVoe8XlNTxZwQJrNc5sO53t0xqytJuaQFfSMwJKLpoEYW3 JRdzHFdFuvFrv6emTqY2YItIW4ma0KQ= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A311F625ED; Mon, 24 Apr 2023 15:11:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C104DC433EF; Mon, 24 Apr 2023 15:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682349073; bh=CH5ETGl1VCk5J+tPCp/iNHJe4ToABvcdm5xjv9j3lBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eGQWsqzImKJ+8lpWetGzUbqVKVCqOyNDACZBvfubmDwpHAUKkWDsXk6wIc8LfJqaK nyLaJYE9kP1DiwLE8yaDX0eQraEuY6HWKq7r5Hl+BvOmqNN+F/w7jjvUIyotvhxmcc AJVuX2xkwrs7BQ/+8D1nH7+PqP0vMBxxrlILiu1rnTe8WBdUM7PrlmX14WU6IGGZVc r4s0mGlEBEyV3aQTHdCOSFpyCYTtCoG1k6sm2tQQfPTTcF+xOsdbflSU/ocxbICwO/ vXjykC6ZZq/0vC+9egeYOjg6yCY+jYo40zseLcQwn6hk0xmlQjWcJW5rNCfvHZp0fi I8ql5Fgb0amOg== From: Jeff Layton To: Alexander Viro , Christian Brauner , "Darrick J. Wong" , Hugh Dickins , Andrew Morton , Dave Chinner , Chuck Lever Cc: Jan Kara , Amir Goldstein , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org Subject: [PATCH v2 3/3] xfs: mark the inode for high-res timestamp update in getattr Date: Mon, 24 Apr 2023 11:11:04 -0400 Message-Id: <20230424151104.175456-4-jlayton@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230424151104.175456-1-jlayton@kernel.org> References: <20230424151104.175456-1-jlayton@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 79AC940019 X-Stat-Signature: rf6aowao5imuw3hfkdac1pe43r4hzjej X-HE-Tag: 1682349074-339423 X-HE-Meta: U2FsdGVkX1/Uj6yPzpdQafhi4Pal2mefk4XP0ZBCf6c60ji/rMy4qr1CzfBB1evAggJZQUgDS0q7Xo07KrfqK30G+HOE3kh15630mY739NYEwi0epCt+ulFbZw9MgApeStGGlLq9PfzGDQ9dUrOsphM7WPg9an5tVHu+pj7xmDnPq5weUnhLYUNzn7sR47AMMvcVLoFFjKRftlfa9dzXB/gT4A9rom0lPOHnKZAkQ0+hiFqNrfvIftE2la6QGNKV5cTxGxyKmLXrPfm+RthdbMKerGL+ICPLUlyZ8bk8YRif0vaAXcwkbCIycI+N1pB3la6pdeqdoqOtIllipTP7NLf5xiJWSMiLTPSzo/wvZQ3RakMPiUKd8AZFr1gBnRQkr5Cju2Y8HWKeyt1iFpG4sqJ3giRXn1o0Hzg+yrhoQ8RN67QYCfyIFmwPgYaqI6z3d3voroacgfzNUx5HnochIyN66fcolpntM7ywLZqMZNZn0p3H5d0FC0qRvJHIVUd+uC+0JjRKqVy8aZEG4ZR96OTeF1+N7yH6uxuKH7Z7ZhG63N4L5fCPCt0614LGvdmT5hUlR2QioIlQLre5T6Bn8hEFBe2f7lR873uTe1eLgGyELvd9ltjLmDQN8Pxtk/zLVcSZijeJcZTEBntHAF+dKokcu7FR3JK/vyf1zTFCalk05c7Z2RU92THI3/SogyCNi74XKkd8rSYXvD0hFyqe9tJXVAARVqu/Hl9VPj3LlbUBqOj0Z7NDKkjZhPObbGD1QdEZzRIpU71Ow94z6P3a1obHNJ9i1S+OcjYtzLxCHJp0dxKRnuHDx3WMHVoLc5iuX07xudKPZ2iyUFqbXLMEeP960JoITfXhgPWv1r5RMdlj5iIbIjhWcgB9Ls6MI7UEeDbNDfPICczOC5BLKOeIhbwuLEKKcTzwS/7B73rz80tA798eSs1STMoDw2AUGlHXt9Idsazu9OhDRUpcXmQ BPk8hLDv ORqVAOQOABZq86aorQoq2MTJKJ3eB3ma6kEPFhBlaIJWgExqPgXIXu/OpUwqnZwTtQ9ABT5x+ZMGQCd/ZMdBBXIX7V1HtN0LCb2lYV7eFGVf73lGDvavTLZdIADFRaUdL4r6K9fb9LL/wb++tqavOW8GUZofOb5+7aZjnBGJ7OTBuOlCJJXaPXAzqx9niWuMLk3/NY5TxfhfCpDcvPWKok8q877oMviheg+I7KB9X+aILB06CJ65lKZe3DymGkNzyX2xtyIbuskugkLoeFvVBa0LrfUgY483u1MRXsfj4XJ+qu6vReRD2tHntHrePhxHblQpF67QGrAfpIWP34QhJbiIU5Q== 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: When the mtime or ctime is being queried via getattr, ensure that we mark the inode for a high-res timestamp update on the next pass. Also, switch to current_cmtime for other c/mtime updates. Signed-off-by: Jeff Layton --- fs/xfs/libxfs/xfs_trans_inode.c | 2 +- fs/xfs/xfs_acl.c | 2 +- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_inode_item.c | 2 +- fs/xfs/xfs_iops.c | 9 ++++++--- fs/xfs/xfs_super.c | 5 ++++- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/fs/xfs/libxfs/xfs_trans_inode.c b/fs/xfs/libxfs/xfs_trans_inode.c index 8b5547073379..c08be3aa3339 100644 --- a/fs/xfs/libxfs/xfs_trans_inode.c +++ b/fs/xfs/libxfs/xfs_trans_inode.c @@ -63,7 +63,7 @@ xfs_trans_ichgtime( ASSERT(tp); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); - tv = current_time(inode); + tv = current_ctime(inode); if (flags & XFS_ICHGTIME_MOD) inode->i_mtime = tv; diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c index 791db7d9c849..85353e6e9004 100644 --- a/fs/xfs/xfs_acl.c +++ b/fs/xfs/xfs_acl.c @@ -233,7 +233,7 @@ xfs_acl_set_mode( xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); inode->i_mode = mode; - inode->i_ctime = current_time(inode); + inode->i_ctime = current_ctime(inode); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); if (xfs_has_wsync(mp)) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 5808abab786c..ac299c1a9838 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -843,7 +843,7 @@ xfs_init_new_inode( ip->i_df.if_nextents = 0; ASSERT(ip->i_nblocks == 0); - tv = current_time(inode); + tv = current_ctime(inode); inode->i_mtime = tv; inode->i_atime = tv; inode->i_ctime = tv; diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index ca2941ab6cbc..dc33f495f4fa 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -381,7 +381,7 @@ xfs_inode_to_log_dinode( memset(to->di_pad3, 0, sizeof(to->di_pad3)); to->di_atime = xfs_inode_to_log_dinode_ts(ip, inode->i_atime); to->di_mtime = xfs_inode_to_log_dinode_ts(ip, inode->i_mtime); - to->di_ctime = xfs_inode_to_log_dinode_ts(ip, inode->i_ctime); + to->di_ctime = xfs_inode_to_log_dinode_ts(ip, timestamp_truncate(inode->i_ctime, inode)); to->di_nlink = inode->i_nlink; to->di_gen = inode->i_generation; to->di_mode = inode->i_mode; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 24718adb3c16..b0490e46e825 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -573,8 +573,11 @@ xfs_vn_getattr( stat->gid = vfsgid_into_kgid(vfsgid); stat->ino = ip->i_ino; stat->atime = inode->i_atime; - stat->mtime = inode->i_mtime; - stat->ctime = inode->i_ctime; + if (request_mask & (STATX_MTIME|STATX_CTIME)) + generic_fill_multigrain_cmtime(inode, stat); + else + stat->result_mask &= ~(STATX_CTIME|STATX_MTIME); + stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks); if (xfs_has_v3inodes(mp)) { @@ -917,7 +920,7 @@ xfs_setattr_size( if (newsize != oldsize && !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) { iattr->ia_ctime = iattr->ia_mtime = - current_time(inode); + current_ctime(inode); iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME; } diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 4f814f9e12ab..ee9d0b43bf15 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1620,7 +1620,7 @@ xfs_fs_fill_super( sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1; sb->s_maxbytes = MAX_LFS_FILESIZE; sb->s_max_links = XFS_MAXLINK; - sb->s_time_gran = 1; + sb->s_time_gran = 2; if (xfs_has_bigtime(mp)) { sb->s_time_min = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MIN); sb->s_time_max = xfs_bigtime_to_unix(XFS_BIGTIME_TIME_MAX); @@ -1633,6 +1633,9 @@ xfs_fs_fill_super( set_posix_acl_flag(sb); + /* Enable multigrain timestamps */ + sb->s_flags |= SB_MULTIGRAIN_TS; + /* version 5 superblocks support inode version counters. */ if (xfs_has_crc(mp)) sb->s_flags |= SB_I_VERSION;