ocfs2-defer-suballocator-block-group-reclaim-to-workqueue.patch removed from -mm tree
The quilt patch titled
Subject: ocfs2: defer suballocator block group reclaim to workqueue
has been removed from the -mm tree. Its filename was
ocfs2-defer-suballocator-block-group-reclaim-to-workqueue.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Joseph Qi <[email protected]>
Subject: ocfs2: defer suballocator block group reclaim to workqueue
Date: Fri, 28 Aug 2026 19:28:25 +0800
When the last bit in a suballocator block group is freed, _ocfs2_free_suballoc_bits() reclaims the group back to the global bitmap. The reclaim takes inode_lock() on the global bitmap inode while running inside the freeing transaction, adding a lock dependency of
j_trans_barrier -> global bitmap inode i_rwsem
This forms a circular dependency with paths such as ocfs2_shutdown_local_alloc(), which take the global bitmap inode lock before starting a transaction:
Task1 (dealloc):
ocfs2_run_deallocs
ocfs2_free_cached_blocks
ocfs2_start_trans
down_read(j_trans_barrier)
_ocfs2_free_suballoc_bits
_ocfs2_reclaim_suballoc_to_main
inode_lock(main_bm_inode) <- wait on Task2
Task2 (dismount):
ocfs2_shutdown_local_alloc
inode_lock(main_bm_inode) ocfs2_start_trans
down_read(j_trans_barrier) <- wait on Task3
Task3 (ocfs2cmt):
ocfs2_commit_cache
down_write(j_trans_barrier) <- wait on Task1's handle jbd2_journal_flush
Task1 waits for Task2's inode_lock(), Task2 waits for the j_trans_barrier down_write() held by ocfs2cmt, and ocfs2cmt waits for Task1's running transaction to commit - a real deadlock, observed with aio-stress direct IO writes racing dismount.
Fix it by deferring the reclaim to the per-superblock ocfs2_wq workqueue, so the freeing transaction no longer takes the global bitmap inode lock. The worker re-checks under the suballocator locks that the block group is still fully freed (it may have been allocated from again in the meantime), takes the global bitmap inode locks before starting its own transaction, and performs the same suballocator cleanup and space return. The inode lock order (suballocator inode -> global bitmap inode) is consistent with the existing "inode lock before transaction" order, breaking the cycle.
Reclaim work can still be queued late in dismount, e.g. when the truncate log is flushed or orphan dir recovery frees inode bits, so both ocfs2_dismount_volume() and the mount error path flush ocfs2_wq right before the system inodes are released, while the journal is still alive, to make sure no reclaim work is left running. The worker also bails out if the journal is already gone.
Tested with the ocfs2 testsuite (including aio-stress direct IO) and umount/mount cycles on a CONFIG_PROVE_LOCKING kernel: the circular locking dependency is gone and freed block groups are still returned to the global bitmap.
---
fs/ocfs2/ocfs2.h | 5 + fs/ocfs2/suballoc.c | 202 +++++++++++++++++++++++++++++++++++------- fs/ocfs2/suballoc.h | 2 fs/ocfs2/super.c | 16 +++ 4 files changed, 195 insertions(+), 30 deletions(-)
fs/ocfs2/ocfs2.h renamed from fs/ocfs2/ocfs2.h~ocfs2-defer-suballocator-block-group-reclaim-to-workqueue +5 -0
@@ -502,6 +502,11 @@ struct ocfs2_super*/ struct workqueue_struct *ocfs2_wq; +/* deferred reclaim of fully freed suballocator block groups */ +spinlock_t os_suballoc_reclaim_lock; +struct list_head os_suballoc_reclaim_list; +struct work_struct os_suballoc_reclaim_work; +/* sysfs directory per partition */ struct kset *osb_dev_kset;
fs/ocfs2/suballoc.c renamed from fs/ocfs2/suballoc.c~ocfs2-defer-suballocator-block-group-reclaim-to-workqueue +173 -29
275 lines not on this page · raw message
fs/ocfs2/suballoc.h renamed from fs/ocfs2/suballoc.h~ocfs2-defer-suballocator-block-group-reclaim-to-workqueue +1 -1
@@ -206,7 +206,7 @@ int ocfs2_lock_allocators(struct inode *int ocfs2_test_inode_bit (struct ocfs2_super *osb,u64 blkno,int *res); - +void ocfs2_suballoc_reclaim_worker (struct work_struct *work);/* * The following two interfaces are for ocfs2_create_inode_in_orphan().
fs/ocfs2/super.c renamed from fs/ocfs2/super.c~ocfs2-defer-suballocator-block-group-reclaim-to-workqueue +16 -0
@@ -1784,6 +1784,9 @@ static int ocfs2_mount_volume(struct sup out_system_inodes:if (osb->local_alloc_state ==OCFS2_LA_ENABLED )ocfs2_shutdown_local_alloc (osb); +/* Drain pending suballoc reclaim work before the journal goes away */ +if (osb->ocfs2_wq) +flush_workqueue (osb->ocfs2_wq);ocfs2_release_system_inodes (osb);/* before journal shutdown, we should release slot_info */ ocfs2_free_slot_info (osb);
@@ -1854,6 +1857,14 @@ static void ocfs2_dismount_volume(structif (osb->cconn)ocfs2_super_unlock (osb,1 ); +/* +* Drain pending suballoc reclaim work while the system inodes and +* the journal are still alive, since the worker needs to look up +* the global bitmap inode and start a transaction. +*/ +if (osb->ocfs2_wq) +flush_workqueue (osb->ocfs2_wq); +ocfs2_release_system_inodes (osb);ocfs2_journal_shutdown (osb);
@@ -2140,6 +2151,11 @@ static int ocfs2_initialize_super(structINIT_WORK (&osb->dquot_drop_work, ocfs2_drop_dquot_refs);init_llist_head (&osb->dquot_drop_list); +spin_lock_init (&osb->os_suballoc_reclaim_lock); +INIT_LIST_HEAD (&osb->os_suballoc_reclaim_list); +INIT_WORK (&osb->os_suballoc_reclaim_work, + ocfs2_suballoc_reclaim_worker); +/* get some pseudo constants for clustersize bits */ osb->s_clustersize_bits =le32_to_cpu (di->id2.i_super.s_clustersize_bits);
_
Patches currently in -mm which might be from [email protected] are
ocfs2-retain-all-security-xattrs-during-inode-creation.patch ocfs2-restore-erange-check-in-ocfs2_xattr_tree_list_index_block.patch ocfs2-fix-possible-deadlock-between-nfs_sync_rwlock-and-fs_reclaim.patch