linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] btrfs-progs: check: Repair invalid inode mode in
@ 2019-09-05  7:57 Qu Wenruo
  2019-09-05  7:57 ` [PATCH v2 1/6] btrfs-progs: check: Export btrfs_type_to_imode Qu Wenruo
                   ` (5 more replies)
  0 siblings, 6 replies; 24+ messages in thread
From: Qu Wenruo @ 2019-09-05  7:57 UTC (permalink / raw)
  To: linux-btrfs

Before this patch, btrfs check can only repair bad free space cache
inode mode (as it was the first case detected by tree-checker and reported)

But Murphy is always right, what may happen will finally happen, we have
users reporting bad inode mode in subvolume trees.
According to the creation time, it looks like some older kernel around
2014 is causing the problem.

Although the reported get the fs fixed by removing the offending old
files, it's still a bad thing that "btrfs check" can't fix it.

This patch will bring the repair functionality to all inodes, along with
needed test image.

The core complexity is in how to determine the correct imode.
This patch will use the following methods to determine the correct
imode:
- INODE_REF
  Do a DIR_INDEX/ITEM search to find a valid filetype then convert it to
  imode. If it works, this should be the most reliable method.

- DIR_INDEX/DIR_ITEM belong to this inode
  Then this inode must be a directory.

- EXTENT_DATA
  This inode can be a regular file or soft link.
  We default to regular file so user can inspect the content to do
  further correction.

- rdev of INODE_ITEM
  If all above fails, and the INODE_ITEM has non-zero rdev, this inode
  must be either BLK or CHR. We default to BLK for this case.

- Error out if nothing matches
  This is to be 100% sure that we won't further corrupt the fs.

Changelog:
v2:
- Implement INODE_REF based imode lookup functionality
- Instead of defaulting to REG, error out if no imode can be found
  To avoid corrupting the fs.

Qu Wenruo (6):
  btrfs-progs: check: Export btrfs_type_to_imode
  btrfs-progs: check/common: Introduce a function to find imode using
    INODE_REF
  btrfs-progs: check/common: Make repair_imode_common() to handle inodes
    in subvolume trees
  btrfs-progs: check/lowmem: Repair bad imode early
  btrfs-progs: check/original: Fix inode mode in subvolume trees
  btrfs-progs: tests/fsck: Add new images for inode mode repair
    functionality

 check/main.c                                  |  50 ++--
 check/mode-common.c                           | 229 +++++++++++++++++-
 check/mode-common.h                           |  17 ++
 check/mode-lowmem.c                           |  39 +++
 .../039-bad-inode-mode/.lowmem_repairable     |   0
 .../bad_free_space_cache_imode.raw.xz}        | Bin
 .../bad_regular_file_imode.img.xz             | Bin 0 -> 2060 bytes
 7 files changed, 298 insertions(+), 37 deletions(-)
 create mode 100644 tests/fsck-tests/039-bad-inode-mode/.lowmem_repairable
 rename tests/fsck-tests/{039-bad-free-space-cache-inode-mode/test.raw.xz => 039-bad-inode-mode/bad_free_space_cache_imode.raw.xz} (100%)
 create mode 100644 tests/fsck-tests/039-bad-inode-mode/bad_regular_file_imode.img.xz

-- 
2.23.0


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2019-09-11 12:45 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05  7:57 [PATCH v2 0/6] btrfs-progs: check: Repair invalid inode mode in Qu Wenruo
2019-09-05  7:57 ` [PATCH v2 1/6] btrfs-progs: check: Export btrfs_type_to_imode Qu Wenruo
2019-09-05  7:57 ` [PATCH v2 2/6] btrfs-progs: check/common: Introduce a function to find imode using INODE_REF Qu Wenruo
2019-09-09 13:25   ` Nikolay Borisov
2019-09-09 14:24     ` Qu Wenruo
2019-09-09 14:34       ` Nikolay Borisov
2019-09-09 13:42   ` Nikolay Borisov
2019-09-09 14:26     ` Qu Wenruo
2019-09-09 14:35       ` Nikolay Borisov
2019-09-05  7:57 ` [PATCH v2 3/6] btrfs-progs: check/common: Make repair_imode_common() to handle inodes in subvolume trees Qu Wenruo
2019-09-09 14:17   ` Nikolay Borisov
2019-09-09 14:27     ` Qu Wenruo
2019-09-10  4:27   ` Su Yue
2019-09-10 16:14   ` Nikolay Borisov
2019-09-11  0:39     ` Qu Wenruo
2019-09-11 12:27       ` Nikolay Borisov
2019-09-11 12:44         ` Qu Wenruo
2019-09-05  7:57 ` [PATCH v2 4/6] btrfs-progs: check/lowmem: Repair bad imode early Qu Wenruo
2019-09-09 14:55   ` Nikolay Borisov
2019-09-10  2:35     ` Qu Wenruo
2019-09-05  7:57 ` [PATCH v2 5/6] btrfs-progs: check/original: Fix inode mode in subvolume trees Qu Wenruo
2019-09-05  7:58 ` [PATCH v2 6/6] btrfs-progs: tests/fsck: Add new images for inode mode repair functionality Qu Wenruo
2019-09-09 15:37   ` Nikolay Borisov
2019-09-09 23:22     ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).