]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: scrub directory metadata
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)
committerEric Sandeen <sandeen@redhat.com>
Fri, 17 Nov 2017 04:11:32 +0000 (22:11 -0600)
Source kernel commit: a5c46e5e8912d232b959faf511cd9a17cc829f0a

Scrub the hash tree and all the entries in a directory.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_dir2.c
libxfs/xfs_dir2.h
libxfs/xfs_fs.h

index ed8ab0285357e757e59a461a23c9ba145753fcd1..49d56e7baefe2e2236f7a2e4931b81a3bc382b57 100644 (file)
@@ -37,7 +37,9 @@ struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR };
 /*
  * Convert inode mode to directory entry filetype
  */
-unsigned char xfs_mode_to_ftype(int mode)
+unsigned char
+xfs_mode_to_ftype(
+       int             mode)
 {
        switch (mode & S_IFMT) {
        case S_IFREG:
index 21c8f8bf94d52ebd62b7a9e41efb50fb6a8a8000..1a8f2cf977caa28812ab1372055dd4dc62409e5a 100644 (file)
@@ -324,4 +324,21 @@ xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp)
                  sizeof(struct xfs_dir2_leaf_tail));
 }
 
+/*
+ * The Linux API doesn't pass down the total size of the buffer
+ * we read into down to the filesystem.  With the filldir concept
+ * it's not needed for correct information, but the XFS dir2 leaf
+ * code wants an estimate of the buffer size to calculate it's
+ * readahead window and size the buffers used for mapping to
+ * physical blocks.
+ *
+ * Try to give it an estimate that's good enough, maybe at some
+ * point we can change the ->readdir prototype to include the
+ * buffer size.  For now we use the current glibc buffer size.
+ * musl libc hardcodes 2k and dietlibc uses PAGE_SIZE.
+ */
+#define XFS_READDIR_BUFSIZE    (32768)
+
+unsigned char xfs_dir3_get_dtype(struct xfs_mount *mp, uint8_t filetype);
+
 #endif /* __XFS_DIR2_H__ */
index a8f007d1804e969229ea07d3be2399f8c216e272..c783de1f2abeb53e988aed07708fda849e45e80c 100644 (file)
@@ -519,9 +519,10 @@ struct xfs_scrub_metadata {
 #define XFS_SCRUB_TYPE_BMBTD   12      /* data fork block mapping */
 #define XFS_SCRUB_TYPE_BMBTA   13      /* attr fork block mapping */
 #define XFS_SCRUB_TYPE_BMBTC   14      /* CoW fork block mapping */
+#define XFS_SCRUB_TYPE_DIR     15      /* directory */
 
 /* Number of scrub subcommands. */
-#define XFS_SCRUB_TYPE_NR      15
+#define XFS_SCRUB_TYPE_NR      16
 
 /* i: Repair this metadata. */
 #define XFS_SCRUB_IFLAG_REPAIR         (1 << 0)