Messages in this thread Patch in this message |  | | Date | Mon, 24 Nov 2025 14:22:59 +0100 | | From | Jan Kara <> | | Subject | Re: [PATCH 09/14] fs: factor out a mark_inode_dirty_time helper |
| |
On Fri 14-11-25 07:26:12, Christoph Hellwig wrote: > 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@lst.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)
What I find a bit concerning here is that mark_inode_dirty_time() takes a different kind of flags than __mark_inode_dirty() so it's relatively easy to confuse. Proper typing of 'flags' would be nice here but it's a bit cumbersome to do in C so I'm not sure if it's worth it for this relatively limited use. So I guess feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> +{ > + 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 > -- Jan Kara <jack@suse.com> SUSE Labs, CR
|  |