[PATCH v18 05/10] ocfs2: record the fsync transaction when CoW makes clusters writable
From: Joseph Qi
Date: Sat Dec 05 2026 - 09:40:31 EST
From: Heming Zhao <heming.zhao@xxxxxxxx>
ocfs2_make_clusters_writable() changes the extent tree to break a
refcount sharing, but it does not record the transaction in the inode's
datasync tid. A subsequent O_DSYNC or fsync that relies on
i_datasync_tid can therefore consider the CoW already committed and skip
waiting for it.
Record it before committing, at out_commit, so the error exits after the
transaction started record it too: earlier loop iterations may already
have dirtied extent tree buffers that ocfs2_commit_trans() will write.
Fixes: 2931cdcb4919 ("ocfs2: improve fsync efficiency and fix deadlock between aio_write and sync_file")
Co-developed-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
Signed-off-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
Signed-off-by: Heming Zhao <heming.zhao@xxxxxxxx>
---
fs/ocfs2/refcounttree.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 4f13b5a6faa7d..0181993f56149 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -3360,6 +3360,8 @@ static int ocfs2_make_clusters_writable(struct super_block *sb,
}
out_commit:
+ ocfs2_update_inode_fsync_trans(handle, context->inode,
+ context->get_clusters == ocfs2_di_get_clusters);
ocfs2_commit_trans(osb, handle);
out:
--
2.39.3