xfs: lockdep annotations for xfs_dqlock2
[safe/jmp/linux-2.6] / fs / xfs / xfs_ialloc_btree.c
index 9f4e33c..99f2408 100644 (file)
@@ -219,6 +219,28 @@ xfs_inobt_kill_root(
        return 0;
 }
 
+#ifdef DEBUG
+STATIC int
+xfs_inobt_keys_inorder(
+       struct xfs_btree_cur    *cur,
+       union xfs_btree_key     *k1,
+       union xfs_btree_key     *k2)
+{
+       return be32_to_cpu(k1->inobt.ir_startino) <
+               be32_to_cpu(k2->inobt.ir_startino);
+}
+
+STATIC int
+xfs_inobt_recs_inorder(
+       struct xfs_btree_cur    *cur,
+       union xfs_btree_rec     *r1,
+       union xfs_btree_rec     *r2)
+{
+       return be32_to_cpu(r1->inobt.ir_startino) + XFS_INODES_PER_CHUNK <=
+               be32_to_cpu(r2->inobt.ir_startino);
+}
+#endif /* DEBUG */
+
 #ifdef XFS_BTREE_TRACE
 ktrace_t       *xfs_inobt_trace_buf;
 
@@ -302,6 +324,11 @@ static const struct xfs_btree_ops xfs_inobt_ops = {
        .init_ptr_from_cur      = xfs_inobt_init_ptr_from_cur,
        .key_diff               = xfs_inobt_key_diff,
 
+#ifdef DEBUG
+       .keys_inorder           = xfs_inobt_keys_inorder,
+       .recs_inorder           = xfs_inobt_recs_inorder,
+#endif
+
 #ifdef XFS_BTREE_TRACE
        .trace_enter            = xfs_inobt_trace_enter,
        .trace_cursor           = xfs_inobt_trace_cursor,
@@ -338,3 +365,19 @@ xfs_inobt_init_cursor(
 
        return cur;
 }
+
+/*
+ * Calculate number of records in an inobt btree block.
+ */
+int
+xfs_inobt_maxrecs(
+       struct xfs_mount        *mp,
+       int                     blocklen,
+       int                     leaf)
+{
+       blocklen -= XFS_INOBT_BLOCK_LEN(mp);
+
+       if (leaf)
+               return blocklen / sizeof(xfs_inobt_rec_t);
+       return blocklen / (sizeof(xfs_inobt_key_t) + sizeof(xfs_inobt_ptr_t));
+}