[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251114062642.1524837-10-hch@lst.de>
Date: Fri, 14 Nov 2025 07:26:12 +0100
From: Christoph Hellwig <hch@....de>
To: Christian Brauner <brauner@...nel.org>
Cc: Al Viro <viro@...iv.linux.org.uk>,
David Sterba <dsterba@...e.com>,
Jan Kara <jack@...e.cz>,
Mike Marshall <hubcap@...ibond.com>,
Martin Brandenburg <martin@...ibond.com>,
Carlos Maiolino <cem@...nel.org>,
Stefan Roesch <shr@...com>,
Jeff Layton <jlayton@...nel.org>,
linux-kernel@...r.kernel.org,
linux-btrfs@...r.kernel.org,
gfs2@...ts.linux.dev,
io-uring@...r.kernel.org,
devel@...ts.orangefs.org,
linux-unionfs@...r.kernel.org,
linux-mtd@...ts.infradead.org,
linux-xfs@...r.kernel.org,
linux-nfs@...r.kernel.org
Subject: [PATCH 09/14] fs: factor out a mark_inode_dirty_time helper
Factor out the inode dirtying vs lazytime logic from generic_update_time
into a new helper so that it can be reused in file system methods.
Signed-off-by: Christoph Hellwig <hch@....de>
---
fs/fs-writeback.c | 15 +++++++++++++++
fs/inode.c | 14 +++-----------
include/linux/fs.h | 3 ++-
3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 2b35e80037fe..930697f39153 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -2671,6 +2671,21 @@ void __mark_inode_dirty(struct inode *inode, int flags)
}
EXPORT_SYMBOL(__mark_inode_dirty);
+void mark_inode_dirty_time(struct inode *inode, unsigned int flags)
+{
+ if (inode->i_sb->s_flags & SB_LAZYTIME) {
+ int dirty_flags = 0;
+
+ if (flags & (S_ATIME | S_MTIME | S_CTIME))
+ dirty_flags = I_DIRTY_TIME;
+ if (flags & S_VERSION)
+ dirty_flags |= I_DIRTY_SYNC;
+ __mark_inode_dirty(inode, dirty_flags);
+ } else {
+ mark_inode_dirty_sync(inode);
+ }
+}
+
/*
* The @s_sync_lock is used to serialise concurrent sync operations
* to avoid lock contention problems with concurrent wait_sb_inodes() calls.
diff --git a/fs/inode.c b/fs/inode.c
index 57c458ee548d..559ce5c07188 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2095,17 +2095,9 @@ EXPORT_SYMBOL(inode_update_timestamps);
*/
int generic_update_time(struct inode *inode, int flags)
{
- int updated = inode_update_timestamps(inode, flags);
- int dirty_flags = 0;
-
- if (!updated)
- return 0;
-
- if (updated & (S_ATIME|S_MTIME|S_CTIME))
- dirty_flags = inode->i_sb->s_flags & SB_LAZYTIME ? I_DIRTY_TIME : I_DIRTY_SYNC;
- if (updated & S_VERSION)
- dirty_flags |= I_DIRTY_SYNC;
- __mark_inode_dirty(inode, dirty_flags);
+ flags = inode_update_timestamps(inode, flags);
+ if (flags)
+ mark_inode_dirty_time(inode, flags);
return 0;
}
EXPORT_SYMBOL(generic_update_time);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c1077ae7c6b2..5c762d80b8a8 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2608,7 +2608,8 @@ static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src,
};
}
-extern void __mark_inode_dirty(struct inode *, int);
+void mark_inode_dirty_time(struct inode *inode, unsigned int flags);
+void __mark_inode_dirty(struct inode *inode, int flags);
static inline void mark_inode_dirty(struct inode *inode)
{
__mark_inode_dirty(inode, I_DIRTY);
--
2.47.3
Powered by blists - more mailing lists