From: Darrick J. Wong Date: Fri, 17 Nov 2017 04:11:32 +0000 (-0600) Subject: xfs: scrub directory metadata X-Git-Tag: v4.15.0-rc1~143^2~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=16c101bb938ad7f83fa6782a09055b0f98d3fdcc;p=thirdparty%2Fxfsprogs-dev.git xfs: scrub directory metadata Source kernel commit: a5c46e5e8912d232b959faf511cd9a17cc829f0a Scrub the hash tree and all the entries in a directory. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_dir2.c b/libxfs/xfs_dir2.c index ed8ab0285..49d56e7ba 100644 --- a/libxfs/xfs_dir2.c +++ b/libxfs/xfs_dir2.c @@ -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: diff --git a/libxfs/xfs_dir2.h b/libxfs/xfs_dir2.h index 21c8f8bf9..1a8f2cf97 100644 --- a/libxfs/xfs_dir2.h +++ b/libxfs/xfs_dir2.h @@ -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__ */ diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index a8f007d18..c783de1f2 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -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)