Re: [PATCH v2 11/12] ext4: simplify i_state checks in __ext4_update_other_inode_time()

Theodore Ts'o
2021-02-03T05:18:10Z

On Tue, Jan 12, 2021 at 02:25:21PM +0100, Christoph Hellwig wrote:
> > We could add:
> >
> > static inline bool other_inode_has_dirtytime(struct inode *inode)
> > {
> > return (inode->state & (I_FREEING | I_WILL_FREE |
> > I_NEW | I_DIRTY_TIME)) == I_DIRTY_TIME;
> > }
> >
> > But it seems a bit weird when it's specific to ext4 at the moment.
> >
> > Are you thinking that other filesystems will implement the same sort of
> > opportunistic update, so we should add the helper now?
>
> For my taste these checks for flags is way too much black magic and will
> trivially break when people add new flags. So having a helper next to
> the definition of the I_* flags that is well documented would be very,
> very helpful. My preferred naming would be something along the lines
> of 'inode_is_dirty_lazytime_only()'.

The name makes sense to me. I'm not sure it's likely that there will
be new types of dirtiness --- as near I can tell the I_DIRTY_TIME was
the first time there has been any changes in a _really_ long time, but
I agree that how the flags interact (even before we added
I_DIRTY_TIME) involved no small amount of black magic, and it's the
kind of thing that requires deep meditation before trying to make any
changes, and then immediately slips out of one's L1 cache very shortly
afterwards. :-)

- Ted