Unverified Commit f8b8820a authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Christian Brauner
Browse files

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: 5cf06ea5 ("fs: add a ->sync_lazytime method")
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20260317134409.1691317-1-hch@lst.de


Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent e9075e42
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -1711,6 +1711,19 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
	}
}

static bool __sync_lazytime(struct inode *inode)
{
	spin_lock(&inode->i_lock);
	if (!(inode_state_read(inode) & I_DIRTY_TIME)) {
		spin_unlock(&inode->i_lock);
		return false;
	}
	inode_state_clear(inode, I_DIRTY_TIME);
	spin_unlock(&inode->i_lock);
	inode->i_op->sync_lazytime(inode);
	return true;
}

bool sync_lazytime(struct inode *inode)
{
	if (!(inode_state_read_once(inode) & I_DIRTY_TIME))
@@ -1718,8 +1731,7 @@ bool sync_lazytime(struct inode *inode)

	trace_writeback_lazytime(inode);
	if (inode->i_op->sync_lazytime)
		inode->i_op->sync_lazytime(inode);
	else
		return __sync_lazytime(inode);
	mark_inode_dirty_sync(inode);
	return true;
}