* [PATCH 01/11] fs: remove inode_update_time
2025-12-23 0:37 re-enable IOCB_NOWAIT writes to files v4 Christoph Hellwig
@ 2025-12-23 0:37 ` Christoph Hellwig
0 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2025-12-23 0:37 UTC (permalink / raw)
To: Christian Brauner
Cc: Al Viro, David Sterba, Jan Kara, Mike Marshall,
Martin Brandenburg, Carlos Maiolino, Stefan Roesch, Jeff Layton,
linux-kernel, linux-btrfs, linux-fsdevel, gfs2, io-uring, devel,
linux-unionfs, linux-mtd, linux-xfs, linux-nfs,
Chaitanya Kulkarni
The only external user is gone now, open code it in the two VFS
callers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
---
fs/inode.c | 23 ++++++++---------------
include/linux/fs.h | 1 -
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/fs/inode.c b/fs/inode.c
index 521383223d8a..07effa0cb999 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2157,19 +2157,6 @@ int generic_update_time(struct inode *inode, int flags)
}
EXPORT_SYMBOL(generic_update_time);
-/*
- * This does the actual work of updating an inodes time or version. Must have
- * had called mnt_want_write() before calling this.
- */
-int inode_update_time(struct inode *inode, int flags)
-{
- if (inode->i_op->update_time)
- return inode->i_op->update_time(inode, flags);
- generic_update_time(inode, flags);
- return 0;
-}
-EXPORT_SYMBOL(inode_update_time);
-
/**
* atime_needs_update - update the access time
* @path: the &struct path to update
@@ -2237,7 +2224,10 @@ void touch_atime(const struct path *path)
* We may also fail on filesystems that have the ability to make parts
* of the fs read only, e.g. subvolumes in Btrfs.
*/
- inode_update_time(inode, S_ATIME);
+ if (inode->i_op->update_time)
+ inode->i_op->update_time(inode, S_ATIME);
+ else
+ generic_update_time(inode, S_ATIME);
mnt_put_write_access(mnt);
skip_update:
sb_end_write(inode->i_sb);
@@ -2392,7 +2382,10 @@ static int file_update_time_flags(struct file *file, unsigned int flags)
if (mnt_get_write_access_file(file))
return 0;
- ret = inode_update_time(inode, sync_mode);
+ if (inode->i_op->update_time)
+ ret = inode->i_op->update_time(inode, sync_mode);
+ else
+ ret = generic_update_time(inode, sync_mode);
mnt_put_write_access_file(file);
return ret;
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f5c9cf28c4dc..ee623c16d835 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2246,7 +2246,6 @@ enum file_time_flags {
extern bool atime_needs_update(const struct path *, struct inode *);
extern void touch_atime(const struct path *);
-int inode_update_time(struct inode *inode, int flags);
static inline void file_accessed(struct file *file)
{
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* re-enable IOCB_NOWAIT writes to files v5
@ 2026-01-06 7:44 Christoph Hellwig
2026-01-06 7:44 ` [PATCH 01/11] fs: remove inode_update_time Christoph Hellwig
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Christoph Hellwig @ 2026-01-06 7:44 UTC (permalink / raw)
To: Christian Brauner
Cc: Al Viro, David Sterba, Jan Kara, Mike Marshall,
Martin Brandenburg, Carlos Maiolino, Stefan Roesch, Jeff Layton,
OGAWA Hirofumi, Trond Myklebust, Anna Schumaker, linux-kernel,
linux-btrfs, linux-fsdevel, gfs2, io-uring, devel, linux-unionfs,
linux-mtd, linux-xfs, linux-nfs
Hi all,
commit 66fa3cedf16a ("fs: Add async write file modification handling.")
effectively disabled IOCB_NOWAIT writes as timestamp updates currently
always require blocking, and the modern timestamp resolution means we
always update timestamps. This leads to a lot of context switches from
applications using io_uring to submit file writes, making it often worse
than using the legacy aio code that is not using IOCB_NOWAIT.
This series allows non-blocking updates for lazytime if the file system
supports it, and adds that support for XFS.
Changes since v4:
- replace the S_* flags with an enum indicating either access or
modification time updates to make the logic less fragile and to
fix a bug in the previous version
Changes since v3:
- fix was_dirty_time handling in __mark_inode_dirty for the racy flag
update case
- refactor inode_update_timestamps to make the lazytime vs blocking
logical more clear
- allow non-blocking timestamp updates for fat
Changes since v2:
- drop patches merged upstream
- adjust for the inode state accesors
- keep a check in __writeback_single_inode instead of exercising
potentially undefined behavior
- more spelling fixes
Changes since v1:
- more regular numbering of the S_* flags
- fix XFS to actually not block
- don't ignore the generic_update_time return value in
file_update_time_flags
- fix the sync_lazytime return value
- fix an out of data comment in btrfs
- fix a race that would update i_version before returning -EAGAIN in XFS
Diffstat:
Documentation/filesystems/locking.rst | 2
Documentation/filesystems/vfs.rst | 6 +
fs/btrfs/inode.c | 8 +-
fs/fs-writeback.c | 33 +++++++---
fs/gfs2/inode.c | 6 +
fs/inode.c | 111 +++++++++++++++++++++-------------
fs/internal.h | 3
fs/nfs/inode.c | 4 -
fs/orangefs/inode.c | 5 +
fs/overlayfs/inode.c | 2
fs/sync.c | 4 -
fs/ubifs/file.c | 13 ++-
fs/xfs/xfs_iops.c | 34 +++++++++-
fs/xfs/xfs_super.c | 29 --------
include/linux/fs.h | 27 ++++++--
include/trace/events/writeback.h | 6 -
16 files changed, 182 insertions(+), 111 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 01/11] fs: remove inode_update_time
2026-01-06 7:44 re-enable IOCB_NOWAIT writes to files v5 Christoph Hellwig
@ 2026-01-06 7:44 ` Christoph Hellwig
2026-01-06 7:44 ` [PATCH 02/11] fs: allow error returns from generic_update_time Christoph Hellwig
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2026-01-06 7:44 UTC (permalink / raw)
To: Christian Brauner
Cc: Al Viro, David Sterba, Jan Kara, Mike Marshall,
Martin Brandenburg, Carlos Maiolino, Stefan Roesch, Jeff Layton,
OGAWA Hirofumi, Trond Myklebust, Anna Schumaker, linux-kernel,
linux-btrfs, linux-fsdevel, gfs2, io-uring, devel, linux-unionfs,
linux-mtd, linux-xfs, linux-nfs, Chaitanya Kulkarni
The only external user is gone now, open code it in the two VFS
callers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
---
fs/inode.c | 23 ++++++++---------------
include/linux/fs.h | 1 -
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/fs/inode.c b/fs/inode.c
index 521383223d8a..07effa0cb999 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2157,19 +2157,6 @@ int generic_update_time(struct inode *inode, int flags)
}
EXPORT_SYMBOL(generic_update_time);
-/*
- * This does the actual work of updating an inodes time or version. Must have
- * had called mnt_want_write() before calling this.
- */
-int inode_update_time(struct inode *inode, int flags)
-{
- if (inode->i_op->update_time)
- return inode->i_op->update_time(inode, flags);
- generic_update_time(inode, flags);
- return 0;
-}
-EXPORT_SYMBOL(inode_update_time);
-
/**
* atime_needs_update - update the access time
* @path: the &struct path to update
@@ -2237,7 +2224,10 @@ void touch_atime(const struct path *path)
* We may also fail on filesystems that have the ability to make parts
* of the fs read only, e.g. subvolumes in Btrfs.
*/
- inode_update_time(inode, S_ATIME);
+ if (inode->i_op->update_time)
+ inode->i_op->update_time(inode, S_ATIME);
+ else
+ generic_update_time(inode, S_ATIME);
mnt_put_write_access(mnt);
skip_update:
sb_end_write(inode->i_sb);
@@ -2392,7 +2382,10 @@ static int file_update_time_flags(struct file *file, unsigned int flags)
if (mnt_get_write_access_file(file))
return 0;
- ret = inode_update_time(inode, sync_mode);
+ if (inode->i_op->update_time)
+ ret = inode->i_op->update_time(inode, sync_mode);
+ else
+ ret = generic_update_time(inode, sync_mode);
mnt_put_write_access_file(file);
return ret;
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f5c9cf28c4dc..ee623c16d835 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2246,7 +2246,6 @@ enum file_time_flags {
extern bool atime_needs_update(const struct path *, struct inode *);
extern void touch_atime(const struct path *);
-int inode_update_time(struct inode *inode, int flags);
static inline void file_accessed(struct file *file)
{
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 02/11] fs: allow error returns from generic_update_time
2026-01-06 7:44 re-enable IOCB_NOWAIT writes to files v5 Christoph Hellwig
2026-01-06 7:44 ` [PATCH 01/11] fs: remove inode_update_time Christoph Hellwig
@ 2026-01-06 7:44 ` Christoph Hellwig
2026-01-06 7:44 ` [PATCH 03/11] nfs: split nfs_update_timestamps Christoph Hellwig
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2026-01-06 7:44 UTC (permalink / raw)
To: Christian Brauner
Cc: Al Viro, David Sterba, Jan Kara, Mike Marshall,
Martin Brandenburg, Carlos Maiolino, Stefan Roesch, Jeff Layton,
OGAWA Hirofumi, Trond Myklebust, Anna Schumaker, linux-kernel,
linux-btrfs, linux-fsdevel, gfs2, io-uring, devel, linux-unionfs,
linux-mtd, linux-xfs, linux-nfs, Chaitanya Kulkarni
Now that no caller looks at the updated flags, switch generic_update_time
to the same calling convention as the ->update_time method and return 0
or a negative errno.
This prepares for adding non-blocking timestamp updates that could return
-EAGAIN.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
---
fs/gfs2/inode.c | 3 +--
fs/inode.c | 4 ++--
fs/ubifs/file.c | 6 ++----
fs/xfs/xfs_iops.c | 6 ++----
include/linux/fs.h | 2 +-
5 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 36618e353199..e08eb419347c 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -2257,8 +2257,7 @@ static int gfs2_update_time(struct inode *inode, int flags)
if (error)
return error;
}
- generic_update_time(inode, flags);
- return 0;
+ return generic_update_time(inode, flags);
}
static const struct inode_operations gfs2_file_iops = {
diff --git a/fs/inode.c b/fs/inode.c
index 07effa0cb999..7eb28dd45a5a 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2141,7 +2141,7 @@ EXPORT_SYMBOL(inode_update_timestamps);
* or S_VERSION need to be updated we attempt to update all three of them. S_ATIME
* updates can be handled done independently of the rest.
*
- * Returns a S_* mask indicating which fields were updated.
+ * Returns a negative error value on error, else 0.
*/
int generic_update_time(struct inode *inode, int flags)
{
@@ -2153,7 +2153,7 @@ int generic_update_time(struct inode *inode, int flags)
if (updated & S_VERSION)
dirty_flags |= I_DIRTY_SYNC;
__mark_inode_dirty(inode, dirty_flags);
- return updated;
+ return 0;
}
EXPORT_SYMBOL(generic_update_time);
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index c3265b8804f5..ec1bb9f43acc 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1379,10 +1379,8 @@ int ubifs_update_time(struct inode *inode, int flags)
.dirtied_ino_d = ALIGN(ui->data_len, 8) };
int err, release;
- if (!IS_ENABLED(CONFIG_UBIFS_ATIME_SUPPORT)) {
- generic_update_time(inode, flags);
- return 0;
- }
+ if (!IS_ENABLED(CONFIG_UBIFS_ATIME_SUPPORT))
+ return generic_update_time(inode, flags);
err = ubifs_budget_space(c, &req);
if (err)
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index ad94fbf55014..9dedb54e3cb0 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1197,10 +1197,8 @@ xfs_vn_update_time(
if (inode->i_sb->s_flags & SB_LAZYTIME) {
if (!((flags & S_VERSION) &&
- inode_maybe_inc_iversion(inode, false))) {
- generic_update_time(inode, flags);
- return 0;
- }
+ inode_maybe_inc_iversion(inode, false)))
+ return generic_update_time(inode, flags);
/* Capture the iversion update that just occurred */
log_flags |= XFS_ILOG_CORE;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index ee623c16d835..fccb0a38cb74 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2399,7 +2399,7 @@ extern void ihold(struct inode * inode);
extern void iput(struct inode *);
void iput_not_last(struct inode *);
int inode_update_timestamps(struct inode *inode, int flags);
-int generic_update_time(struct inode *, int);
+int generic_update_time(struct inode *inode, int flags);
/* /sys/fs */
extern struct kobject *fs_kobj;
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 03/11] nfs: split nfs_update_timestamps
2026-01-06 7:44 re-enable IOCB_NOWAIT writes to files v5 Christoph Hellwig
2026-01-06 7:44 ` [PATCH 01/11] fs: remove inode_update_time Christoph Hellwig
2026-01-06 7:44 ` [PATCH 02/11] fs: allow error returns from generic_update_time Christoph Hellwig
@ 2026-01-06 7:44 ` Christoph Hellwig
2026-01-06 7:44 ` [PATCH 04/11] fat: cleanup the flags for fat_truncate_time Christoph Hellwig
2026-01-06 7:54 ` re-enable IOCB_NOWAIT writes to files v5 Christoph Hellwig
4 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2026-01-06 7:44 UTC (permalink / raw)
To: Christian Brauner
Cc: Al Viro, David Sterba, Jan Kara, Mike Marshall,
Martin Brandenburg, Carlos Maiolino, Stefan Roesch, Jeff Layton,
OGAWA Hirofumi, Trond Myklebust, Anna Schumaker, linux-kernel,
linux-btrfs, linux-fsdevel, gfs2, io-uring, devel, linux-unionfs,
linux-mtd, linux-xfs, linux-nfs
The VFS paths update either the atime or ctime and mtime but never mix
between atime and the others. Split nfs_update_timestamps to match this
to prepare for cleaning up the VFS interfaces.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/nfs/inode.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 84049f3cd340..3be8ba7b98c5 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -669,35 +669,31 @@ static void nfs_set_timestamps_to_ts(struct inode *inode, struct iattr *attr)
NFS_I(inode)->cache_validity &= ~cache_flags;
}
-static void nfs_update_timestamps(struct inode *inode, unsigned int ia_valid)
+static void nfs_update_atime(struct inode *inode)
{
- enum file_time_flags time_flags = 0;
- unsigned int cache_flags = 0;
+ inode_update_timestamps(inode, S_ATIME);
+ NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_ATIME;
+}
- if (ia_valid & ATTR_MTIME) {
- time_flags |= S_MTIME | S_CTIME;
- cache_flags |= NFS_INO_INVALID_CTIME | NFS_INO_INVALID_MTIME;
- }
- if (ia_valid & ATTR_ATIME) {
- time_flags |= S_ATIME;
- cache_flags |= NFS_INO_INVALID_ATIME;
- }
- inode_update_timestamps(inode, time_flags);
- NFS_I(inode)->cache_validity &= ~cache_flags;
+static void nfs_update_mtime(struct inode *inode)
+{
+ inode_update_timestamps(inode, S_MTIME | S_CTIME);
+ NFS_I(inode)->cache_validity &=
+ ~(NFS_INO_INVALID_CTIME | NFS_INO_INVALID_MTIME);
}
void nfs_update_delegated_atime(struct inode *inode)
{
spin_lock(&inode->i_lock);
if (nfs_have_delegated_atime(inode))
- nfs_update_timestamps(inode, ATTR_ATIME);
+ nfs_update_atime(inode);
spin_unlock(&inode->i_lock);
}
void nfs_update_delegated_mtime_locked(struct inode *inode)
{
if (nfs_have_delegated_mtime(inode))
- nfs_update_timestamps(inode, ATTR_MTIME);
+ nfs_update_mtime(inode);
}
void nfs_update_delegated_mtime(struct inode *inode)
@@ -747,7 +743,10 @@ nfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
ATTR_ATIME|ATTR_ATIME_SET);
}
} else {
- nfs_update_timestamps(inode, attr->ia_valid);
+ if (attr->ia_valid & ATTR_MTIME)
+ nfs_update_mtime(inode);
+ if (attr->ia_valid & ATTR_ATIME)
+ nfs_update_atime(inode);
attr->ia_valid &= ~(ATTR_MTIME|ATTR_ATIME);
}
spin_unlock(&inode->i_lock);
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 04/11] fat: cleanup the flags for fat_truncate_time
2026-01-06 7:44 re-enable IOCB_NOWAIT writes to files v5 Christoph Hellwig
` (2 preceding siblings ...)
2026-01-06 7:44 ` [PATCH 03/11] nfs: split nfs_update_timestamps Christoph Hellwig
@ 2026-01-06 7:44 ` Christoph Hellwig
2026-01-06 7:54 ` re-enable IOCB_NOWAIT writes to files v5 Christoph Hellwig
4 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2026-01-06 7:44 UTC (permalink / raw)
To: Christian Brauner
Cc: Al Viro, David Sterba, Jan Kara, Mike Marshall,
Martin Brandenburg, Carlos Maiolino, Stefan Roesch, Jeff Layton,
OGAWA Hirofumi, Trond Myklebust, Anna Schumaker, linux-kernel,
linux-btrfs, linux-fsdevel, gfs2, io-uring, devel, linux-unionfs,
linux-mtd, linux-xfs, linux-nfs
Fat only has a single on-disk timestamp covering ctime and mtime. Add
fat-specific flags that indicate which timestamp fat_truncate_time should
update to make this more clear. This allows removing no-op
fat_truncate_time calls with the S_CTIME flag and prepares for removing
the S_* flags.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/fat/dir.c | 2 +-
fs/fat/fat.h | 8 ++++----
fs/fat/file.c | 14 ++++++--------
fs/fat/inode.c | 2 +-
fs/fat/misc.c | 39 ++++++++++++++++-----------------------
fs/fat/namei_msdos.c | 13 +++++--------
fs/fat/namei_vfat.c | 9 ++++-----
7 files changed, 37 insertions(+), 50 deletions(-)
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 92b091783966..3d03bff40944 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -1080,7 +1080,7 @@ int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo)
}
}
- fat_truncate_time(dir, NULL, S_ATIME|S_MTIME);
+ fat_truncate_time(dir, NULL, FAT_UPDATE_ATIME | FAT_UPDATE_CMTIME);
if (IS_DIRSYNC(dir))
(void)fat_sync_inode(dir);
else
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index d3e426de5f01..767b566b1cab 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -468,10 +468,10 @@ extern void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts,
__le16 *time, __le16 *date, u8 *time_cs);
extern struct timespec64 fat_truncate_atime(const struct msdos_sb_info *sbi,
const struct timespec64 *ts);
-extern struct timespec64 fat_truncate_mtime(const struct msdos_sb_info *sbi,
- const struct timespec64 *ts);
-extern int fat_truncate_time(struct inode *inode, struct timespec64 *now,
- int flags);
+#define FAT_UPDATE_ATIME (1u << 0)
+#define FAT_UPDATE_CMTIME (1u << 1)
+void fat_truncate_time(struct inode *inode, struct timespec64 *now,
+ unsigned int flags);
extern int fat_update_time(struct inode *inode, int flags);
extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs);
diff --git a/fs/fat/file.c b/fs/fat/file.c
index 4fc49a614fb8..f9bc93411aa2 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -224,7 +224,7 @@ static int fat_cont_expand(struct inode *inode, loff_t size)
if (err)
goto out;
- fat_truncate_time(inode, NULL, S_CTIME|S_MTIME);
+ fat_truncate_time(inode, NULL, FAT_UPDATE_CMTIME);
mark_inode_dirty(inode);
if (IS_SYNC(inode)) {
int err2;
@@ -327,7 +327,7 @@ static int fat_free(struct inode *inode, int skip)
MSDOS_I(inode)->i_logstart = 0;
}
MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
- fat_truncate_time(inode, NULL, S_CTIME|S_MTIME);
+ fat_truncate_time(inode, NULL, FAT_UPDATE_CMTIME);
if (wait) {
err = fat_sync_inode(inode);
if (err) {
@@ -553,15 +553,13 @@ int fat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
}
/*
- * setattr_copy can't truncate these appropriately, so we'll
- * copy them ourselves
+ * setattr_copy can't truncate these appropriately, so we'll copy them
+ * ourselves. See fat_truncate_time for the c/mtime logic on fat.
*/
if (attr->ia_valid & ATTR_ATIME)
- fat_truncate_time(inode, &attr->ia_atime, S_ATIME);
- if (attr->ia_valid & ATTR_CTIME)
- fat_truncate_time(inode, &attr->ia_ctime, S_CTIME);
+ fat_truncate_time(inode, &attr->ia_atime, FAT_UPDATE_ATIME);
if (attr->ia_valid & ATTR_MTIME)
- fat_truncate_time(inode, &attr->ia_mtime, S_MTIME);
+ fat_truncate_time(inode, &attr->ia_mtime, FAT_UPDATE_CMTIME);
attr->ia_valid &= ~(ATTR_ATIME|ATTR_CTIME|ATTR_MTIME);
setattr_copy(idmap, inode, attr);
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 0b6009cd1844..59fa90617b5b 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -246,7 +246,7 @@ static int fat_write_end(const struct kiocb *iocb,
if (err < len)
fat_write_failed(mapping, pos + len);
if (!(err < 0) && !(MSDOS_I(inode)->i_attrs & ATTR_ARCH)) {
- fat_truncate_time(inode, NULL, S_CTIME|S_MTIME);
+ fat_truncate_time(inode, NULL, FAT_UPDATE_CMTIME);
MSDOS_I(inode)->i_attrs |= ATTR_ARCH;
mark_inode_dirty(inode);
}
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index 950da09f0961..f4a1fa58bf05 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -299,43 +299,36 @@ struct timespec64 fat_truncate_atime(const struct msdos_sb_info *sbi,
}
/*
- * truncate mtime to 2 second granularity
- */
-struct timespec64 fat_truncate_mtime(const struct msdos_sb_info *sbi,
- const struct timespec64 *ts)
-{
- return fat_timespec64_trunc_2secs(*ts);
-}
-
-/*
- * truncate the various times with appropriate granularity:
- * all times in root node are always 0
+ * Update the in-inode atime and/or mtime after truncating the timestamp to the
+ * granularity. All timestamps in root inode are always 0.
+ *
+ * ctime and mtime share the same on-disk field, and should be identical in
+ * memory. All mtime updates will be applied to ctime, but ctime updates are
+ * ignored.
*/
-int fat_truncate_time(struct inode *inode, struct timespec64 *now, int flags)
+void fat_truncate_time(struct inode *inode, struct timespec64 *now,
+ unsigned int flags)
{
struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
struct timespec64 ts;
if (inode->i_ino == MSDOS_ROOT_INO)
- return 0;
+ return;
if (now == NULL) {
now = &ts;
ts = current_time(inode);
}
- if (flags & S_ATIME)
+ if (flags & FAT_UPDATE_ATIME)
inode_set_atime_to_ts(inode, fat_truncate_atime(sbi, now));
- /*
- * ctime and mtime share the same on-disk field, and should be
- * identical in memory. all mtime updates will be applied to ctime,
- * but ctime updates are ignored.
- */
- if (flags & S_MTIME)
- inode_set_mtime_to_ts(inode,
- inode_set_ctime_to_ts(inode, fat_truncate_mtime(sbi, now)));
+ if (flags & FAT_UPDATE_CMTIME) {
+ /* truncate mtime to 2 second granularity */
+ struct timespec64 mtime = fat_timespec64_trunc_2secs(*now);
- return 0;
+ inode_set_mtime_to_ts(inode, mtime);
+ inode_set_ctime_to_ts(inode, mtime);
+ }
}
EXPORT_SYMBOL_GPL(fat_truncate_time);
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 0b920ee40a7f..ba0152ed0810 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -251,7 +251,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
if (err)
return err;
- fat_truncate_time(dir, ts, S_CTIME|S_MTIME);
+ fat_truncate_time(dir, ts, FAT_UPDATE_CMTIME);
if (IS_DIRSYNC(dir))
(void)fat_sync_inode(dir);
else
@@ -295,7 +295,7 @@ static int msdos_create(struct mnt_idmap *idmap, struct inode *dir,
err = PTR_ERR(inode);
goto out;
}
- fat_truncate_time(inode, &ts, S_ATIME|S_CTIME|S_MTIME);
+ fat_truncate_time(inode, &ts, FAT_UPDATE_ATIME | FAT_UPDATE_CMTIME);
/* timestamp is already written, so mark_inode_dirty() is unneeded. */
d_instantiate(dentry, inode);
@@ -328,7 +328,6 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
drop_nlink(dir);
clear_nlink(inode);
- fat_truncate_time(inode, NULL, S_CTIME);
fat_detach(inode);
out:
mutex_unlock(&MSDOS_SB(sb)->s_lock);
@@ -382,7 +381,7 @@ static struct dentry *msdos_mkdir(struct mnt_idmap *idmap, struct inode *dir,
goto out;
}
set_nlink(inode, 2);
- fat_truncate_time(inode, &ts, S_ATIME|S_CTIME|S_MTIME);
+ fat_truncate_time(inode, &ts, FAT_UPDATE_ATIME | FAT_UPDATE_CMTIME);
/* timestamp is already written, so mark_inode_dirty() is unneeded. */
d_instantiate(dentry, inode);
@@ -415,7 +414,6 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry)
if (err)
goto out;
clear_nlink(inode);
- fat_truncate_time(inode, NULL, S_CTIME);
fat_detach(inode);
out:
mutex_unlock(&MSDOS_SB(sb)->s_lock);
@@ -480,7 +478,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
mark_inode_dirty(old_inode);
inode_inc_iversion(old_dir);
- fat_truncate_time(old_dir, NULL, S_CTIME|S_MTIME);
+ fat_truncate_time(old_dir, NULL, FAT_UPDATE_CMTIME);
if (IS_DIRSYNC(old_dir))
(void)fat_sync_inode(old_dir);
else
@@ -540,7 +538,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
if (err)
goto error_dotdot;
inode_inc_iversion(old_dir);
- fat_truncate_time(old_dir, &ts, S_CTIME|S_MTIME);
+ fat_truncate_time(old_dir, &ts, FAT_UPDATE_CMTIME);
if (IS_DIRSYNC(old_dir))
(void)fat_sync_inode(old_dir);
else
@@ -550,7 +548,6 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
drop_nlink(new_inode);
if (is_dir)
drop_nlink(new_inode);
- fat_truncate_time(new_inode, &ts, S_CTIME);
}
out:
brelse(sinfo.bh);
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index 5dbc4cbb8fce..e46f34cade1a 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -676,7 +676,7 @@ static int vfat_add_entry(struct inode *dir, const struct qstr *qname,
goto cleanup;
/* update timestamp */
- fat_truncate_time(dir, ts, S_CTIME|S_MTIME);
+ fat_truncate_time(dir, ts, FAT_UPDATE_CMTIME);
if (IS_DIRSYNC(dir))
(void)fat_sync_inode(dir);
else
@@ -806,7 +806,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry)
drop_nlink(dir);
clear_nlink(inode);
- fat_truncate_time(inode, NULL, S_ATIME|S_MTIME);
+ fat_truncate_time(inode, NULL, FAT_UPDATE_ATIME | FAT_UPDATE_CMTIME);
fat_detach(inode);
vfat_d_version_set(dentry, inode_query_iversion(dir));
out:
@@ -832,7 +832,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
if (err)
goto out;
clear_nlink(inode);
- fat_truncate_time(inode, NULL, S_ATIME|S_MTIME);
+ fat_truncate_time(inode, NULL, FAT_UPDATE_ATIME | FAT_UPDATE_CMTIME);
fat_detach(inode);
vfat_d_version_set(dentry, inode_query_iversion(dir));
out:
@@ -918,7 +918,7 @@ static int vfat_update_dotdot_de(struct inode *dir, struct inode *inode,
static void vfat_update_dir_metadata(struct inode *dir, struct timespec64 *ts)
{
inode_inc_iversion(dir);
- fat_truncate_time(dir, ts, S_CTIME | S_MTIME);
+ fat_truncate_time(dir, ts, FAT_UPDATE_CMTIME);
if (IS_DIRSYNC(dir))
(void)fat_sync_inode(dir);
else
@@ -996,7 +996,6 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
drop_nlink(new_inode);
if (is_dir)
drop_nlink(new_inode);
- fat_truncate_time(new_inode, &ts, S_CTIME);
}
out:
brelse(sinfo.bh);
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 01/11] fs: remove inode_update_time
2026-01-06 7:49 re-enable IOCB_NOWAIT writes to files v5 Christoph Hellwig
@ 2026-01-06 7:49 ` Christoph Hellwig
0 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2026-01-06 7:49 UTC (permalink / raw)
To: Christian Brauner
Cc: Al Viro, David Sterba, Jan Kara, Mike Marshall,
Martin Brandenburg, Carlos Maiolino, Stefan Roesch, Jeff Layton,
OGAWA Hirofumi, Trond Myklebust, Anna Schumaker, linux-kernel,
linux-btrfs, linux-fsdevel, gfs2, io-uring, devel, linux-unionfs,
linux-mtd, linux-xfs, linux-nfs, Chaitanya Kulkarni
The only external user is gone now, open code it in the two VFS
callers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
---
fs/inode.c | 23 ++++++++---------------
include/linux/fs.h | 1 -
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/fs/inode.c b/fs/inode.c
index 521383223d8a..07effa0cb999 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2157,19 +2157,6 @@ int generic_update_time(struct inode *inode, int flags)
}
EXPORT_SYMBOL(generic_update_time);
-/*
- * This does the actual work of updating an inodes time or version. Must have
- * had called mnt_want_write() before calling this.
- */
-int inode_update_time(struct inode *inode, int flags)
-{
- if (inode->i_op->update_time)
- return inode->i_op->update_time(inode, flags);
- generic_update_time(inode, flags);
- return 0;
-}
-EXPORT_SYMBOL(inode_update_time);
-
/**
* atime_needs_update - update the access time
* @path: the &struct path to update
@@ -2237,7 +2224,10 @@ void touch_atime(const struct path *path)
* We may also fail on filesystems that have the ability to make parts
* of the fs read only, e.g. subvolumes in Btrfs.
*/
- inode_update_time(inode, S_ATIME);
+ if (inode->i_op->update_time)
+ inode->i_op->update_time(inode, S_ATIME);
+ else
+ generic_update_time(inode, S_ATIME);
mnt_put_write_access(mnt);
skip_update:
sb_end_write(inode->i_sb);
@@ -2392,7 +2382,10 @@ static int file_update_time_flags(struct file *file, unsigned int flags)
if (mnt_get_write_access_file(file))
return 0;
- ret = inode_update_time(inode, sync_mode);
+ if (inode->i_op->update_time)
+ ret = inode->i_op->update_time(inode, sync_mode);
+ else
+ ret = generic_update_time(inode, sync_mode);
mnt_put_write_access_file(file);
return ret;
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f5c9cf28c4dc..ee623c16d835 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2246,7 +2246,6 @@ enum file_time_flags {
extern bool atime_needs_update(const struct path *, struct inode *);
extern void touch_atime(const struct path *);
-int inode_update_time(struct inode *inode, int flags);
static inline void file_accessed(struct file *file)
{
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: re-enable IOCB_NOWAIT writes to files v5
2026-01-06 7:44 re-enable IOCB_NOWAIT writes to files v5 Christoph Hellwig
` (3 preceding siblings ...)
2026-01-06 7:44 ` [PATCH 04/11] fat: cleanup the flags for fat_truncate_time Christoph Hellwig
@ 2026-01-06 7:54 ` Christoph Hellwig
4 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2026-01-06 7:54 UTC (permalink / raw)
To: Christian Brauner
Cc: Al Viro, David Sterba, Jan Kara, Mike Marshall,
Martin Brandenburg, Carlos Maiolino, Stefan Roesch, Jeff Layton,
OGAWA Hirofumi, Trond Myklebust, Anna Schumaker, linux-kernel,
linux-btrfs, linux-fsdevel, gfs2, io-uring, devel, linux-unionfs,
linux-mtd, linux-xfs, linux-nfs
Sorry, sending this got interrupted by the broken train wifi.
Please look at the immediately following full series instead.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 01/11] fs: remove inode_update_time
2026-01-08 14:19 re-enable IOCB_NOWAIT writes to files v6 Christoph Hellwig
@ 2026-01-08 14:19 ` Christoph Hellwig
0 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2026-01-08 14:19 UTC (permalink / raw)
To: Christian Brauner
Cc: Al Viro, David Sterba, Jan Kara, Mike Marshall,
Martin Brandenburg, Carlos Maiolino, Stefan Roesch, Jeff Layton,
OGAWA Hirofumi, Trond Myklebust, Anna Schumaker, linux-kernel,
linux-btrfs, linux-fsdevel, gfs2, io-uring, devel, linux-unionfs,
linux-mtd, linux-xfs, linux-nfs, Chaitanya Kulkarni
The only external user is gone now, open code it in the two VFS
callers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
---
fs/inode.c | 23 ++++++++---------------
include/linux/fs.h | 1 -
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/fs/inode.c b/fs/inode.c
index 521383223d8a..07effa0cb999 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2157,19 +2157,6 @@ int generic_update_time(struct inode *inode, int flags)
}
EXPORT_SYMBOL(generic_update_time);
-/*
- * This does the actual work of updating an inodes time or version. Must have
- * had called mnt_want_write() before calling this.
- */
-int inode_update_time(struct inode *inode, int flags)
-{
- if (inode->i_op->update_time)
- return inode->i_op->update_time(inode, flags);
- generic_update_time(inode, flags);
- return 0;
-}
-EXPORT_SYMBOL(inode_update_time);
-
/**
* atime_needs_update - update the access time
* @path: the &struct path to update
@@ -2237,7 +2224,10 @@ void touch_atime(const struct path *path)
* We may also fail on filesystems that have the ability to make parts
* of the fs read only, e.g. subvolumes in Btrfs.
*/
- inode_update_time(inode, S_ATIME);
+ if (inode->i_op->update_time)
+ inode->i_op->update_time(inode, S_ATIME);
+ else
+ generic_update_time(inode, S_ATIME);
mnt_put_write_access(mnt);
skip_update:
sb_end_write(inode->i_sb);
@@ -2392,7 +2382,10 @@ static int file_update_time_flags(struct file *file, unsigned int flags)
if (mnt_get_write_access_file(file))
return 0;
- ret = inode_update_time(inode, sync_mode);
+ if (inode->i_op->update_time)
+ ret = inode->i_op->update_time(inode, sync_mode);
+ else
+ ret = generic_update_time(inode, sync_mode);
mnt_put_write_access_file(file);
return ret;
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f5c9cf28c4dc..ee623c16d835 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2246,7 +2246,6 @@ enum file_time_flags {
extern bool atime_needs_update(const struct path *, struct inode *);
extern void touch_atime(const struct path *);
-int inode_update_time(struct inode *inode, int flags);
static inline void file_accessed(struct file *file)
{
--
2.47.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-01-08 14:19 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-06 7:44 re-enable IOCB_NOWAIT writes to files v5 Christoph Hellwig
2026-01-06 7:44 ` [PATCH 01/11] fs: remove inode_update_time Christoph Hellwig
2026-01-06 7:44 ` [PATCH 02/11] fs: allow error returns from generic_update_time Christoph Hellwig
2026-01-06 7:44 ` [PATCH 03/11] nfs: split nfs_update_timestamps Christoph Hellwig
2026-01-06 7:44 ` [PATCH 04/11] fat: cleanup the flags for fat_truncate_time Christoph Hellwig
2026-01-06 7:54 ` re-enable IOCB_NOWAIT writes to files v5 Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2026-01-08 14:19 re-enable IOCB_NOWAIT writes to files v6 Christoph Hellwig
2026-01-08 14:19 ` [PATCH 01/11] fs: remove inode_update_time Christoph Hellwig
2026-01-06 7:49 re-enable IOCB_NOWAIT writes to files v5 Christoph Hellwig
2026-01-06 7:49 ` [PATCH 01/11] fs: remove inode_update_time Christoph Hellwig
2025-12-23 0:37 re-enable IOCB_NOWAIT writes to files v4 Christoph Hellwig
2025-12-23 0:37 ` [PATCH 01/11] fs: remove inode_update_time Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox