From b4a8e309923630d5b42c0bee70e6dfd066ba862b Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Tue, 25 Feb 2020 15:13:48 -0800 Subject: xfs: online repair of directories If a directory looks like it's in bad shape, try to sift through the rubble to find whatever directory entries we can, zap the old tree, and re-add the entries. Signed-off-by: Darrick J. Wong --- fs/xfs/scrub/dir.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'fs/xfs/scrub/dir.c') diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c index 7c432997edad..5d8eb883e987 100644 --- a/fs/xfs/scrub/dir.c +++ b/fs/xfs/scrub/dir.c @@ -25,7 +25,22 @@ xchk_setup_directory( struct xfs_scrub *sc, struct xfs_inode *ip) { - return xchk_setup_inode_contents(sc, ip, 0); + unsigned int sz; + int error; + + error = xchk_setup_inode_contents(sc, ip, 0); + if (error) + return error; + + if (!(sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)) + return 0; + + sz = max_t(unsigned int, MAXNAMELEN + 1, sizeof(struct xfs_da_args)); + sc->buf = kmem_alloc_large(sz, 0); + if (!sc->buf) + return -ENOMEM; + + return 0; } /* Directories */ -- cgit v1.2.3