[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251120064859.2911749-11-hch@lst.de>
Date: Thu, 20 Nov 2025 07:47:31 +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,
linux-fsdevel@...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,
Chaitanya Kulkarni <kch@...dia.com>
Subject: [PATCH 10/16] 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>
Reviewed-by: Chaitanya Kulkarni <kch@...dia.com>
Reviewed-by: Jeff Layton <jlayton@...nel.org>
---
fs/fs-writeback.c | 16 ++++++++++++++++
fs/inode.c | 14 +++-----------
include/linux/fs.h | 3 ++-
3 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 2b35e80037fe..a115e26e0139 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -2671,6 +2671,22 @@ 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);
+ }
+}
+EXPORT_SYMBOL_GPL(mark_inode_dirty_time);
+
/*
* 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 cda78f76e1dd..edbc24a489ca 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2107,17 +2107,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 4759aa61cb14..b4d82e5c6c32 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