]> git.karo-electronics.de Git - linux-beck.git/commitdiff
libxfs: clean up _dir2_data_freescan
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 8 Nov 2016 00:56:51 +0000 (11:56 +1100)
committerDave Chinner <david@fromorbit.com>
Tue, 8 Nov 2016 00:56:51 +0000 (11:56 +1100)
Refactor the implementations of xfs_dir2_data_freescan into a
routine that takes the raw directory block parameters and
a second function that figures out the raw parameters from the
directory inode.  This enables us to use the exact same code
for both userspace and the kernel, since repair knows exactly
which directory block geometry parameters it needs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/libxfs/xfs_dir2.h
fs/xfs/libxfs/xfs_dir2_data.c

index becc926c3e3d900db0a021dd091e46e828fa6f09..b55db61bd913ca0e28ac0a7fee1ff2fc22639aec 100644 (file)
@@ -157,6 +157,9 @@ extern int xfs_dir2_isleaf(struct xfs_da_args *args, int *r);
 extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
                                struct xfs_buf *bp);
 
+extern void xfs_dir2_data_freescan_int(struct xfs_da_geometry *geo,
+               const struct xfs_dir_ops *ops,
+               struct xfs_dir2_data_hdr *hdr, int *loghead);
 extern void xfs_dir2_data_freescan(struct xfs_inode *dp,
                struct xfs_dir2_data_hdr *hdr, int *loghead);
 extern void xfs_dir2_data_log_entry(struct xfs_da_args *args,
index 725fc7841fdeb38fdfdba08f1621a83f764baeea..cd75ab9f3bf85c65e456e29fe08a1f24ffbea1bc 100644 (file)
@@ -505,8 +505,9 @@ xfs_dir2_data_freeremove(
  * Given a data block, reconstruct its bestfree map.
  */
 void
-xfs_dir2_data_freescan(
-       struct xfs_inode        *dp,
+xfs_dir2_data_freescan_int(
+       struct xfs_da_geometry  *geo,
+       const struct xfs_dir_ops *ops,
        struct xfs_dir2_data_hdr *hdr,
        int                     *loghead)
 {
@@ -516,7 +517,6 @@ xfs_dir2_data_freescan(
        struct xfs_dir2_data_free *bf;
        char                    *endp;          /* end of block's data */
        char                    *p;             /* current entry pointer */
-       struct xfs_da_geometry  *geo = dp->i_mount->m_dir_geo;
 
        ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
               hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
@@ -526,13 +526,13 @@ xfs_dir2_data_freescan(
        /*
         * Start by clearing the table.
         */
-       bf = dp->d_ops->data_bestfree_p(hdr);
+       bf = ops->data_bestfree_p(hdr);
        memset(bf, 0, sizeof(*bf) * XFS_DIR2_DATA_FD_COUNT);
        *loghead = 1;
        /*
         * Set up pointers.
         */
-       p = (char *)dp->d_ops->data_entry_p(hdr);
+       p = (char *)ops->data_entry_p(hdr);
        if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
            hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
                btp = xfs_dir2_block_tail_p(geo, hdr);
@@ -559,12 +559,22 @@ xfs_dir2_data_freescan(
                else {
                        dep = (xfs_dir2_data_entry_t *)p;
                        ASSERT((char *)dep - (char *)hdr ==
-                              be16_to_cpu(*dp->d_ops->data_entry_tag_p(dep)));
-                       p += dp->d_ops->data_entsize(dep->namelen);
+                              be16_to_cpu(*ops->data_entry_tag_p(dep)));
+                       p += ops->data_entsize(dep->namelen);
                }
        }
 }
 
+void
+xfs_dir2_data_freescan(
+       struct xfs_inode        *dp,
+       struct xfs_dir2_data_hdr *hdr,
+       int                     *loghead)
+{
+       return xfs_dir2_data_freescan_int(dp->i_mount->m_dir_geo, dp->d_ops,
+                       hdr, loghead);
+}
+
 /*
  * Initialize a data block at the given block number in the directory.
  * Give back the buffer for the created block.