fsck.f2fs: reconnect unreachable files to lost+found
authorSheng Yong <shengyong1@huawei.com>
Tue, 6 Mar 2018 03:39:40 +0000 (11:39 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 7 May 2018 21:49:38 +0000 (14:49 -0700)
commiteb61637ad1f281e0db79f5855382114dbb9c6ad1
treef9cd36a329ad4338198970927fea42b5d20a5ce2
parentff3782931fcb168f16e9028a040db8ce94b4deed
fsck.f2fs: reconnect unreachable files to lost+found

This patch introduces lost_found feature to fsck. If a file is found
unreachable by fsck. Fsck tries to reconnect the file to lost+found
directory:
  1. Scan all unreachable file inodes, ignore non-inodes ones and
     directories.
  2. Check them and fix incorrupted data to make sure filesystem
     metadata (mainly counters and main/nat bitmap) are all consistent.
  3. Reconnect these files to lost+found. If lost+found does not exist,
     create it first. During reconnecting, expand lost+found's dentry
     block automatically. Reconnected files are renamed after its ino
     number.
  4. If reconnect fails drop the node and restore filesystem metadata.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fsck/dir.c
fsck/fsck.c
fsck/fsck.h
fsck/mount.c