Browse Source

xfs: add lockdep annotations for the rt inodes

The rt bitmap and summary inodes do not participate in the normal inode
locking protocol.  Instead the rt bitmap inode can be locked in any
transaction involving rt allocations, and the both of the rt inodes can
be locked at the same time.  Add specific lockdep subclasses for the rt
inodes to prevent lockdep from blowing up.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
Christoph Hellwig 14 years ago
parent
commit
9681153b46
3 changed files with 26 additions and 15 deletions
  1. 1 1
      fs/xfs/xfs_bmap.c
  2. 15 8
      fs/xfs/xfs_inode.h
  3. 10 6
      fs/xfs/xfs_rtalloc.c

+ 1 - 1
fs/xfs/xfs_bmap.c

@@ -2371,7 +2371,7 @@ xfs_bmap_rtalloc(
 	 * Lock out other modifications to the RT bitmap inode.
 	 * Lock out other modifications to the RT bitmap inode.
 	 */
 	 */
 	error = xfs_trans_iget(mp, ap->tp, mp->m_sb.sb_rbmino, 0,
 	error = xfs_trans_iget(mp, ap->tp, mp->m_sb.sb_rbmino, 0,
-			       XFS_ILOCK_EXCL, &ip);
+			       XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP, &ip);
 	if (error)
 	if (error)
 		return error;
 		return error;
 	ASSERT(ip == mp->m_rbmip);
 	ASSERT(ip == mp->m_rbmip);

+ 15 - 8
fs/xfs/xfs_inode.h

@@ -409,28 +409,35 @@ static inline void xfs_ifunlock(xfs_inode_t *ip)
 /*
 /*
  * Flags for lockdep annotations.
  * Flags for lockdep annotations.
  *
  *
- * XFS_I[O]LOCK_PARENT - for operations that require locking two inodes
- * (ie directory operations that require locking a directory inode and
- * an entry inode).  The first inode gets locked with this flag so it
- * gets a lockdep subclass of 1 and the second lock will have a lockdep
- * subclass of 0.
+ * XFS_LOCK_PARENT - for directory operations that require locking a
+ * parent directory inode and a child entry inode.  The parent gets locked
+ * with this flag so it gets a lockdep subclass of 1 and the child entry
+ * lock will have a lockdep subclass of 0.
+ *
+ * XFS_LOCK_RTBITMAP/XFS_LOCK_RTSUM - the realtime device bitmap and summary
+ * inodes do not participate in the normal lock order, and thus have their
+ * own subclasses.
  *
  *
  * XFS_LOCK_INUMORDER - for locking several inodes at the some time
  * XFS_LOCK_INUMORDER - for locking several inodes at the some time
  * with xfs_lock_inodes().  This flag is used as the starting subclass
  * with xfs_lock_inodes().  This flag is used as the starting subclass
  * and each subsequent lock acquired will increment the subclass by one.
  * and each subsequent lock acquired will increment the subclass by one.
- * So the first lock acquired will have a lockdep subclass of 2, the
- * second lock will have a lockdep subclass of 3, and so on. It is
+ * So the first lock acquired will have a lockdep subclass of 4, the
+ * second lock will have a lockdep subclass of 5, and so on. It is
  * the responsibility of the class builder to shift this to the correct
  * the responsibility of the class builder to shift this to the correct
  * portion of the lock_mode lockdep mask.
  * portion of the lock_mode lockdep mask.
  */
  */
 #define XFS_LOCK_PARENT		1
 #define XFS_LOCK_PARENT		1
-#define XFS_LOCK_INUMORDER	2
+#define XFS_LOCK_RTBITMAP	2
+#define XFS_LOCK_RTSUM		3
+#define XFS_LOCK_INUMORDER	4
 
 
 #define XFS_IOLOCK_SHIFT	16
 #define XFS_IOLOCK_SHIFT	16
 #define	XFS_IOLOCK_PARENT	(XFS_LOCK_PARENT << XFS_IOLOCK_SHIFT)
 #define	XFS_IOLOCK_PARENT	(XFS_LOCK_PARENT << XFS_IOLOCK_SHIFT)
 
 
 #define XFS_ILOCK_SHIFT		24
 #define XFS_ILOCK_SHIFT		24
 #define	XFS_ILOCK_PARENT	(XFS_LOCK_PARENT << XFS_ILOCK_SHIFT)
 #define	XFS_ILOCK_PARENT	(XFS_LOCK_PARENT << XFS_ILOCK_SHIFT)
+#define	XFS_ILOCK_RTBITMAP	(XFS_LOCK_RTBITMAP << XFS_ILOCK_SHIFT)
+#define	XFS_ILOCK_RTSUM		(XFS_LOCK_RTSUM << XFS_ILOCK_SHIFT)
 
 
 #define XFS_IOLOCK_DEP_MASK	0x00ff0000
 #define XFS_IOLOCK_DEP_MASK	0x00ff0000
 #define XFS_ILOCK_DEP_MASK	0xff000000
 #define XFS_ILOCK_DEP_MASK	0xff000000

+ 10 - 6
fs/xfs/xfs_rtalloc.c

@@ -1972,8 +1972,10 @@ xfs_growfs_rt(
 		/*
 		/*
 		 * Lock out other callers by grabbing the bitmap inode lock.
 		 * Lock out other callers by grabbing the bitmap inode lock.
 		 */
 		 */
-		if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0,
-						XFS_ILOCK_EXCL, &ip)))
+		error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0,
+				       XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP,
+				       &ip);
+		if (error)
 			goto error_cancel;
 			goto error_cancel;
 		ASSERT(ip == mp->m_rbmip);
 		ASSERT(ip == mp->m_rbmip);
 		/*
 		/*
@@ -1986,8 +1988,9 @@ xfs_growfs_rt(
 		/*
 		/*
 		 * Get the summary inode into the transaction.
 		 * Get the summary inode into the transaction.
 		 */
 		 */
-		if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0,
-						XFS_ILOCK_EXCL, &ip)))
+		error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0,
+				       XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM, &ip);
+		if (error)
 			goto error_cancel;
 			goto error_cancel;
 		ASSERT(ip == mp->m_rsumip);
 		ASSERT(ip == mp->m_rsumip);
 		/*
 		/*
@@ -2160,8 +2163,9 @@ xfs_rtfree_extent(
 	/*
 	/*
 	 * Synchronize by locking the bitmap inode.
 	 * Synchronize by locking the bitmap inode.
 	 */
 	 */
-	if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0,
-					XFS_ILOCK_EXCL, &ip)))
+	error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0,
+			       XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP, &ip);
+	if (error)
 		return error;
 		return error;
 #if defined(__KERNEL__) && defined(DEBUG)
 #if defined(__KERNEL__) && defined(DEBUG)
 	/*
 	/*