]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: clean up _dir2_data_freescan
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 10 Jan 2017 02:16:33 +0000 (20:16 -0600)
committerEric Sandeen <sandeen@redhat.com>
Tue, 10 Jan 2017 02:16:33 +0000 (20:16 -0600)
Source kernel commit: 523b2e76e3ecb54e0ec8651e32291bdaefc5f866

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_api_defs.h
libxfs/libxfs_priv.h
libxfs/xfs_dir2.h
libxfs/xfs_dir2_data.c
repair/dir2.c
repair/phase6.c

index d60b6c2246866ca26f15d493ae3dc45d6274697c..b7b104350881eb1fc0b2b6283bae4ffde4f8a039 100644 (file)
@@ -88,7 +88,7 @@
 #define xfs_dir_replace                        libxfs_dir_replace
 #define xfs_dir2_isblock               libxfs_dir2_isblock
 #define xfs_dir2_isleaf                        libxfs_dir2_isleaf
-#define __xfs_dir2_data_freescan       libxfs_dir2_data_freescan
+#define xfs_dir2_data_freescan_int     libxfs_dir2_data_freescan_int
 #define xfs_dir2_data_log_entry                libxfs_dir2_data_log_entry
 #define xfs_dir2_data_log_header       libxfs_dir2_data_log_header
 #define xfs_dir2_data_make_free                libxfs_dir2_data_make_free
index a101a007808fb40cdfb53ea5ef69cc6d9c131ac9..f4db1833a95fbda93489b348b2460f5de1e20ff8 100644 (file)
 #ifndef __LIBXFS_INTERNAL_XFS_H__
 #define __LIBXFS_INTERNAL_XFS_H__
 
-/*
- * Repair doesn't have a inode when it calls libxfs_dir2_data_freescan,
- * so we to work around this internally for now.
- */
-#define xfs_dir2_data_freescan(ip, hdr, loghead) \
-       __xfs_dir2_data_freescan((ip)->i_mount->m_dir_geo, \
-                                (ip)->d_ops, hdr, loghead)
-
 #include "libxfs_api_defs.h"
 #include "platform_defs.h"
 #include "xfs.h"
index 89b9e2484eb6a99ea8257d8b80e20cbfaada0894..0197590fa7d7c0a3d97d68dccdcfb3bd0709964b 100644 (file)
@@ -157,9 +157,11 @@ 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(struct xfs_da_geometry *geo,
+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,
                struct xfs_buf *bp, struct xfs_dir2_data_entry *dep);
 extern void xfs_dir2_data_log_header(struct xfs_da_args *args,
index 6ae5cd2f068c6ab19894416c4d6bb531396c1049..f8def7c7744bce8d2c1b0faf838eea84d447a2db 100644 (file)
@@ -502,7 +502,7 @@ xfs_dir2_data_freeremove(
  * Given a data block, reconstruct its bestfree map.
  */
 void
-__xfs_dir2_data_freescan(
+xfs_dir2_data_freescan_int(
        struct xfs_da_geometry  *geo,
        const struct xfs_dir_ops *ops,
        struct xfs_dir2_data_hdr *hdr,
@@ -562,6 +562,16 @@ __xfs_dir2_data_freescan(
        }
 }
 
+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.
index 61912d1056cd0adb89507b26594ecea9d26b476f..e6415e49b6214d3d381a0eace132399cde6d5b11 100644 (file)
@@ -921,8 +921,8 @@ _("bad bestfree table in block %u in directory inode %" PRIu64 ": "),
                        da_bno, ino);
                if (!no_modify) {
                        do_warn(_("repairing table\n"));
-                       libxfs_dir2_data_freescan(mp->m_dir_geo, M_DIROPS(mp),
-                                                 d, &i);
+                       libxfs_dir2_data_freescan_int(mp->m_dir_geo,
+                                       M_DIROPS(mp), d, &i);
                        *dirty = 1;
                } else {
                        do_warn(_("would repair table\n"));
index 06eed16c28fa9252e6e8e6c35f8498d41ad0bedc..399ecde36e2ef8810a87fd0548093f41d3084b73 100644 (file)
@@ -1883,7 +1883,8 @@ _("entry \"%s\" in dir inode %" PRIu64 " inconsistent with .. value (%" PRIu64 "
        }
        *num_illegal += nbad;
        if (needscan)
-               libxfs_dir2_data_freescan(mp->m_dir_geo, M_DIROPS(mp), d, &i);
+               libxfs_dir2_data_freescan_int(mp->m_dir_geo, M_DIROPS(mp),
+                               d, &i);
        if (needlog)
                libxfs_dir2_data_log_header(&da, bp);
        libxfs_defer_finish(&tp, &dfops, ip);