* [PATCH] fs: clear I_DIRTY_TIME in sync_lazytime
@ 2026-03-17 13:44 Christoph Hellwig
2026-03-17 14:12 ` Christian Brauner
2026-03-18 17:34 ` Jan Kara
0 siblings, 2 replies; 3+ messages in thread
From: Christoph Hellwig @ 2026-03-17 13:44 UTC (permalink / raw)
To: brauner, viro; +Cc: jack, linux-fsdevel, linux-xfs
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: 5cf06ea56ee6 ("fs: add a ->sync_lazytime method")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/fs-writeback.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 7c75ed7e8979..d8dac1931595 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -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,9 +1731,8 @@ bool sync_lazytime(struct inode *inode)
trace_writeback_lazytime(inode);
if (inode->i_op->sync_lazytime)
- inode->i_op->sync_lazytime(inode);
- else
- mark_inode_dirty_sync(inode);
+ return __sync_lazytime(inode);
+ mark_inode_dirty_sync(inode);
return true;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] fs: clear I_DIRTY_TIME in sync_lazytime
2026-03-17 13:44 [PATCH] fs: clear I_DIRTY_TIME in sync_lazytime Christoph Hellwig
@ 2026-03-17 14:12 ` Christian Brauner
2026-03-18 17:34 ` Jan Kara
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2026-03-17 14:12 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Christian Brauner, jack, linux-fsdevel, linux-xfs, viro
On Tue, 17 Mar 2026 14:44:04 +0100, Christoph Hellwig wrote:
> 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.
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] fs: clear I_DIRTY_TIME in sync_lazytime
https://git.kernel.org/vfs/vfs/c/f8b8820a4a16
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] fs: clear I_DIRTY_TIME in sync_lazytime
2026-03-17 13:44 [PATCH] fs: clear I_DIRTY_TIME in sync_lazytime Christoph Hellwig
2026-03-17 14:12 ` Christian Brauner
@ 2026-03-18 17:34 ` Jan Kara
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2026-03-18 17:34 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: brauner, viro, jack, linux-fsdevel, linux-xfs
On Tue 17-03-26 14:44:04, Christoph Hellwig wrote:
> 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: 5cf06ea56ee6 ("fs: add a ->sync_lazytime method")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/fs-writeback.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 7c75ed7e8979..d8dac1931595 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -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,9 +1731,8 @@ bool sync_lazytime(struct inode *inode)
>
> trace_writeback_lazytime(inode);
> if (inode->i_op->sync_lazytime)
> - inode->i_op->sync_lazytime(inode);
> - else
> - mark_inode_dirty_sync(inode);
> + return __sync_lazytime(inode);
> + mark_inode_dirty_sync(inode);
> return true;
> }
>
> --
> 2.47.3
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-18 17:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-17 13:44 [PATCH] fs: clear I_DIRTY_TIME in sync_lazytime Christoph Hellwig
2026-03-17 14:12 ` Christian Brauner
2026-03-18 17:34 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox