Skip to content

Commit 563a506

Browse files
committed
Merge tag 'xfs-6.10-fixes-4' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs fix from Chandan Babu: - Fix assertion failure due to a race between unlink and cluster buffer instantiation. * tag 'xfs-6.10-fixes-4' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: fix unlink vs cluster buffer instantiation race
2 parents c3de9b5 + 348a198 commit 563a506

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

fs/xfs/xfs_inode.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,11 +2548,26 @@ xfs_ifree_cluster(
25482548
* This buffer may not have been correctly initialised as we
25492549
* didn't read it from disk. That's not important because we are
25502550
* only using to mark the buffer as stale in the log, and to
2551-
* attach stale cached inodes on it. That means it will never be
2552-
* dispatched for IO. If it is, we want to know about it, and we
2553-
* want it to fail. We can acheive this by adding a write
2554-
* verifier to the buffer.
2551+
* attach stale cached inodes on it.
2552+
*
2553+
* For the inode that triggered the cluster freeing, this
2554+
* attachment may occur in xfs_inode_item_precommit() after we
2555+
* have marked this buffer stale. If this buffer was not in
2556+
* memory before xfs_ifree_cluster() started, it will not be
2557+
* marked XBF_DONE and this will cause problems later in
2558+
* xfs_inode_item_precommit() when we trip over a (stale, !done)
2559+
* buffer to attached to the transaction.
2560+
*
2561+
* Hence we have to mark the buffer as XFS_DONE here. This is
2562+
* safe because we are also marking the buffer as XBF_STALE and
2563+
* XFS_BLI_STALE. That means it will never be dispatched for
2564+
* IO and it won't be unlocked until the cluster freeing has
2565+
* been committed to the journal and the buffer unpinned. If it
2566+
* is written, we want to know about it, and we want it to
2567+
* fail. We can acheive this by adding a write verifier to the
2568+
* buffer.
25552569
*/
2570+
bp->b_flags |= XBF_DONE;
25562571
bp->b_ops = &xfs_inode_buf_ops;
25572572

25582573
/*

0 commit comments

Comments
 (0)