Commit Graph

456 Commits

Author SHA1 Message Date
Ming-Hung Tsai
061d966e7a [io_generator] Support mixed sequential and random io pattern 2020-07-25 17:46:59 +08:00
Ming-Hung Tsai
d1fed5f5ec [thin_generate_damage] Introduce tools to generate metadata damage 2020-07-25 16:53:44 +08:00
Ming-Hung Tsai
e46fabde1a [thin_generate_metadata] Fix command line options
- Remove unused options
- Fix potential option conflict
2020-07-25 16:53:44 +08:00
Ming-Hung Tsai
8d8ee51599 [thin_generate_metadata] Support setting the needs_check flag 2020-07-25 16:53:44 +08:00
Joe Thornber
fec11289b0 [thin_check/dump] Under populated nodes are now 'non fatal errors'
thin_dump always ignores non-fatal-errors.
2020-07-02 16:03:23 +01:00
Joe Thornber
9adcc7911f Merge branch 'master' of github.com:jthornber/thin-provisioning-tools 2020-07-02 10:53:10 +01:00
Joe Thornber
a407c831df [thin_repair] Fix segfault with metadata containing loops (bz1853241)
'seen' bit was being set too late.
2020-07-02 10:51:10 +01:00
Ming-Hung Tsai
19e482fd2f [thin_generate_mappings] Update help text 2020-06-24 12:26:15 +08:00
Ming-Hung Tsai
8006e18173 [thin_pool] Fix the number of mapped blocks 2020-06-24 12:26:14 +08:00
Ming-Hung Tsai
084ac4b950 [io_generator] Simplify the class interface 2020-06-24 12:26:09 +08:00
Ming-Hung Tsai
8fa59553c4 [thin_generate_mappings] Introduce the mapping generation tool 2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
621b466333 [all] Eliminate duplicated sector_t typedefs 2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
5260a87c0b [base] Move math_utils to namespace base 2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
ef8e94b22c [thin_generate_metadata] Support setting transaction id and metadata snapshots 2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
524de134a4 [thin_pool] Support creating metadadata snapshot 2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
e33c60c7e2 [thin_pool] Add close_thin() 2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
89409927b4 [thin_generate_metadata] Support device deletion 2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
a5614f7db2 [thin_pool] Complete device deletion 2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
4e1ec9326b [thin_pool] Tidying
- Remove unused headers
- Use predefined types
2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
598696bc32 [thin_pool] Implement synchronous mapping insertion and removal 2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
383ae78871 [thin_pool] Determine shared blocks while looking up mappings 2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
a842b4ecfd [thin_generate_metadata] Make use of thin_pool.cc 2020-06-19 18:07:55 +08:00
Ming-Hung Tsai
66b519db83 [thin_pool] Fix snapshot creation 2020-06-19 17:22:19 +08:00
Ming-Hung Tsai
2cce8a51a7 [thin_pool] Fix mapped block time 2020-06-19 17:22:19 +08:00
Ming-Hung Tsai
7f7ba950ef [thin_pool] Complete device creation
- Set up the device details
- Cache device details of opened devices
- Update changed devices at once while committing the pool
2020-06-19 17:22:19 +08:00
Ming-Hung Tsai
77adb08c3f [thin_pool] Replace the member pointer by references 2020-06-17 19:09:24 +08:00
Ming-Hung Tsai
0b058a2850 [thin_pool] Encapsulate metadata into the pool class 2020-06-17 19:09:24 +08:00
Ming-Hung Tsai
5810846409 [thin] Add more constructors to device_details 2020-06-17 19:09:24 +08:00
Joe Thornber
0b5afc6cb0 [thin_check] fix bugs in thin_check -m 2020-06-12 13:41:47 +01:00
Joe Thornber
86704deacb [thin_check] Add support for --metadata-snap.
Not tested yet.
2020-06-09 14:25:19 +01:00
Joe Thornber
01a7462ece Merge branch 'master' into 2020-05-27-check-data-space-map 2020-06-09 13:39:46 +01:00
Joe Thornber
61de3f9287 [thin_metadata_pack/unpack] Replace C++ implementation with a Rust one.
The Rust implementation is multithreaded, performs better in general and
does custom compression of btree nodes to achieve much better compression
ratios.  unpack also checksums expanded metadata to validate it.

Format version has jumped to 3, no backwards compatibility, but I think
that's ok since we never made a release that contained the C++ version
of these tools.

Benchmarks
==========

On an 8 core, 16 hyperthread machine.

metadata 1G, full:

      Pack size    pack time     unpack time
------------------------------------------------------
C++      193M        50.3s          6.9s (no verify)
Rust      70M         1.4s          1.8s (verify)

metadata 16G, sparse:

       Pack size    pack time     unpack time
------------------------------------------------------
C++      21M          68s           1s   (no verify)
Rust      4M           8.6s         0.5s (verify)
2020-06-09 09:15:00 +01:00
Joe Thornber
c48851e747 Merge branch 'master' of github.com:jthornber/thin-provisioning-tools 2020-06-01 11:14:24 +01:00
Joe Thornber
9f2b747ffa [thin_metadata_pack] Prefetch blocks.
Doubles performance
2020-06-01 11:13:51 +01:00
Joe Thornber
16a10d2554 [thin_check] Remove the metadata_checker base class.
It's really only a single method.
2020-05-28 14:43:03 +01:00
Joe Thornber
c94f560be8 [thin_check] Check the ref counts in the data space map.
Hadn't realised this was being done.
2020-05-28 14:35:51 +01:00
Ming-Hung Tsai
0f2918e989 [thin_generate_metadata] Implement format_metadata and create_thin 2020-05-28 17:30:15 +08:00
Ming-Hung Tsai
0c6d132774 [thin_generate_metadata] Preparation for revising the features 2020-05-28 15:09:20 +08:00
Joe Thornber
e92ae10408 [thin_metadata_pack/unpack] Add version field to header. 2020-05-26 10:59:13 +01:00
Joe Thornber
a934a34d22 [thin_metadata_pack/unpack] Move the file magic nr before the compressed stream.
Makes it easier to spot whether it's a pack file or not.
2020-05-26 10:53:14 +01:00
Ming-Hung Tsai
c0106fc0b3 [thin_metadata_pack] Improve block scanning performance 2020-05-23 20:32:09 +08:00
Joe Thornber
0e1700fbe9 [thin_metadata_pack] First pass at pack/unpack 2020-05-22 14:11:48 +01:00
Joe Thornber
b7d20bce48 [dev-tools] Update dev tools to use non-template version of block_manager. 2020-05-01 14:11:33 +01:00
Joe Thornber
4313469475 [all] Switch from boost::shared_ptr -> std::shared_ptr.
Shared_ptr has moved into the standard library since these tools were
first written.
2020-04-30 15:02:43 +01:00
Joe Thornber
e801cc607b [block_manager] Hard code block size to 4k.
We're never going to use anything other than 4k, and by hard coding it we
avoid making block_manager a template.
2020-04-30 14:30:01 +01:00
Joe Thornber
ad79b627a4 Merge branch 'master' of github.com:jthornber/thin-provisioning-tools 2020-04-08 12:30:26 +01:00
Joe Thornber
0098803345 [thinp_*] Make mtree_ref_counter derive from ref_counter.
Slight performance hit, but I'd rather everything was derived
from ref_counter.

Also implement it!  Not sure why this wasn't done before.
2020-04-08 12:24:37 +01:00
Joe Thornber
0ccee1759e [various] Squash a couple of clang warning wrt friend declarations. 2020-04-08 12:18:24 +01:00
Joe Thornber
5e347dddbf [various] remove dead code.
Squashes warnings from clang++
2020-04-08 12:12:59 +01:00
Arusekk
3ed3925370 Fix compilation with uClibc
Closes #12
2020-03-25 15:58:02 +01:00
Ming-Hung Tsai
955e11bc28 [block-cache] fix potential file descriptor leak
Encapsulate file descriptor into an object, to ensure that an fd will be
closed properly while exception raised, e.g., the block_cache throws
exception during the block_manager's construction.
2020-02-23 15:41:16 +08:00
Ming-Hung Tsai
c85ea5ef76 [thin_check] factor out metadata_checker 2020-02-17 11:42:24 +00:00
Joe Thornber
5f2c3bed69 Add some ftests, and fixup whitespace from Nikhil's work 2019-10-28 11:52:21 +00:00
Nikhil Kshirsagar
91b4714e38 Corrupt superblock repair 2019-10-25 15:02:56 +05:30
Joe Thornber
0fc7529c01 [cache_repair, thin_repair] fix bug introduced in recent patch
I hadn't realised that check_file_exists() also checked that it was
a regular file, which we don't want for the couple of uses I recently
added.

This patch adds an optional arg must_be_regular_file, and defaults
it to true, preserving the original behaviour.  The recent additions
have this set to false.
2019-10-14 09:21:38 +01:00
Joe Thornber
1dd7b454bb [thin_repair, cache_repair] Check input file exists earlier
and zero superblock if we fail part way through a repair.

bz1499781
2019-10-08 14:34:24 +01:00
Joe Thornber
733c7df798 [thin_repair/thin_dump] Fix some more spurious error messages when doing repair.
Repair was falling back to non-repair behaviour if it thought the roots
were ok.  Now if --repair is specified the same dumping code is always
executed.
2019-06-03 14:03:24 +01:00
Joe Thornber
e45a211902 [thin/metadata_dumper] Change a couple of confusing class names.
metadata_emitter is actually a visitor that passes on it's data
to an encapsulated emitter object.

metadata_emitter -> metadata_emit_visitor
metadata_tree_emitter -> metadata_tree_emit_visitor
2019-06-03 11:07:32 +01:00
Joe Thornber
0624ded67f [thin_repair, thin_dump] Don't look for better roots if the ones in the sb are ok.
Calculating the most recent trees is inexact, so trees other than the ones
in the superblock, which presumably are the most recent, could be chosen.
2019-05-27 16:43:32 +01:00
Joe Thornber
5e6ddbf2da [thin_dump, thin_repair] Fix bad metadata_damage exception
The first pass of the repair process scans all metadata working out the
largest orphan btrees.  This scan doesn't use as much validation as
the btree_walk function which subsequently gets called.

This patch catches any exceptions thrown by the btree walk function
and removes that btree from consideration.
2019-05-27 16:06:59 +01:00
Joe Thornber
65264911c1 [thin_repair, thin_dump] --repair falg wasn't being passed through properly.
Recent regression.
2019-05-27 09:04:55 +01:00
Joe Thornber
595ddfc50f [thin_repair/thin_dump] repair flag wasn't being set internally.
Introduced by recent changes
2019-05-03 15:15:01 +01:00
Joe Thornber
9e20465fd1 [thin-repair, thin_dump] When repairing we now hunt for the best btree roots.
We've had a trickle of users who accidentally activate the same pool on a
VM and host at the same time.  Typically the host doesn't do any IO, but
the kernel will still rewrite the superblock on shutdown.  This leaves
the superblock pointing to very out of date btree roots and so we get
massive metadata loss.

This patch changes thin_repair, and thin_dump --repair.  They now hunt
for the most recent, undamaged and consistent roots of the device and
mapping trees, and use that as the starting point of the repair.
2019-04-17 12:17:13 +01:00
Joe Thornber
b027a1039f [thin-provisioning] Add a new constructor for the metadata class
This one takes a superblock.  Used when repairing.
2019-04-17 12:15:46 +01:00
Joe Thornber
b777a77023 [thin-provisioning] pass the tm by reference to the metadata object 2019-04-04 15:06:41 +01:00
Joe Thornber
aace49cdd6 [thin_repair] work in progress 2019-03-29 12:56:31 +00:00
Joe Thornber
d1a41d01cc [thin-check] print out some info fields.
These are consumed by lvm.
2018-11-09 12:43:21 +00:00
Joe Thornber
de7c9a5781 [thin_journal_check] Checks journal of block manager activity.
You need to apply doc/bm-journal.patch to create the journal.

thin_journal_check confirms that if the machine had crashed at any time
during the test run no metadata corruption would have occured.
2018-09-24 14:51:46 +01:00
Joe Thornber
70cdfe12a2 [thin_journal_check] first code drop 2018-08-28 13:12:20 +01:00
Ming-Hung Tsai
9837feaee5 [thin_scan] refactoring and performance improvement (#111) 2018-08-15 07:56:45 +01:00
Dennis Schridde
1311447a94 [build] Include boost/optional/optional_io.hpp in thin-provisioning/emitter.h (#102)
This fixes following build failure with Boost 1.67.0:
```
In file included from /usr/include/boost/optional/optional.hpp:33,
                 from /usr/include/boost/optional.hpp:15,
                 from ./thin-provisioning/emitter.h:23,
                 from contrib/thin_sexp_emitter.cc:2:
/usr/include/boost/optional/optional.hpp: In instantiation of ‘std::basic_ostream<_CharT, _Traits>& boost::operator<<(std::basic_ostream<_CharT, _Traits>&, const boost::optional_detail::optional_tag&) [with CharType = char; CharTrait = std::char_traits<char>]’:
./base/indented_stream.h:31:9:   required from ‘{anonymous}::indented_stream& {anonymous}::indented_stream::operator<<(const T&) [with T = boost::optional<unsigned int>]’
contrib/thin_sexp_emitter.cc:105:29:   required from ‘void {anonymous}::sexp_emitter::kv(const char*, const T&) [with T = boost::optional<unsigned int>]’
contrib/thin_sexp_emitter.cc:29:21:   required from here
/usr/include/boost/optional/optional.hpp:1481:3: error: static assertion failed: If you want to output boost::optional, include header <boost/optional/optional_io.hpp>
   BOOST_STATIC_ASSERT_MSG(sizeof(CharType) == 0, "If you want to output boost::optional, include header <boost/optional/optional_io.hpp>");
   ^~~~~~~~~~~~~~~~~~~~~~~
make: *** [contrib/Makefile:15: contrib/thin_sexp_emitter.o] Error 1
```

boost/optional/optional_io.hpp exists since at least Boost 1.34.0, so it is
 safe to include in older versions, too.
2018-06-13 08:42:30 +01:00
Ming-Hung Tsai
582e424560 [space-map-disk] fix the number of free blocks (#93) 2018-04-17 14:00:44 +01:00
Joe Thornber
1433d11f59 [thin-provisioning/metadata] Use latest metadata version (2) 2018-04-17 13:32:49 +01:00
Joe Thornber
abb32897e2 [thin_dump] human_readable emitter didn't print the metadata_snap. 2018-04-17 10:29:31 +01:00
csonto
5b5aa971a0 Detect XML in *_check tools (#86)
* [*_check] Detect XML in cache_check and era_check

This is based on previous commit b10d8d4440.

* [*_check] Fix typo in check_superblock
2017-10-05 13:47:10 +01:00
Joe Thornber
3c761e6822 [all tools] Factor out open_bm() and open_tm.
Many duplicates of this code.
2017-10-05 11:53:40 +01:00
Joe Thornber
99e8459be3 [thin_rmap] tweak an error message. 2017-10-05 08:22:58 +01:00
Joe Thornber
24931b3bda [thin_check] --override-mapping-root 2017-10-04 11:43:13 +01:00
Joe Thornber
5b92f410ec [*_restore] if things go wrong wipe the superblock.
So we don't leave the metadata device with partially restored metadata.
2017-09-28 14:39:24 +01:00
Joe Thornber
48e7ab89a5 [*_dump] Fix segfault when given a tiny metadata file 2017-09-21 10:22:38 +01:00
Joe Thornber
313716028e [thin-metadata-size] -V was exiting with 1 2017-09-19 11:29:35 +01:00
Joe Thornber
3790f2e79c [thin_rmap] Fail if no regions are supplied. 2017-09-19 11:05:00 +01:00
Joe Thornber
f7d79339e8 [man pages] Various updates. 2017-09-18 16:10:56 +01:00
Joe Thornber
b10d8d4440 [thin_check] Spot XML and be helpful. 2017-09-15 15:22:04 +01:00
Joe Thornber
a424417475 [thin_delta] long opts weren't being terminated properly.
This caused a seg fault with an unknown switch
2017-09-15 12:28:19 +01:00
Ming-Hung Tsai
b7d418131d Spin-off syscall-related file operations (#78)
* [file_utils] spin-off syscall-related file operations

1. Eliminate the potential circular dependency between
   persistent-data/block.h and persistent-data/file_utils.h,
   if the former one wants to include the latter.
2. Avoid namespace pollution by removing the "using namespace std"
   declaration in block.tcc.
3. Correct the header hierarchy: base/xml_utils.h now no longer
   depends on the higher-level persistent-data/file_utils.h

* [file_utils] support block files in get_file_length()
2017-04-29 18:51:52 +01:00
Joe Thornber
4c311cf6d4 Switch an auto_ptr to a unique_ptr 2017-03-13 13:20:52 +00:00
Thanos Makatos
73e583e662 remove debug print 2017-02-06 13:11:10 +03:00
Thanos Makatos
0c78d8d0c5 fix compilation for gcc 5.4.0 2016-09-07 13:49:36 +00:00
Ming-Hung Tsai
45dbc2593a [thin_ll_restore] check preallocation of output file 2016-08-10 23:41:25 +08:00
Ming-Hung Tsai
6863db6f86 [thin] fix duplicated counting of mapped blocks in restore emitter 2016-08-10 23:40:48 +08:00
Joe Thornber
e6562c6110 thin_generate_metadata 2016-07-15 11:23:07 +01:00
Joe Thornber
52de2dd38e Merge branch 'v0.7-devel' of github.com:jthornber/thin-provisioning-tools into v0.7-devel 2016-07-11 15:51:58 +01:00
Joe Thornber
c2fdbad322 Merge branch '2016-07-07-improve-thin-repair-error-message' into v0.7-devel
Conflicts:
	Makefile.in
	VERSION
	configure.ac
	persistent-data/file_utils.cc
2016-07-11 15:51:30 +01:00
Joe Thornber
4779fb9b80 [various] Improve documentation
Output file must be preallocated.
2016-07-11 14:53:03 +01:00
Ming-Hung Tsai
7eac48793c [space map disk] tidy up: add const qualifier 2016-06-20 00:40:10 +08:00
Ming-Hung Tsai
3439dbfdfc [metadata_counter] hide count_trees() and count_space_maps() 2016-06-20 00:30:26 +08:00
Ming-Hung Tsai
9e7af6b677 [metadata_counter] remove explicit try/catch when counting data space map
Unlike metadata_index_store, the constructor of btree_index_store
doesn't throw exceptions.
2016-06-20 00:30:26 +08:00
Ming-Hung Tsai
e8f1bda1a5 [thin] store the device id in single_mapping_tree_damage_visitor for error reporting
1. fix the damage type for single_mapping_tree_damage_visitor
2. walk_mapping_tree() now requires the device id
3. update metadata_dumper and thin_ls for the new walk_mapping_tree()
2016-06-20 00:30:25 +08:00
Joe Thornber
a3eac8d5d8 Merge branch 'v0.7-devel' of github.com:jthornber/thin-provisioning-tools into v0.7-devel 2016-06-14 16:33:00 +01:00