Re: The bug of iput() removal from flusher thread?

From: Jan Kara
Date: Tue Nov 20 2012 - 20:48:44 EST


On Wed 21-11-12 02:11:11, Jan Kara wrote:
> On Tue 20-11-12 06:53:12, OGAWA Hirofumi wrote:
> > Jan Kara <jack@xxxxxxx> writes:
> >
> > >> > static void inode_sync_complete(struct inode *inode)
> > >> > {
> > >> > + /* If inode is clean an unused, put it into LRU now. */
> > >> > + if (!(inode->i_state & I_DIRTY) && !atomic_read(&inode->i_count))
> > >> > + inode_lru_list_add(inode);
> > >>
> > >> IMHO, open coding this would be bad idea.
> > > Do you mean creating a separate function for the above two lines?
> >
> > Yes. And the intent is to consolidate "when adds inode to LRU" with
> > iput_final()'s one.
> >
> > >> And another one is I_REFERENCED. We really want to remove I_REFERENCED?
> > > We don't want I_REFERENCED set - noone used the inode. But looking into
> > > the code with fresh eyes, the fix isn't as simple as I thought. First I
> > > need to check MS_ACTIVE and second I need to check I_FREEING... So the
> > > condition will be complex enough to warrant a separate function.
> >
> > I can't see the issue (sync_filesystem() will wait I_DIRTY before
> > MS_ACTIVE, and I_DIRTY prevents I_FREEING) though, it may be possible.
> E.g. when inode is deleted it can be both I_DIRTY (and flusher thread
> can be working on it) while it is also marked as I_FREEING. In such case we
> must avoid adding the inode to the LRU.
>
> Regarding MS_ACTIVE - you are right that sync_filesystem() should clean
> all dirty inodes but some filesystems dirty their internal inodes during
> umount so it's better to make flusher thread safe and not add such inodes
> to the LRU during umount.
Here's the patch I currently have BTW.

Honza
--
Jan Kara <jack@xxxxxxx>
SUSE Labs, CR