]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: add a lockdep class key per rtgroup
authorDarrick J. Wong <djwong@kernel.org>
Wed, 3 Jul 2024 21:22:17 +0000 (14:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 9 Jul 2024 22:37:18 +0000 (15:37 -0700)
Add a dynamic lockdep class key to each rtgroup.  This will enable
lockdep to deduce inconsistencies in the rtgroup metadata ILOCK locking
order.  Each class can have 8 subclasses, and for now we will only have
2 inodes per group.  This enables rtgroup order and inode order checks.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/xfs_rtgroup.c
libxfs/xfs_rtgroup.h

index 97451ea3a656f22033183068fe2460ca6869f7f7..258d47403af87a52ab240c7b5652726a274edccf 100644 (file)
@@ -160,6 +160,8 @@ xfs_initialize_rtgroups(
                /* Place kernel structure only init below this point. */
                spin_lock_init(&rtg->rtg_state_lock);
                init_waitqueue_head(&rtg->rtg_active_wq);
+               memset(&rtg->lock_class, 0, sizeof(rtg->lock_class));
+               lockdep_register_key(&rtg->lock_class);
 #endif /* __KERNEL__ */
 
                /* Active ref owned by mount indicates rtgroup is online. */
@@ -199,6 +201,9 @@ xfs_free_unused_rtgroup_range(
                spin_unlock(&mp->m_rtgroup_lock);
                if (!rtg)
                        break;
+#ifdef __KERNEL__
+               lockdep_unregister_key(&rtg->lock_class);
+#endif
                kfree(rtg);
        }
 }
@@ -232,6 +237,9 @@ xfs_free_rtgroups(
                spin_unlock(&mp->m_rtgroup_lock);
                ASSERT(rtg);
                XFS_IS_CORRUPT(mp, atomic_read(&rtg->rtg_ref) != 0);
+#ifdef __KERNEL__
+               lockdep_unregister_key(&rtg->lock_class);
+#endif
 
                /* drop the mount's active reference */
                xfs_rtgroup_rele(rtg);
index c79786276d86158df2a6df2ad8ce06ade983685e..7f5e04eee59716402fa9915a9cba4654c6eb047c 100644 (file)
@@ -36,6 +36,8 @@ struct xfs_rtgroup {
 #ifdef __KERNEL__
        /* -- kernel only structures below this line -- */
        spinlock_t              rtg_state_lock;
+
+       struct lock_class_key   lock_class;
 #endif /* __KERNEL__ */
 };