]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: unify xfs_btree.c with kernel code
authorDave Chinner <dchinner@redhat.com>
Wed, 13 Nov 2013 06:40:30 +0000 (06:40 +0000)
committerRich Johnston <rjohnston@sgi.com>
Wed, 13 Nov 2013 17:03:09 +0000 (11:03 -0600)
The libxfs/xfs_btree.c code does not contain a small amount of code
for btree block readahead that the kernel code does. Instead, it
short circuits it at a higher layer and doesn't include the lower
layer functions. There is no harm in calling the lower lay functions
and have them do nothing, and doing so unifies the kernel and
userspace code.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
libxfs/xfs.h
libxfs/xfs_btree.c

index 31acf1bdce5fd8be94bfafca862e2a363a555fcd..364fd83e6de764e2e9edb6b6b6ccd031282e6fa5 100644 (file)
@@ -319,10 +319,12 @@ roundup_64(__uint64_t x, __uint32_t y)
 
 #define xfs_trans_buf_copy_type(dbp, sbp)
 
-#define xfs_buf_readahead(a,b,c,ops)           ((void) 0)      /* no readahead */
+/* no readahead, need to avoid set-but-unused var warnings. */
+#define xfs_buf_readahead(a,d,c,ops)           ({      \
+       xfs_daddr_t __d = d;                            \
+       __d = __d; /* no set-but-unused warning */      \
+})
 #define xfs_buf_readahead_map(a,b,c,ops)       ((void) 0)      /* no readahead */
-#define xfs_btree_reada_bufl(m,fsb,c,ops)      ((void) 0)
-#define xfs_btree_reada_bufs(m,fsb,c,x,ops)    ((void) 0)
 #define xfs_buftrace(x,y)                      ((void) 0)      /* debug only */
 
 #define xfs_cmn_err(tag,level,mp,fmt,args...)  cmn_err(level,fmt, ## args)
index 009992650300e5653b27101aefae631ffb4fc594..ce149adb843e91e1d8303104cfb40f903e91171d 100644 (file)
@@ -396,7 +396,6 @@ static inline size_t xfs_btree_block_len(struct xfs_btree_cur *cur)
                        return XFS_BTREE_LBLOCK_CRC_LEN;
                return XFS_BTREE_LBLOCK_LEN;
        }
-
        if (cur->bc_flags & XFS_BTREE_CRC_BLOCKS)
                return XFS_BTREE_SBLOCK_CRC_LEN;
        return XFS_BTREE_SBLOCK_LEN;
@@ -493,7 +492,7 @@ xfs_btree_ptr_addr(
 }
 
 /*
- * Get the root block which is stored in the inode.
+ * Get the root block which is stored in the inode.
  *
  * For now this btree implementation assumes the btree root is always
  * stored in the if_broot field of an inode fork.
@@ -716,6 +715,46 @@ xfs_btree_read_bufl(
        return 0;
 }
 
+/*
+ * Read-ahead the block, don't wait for it, don't return a buffer.
+ * Long-form addressing.
+ */
+/* ARGSUSED */
+void
+xfs_btree_reada_bufl(
+       struct xfs_mount        *mp,            /* file system mount point */
+       xfs_fsblock_t           fsbno,          /* file system block number */
+       xfs_extlen_t            count,          /* count of filesystem blocks */
+       const struct xfs_buf_ops *ops)
+{
+       xfs_daddr_t             d;
+
+       ASSERT(fsbno != NULLFSBLOCK);
+       d = XFS_FSB_TO_DADDR(mp, fsbno);
+       xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count, ops);
+}
+
+/*
+ * Read-ahead the block, don't wait for it, don't return a buffer.
+ * Short-form addressing.
+ */
+/* ARGSUSED */
+void
+xfs_btree_reada_bufs(
+       struct xfs_mount        *mp,            /* file system mount point */
+       xfs_agnumber_t          agno,           /* allocation group number */
+       xfs_agblock_t           agbno,          /* allocation group block number */
+       xfs_extlen_t            count,          /* count of filesystem blocks */
+       const struct xfs_buf_ops *ops)
+{
+       xfs_daddr_t             d;
+
+       ASSERT(agno != NULLAGNUMBER);
+       ASSERT(agbno != NULLAGBLOCK);
+       d = XFS_AGB_TO_DADDR(mp, agno, agbno);
+       xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count, ops);
+}
+
 STATIC int
 xfs_btree_readahead_lblock(
        struct xfs_btree_cur    *cur,
@@ -1339,7 +1378,7 @@ xfs_btree_log_block(
                         * We don't log the CRC when updating a btree
                         * block but instead recreate it during log
                         * recovery.  As the log buffers have checksums
-                        * of their this is safe and avoids logging a crc
+                        * of their own this is safe and avoids logging a crc
                         * update in a lot of places.
                         */
                        if (fields == XFS_BB_ALL_BITS)
@@ -1629,7 +1668,7 @@ xfs_lookup_get_search_key(
 
 /*
  * Lookup the record.  The cursor is made to point to it, based on dir.
- * Return 0 if can't find any such record, 1 for success.
+ * stat is set to 0 if can't find any such record, 1 for success.
  */
 int                                    /* error */
 xfs_btree_lookup(
@@ -2701,7 +2740,6 @@ xfs_btree_make_block_unfull(
 
                if (numrecs < cur->bc_ops->get_dmaxrecs(cur, level)) {
                        /* A root block that can be made bigger. */
-
                        xfs_iroot_realloc(ip, 1, cur->bc_private.b.whichfork);
                } else {
                        /* A root block that needs replacing */