Skip to content

Commit f8b8820

Browse files
Christoph Hellwigbrauner
authored andcommitted
fs: clear I_DIRTY_TIME in sync_lazytime
For file systems implementing ->sync_lazytime, I_DIRTY_TIME fails to get cleared in sync_lazytime, and might cause additional calls to sync_lazytime during inode deactivation. Use the same pattern as in __mark_inode_dirty to clear the flag under the inode lock. Fixes: 5cf06ea ("fs: add a ->sync_lazytime method") Signed-off-by: Christoph Hellwig <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent e9075e4 commit f8b8820

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

fs/fs-writeback.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,16 +1711,28 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
17111711
}
17121712
}
17131713

1714+
static bool __sync_lazytime(struct inode *inode)
1715+
{
1716+
spin_lock(&inode->i_lock);
1717+
if (!(inode_state_read(inode) & I_DIRTY_TIME)) {
1718+
spin_unlock(&inode->i_lock);
1719+
return false;
1720+
}
1721+
inode_state_clear(inode, I_DIRTY_TIME);
1722+
spin_unlock(&inode->i_lock);
1723+
inode->i_op->sync_lazytime(inode);
1724+
return true;
1725+
}
1726+
17141727
bool sync_lazytime(struct inode *inode)
17151728
{
17161729
if (!(inode_state_read_once(inode) & I_DIRTY_TIME))
17171730
return false;
17181731

17191732
trace_writeback_lazytime(inode);
17201733
if (inode->i_op->sync_lazytime)
1721-
inode->i_op->sync_lazytime(inode);
1722-
else
1723-
mark_inode_dirty_sync(inode);
1734+
return __sync_lazytime(inode);
1735+
mark_inode_dirty_sync(inode);
17241736
return true;
17251737
}
17261738

0 commit comments

Comments
 (0)