Commit Graph

456 Commits

Author SHA1 Message Date
Ming-Hung Tsai
e7fa012701 [btree] Fix ref-counting on overwritten values 2021-09-22 17:05:59 +08:00
Ming-Hung Tsai
e6f17d4b4f [thin_repair/thin_dump] Exclude unwanted btree nodes 2021-08-24 22:26:22 +08:00
Ming-Hung Tsai
d2d6ab7926 [thin_repair/thin_dump] Check consistency of thin_ids before running a regular dump 2021-08-24 22:26:22 +08:00
Ming-Hung Tsai
d1e8168fb6 [thin_repair/thin_dump] Change the label type for empty leaves
Empty leaves now are treated as bottom-level leaves, so that empty
devices could be recovered.
2021-08-24 22:26:22 +08:00
Ming-Hung Tsai
c2e6db74b9 [thin_repair/thin_dump] Remove unused function parameter 2021-08-24 22:26:22 +08:00
Ming-Hung Tsai
c286041f25 [thin_repair/thin_dump] Fix sorting of data mapping candidates
- Fix the references for sorting. The timestamp statistics is stored
  in node_info corresponding to the second element.
- Fix the timestamp comparison routine. The mapping root with more recent
  blocks should have higher priority.
2021-08-24 22:26:15 +08:00
Joe Thornber
8e609458c2
Merge pull request #177 from mingnus/2021-06-03-cache-restore-fixes
Fix restoration tools
2021-06-22 09:50:49 +01:00
Ming-Hung Tsai
fba2adbe56 [tests] Fix minor test errors
- Fix command line arguments
- Adapt error messages for rust implementations
2021-06-21 23:27:51 +08:00
Ming-Hung Tsai
c32517f827 [thin] Clear superblock flags in restored metadata
The needs_check flag is unnecessary for a restored metadata since
it is assumed clean and has no errors
2021-06-07 19:06:56 +08:00
Ming-Hung Tsai
25ed2dfc9a [thin_dump] Fix warnings on potential NULL pointer 2021-06-03 18:54:26 +08:00
Ming-Hung Tsai
2e62363446 [all] Fix uninitialized class members 2021-06-03 18:54:26 +08:00
Ming-Hung Tsai
3145a1f4de [thin_metadata_size] Fix potential string overflow 2021-06-03 18:54:26 +08:00
Ming-Hung Tsai
759407445f [thin_show_duplicates] Fix potential errors
- Fix error if no --block-sector provided
- Fix errors on pools without mappings, or zero-length file
2021-06-03 18:50:20 +08:00
Ming-Hung Tsai
75c0a3656c [thin_dump] Fix leaked shared object handle 2021-06-02 03:43:58 +08:00
Ming-Hung Tsai
0004dced93 [thin_show_metadata] Fix out-of-bounds access 2021-06-02 00:51:39 +08:00
Ming-Hung Tsai
f7e4a8faa9 [all] Fix resource leaks 2021-06-02 00:51:39 +08:00
Ming-Hung Tsai
a81cef4467 [dbg] Pull out common code into dbg-lib
- Modularize common routines
- Extract the block_dumper interface for displaying blocks
- Remove inheritance from show_traits
2021-02-21 01:04:35 +08:00
Ming-Hung Tsai
e3a646e4d2 [dbg] Improve error resilience of debugging tools
Do not open the metadata. The tool interprets user specified blocks one-by-one.
Thus, there's no need to preload the metadata structures.

Also remove the unused --ignore-metadata-space-map option. It was designed
to control the loading of space maps with the old metadata constructors.
2021-02-18 00:00:55 +08:00
Ming-Hung Tsai
a05ac553b6 [dbg] Hide implementations of shared components 2021-02-04 14:28:17 +08:00
Ming-Hung Tsai
b9b04dc872 [thin_debug] Factor out reusable componments 2021-02-04 14:19:28 +08:00
Ming-Hung Tsai
e046bbf5c4 [thin_debug] Simplify the output format
Turn nested fields into attributes. Also replace spaces in field names
by underscores.
2021-02-03 15:51:52 +08:00
Ming-Hung Tsai
0816430ba0 [thin_debug] Remove the using boost directive to avoid namespace pollution
boost::uint32_t might conflict with the toolchain defined uint32_t.
which causes template argument deduction failed.
2021-02-03 15:51:52 +08:00
Ming-Hung Tsai
ab3b2cbda2 [thin_debug] Refine the outputs
- Show the blocknr from node header
- Display the index of node entries
2021-02-03 15:51:52 +08:00
Ming-Hung Tsai
6dc5086643 [thin_debug] Add commands to show space maps 2021-02-03 15:51:52 +08:00
Ming-Hung Tsai
3bfa775887 [thin_debug] Show space map roots in superblock 2021-02-03 15:51:52 +08:00
Ming-Hung Tsai
127f44c66b [thin_debug] Enhance error handling
- Handle exception thrown by commands
- Add help and exit commands
2021-02-03 15:51:52 +08:00
Ming-Hung Tsai
62d09c6752 [thin_debug] Reduce code size by eliminating duplicated types
This patch doesn't have a significant effect - only a few KBs of code
is reduced. However, it's still a nice have.
2021-02-03 15:51:52 +08:00
Ming-Hung Tsai
0ce026caf5 [thin_debug] Integrate thin_debug into the main program 2021-02-03 15:51:52 +08:00
Ming-Hung Tsai
6a2fa73924 [build] Enable building the dev-tools for functional tests
- Factor out the dev-tools into a stand-alone, no-installed program
- Built the dev-tools if --enable-testing is specified
- Remove the --enable-dev-tools configure option
- Allow suffix on the binary name
- Update symlinks
- Cleanup Makefile
2021-01-12 16:08:51 +08:00
Ming-Hung Tsai
565c656ed2 [thin_generate_damage] Do not open a new transaction to prevent ref-count underflow
There's a chance that thin_generate_damage tries to change ref-counts of
space map blocks due to its random nature, which could lead to problems.
If the ref-counts of metadata space map blocks (shadow source) is changed
to zero, then the ref-counts will become underflow after a shadow operation.

In-place space map modification is a way to prevent that value underflow.
An alternative approach is to avoid changing ref-counts of space map blocks.
2020-11-24 18:18:21 +08:00
Ming-Hung Tsai
61f07573e1 [metadata_counter] Count under populated nodes if the option is provided 2020-11-24 18:18:21 +08:00
Ming-Hung Tsai
1fe8a0dbde [thin_check] Allow using --clear-needs-check and --skip-mappings together
Although it is not recommended to clear the flag without a full
examination, however, the usage has been documented as an approach
to reduce lvchange run time [1]. For the purpose of backward
compatibility and avoiding boot failure after upgrading thin_check [2],
the limitation is now removed.

[1] https://wiki.archlinux.org/index.php/LVM#Thinly-provisioned_root_volume_device_times_out
[2] Community feedback on previous commit:
    https://github.com/jthornber/thin-provisioning-tools/commit/b278f4f
2020-11-24 18:17:36 +08:00
Ming-Hung Tsai
7ceb500fc8 [thin_delta] Support comparing two specific subtrees 2020-11-24 15:58:01 +08:00
Ming-Hung Tsai
1d5b52b0dd [thin_delta] Clean up duplicated code 2020-11-24 15:17:35 +08:00
Ming-Hung Tsai
b42408ef41 [thin] Introduce thin_patch_superblock to override superblock fields 2020-11-24 14:57:05 +08:00
Ming-Hung Tsai
9f3823c97d [metadata_checker] Rename function to reflect command line changes 2020-08-14 18:49:41 +08:00
Joe Thornber
2860b4c0b1 [thin_check] rename --fix-metadata-leaks to --auto-repair
This flag will cover all trivial fixes, such as data leaks.
2020-08-12 10:45:20 +01:00
Ming-Hung Tsai
6c90f9483e [metadata_checker] Support in-place metadata space map modification 2020-08-12 16:57:16 +08:00
Ming-Hung Tsai
1cfdcd58c5 [metadata_checker] Disable checking data block ref-counts due to performance concerns 2020-08-12 16:57:16 +08:00
Ming-Hung Tsai
b16ff123b7 [thin] Stop metadata counting on the first error 2020-08-12 15:56:26 +08:00
Ming-Hung Tsai
c952f52c79 [metadata_checker] Fix expected ref-counts in data space map comparison 2020-08-10 20:39:22 +08:00
Ming-Hung Tsai
2d9eaa1c56 [metadata_checker] Do not update the superblock if the needs_check flag is not set 2020-08-08 01:20:15 +08:00
Ming-Hung Tsai
3f19818c56 [thin] Adopt stateful random number generators 2020-08-05 22:14:01 +08:00
Ming-Hung Tsai
90f2d43a95 [thin_generate_damage] Add help text 2020-07-30 23:00:50 +08:00
Ming-Hung Tsai
b278f4ffa4 [thin_check] Change the policy of --clear-needs-check-flag to prevent error recurrence
- Disallow clearing the needs_check flag if there's any error,
  i.e., the metadata must be fully examined, and the result must
  be NO_ERROR.
- Disallow combining --clear-needs-check with -m, --super-blocks-only,
  --skip-mappings, --override-mapping-root, or --ignore-non-fatal-errors.
2020-07-30 23:00:50 +08:00
Ming-Hung Tsai
49efa06ffa [thin_check] Support fixing leaked metadata blocks
- The leaked blocks are defined as allocated but not used ones,
  i.e., expected ref-count == 0 and actual ref-count <= 2.
- Blocks with expected ref-count > 0, or actual ref-count > 2,
  are treated as unrepairable leaks.
- The fixing processing won't be executed if there's any
  unrepairable leak or errors.
- The fixing process implicitly clearing the superblock
  needs_check flag if there's no error.
2020-07-30 23:00:50 +08:00
Ming-Hung Tsai
7be6b91420 [metadata_checker] Tidying: rename variables 2020-07-29 16:47:22 +08:00
Ming-Hung Tsai
ecb5226acc [thin] Fix indent and trailing whitespaces 2020-07-29 16:47:22 +08:00
Ming-Hung Tsai
b693c7d6b0 [metadata_checker] Fix missing member initialization 2020-07-29 16:47:22 +08:00
Ming-Hung Tsai
e62022a200 [base] Move run_set to namespace base 2020-07-29 15:33:25 +08:00