Commit Graph

247 Commits

Author SHA1 Message Date
Ming-Hung Tsai
e5f0acd288 [thin_metadata_size (rust)] First code drop 2021-10-21 17:51:28 +08:00
Ming-Hung Tsai
34f6b6fc62 [cache_metadata_size (rust)] First code drop 2021-10-21 17:51:28 +08:00
Ming-Hung Tsai
cc89cef43f [era_dump (rust)] Dump the current_writeset that has not been archived
This patch is added in corresponding to the dm-era patch de89afc1 in kernel:
dm era: Recover committed writeset after crash
2021-10-21 17:51:28 +08:00
Ming-Hung Tsai
533e174051 [era_dump (rust)] Support wrapped-around era in logical dump 2021-10-21 17:51:28 +08:00
Ming-Hung Tsai
89e568b897 [era_dump (rust)] Implement logical dump 2021-10-21 17:51:28 +08:00
Ming-Hung Tsai
0215b5fecd [era_check (rust)] Remove unused option 2021-10-21 17:51:28 +08:00
Ming-Hung Tsai
8fa7f96dfd [era_dump/restore (rust)] Support displaying writeset blocks in ranges
- Group adjacent marked blocks into ranges
- Show marked blocks only, and ignore untouched blocks
2021-10-21 17:49:36 +08:00
Ming-Hung Tsai
4559039066 [era_invalidate (rust)] First code drop 2021-10-21 17:04:54 +08:00
Ming-Hung Tsai
0791208ca4 [io_engine (rust)] Open file exclusively 2021-10-21 16:18:14 +08:00
Ming-Hung Tsai
9ab4172790 [cache_restore (rust)] Tidy up 2021-10-21 16:18:14 +08:00
Ming-Hung Tsai
36767bcda6 [era_repair (rust)] First code drop 2021-10-21 16:18:14 +08:00
Ming-Hung Tsai
3a8dc8da2d [xml (rust)] Log invalid attribute name 2021-10-21 16:18:14 +08:00
Ming-Hung Tsai
ed7480e96d [era_restore (rust)] First code drop 2021-10-21 16:18:14 +08:00
Ming-Hung Tsai
55a81c0b9f [era_dump (rust)] First code drop 2021-10-21 16:18:14 +08:00
Ming-Hung Tsai
8a1399e3bb [cache_dump (rust)] Make use of the --repair option
Ignore non-fatal errors, and regenerate unavailable dirty bits if --repair was applied.
2021-10-21 16:18:14 +08:00
Ming-Hung Tsai
3d36456a36 [era_check (rust)] First code drop 2021-10-21 16:18:14 +08:00
Ming-Hung Tsai
c8a1da1df9 [all] Apply cargo fmt, and fix clippy warnings 2021-10-20 20:23:27 +08:00
Joe Thornber
959b04ecb5 [thin_dump] fix overrides 2021-10-20 13:06:15 +01:00
Joe Thornber
a568da8c71 [tests/thin_dump] remove some extraneous output to stderr 2021-10-19 15:23:17 +01:00
Joe Thornber
024554c987 Merge rust tools into a single pdata_tools exe 2021-10-11 12:07:26 +01:00
Ming-Hung Tsai
d712190db4 [io_engine (rust)] Open file exclusively 2021-09-22 17:07:56 +08:00
Ming-Hung Tsai
66c1d629a4 [all (rust)] Keep silent if --quiet was applied 2021-09-22 17:07:56 +08:00
Ming-Hung Tsai
d436f35ed3 [thin_dump/thin_repair/thin_restore (rust)] Fix errors in tests
- Move error messages to stderr
- Fix the transaction_id and data_block_size in test fixture,
  and check the data_block_size in thin_restore.
- Disable the missing_something tests for Rust. The transaction_id
  and nr_data_blocks now could be recovered automatically.
- Limit the use of override options in test cases. Only broken
  superblocks could be overridden, and the provided values
  should be compatible to the original metadata.
- Remove unused option
2021-09-22 17:06:28 +08:00
Ming-Hung Tsai
c133e62353 [thin_dump] Emit superblock flags 2021-09-22 17:05:59 +08:00
Ming-Hung Tsai
34f927d989 [thin_check (rust)] Make better use of Rust's Result type
Replace the bail_out checking with the returned Result, which helps
decoupling the internal state of Report from application logic.
2021-09-22 17:05:59 +08:00
Ming-Hung Tsai
438730951e [thin_check (rust)] Allow ignoring non-fatal errors in mapping tree 2021-09-22 17:05:59 +08:00
Ming-Hung Tsai
a18fd60f3f [thin_check (rust)] Fix auto-repair related errors
- Returns error on metadata leaks
- Clear needs_check flag on success
- Check auto-repair write errors
- Fix file open flags, and correct spelling
2021-09-22 17:05:59 +08:00
Ming-Hung Tsai
f8c40a1fda [thin_check (rust)] Set compatibility between options 2021-09-22 17:05:59 +08:00
Ming-Hung Tsai
bb53083271 [array (rust)] Fix building uncontiguous array 2021-09-22 17:05:59 +08:00
Ming-Hung Tsai
2f22a8c55d [all (rust)] Fix errors in testing input option
- Fix file mode bits checking
- Return error reason from stat
2021-09-22 17:05:59 +08:00
Ming-Hung Tsai
4ed2348b36 [cache_restore (rust)] Fix errors in tests
- Move error messages to stderr (fixes unwritable_output_file,
  input_file_not_found, and missing_input_option)
- Validate XML structures implicitly (fixes corrupted_input_data)
- Check output file size (fixes tiny_output_file)
- Allow restoring XML without the hints (for creating test fixtures)
- Provide XML error context
- Remove unused option
2021-09-22 17:05:29 +08:00
Ming-Hung Tsai
0acc57d17f [thin_restore (rust)] Fix errors in tests
- Move error messages to stderr (fixes unwritable_output_file,
  input_file_not_found, and missing_input_option)
- Validate XML structures implicitly (fixes corrupted_input_data)
- Check output file size (fixes tiny_output_file)
- Provide XML error context
- Fix mk_valid_input()
2021-09-16 21:55:46 +08:00
Ming-Hung Tsai
0d87619a93 [thin_repair/thin_dump (rust)] Show repairing progress 2021-08-27 17:30:56 +08:00
Ming-Hung Tsai
71d47ef58b [thin/cache (rust)] Validate superblock checksum 2021-08-27 11:17:27 +08:00
Ming-Hung Tsai
8a822cebec [thin_repair/thin_dump (rust)] Support rebuilding superblock 2021-08-27 02:17:57 +08:00
Ming-Hung Tsai
213442bffd [all (rust)] Fix cosmetic names for argument values 2021-08-27 02:17:57 +08:00
Ming-Hung Tsai
434d24d10a [thin_repair (rust)] Support setting missing superblock fields automatically
While rebuilding a superblock, the transaction_id, data_block_size, and
nr_data_blocks could be inherited from the current superblock if available
(assumed it's a multiple-activated copy, so supposed partially valid),
or derived from the probed data mappings and device details, that saves
the hassle of manual input.

Note that either the current superblock or user-overrides must be compatible
with the probed values, thus the filters are applied.
2021-08-27 02:17:57 +08:00
Ming-Hung Tsai
5dad1097c3 [thin_repair (rust)] Add searching for missing roots
Based on the method of commit 9e20465
2021-08-27 02:17:57 +08:00
Ming-Hung Tsai
b7132440d0 [space_map (rust)] Encapsulate implementations 2021-08-27 00:08:21 +08:00
Ming-Hung Tsai
ec44d043e8 [space_map (rust)] Restrict metadata space map size 2021-08-06 13:22:13 +08:00
Ming-Hung Tsai
c167403212 [space_map (rust)] Fix the maximum value of reference counts 2021-08-06 13:22:13 +08:00
Ming-Hung Tsai
e158dc7601 [btree_builder] Fix issues with under populated shared nodes
A pre-built node could be under populated (less than half-full) due to
following reasons:

- A single shared leaf generated by dm-thin key removal. The residency
  could drop below 50%, until it reaches the merge threshold (33% or 44%,
  depends on its context).
- A shared root, which could have any possible nr_entries.
- Underfull shared nodes (less than 33% residency) caused by kernel issues.

To avoid producing under populated nodes, those kinds of pre-built nodes,
except the roots, will be merged into their siblings.
2021-08-06 13:22:13 +08:00
Ming-Hung Tsai
bd39b570ef [btree_builder] Fix reference counts of unshifted child values
The ref counts now are handled in a straightforward method:
The pre-built subtrees serve as snapshots of potentially shared nodes.
They hold an initial ref count on the pre-built nodes and their children.
The temporary ref counts are later dropped at the end of device building.

This way fixes the ref counts of unshifted nodes, thus the 'reserve'
operation introduced by commit 6d16c58 is reverted.
2021-08-05 23:41:23 +08:00
Ming-Hung Tsai
052c9f90ea [thin/cache_repair (rust)] Fix file open options 2021-08-05 23:41:23 +08:00
Ming-Hung Tsai
7239204b01 [cache_repair (rust)] First pass at cache_repair 2021-07-27 23:51:20 +08:00
Ming-Hung Tsai
4b9766846e [cache (rust)] Prepare for cache_repair
- Adapt function interfaces for repairing purpose
- Finalize the metadata in the Restorer
- Make the Restorer public
2021-07-27 23:51:20 +08:00
Ming-Hung Tsai
85581cdf5a [thin_repair (rust)] First pass at thin_repair 2021-07-27 23:51:20 +08:00
Ming-Hung Tsai
dccd844714 [thin_restore (rust)] Prepare for thin_repair
- Finalize the metadata in the Restorer
- Make the Restorer public
2021-07-27 23:51:20 +08:00
Ming-Hung Tsai
d42bde371f [thin_dump (rust)] Prepare for thin_repair
- Adapt function interfaces for repairing purpose
- Pull out reuseable structures
2021-07-27 23:51:20 +08:00
Ming-Hung Tsai
56d7da66aa [thin_dump (rust)] Tidy up
- Do not use shared internals as Defs
- Build Defs with common leaf sequences only, that could forms
  more common Defs between partially shared subtrees.
2021-07-27 23:45:02 +08:00