Compare commits

...

No commits in common. "c8" and "c9" have entirely different histories.
c8 ... c9

35 changed files with 2486 additions and 2729 deletions

View File

@ -1,2 +1,2 @@
0fa12a08d4230359e0e89a5764edbde5e826bd33 SOURCES/dmpd090-vendor3.tar.gz
2015701a5767bae5960c8611673088fa9dcf3b60 SOURCES/v0.9.0.tar.gz
d336474a4772430fa2b8a5f76a6c2f2a78caa698 SOURCES/dmpd109-vendor.tar.gz
8862f41bf5fad011879b6d819ab5e5b11afcda7e SOURCES/v1.0.9.tar.gz

4
.gitignore vendored
View File

@ -1,2 +1,2 @@
SOURCES/dmpd090-vendor3.tar.gz
SOURCES/v0.9.0.tar.gz
SOURCES/dmpd109-vendor.tar.gz
SOURCES/v1.0.9.tar.gz

View File

@ -0,0 +1,29 @@
From 0d5347bd771e960294cd0c2f083d96448613ab9c Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Thu, 27 Jul 2023 11:37:01 +0200
Subject: [PATCH] Tweak cargo.toml to work with vendor directory
Mock works offline, cargo would try to download the files from github.
So cargo vendor has to be run first, and then change the Cargo.toml to
make mock happy.
---
Cargo.toml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Cargo.toml b/Cargo.toml
index 500345a4..d4aa38a6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,7 +27,8 @@ quick-xml = "0.29"
rand = "0.8"
rangemap = "1.4"
roaring = "0.10"
-rio = { git = "https://github.com/jthornber/rio", branch = "master", optional = true }
+#rio = { git = "https://github.com/jthornber/rio", branch = "master", optional = true }
+rio = { version = "0.9.4", optional = true }
safemem = "0.3"
threadpool = "1.8"
thiserror = "1.0"
--
2.43.0

View File

@ -1,25 +0,0 @@
From 4a45e1d7eafb83ec9c76f0b3278f4bc7efbdde9d Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Tue, 1 Sep 2020 14:55:48 +0200
Subject: [PATCH] Update dependencies
---
Cargo.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Cargo.toml b/Cargo.toml
index 892ea4c..93fc807 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,7 @@ license = "GPL3"
anyhow = "1.0"
byteorder = "1.3"
clap = "2.33"
-crc32c = "0.4"
+crc32c = "0.6"
flate2 = "1.0"
fixedbitset = "0.3"
libc = "0.2.71"
--
1.8.3.1

View File

@ -1,42 +0,0 @@
From 48676b9f1aac63f8a30ed8061b6e719929b82c98 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Wed, 28 Apr 2021 10:34:16 +0800
Subject: [PATCH 01/10] [all] Fix resource leaks
---
base/file_utils.cc | 4 +++-
thin-provisioning/cache_stream.cc | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/base/file_utils.cc b/base/file_utils.cc
index e4f3722..8253660 100644
--- a/base/file_utils.cc
+++ b/base/file_utils.cc
@@ -155,8 +155,10 @@ file_utils::zero_superblock(std::string const &path)
throw runtime_error("out of memory");
memset(buffer, 0, SUPERBLOCK_SIZE);
- if (::write(fd.fd_, buffer, SUPERBLOCK_SIZE) != SUPERBLOCK_SIZE)
+ if (::write(fd.fd_, buffer, SUPERBLOCK_SIZE) != SUPERBLOCK_SIZE) {
+ free(buffer);
throw runtime_error("couldn't zero superblock");
+ }
}
//----------------------------------------------------------------
diff --git a/thin-provisioning/cache_stream.cc b/thin-provisioning/cache_stream.cc
index 002b6ba..73b01b4 100644
--- a/thin-provisioning/cache_stream.cc
+++ b/thin-provisioning/cache_stream.cc
@@ -62,7 +62,7 @@ chunk const &
cache_stream::get()
{
chunk_wrapper *w = new chunk_wrapper(*this);
- return w->c_;
+ return w->c_; // wrapper will get freed by the put method
}
void
--
1.8.3.1

View File

@ -0,0 +1,181 @@
From f088ce90f5f7934489a8d1062ebfd3d23e4aec38 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Tue, 12 Dec 2023 14:25:27 +0800
Subject: [PATCH 2/6] [space map] Fix incorrect index_entry.nr_free while
expansion
Do not truncate the nr_free value of the last index_entry to the space
map boundary, to address the issue in kernel that sm_ll_extend() doesn't
extend the nr_free value of the last index_entry while expanding the
space map. Without this fix, we'll have incorrect free space estimation
in later block allocations, leading to under-utilized space maps.
(cherry picked from commit 9a405f57c591020321fc16f00efdb5197e1df2c0)
---
src/pdata/space_map/common.rs | 20 +++++---
src/pdata/space_map/tests.rs | 96 +++++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+), 8 deletions(-)
diff --git a/src/pdata/space_map/common.rs b/src/pdata/space_map/common.rs
index d92b8115..4be9c303 100644
--- a/src/pdata/space_map/common.rs
+++ b/src/pdata/space_map/common.rs
@@ -211,22 +211,28 @@ pub fn write_common(
let len = std::cmp::min(nr_blocks - begin, ENTRIES_PER_BITMAP as u64);
let mut entries = Vec::with_capacity(ENTRIES_PER_BITMAP);
let mut first_free: Option<u32> = None;
- let mut nr_free: u32 = 0;
+ let mut nr_free = ENTRIES_PER_BITMAP as u32; // do not truncate to the sm size boundary
for i in 0..len {
let b = begin + i;
let rc = sm.get(b)?;
let e = match rc {
0 => {
- nr_free += 1;
if first_free.is_none() {
first_free = Some(i as u32);
}
Small(0)
}
- 1 => Small(1),
- 2 => Small(2),
+ 1 => {
+ nr_free -= 1;
+ Small(1)
+ }
+ 2 => {
+ nr_free -= 1;
+ Small(2)
+ }
_ => {
+ nr_free -= 1;
overflow_builder.push_value(w, b, rc)?;
Overflow
}
@@ -334,16 +340,14 @@ pub fn write_metadata_common(w: &mut WriteBatcher) -> anyhow::Result<(Vec<IndexE
let nr_blocks = w.sm.lock().unwrap().get_nr_blocks()?;
let nr_bitmaps = div_up(nr_blocks, ENTRIES_PER_BITMAP as u64) as usize;
let nr_used_bitmaps = index_entries.len();
- for bm in nr_used_bitmaps..nr_bitmaps {
- let begin = bm as u64 * ENTRIES_PER_BITMAP as u64;
- let len = std::cmp::min(nr_blocks - begin, ENTRIES_PER_BITMAP as u64);
+ for _bm in nr_used_bitmaps..nr_bitmaps {
let entries = vec![BitmapEntry::Small(0); ENTRIES_PER_BITMAP];
let blocknr = write_bitmap(w, entries)?;
// Insert into the index list
let ie = IndexEntry {
blocknr,
- nr_free: len as u32,
+ nr_free: ENTRIES_PER_BITMAP as u32, // do not truncate to the sm size boundary
none_free_before: 0,
};
index_entries.push(ie);
diff --git a/src/pdata/space_map/tests.rs b/src/pdata/space_map/tests.rs
index 26d7834d..fb08a9dc 100644
--- a/src/pdata/space_map/tests.rs
+++ b/src/pdata/space_map/tests.rs
@@ -152,3 +152,99 @@ mod core_sm_u8 {
}
//------------------------------------------
+
+mod metadata_sm {
+ use anyhow::{ensure, Result};
+ use std::sync::Arc;
+
+ use crate::io_engine::core::CoreIoEngine;
+ use crate::io_engine::*;
+ use crate::math::div_up;
+ use crate::pdata::space_map::common::ENTRIES_PER_BITMAP;
+ use crate::pdata::space_map::metadata::*;
+ use crate::write_batcher::WriteBatcher;
+
+ fn check_index_entries(nr_blocks: u64) -> Result<()> {
+ let engine = Arc::new(CoreIoEngine::new(nr_blocks));
+ let meta_sm = core_metadata_sm(engine.get_nr_blocks(), u32::MAX);
+
+ let mut w = WriteBatcher::new(engine.clone(), meta_sm.clone(), engine.get_batch_size());
+ w.alloc()?; // reserved for the superblock
+ let root = write_metadata_sm(&mut w)?;
+
+ let b = engine.read(root.bitmap_root)?;
+ let entries = check_and_unpack_metadata_index(&b)?.indexes;
+ ensure!(entries.len() as u64 == div_up(nr_blocks, ENTRIES_PER_BITMAP as u64));
+
+ // the number of blocks observed by index_entries must be multiple of ENTRIES_PER_BITMAP
+ let nr_allocated = meta_sm.lock().unwrap().get_nr_allocated()?;
+ let nr_free: u64 = entries.iter().map(|ie| ie.nr_free as u64).sum();
+ ensure!(nr_allocated + nr_free == (entries.len() * ENTRIES_PER_BITMAP) as u64);
+
+ Ok(())
+ }
+
+ #[test]
+ fn check_single_index_entry() -> Result<()> {
+ check_index_entries(1000)
+ }
+
+ #[test]
+ fn check_multiple_index_entries() -> Result<()> {
+ check_index_entries(ENTRIES_PER_BITMAP as u64 * 16 + 1000)
+ }
+}
+
+//------------------------------------------
+
+mod disk_sm {
+ use anyhow::{ensure, Result};
+ use std::ops::Deref;
+ use std::sync::Arc;
+
+ use crate::io_engine::core::CoreIoEngine;
+ use crate::io_engine::*;
+ use crate::math::div_up;
+ use crate::pdata::btree_walker::btree_to_value_vec;
+ use crate::pdata::space_map::common::{IndexEntry, ENTRIES_PER_BITMAP};
+ use crate::pdata::space_map::disk::*;
+ use crate::pdata::space_map::metadata::*;
+ use crate::pdata::space_map::*;
+ use crate::write_batcher::WriteBatcher;
+
+ fn check_index_entries(nr_blocks: u64) -> Result<()> {
+ let engine = Arc::new(CoreIoEngine::new(1024));
+ let meta_sm = core_metadata_sm(engine.get_nr_blocks(), u32::MAX);
+
+ let mut w = WriteBatcher::new(engine.clone(), meta_sm.clone(), engine.get_batch_size());
+ w.alloc()?; // reserved for the superblock
+
+ let data_sm = core_sm(nr_blocks, u32::MAX);
+ data_sm.lock().unwrap().inc(0, 100)?;
+
+ let root = write_disk_sm(&mut w, data_sm.lock().unwrap().deref())?;
+
+ let entries =
+ btree_to_value_vec::<IndexEntry>(&mut Vec::new(), engine, false, root.bitmap_root)?;
+ ensure!(entries.len() as u64 == div_up(nr_blocks, ENTRIES_PER_BITMAP as u64));
+
+ // the number of blocks observed by index_entries must be a multiple of ENTRIES_PER_BITMAP
+ let nr_allocated = data_sm.lock().unwrap().get_nr_allocated()?;
+ let nr_free: u64 = entries.iter().map(|ie| ie.nr_free as u64).sum();
+ ensure!(nr_allocated + nr_free == (entries.len() * ENTRIES_PER_BITMAP) as u64);
+
+ Ok(())
+ }
+
+ #[test]
+ fn check_single_index_entry() -> Result<()> {
+ check_index_entries(1000)
+ }
+
+ #[test]
+ fn check_multiple_index_entries() -> Result<()> {
+ check_index_entries(ENTRIES_PER_BITMAP as u64 * 16 + 1000)
+ }
+}
+
+//------------------------------------------
--
2.43.0

View File

@ -1,26 +0,0 @@
From 691a0237809b5364117446a8a9b0cceeb0a747c1 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Tue, 1 Jun 2021 11:24:11 +0800
Subject: [PATCH 02/10] [thin_show_metadata] Fix out-of-bounds access
---
thin-provisioning/thin_show_metadata.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/thin-provisioning/thin_show_metadata.cc b/thin-provisioning/thin_show_metadata.cc
index bdbab3f..dbc7a80 100644
--- a/thin-provisioning/thin_show_metadata.cc
+++ b/thin-provisioning/thin_show_metadata.cc
@@ -206,7 +206,8 @@ namespace {
void run() {
auto line_length = 80;
- for (block_address b = 0; b < 2000; b++) {
+ block_address nr_blocks = std::min<block_address>(2000, bm_.get_nr_blocks());
+ for (block_address b = 0; b < nr_blocks; b++) {
block_manager::read_ref rr = bm_.read_lock(b);
if (!(b % line_length)) {
--
1.8.3.1

View File

@ -1,25 +0,0 @@
From 65369d88610069ba7bbd011b00af19523638b0fb Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Tue, 1 Jun 2021 13:32:26 +0800
Subject: [PATCH 03/10] [build] Fix customized emitter linkage
---
contrib/Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/Makefile.in b/contrib/Makefile.in
index 038c41c..7192258 100644
--- a/contrib/Makefile.in
+++ b/contrib/Makefile.in
@@ -18,7 +18,7 @@ contrib/%.a: contrib/%.o
$(V)echo " [AR] $@"
$(V)$(AR) rcs $@ $^
-contrib/%.so: contrib/%.a
+contrib/%.so: contrib/%.o
$(V)echo " [LD] $@"
$(V)$(CC) -shared -Wl,-soname,$@ -o $@ $<
--
1.8.3.1

View File

@ -0,0 +1,69 @@
From add81da22a3998503a6f340350d7e59ed3b52e28 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Wed, 10 Jan 2024 15:56:39 +0800
Subject: [PATCH 3/6] [thin_repair] Fix child keys checking on the node with a
zero key
Fix the issue that keys overlapping between the second and the first
child nodes indexed by zero not being checked.
(cherry picked from commit 386123bd0f74f7603e993bf3c26aac002162d5db)
---
src/thin/metadata_repair.rs | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/src/thin/metadata_repair.rs b/src/thin/metadata_repair.rs
index 9716b1e3..8fece4b9 100644
--- a/src/thin/metadata_repair.rs
+++ b/src/thin/metadata_repair.rs
@@ -128,10 +128,11 @@ impl DevInfo {
}
fn push_child(&mut self, child: &DevInfo) -> Result<()> {
- if self.key_high > 0 && child.key_low <= self.key_high {
- return Err(anyhow!("incompatible child"));
- }
- if !self.pushed {
+ if self.pushed {
+ if child.key_low <= self.key_high {
+ return Err(anyhow!("incompatible child"));
+ }
+ } else {
self.key_low = child.key_low;
self.pushed = true;
}
@@ -175,10 +176,11 @@ impl MappingsInfo {
}
fn push_child(&mut self, child: &MappingsInfo) -> Result<()> {
- if self.key_high > 0 && child.key_low <= self.key_high {
- return Err(anyhow!("incompatible child"));
- }
- if !self.pushed {
+ if self.pushed {
+ if child.key_low <= self.key_high {
+ return Err(anyhow!("incompatible child"));
+ }
+ } else {
self.key_low = child.key_low;
self.pushed = true;
}
@@ -221,10 +223,11 @@ impl DetailsInfo {
}
fn push_child(&mut self, child: &DetailsInfo) -> Result<()> {
- if self.key_high > 0 && child.key_low <= self.key_high {
- return Err(anyhow!("incompatible child"));
- }
- if !self.pushed {
+ if self.pushed {
+ if child.key_low <= self.key_high {
+ return Err(anyhow!("incompatible child"));
+ }
+ } else {
self.key_low = child.key_low;
self.pushed = true;
}
--
2.43.0

View File

@ -0,0 +1,269 @@
From 9b948a9639b00fe9226065ca4dd6fd2257cc126c Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Thu, 11 Jan 2024 22:57:36 +0800
Subject: [PATCH 4/6] [space_map] Allow non-zero values in unused index block
entries
Previously, we assumed unused entries in the index block were all
zero-initialized, leading to issues while loading the block with
unexpected bytes and a valid checksum [1]. The updated approach loads
index entries based on actual size information from superblock and
therefore improves compatibility.
[1] stratis-storage/stratisd#3520
(cherry picked from commit d5fe6a1e1c539a0f260a96eb4d7ed9b83c3f84c9)
---
src/commands/engine.rs | 6 ++++-
src/pdata/space_map/allocated_blocks.rs | 15 ++++++-----
src/pdata/space_map/checker.rs | 12 ++++++---
src/pdata/space_map/metadata.rs | 22 +++++++++-------
src/pdata/space_map/tests.rs | 35 +++++++++++++++++++++++--
src/thin/damage_generator.rs | 4 +--
src/thin/stat.rs | 6 +++--
7 files changed, 75 insertions(+), 25 deletions(-)
diff --git a/src/commands/engine.rs b/src/commands/engine.rs
index 1e752d6e..e8b75301 100644
--- a/src/commands/engine.rs
+++ b/src/commands/engine.rs
@@ -137,7 +137,11 @@ fn thin_valid_blocks<P: AsRef<Path>>(path: P, opts: &EngineOptions) -> RoaringBi
return all_blocks(e.get_nr_blocks() as u32);
}
let metadata_root = metadata_root.unwrap();
- let valid_blocks = allocated_blocks(e.clone(), metadata_root.bitmap_root);
+ let valid_blocks = allocated_blocks(
+ e.clone(),
+ metadata_root.bitmap_root,
+ metadata_root.nr_blocks,
+ );
valid_blocks.unwrap_or_else(|_| all_blocks(e.get_nr_blocks() as u32))
}
diff --git a/src/pdata/space_map/allocated_blocks.rs b/src/pdata/space_map/allocated_blocks.rs
index aa75cb7a..71497a76 100644
--- a/src/pdata/space_map/allocated_blocks.rs
+++ b/src/pdata/space_map/allocated_blocks.rs
@@ -17,18 +17,21 @@ struct IndexInfo {
pub fn allocated_blocks(
engine: Arc<dyn IoEngine + Send + Sync>,
sm_root: u64,
+ nr_blocks: u64,
) -> Result<RoaringBitmap> {
// Walk index tree to find where the bitmaps are.
let b = engine.read(sm_root)?;
- let (_, indexes) = MetadataIndex::unpack(b.get_data())?;
+ let indexes = load_metadata_index(&b, nr_blocks)?;
- let mut infos = Vec::new();
- for (key, entry) in indexes.indexes.iter().enumerate() {
- infos.push(IndexInfo {
+ let mut infos: Vec<_> = indexes
+ .indexes
+ .iter()
+ .enumerate()
+ .map(|(key, entry)| IndexInfo {
key: key as u64,
loc: entry.blocknr,
- });
- }
+ })
+ .collect();
// Read bitmaps in sequence
infos.sort_by(|lhs, rhs| lhs.loc.partial_cmp(&rhs.loc).unwrap());
diff --git a/src/pdata/space_map/checker.rs b/src/pdata/space_map/checker.rs
index cfafa79b..7cc8286b 100644
--- a/src/pdata/space_map/checker.rs
+++ b/src/pdata/space_map/checker.rs
@@ -194,10 +194,11 @@ fn gather_disk_index_entries(
fn gather_metadata_index_entries(
engine: Arc<dyn IoEngine + Send + Sync>,
bitmap_root: u64,
+ nr_blocks: u64,
metadata_sm: ASpaceMap,
) -> Result<Vec<IndexEntry>> {
let b = engine.read(bitmap_root)?;
- let entries = check_and_unpack_metadata_index(&b)?.indexes;
+ let entries = load_metadata_index(&b, nr_blocks)?.indexes;
metadata_sm.lock().unwrap().inc(bitmap_root, 1)?;
inc_entries(&metadata_sm, &entries[0..])?;
@@ -254,8 +255,13 @@ pub fn check_metadata_space_map(
metadata_sm.clone(),
false,
)?;
- let entries =
- gather_metadata_index_entries(engine.clone(), root.bitmap_root, metadata_sm.clone())?;
+
+ let entries = gather_metadata_index_entries(
+ engine.clone(),
+ root.bitmap_root,
+ root.nr_blocks,
+ metadata_sm.clone(),
+ )?;
// check overflow ref-counts
{
diff --git a/src/pdata/space_map/metadata.rs b/src/pdata/space_map/metadata.rs
index b466c135..be232389 100644
--- a/src/pdata/space_map/metadata.rs
+++ b/src/pdata/space_map/metadata.rs
@@ -6,6 +6,7 @@ use std::sync::{Arc, Mutex};
use crate::checksum;
use crate::io_engine::*;
+use crate::math::div_up;
use crate::pdata::space_map::common::*;
use crate::pdata::space_map::*;
use crate::pdata::unpack::*;
@@ -32,14 +33,11 @@ impl Unpack for MetadataIndex {
let (i, _csum) = le_u32(i)?;
let (i, _padding) = le_u32(i)?;
let (i, blocknr) = le_u64(i)?;
- let (i, indexes) = nom::multi::count(IndexEntry::unpack, MAX_METADATA_BITMAPS)(i)?;
+ let (i, mut indexes) = nom::multi::count(IndexEntry::unpack, MAX_METADATA_BITMAPS)(i)?;
- // Filter out unused entries
- let indexes: Vec<IndexEntry> = indexes
- .iter()
- .take_while(|e| e.blocknr != 0)
- .cloned()
- .collect();
+ // Drop unused entries that point to block 0
+ let nr_bitmaps = indexes.iter().take_while(|e| e.blocknr != 0).count();
+ indexes.truncate(nr_bitmaps);
Ok((i, MetadataIndex { blocknr, indexes }))
}
@@ -69,9 +67,15 @@ fn verify_checksum(b: &Block) -> Result<()> {
}
}
-pub fn check_and_unpack_metadata_index(b: &Block) -> Result<MetadataIndex> {
+pub fn load_metadata_index(b: &Block, nr_blocks: u64) -> Result<MetadataIndex> {
verify_checksum(b)?;
- unpack::<MetadataIndex>(b.get_data()).map_err(|e| e.into())
+ let mut entries = unpack::<MetadataIndex>(b.get_data())?;
+ if entries.blocknr != b.loc {
+ return Err(anyhow!("blocknr mismatch"));
+ }
+ let nr_bitmaps = div_up(nr_blocks, ENTRIES_PER_BITMAP as u64) as usize;
+ entries.indexes.truncate(nr_bitmaps);
+ Ok(entries)
}
//------------------------------------------
diff --git a/src/pdata/space_map/tests.rs b/src/pdata/space_map/tests.rs
index fb08a9dc..fa118189 100644
--- a/src/pdata/space_map/tests.rs
+++ b/src/pdata/space_map/tests.rs
@@ -171,10 +171,11 @@ mod metadata_sm {
let mut w = WriteBatcher::new(engine.clone(), meta_sm.clone(), engine.get_batch_size());
w.alloc()?; // reserved for the superblock
let root = write_metadata_sm(&mut w)?;
+ drop(w);
let b = engine.read(root.bitmap_root)?;
- let entries = check_and_unpack_metadata_index(&b)?.indexes;
- ensure!(entries.len() as u64 == div_up(nr_blocks, ENTRIES_PER_BITMAP as u64));
+ let entries = load_metadata_index(&b, root.nr_blocks)?.indexes;
+ ensure!(entries.len() == div_up(nr_blocks, ENTRIES_PER_BITMAP as u64) as usize);
// the number of blocks observed by index_entries must be multiple of ENTRIES_PER_BITMAP
let nr_allocated = meta_sm.lock().unwrap().get_nr_allocated()?;
@@ -193,6 +194,35 @@ mod metadata_sm {
fn check_multiple_index_entries() -> Result<()> {
check_index_entries(ENTRIES_PER_BITMAP as u64 * 16 + 1000)
}
+
+ #[test]
+ fn ignore_junk_bytes_in_index_block() -> Result<()> {
+ use crate::checksum;
+ use crate::pdata::space_map::common::IndexEntry;
+ use crate::pdata::unpack::Unpack;
+
+ let nr_blocks = ENTRIES_PER_BITMAP as u64 * 4 + 1000;
+ let nr_bitmaps = div_up(nr_blocks, ENTRIES_PER_BITMAP as u64) as usize;
+ let engine = Arc::new(CoreIoEngine::new(nr_blocks));
+ let meta_sm = core_metadata_sm(engine.get_nr_blocks(), u32::MAX);
+
+ let mut w = WriteBatcher::new(engine.clone(), meta_sm.clone(), engine.get_batch_size());
+ w.alloc()?; // reserved for the superblock
+ let root = write_metadata_sm(&mut w)?;
+
+ // append junk bytes to the unused entry
+ let index_block = w.read(root.bitmap_root)?;
+ index_block.get_data()[nr_bitmaps * IndexEntry::disk_size() as usize + 16] = 1;
+ w.write(index_block, checksum::BT::INDEX)?;
+ w.flush()?;
+ drop(w);
+
+ let b = engine.read(root.bitmap_root)?;
+ let entries = load_metadata_index(&b, root.nr_blocks)?.indexes;
+ ensure!(entries.len() == nr_bitmaps);
+
+ Ok(())
+ }
}
//------------------------------------------
@@ -223,6 +253,7 @@ mod disk_sm {
data_sm.lock().unwrap().inc(0, 100)?;
let root = write_disk_sm(&mut w, data_sm.lock().unwrap().deref())?;
+ drop(w);
let entries =
btree_to_value_vec::<IndexEntry>(&mut Vec::new(), engine, false, root.bitmap_root)?;
diff --git a/src/thin/damage_generator.rs b/src/thin/damage_generator.rs
index 56685d4d..df1be4cd 100644
--- a/src/thin/damage_generator.rs
+++ b/src/thin/damage_generator.rs
@@ -23,7 +23,7 @@ fn find_blocks_of_rc(
let mut found = Vec::<u64>::new();
if ref_count < 3 {
let b = engine.read(sm_root.bitmap_root)?;
- let entries = check_and_unpack_metadata_index(&b)?.indexes;
+ let entries = load_metadata_index(&b, sm_root.nr_blocks)?.indexes;
let bitmaps: Vec<u64> = entries.iter().map(|ie| ie.blocknr).collect();
let nr_bitmaps = bitmaps.len();
@@ -75,7 +75,7 @@ fn adjust_bitmap_entries(
};
let index_block = engine.read(sm_root.bitmap_root)?;
- let entries = check_and_unpack_metadata_index(&index_block)?.indexes;
+ let entries = load_metadata_index(&index_block, sm_root.nr_blocks)?.indexes;
let bi = blocks_to_bitmaps(blocks);
let bitmaps: Vec<u64> = bi.iter().map(|i| entries[*i].blocknr).collect();
diff --git a/src/thin/stat.rs b/src/thin/stat.rs
index 03ae6845..c6f2bf44 100644
--- a/src/thin/stat.rs
+++ b/src/thin/stat.rs
@@ -72,9 +72,10 @@ fn gather_btree_index_entries(
fn gather_metadata_index_entries(
engine: Arc<dyn IoEngine + Send + Sync>,
bitmap_root: u64,
+ nr_blocks: u64,
) -> Result<Vec<IndexEntry>> {
let b = engine.read(bitmap_root)?;
- let entries = check_and_unpack_metadata_index(&b)?.indexes;
+ let entries = load_metadata_index(&b, nr_blocks)?.indexes;
Ok(entries)
}
@@ -152,7 +153,8 @@ fn stat_metadata_block_ref_counts(
) -> Result<BTreeMap<u32, u64>> {
let mut histogram = BTreeMap::<u32, u64>::new();
- let index_entries = gather_metadata_index_entries(engine.clone(), root.bitmap_root)?;
+ let index_entries =
+ gather_metadata_index_entries(engine.clone(), root.bitmap_root, root.nr_blocks)?;
stat_low_ref_counts(engine.clone(), &index_entries, &mut histogram)?;
let histogram = stat_overflow_ref_counts(engine, root.ref_count_root, histogram)?;
--
2.43.0

View File

@ -1,139 +0,0 @@
From 7fbd79cab2e548eb388bc782dd39f1cde027173b Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Tue, 1 Jun 2021 23:37:36 +0800
Subject: [PATCH 04/10] [thin_dump] Fix leaked shared object handle
---
thin-provisioning/shared_library_emitter.cc | 113 ++++++++++++++++++++++++----
1 file changed, 100 insertions(+), 13 deletions(-)
diff --git a/thin-provisioning/shared_library_emitter.cc b/thin-provisioning/shared_library_emitter.cc
index 58f12d2..2e845f3 100644
--- a/thin-provisioning/shared_library_emitter.cc
+++ b/thin-provisioning/shared_library_emitter.cc
@@ -8,22 +8,109 @@ using namespace thin_provisioning;
//----------------------------------------------------------------
-emitter::ptr
-thin_provisioning::create_custom_emitter(string const &shared_lib, ostream &out)
-{
- emitter::ptr (*create_fn)(ostream &out);
- void *handle = dlopen(shared_lib.c_str(), RTLD_LAZY);
- if (!handle)
- throw runtime_error(dlerror());
+struct shared_object {
+public:
+ shared_object(const char *shared_lib) {
+ handle_ = dlopen(shared_lib, RTLD_LAZY);
+ if (!handle_)
+ throw runtime_error(dlerror());
+
+ dlerror(); // Clear any existing error
+ }
+
+ virtual ~shared_object() {
+ dlclose(handle_);
+ }
+
+ void *get_symbol(const char *symbol) {
+ void *sym = dlsym(handle_, symbol);
+
+ char *error = dlerror();
+ if (error)
+ throw runtime_error(error);
+
+ return sym;
+ }
+
+ void *handle_;
+};
+
+class shared_emitter : public emitter {
+public:
+ shared_emitter(const char *shared_lib, ostream &out): sobj_(shared_lib) {
+ emitter::ptr (*create_fn)(ostream &out);
+ create_fn = reinterpret_cast<emitter::ptr (*)(ostream &)>(
+ sobj_.get_symbol("create_emitter"));
+ inner_ = create_fn(out);
+ }
+
+ virtual ~shared_emitter() {
+ }
+
+ void begin_superblock(std::string const &uuid,
+ uint64_t time,
+ uint64_t trans_id,
+ boost::optional<uint32_t> flags,
+ boost::optional<uint32_t> version,
+ uint32_t data_block_size,
+ uint64_t nr_data_blocks,
+ boost::optional<uint64_t> metadata_snap) {
+ inner_->begin_superblock(uuid,
+ time,
+ trans_id,
+ flags,
+ version,
+ data_block_size,
+ nr_data_blocks,
+ metadata_snap);
+ }
- dlerror(); // Clear any existing error
- create_fn = reinterpret_cast<emitter::ptr (*)(ostream &)>(dlsym(handle, "create_emitter"));
+ void end_superblock() {
+ inner_->end_superblock();
+ }
- char *error = dlerror();
- if (error)
- throw runtime_error(error);
+ void begin_device(uint32_t dev_id,
+ uint64_t mapped_blocks,
+ uint64_t trans_id,
+ uint64_t creation_time,
+ uint64_t snap_time) {
+ inner_->begin_device(dev_id, mapped_blocks, trans_id, creation_time, snap_time);
+ }
- return create_fn(out);
+ void end_device() {
+ inner_->end_device();
+ }
+
+ void begin_named_mapping(std::string const &name) {
+ inner_->begin_named_mapping(name);
+ }
+
+ void end_named_mapping() {
+ inner_->end_named_mapping();
+ }
+
+ void identifier(std::string const &name) {
+ inner_->identifier(name);
+ }
+
+ void range_map(uint64_t origin_begin, uint64_t data_begin, uint32_t time, uint64_t len) {
+ inner_->range_map(origin_begin, data_begin, time, len);
+ }
+
+ void single_map(uint64_t origin_block, uint64_t data_block, uint32_t time) {
+ inner_->single_map(origin_block, data_block, time);
+ }
+
+ shared_object sobj_;
+ emitter::ptr inner_;
+};
+
+//----------------------------------------------------------------
+
+emitter::ptr
+thin_provisioning::create_custom_emitter(string const &shared_lib, ostream &out)
+{
+ return emitter::ptr(new shared_emitter(shared_lib.c_str(), out));
}
//----------------------------------------------------------------
--
1.8.3.1

View File

@ -0,0 +1,111 @@
From 96fc598f76beac1deb0c9564dc67416f70ae4ac4 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Tue, 30 Jan 2024 15:20:31 +0800
Subject: [PATCH 5/6] [cache_check] Fix boundary check on the bitset for cached
blocks
The bitset for cached block addresses grows dynamically if the metadata
is not shutdown properly, in which the size hint of the slow (backing)
device is not available. Fix a bug in determining whether resizing is
needed (bz2258485).
(cherry picked from commit d2390a50f38d88f0f32b13e59444bbbca7e660b3)
---
src/cache/check.rs | 6 +++---
tests/cache_check.rs | 45 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/src/cache/check.rs b/src/cache/check.rs
index 18bd51b3..c71d3059 100644
--- a/src/cache/check.rs
+++ b/src/cache/check.rs
@@ -19,7 +19,7 @@ use crate::report::*;
//------------------------------------------
-// 16m entries is capable for a 1TB cache with 64KB block size
+// 16m entries is capable to address a 1TB device with 64KB block size
const DEFAULT_OBLOCKS: usize = 16777216;
fn inc_superblock(sm: &ASpaceMap) -> anyhow::Result<()> {
@@ -82,7 +82,7 @@ mod format1 {
}
let mut seen_oblocks = self.seen_oblocks.lock().unwrap();
- if m.oblock as usize > seen_oblocks.len() {
+ if m.oblock as usize >= seen_oblocks.len() {
seen_oblocks.grow(m.oblock as usize + 1);
} else if seen_oblocks.contains(m.oblock as usize) {
return Err(array::value_err("origin block already mapped".to_string()));
@@ -179,7 +179,7 @@ mod format2 {
));
}
- if m.oblock as usize > seen_oblocks.len() {
+ if m.oblock as usize >= seen_oblocks.len() {
seen_oblocks.grow(m.oblock as usize + 1);
} else if seen_oblocks.contains(m.oblock as usize) {
return Err(array::value_err("origin block already mapped".to_string()));
diff --git a/tests/cache_check.rs b/tests/cache_check.rs
index 81f4c578..8988694a 100644
--- a/tests/cache_check.rs
+++ b/tests/cache_check.rs
@@ -11,6 +11,8 @@ use common::program::*;
use common::target::*;
use common::test_dir::*;
+use std::io::Write;
+
//------------------------------------------
const USAGE: &str = "Validates cache metadata on a device or file.
@@ -294,3 +296,46 @@ fn no_clear_needs_check_if_error() -> Result<()> {
}
//------------------------------------------
+
+fn metadata_without_slow_dev_size_info(use_v1: bool) -> Result<()> {
+ let mut td = TestDir::new()?;
+
+ // The input metadata has a cached oblock with address equals to the default bitset size
+ // boundary (DEFAULT_OBLOCKS = 16777216), triggering bitset resize.
+ let xml = td.mk_path("meta.xml");
+ let mut file = std::fs::File::create(&xml)?;
+ file.write_all(b"<superblock uuid=\"\" block_size=\"128\" nr_cache_blocks=\"1024\" policy=\"smq\" hint_width=\"4\">
+ <mappings>
+ <mapping cache_block=\"0\" origin_block=\"16777216\" dirty=\"false\"/>
+ </mappings>
+ <hints>
+ <hint cache_block=\"0\" data=\"AAAAAA==\"/>
+ </hints>
+</superblock>")?;
+
+ let md = td.mk_path("meta.bin");
+ thinp::file_utils::create_sized_file(&md, 4096 * 4096)?;
+
+ let cache_restore_args = if use_v1 {
+ args!["-i", &xml, "-o", &md, "--metadata-version=1"]
+ } else {
+ args!["-i", &xml, "-o", &md, "--metadata-version=2"]
+ };
+
+ run_ok(cache_restore_cmd(cache_restore_args))?;
+ run_ok(cache_check_cmd(args![&md]))?;
+
+ Ok(())
+}
+
+#[test]
+fn metadata_v1_without_slow_dev_size_info() -> Result<()> {
+ metadata_without_slow_dev_size_info(true)
+}
+
+#[test]
+fn metadata_v2_without_slow_dev_size_info() -> Result<()> {
+ metadata_without_slow_dev_size_info(false)
+}
+
+//------------------------------------------
--
2.43.0

View File

@ -1,52 +0,0 @@
From 32de33be68f3892698d492b9ab8f21f9186b3f4c Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Wed, 2 Jun 2021 01:23:13 +0800
Subject: [PATCH 05/10] [thin_show_duplicates] Fix potential errors
- Fix error if no --block-sector provided
- Fix errors on pools without mappings, or zero-length file
---
thin-provisioning/thin_show_duplicates.cc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/thin-provisioning/thin_show_duplicates.cc b/thin-provisioning/thin_show_duplicates.cc
index b1eebb7..f7354eb 100644
--- a/thin-provisioning/thin_show_duplicates.cc
+++ b/thin-provisioning/thin_show_duplicates.cc
@@ -56,7 +56,7 @@ using namespace thin_provisioning;
namespace {
bool factor_of(block_address f, block_address n) {
- return (n % f) == 0;
+ return f && (n % f) == 0;
}
uint64_t parse_int(string const &str, string const &desc) {
@@ -132,11 +132,15 @@ namespace {
class duplicate_detector {
public:
void scan_with_variable_sized_chunks(chunk_stream &stream) {
+ if (!stream.size())
+ return;
variable_chunk_stream vstream(stream, 4096);
scan(vstream);
}
void scan_with_fixed_sized_chunks(chunk_stream &stream, block_address chunk_size) {
+ if (!stream.size())
+ return;
fixed_chunk_stream fstream(stream, chunk_size);
scan(fstream);
}
@@ -222,7 +226,7 @@ namespace {
if (fs.content_based_chunks)
detector.scan_with_variable_sized_chunks(pstream);
else {
- if (*fs.block_size) {
+ if (!!fs.block_size) {
if (factor_of(*fs.block_size, block_size))
block_size = *fs.block_size;
else
--
1.8.3.1

View File

@ -0,0 +1,62 @@
From e295610fad85ec1a64e569cba425ca557a56c6e6 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Wed, 31 Jan 2024 11:36:17 +0800
Subject: [PATCH 6/6] [thin/cache_check] Print suggestive hints for improving
error resolution
Enhance error messages to instruct users on addressing recoverable
errors, eliminating the guesswork (bz2233177).
(cherry picked from commit aaf3b396574709902ffba47e03a5c7ded6a103c5)
---
src/cache/check.rs | 5 ++++-
src/thin/check.rs | 10 ++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/cache/check.rs b/src/cache/check.rs
index c71d3059..17d1af77 100644
--- a/src/cache/check.rs
+++ b/src/cache/check.rs
@@ -387,7 +387,10 @@ pub fn check(opts: CacheCheckOptions) -> anyhow::Result<()> {
ctx.report.warning("Repairing metadata leaks.");
repair_space_map(ctx.engine.clone(), metadata_leaks, metadata_sm.clone())?;
} else if !opts.ignore_non_fatal {
- return Err(anyhow!("metadata space map contains leaks"));
+ return Err(anyhow!(concat!(
+ "metadata space map contains leaks\n",
+ "perhaps you wanted to run with --auto-repair"
+ )));
}
}
diff --git a/src/thin/check.rs b/src/thin/check.rs
index 8b829899..f6fde359 100644
--- a/src/thin/check.rs
+++ b/src/thin/check.rs
@@ -1246,7 +1246,10 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> {
report.warning("Repairing data leaks.");
repair_space_map(engine.clone(), data_leaks, data_sm.clone())?;
} else if !opts.ignore_non_fatal {
- return Err(anyhow!("data space map contains leaks"));
+ return Err(anyhow!(concat!(
+ "data space map contains leaks\n",
+ "perhaps you wanted to run with --auto-repair"
+ )));
}
}
@@ -1255,7 +1258,10 @@ pub fn check(opts: ThinCheckOptions) -> Result<()> {
report.warning("Repairing metadata leaks.");
repair_space_map(engine.clone(), metadata_leaks, metadata_sm.clone())?;
} else if !opts.ignore_non_fatal {
- return Err(anyhow!("metadata space map contains leaks"));
+ return Err(anyhow!(concat!(
+ "metadata space map contains leaks\n",
+ "perhaps you wanted to run with --auto-repair"
+ )));
}
}
--
2.43.0

View File

@ -1,33 +0,0 @@
From 35e96e07c956a501cb8a12f5b873db173bb09179 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Wed, 2 Jun 2021 11:39:01 +0800
Subject: [PATCH 06/10] [thin_metadata_size] Fix potential string overflow
---
thin-provisioning/thin_metadata_size.cc | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/thin-provisioning/thin_metadata_size.cc b/thin-provisioning/thin_metadata_size.cc
index b6a5718..f14696c 100644
--- a/thin-provisioning/thin_metadata_size.cc
+++ b/thin-provisioning/thin_metadata_size.cc
@@ -192,9 +192,13 @@ static void printf_aligned(struct global *g, char const *a, char const *b, char
{
char buf[80];
- strcpy(buf, b);
- if (units)
- strcat(buf, mandatory ? "{" :"["), strcat(buf, g->unit.chars), strcat(buf, mandatory ? "}" : "]");
+ if (units) {
+ char left_bracket = mandatory ? '{' : '[';
+ char right_bracket = mandatory ? '}' : ']';
+ snprintf(buf, 80, "%s%c%s%c", b, left_bracket, g->unit.chars, right_bracket);
+ } else {
+ snprintf(buf, 80, "%s", b);
+ }
printf("\t%-4s%-44s%s\n", a, buf, c);
}
--
1.8.3.1

View File

@ -1,83 +0,0 @@
From f1e404c33ad14f6784aa1926ae75fa49e614748e Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Wed, 2 Jun 2021 12:14:34 +0800
Subject: [PATCH 07/10] [all] Fix uninitialized class members
---
era/restore_emitter.cc | 1 +
thin-provisioning/metadata_dumper.cc | 10 +++++++---
thin-provisioning/thin_delta.cc | 4 +++-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/era/restore_emitter.cc b/era/restore_emitter.cc
index c09fa66..7fbac7d 100644
--- a/era/restore_emitter.cc
+++ b/era/restore_emitter.cc
@@ -14,6 +14,7 @@ namespace {
: md_(md),
in_superblock_(false),
in_writeset_(false),
+ era_(0),
in_era_array_(false) {
}
diff --git a/thin-provisioning/metadata_dumper.cc b/thin-provisioning/metadata_dumper.cc
index 4feb40f..665c762 100644
--- a/thin-provisioning/metadata_dumper.cc
+++ b/thin-provisioning/metadata_dumper.cc
@@ -180,7 +180,7 @@ namespace {
// This is about classifying and summarising btree nodes. The use of a btree
// node may not be obvious when inspecting it in isolation. But more information
// may be gleaned by examining child and sibling nodes.
-//
+//
// So the process is:
// - scan every metadata block, summarising it's potential uses.
// - repeatedly iterate those summaries until we can glean no more useful information.
@@ -474,7 +474,7 @@ namespace {
node_info get_internal_info(block_manager::read_ref &rr) {
node_info info;
info.b = rr.get_location();
-
+
// values refer to blocks, so we should have infos for them.
auto n = to_node<block_traits>(rr);
::uint64_t key_low = 0;
@@ -524,7 +524,7 @@ namespace {
node_info info;
info.b = rr.get_location();
- auto vsize = to_cpu<uint32_t>(hdr.value_size);
+ auto vsize = to_cpu<uint32_t>(hdr.value_size);
info.values = to_cpu<uint32_t>(hdr.nr_entries);
if (vsize == sizeof(device_details_traits::disk_type)) {
@@ -645,6 +645,10 @@ namespace {
public:
mapping_emit_visitor(emitter::ptr e)
: e_(e),
+ origin_start_(0),
+ dest_start_(0),
+ time_(0),
+ len_(0),
in_range_(false) {
}
diff --git a/thin-provisioning/thin_delta.cc b/thin-provisioning/thin_delta.cc
index 5b31608..ee48dea 100644
--- a/thin-provisioning/thin_delta.cc
+++ b/thin-provisioning/thin_delta.cc
@@ -259,7 +259,9 @@ namespace local {
class simple_emitter : public diff_emitter {
public:
simple_emitter(indented_stream &out)
- : diff_emitter(out) {
+ : diff_emitter(out),
+ vbegin_(0),
+ vend_(0) {
}
void left_only(uint64_t vbegin, uint64_t dbegin, uint64_t len) {
--
1.8.3.1

View File

@ -0,0 +1,225 @@
From 6f7f70da8341cfe8447c6c70ebb4085629983b0d Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Tue, 20 Feb 2024 04:16:46 +0800
Subject: [PATCH 07/10] [thin_dump] Do not print error messages on BrokenPipe
(EPIPE)
Considering BrokenPipe is an expected result in most use cases,
thin_dump should not print error messages in this situation but should
return a non-zero exit code instead. For instance, lvconvert fetches
only the first line of thin_dump then closes the pipe immediately,
causing BrokenPipe to terminate thin_dump intentionally.
Changes made include removing the unused NodeVisitor abstraction for
MappingVisitor to keep the error type from low-level io, and printing
messages based on the error type returned upward (bz2233177).
(cherry picked from commit d7b91f9f7e9e4118f1f47df19d81fc9bc6965ec5)
---
src/commands/utils.rs | 16 ++++++---
src/thin/dump.rs | 31 +++---------------
tests/common/process.rs | 2 +-
tests/thin_dump.rs | 72 ++++++++++++++++++++++++++++++++++++++++-
4 files changed, 89 insertions(+), 32 deletions(-)
diff --git a/src/commands/utils.rs b/src/commands/utils.rs
index 0be4fa7f..38751603 100644
--- a/src/commands/utils.rs
+++ b/src/commands/utils.rs
@@ -162,10 +162,18 @@ pub fn check_overwrite_metadata(report: &Report, path: &Path) -> Result<()> {
pub fn to_exit_code<T>(report: &Report, result: anyhow::Result<T>) -> exitcode::ExitCode {
if let Err(e) = result {
- if e.chain().len() > 1 {
- report.fatal(&format!("{}: {}", e, e.root_cause()));
- } else {
- report.fatal(&format!("{}", e));
+ let root_cause = e.root_cause();
+ let is_broken_pipe = root_cause
+ .downcast_ref::<Arc<std::io::Error>>() // quick_xml::Error::Io wraps io::Error in Arc
+ .map(|err| err.kind() == std::io::ErrorKind::BrokenPipe)
+ .unwrap_or(false);
+
+ if !is_broken_pipe {
+ if e.chain().len() > 1 {
+ report.fatal(&format!("{}: {}", e, root_cause));
+ } else {
+ report.fatal(&format!("{}", e));
+ }
}
// FIXME: we need a way of getting more meaningful error codes
diff --git a/src/thin/dump.rs b/src/thin/dump.rs
index f6046487..561ea566 100644
--- a/src/thin/dump.rs
+++ b/src/thin/dump.rs
@@ -10,8 +10,7 @@ use crate::checksum;
use crate::commands::engine::*;
use crate::dump_utils::*;
use crate::io_engine::*;
-use crate::pdata::btree::{self, *};
-use crate::pdata::btree_walker::*;
+use crate::pdata::btree::*;
use crate::pdata::space_map::common::*;
use crate::pdata::unpack::*;
use crate::report::*;
@@ -104,9 +103,7 @@ impl<'a> MappingVisitor<'a> {
}),
}
}
-}
-impl<'a> NodeVisitor<BlockTime> for MappingVisitor<'a> {
fn visit(
&self,
_path: &[u64],
@@ -114,39 +111,21 @@ impl<'a> NodeVisitor<BlockTime> for MappingVisitor<'a> {
_h: &NodeHeader,
keys: &[u64],
values: &[BlockTime],
- ) -> btree::Result<()> {
+ ) -> Result<()> {
let mut inner = self.inner.lock().unwrap();
for (k, v) in keys.iter().zip(values.iter()) {
if let Some(run) = inner.builder.next(*k, v.block, v.time) {
- // FIXME: BTreeError should carry more information than a string
- // so the caller could identify the actual root cause,
- // e.g., a broken pipe error or something.
- inner
- .md_out
- .map(&run)
- .map_err(|e| btree::value_err(format!("{}", e)))?;
+ inner.md_out.map(&run)?;
}
}
Ok(())
}
- fn visit_again(&self, _path: &[u64], b: u64) -> btree::Result<()> {
- let mut inner = self.inner.lock().unwrap();
- inner
- .md_out
- .ref_shared(&format!("{}", b))
- .map_err(|e| btree::value_err(format!("{}", e)))?;
- Ok(())
- }
-
- fn end_walk(&self) -> btree::Result<()> {
+ fn end_walk(&self) -> Result<()> {
let mut inner = self.inner.lock().unwrap();
if let Some(run) = inner.builder.complete() {
- inner
- .md_out
- .map(&run)
- .map_err(|e| btree::value_err(format!("{}", e)))?;
+ inner.md_out.map(&run)?;
}
Ok(())
}
diff --git a/tests/common/process.rs b/tests/common/process.rs
index 99f10dc7..ad26c38b 100644
--- a/tests/common/process.rs
+++ b/tests/common/process.rs
@@ -39,7 +39,7 @@ impl Command {
Command { program, args }
}
- fn to_expr(&self) -> duct::Expression {
+ pub fn to_expr(&self) -> duct::Expression {
duct::cmd(&self.program, &self.args)
}
}
diff --git a/tests/thin_dump.rs b/tests/thin_dump.rs
index 28cb237d..6e2cd3db 100644
--- a/tests/thin_dump.rs
+++ b/tests/thin_dump.rs
@@ -129,7 +129,7 @@ fn dump_restore_cycle() -> Result<()> {
// test no stderr with a normal dump
#[test]
-fn no_stderr() -> Result<()> {
+fn no_stderr_on_success() -> Result<()> {
let mut td = TestDir::new()?;
let md = mk_valid_md(&mut td)?;
@@ -139,6 +139,76 @@ fn no_stderr() -> Result<()> {
Ok(())
}
+//------------------------------------------
+// test no stderr on broken pipe errors
+
+#[test]
+fn no_stderr_on_broken_pipe() -> Result<()> {
+ use anyhow::ensure;
+
+ let mut td = TestDir::new()?;
+
+ // use the metadata producing dump more than 64KB (the default pipe buffer size),
+ // such that thin_dump will be blocked on writing to the pipe, then hits EPIPE.
+ let md = prep_metadata(&mut td)?;
+
+ let mut pipefd = [0i32; 2];
+ unsafe {
+ ensure!(libc::pipe2(pipefd.as_mut_slice().as_mut_ptr(), libc::O_CLOEXEC) == 0);
+ }
+
+ let cmd = thin_dump_cmd(args![&md])
+ .to_expr()
+ .stdout_file(pipefd[1])
+ .stderr_capture();
+ let handle = cmd.unchecked().start()?;
+
+ // wait for thin_dump to fill the pipe buffer
+ std::thread::sleep(std::time::Duration::from_millis(1000));
+
+ unsafe {
+ libc::close(pipefd[1]); // close the unused write-end
+ libc::close(pipefd[0]); // causing broken pipe
+ }
+
+ let output = handle.wait()?;
+ ensure!(!output.status.success());
+ ensure!(output.stderr.is_empty());
+
+ Ok(())
+}
+
+#[test]
+fn no_stderr_on_broken_fifo() -> Result<()> {
+ use anyhow::ensure;
+
+ let mut td = TestDir::new()?;
+
+ // use the metadata producing dump more than 64KB (the default pipe buffer size),
+ // such that thin_dump will be blocked on writing to the pipe, then hits EPIPE.
+ let md = prep_metadata(&mut td)?;
+
+ let out_fifo = td.mk_path("out_fifo");
+ unsafe {
+ let c_str = std::ffi::CString::new(out_fifo.as_os_str().as_encoded_bytes()).unwrap();
+ ensure!(libc::mkfifo(c_str.as_ptr(), 0o666) == 0);
+ };
+
+ let cmd = thin_dump_cmd(args![&md, "-o", &out_fifo])
+ .to_expr()
+ .stderr_capture();
+ let handle = cmd.unchecked().start()?;
+
+ let fifo = std::fs::File::open(out_fifo)?;
+ drop(fifo); // causing broken pipe
+
+ let output = handle.wait()?;
+ ensure!(!output.status.success());
+ ensure!(output.stderr.is_empty());
+
+ Ok(())
+}
+
//------------------------------------------
// test dump metadata snapshot from a live metadata
// here we use a corrupted metadata to ensure that "thin_dump -m" reads the
--
2.43.0

View File

@ -1,88 +0,0 @@
From 5d79a5c944d05f71425d3156597a2a61c5f2ab9a Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Wed, 2 Jun 2021 13:08:47 +0800
Subject: [PATCH 08/10] [thin_dump] Fix warnings on potential NULL pointer
---
base/application.cc | 8 +++++++-
base/application.h | 2 +-
thin-provisioning/thin_dump.cc | 16 ++--------------
3 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/base/application.cc b/base/application.cc
index 61338ff..dbd55a5 100644
--- a/base/application.cc
+++ b/base/application.cc
@@ -25,8 +25,14 @@ command::die(string const &msg)
}
::uint64_t
-command::parse_uint64(string const &str, string const &desc)
+command::parse_uint64(char const *str, char const *desc)
{
+ if (!str) {
+ ostringstream out;
+ out << "Couldn't parse " << desc << ": NULL";
+ die(out.str());
+ }
+
try {
// FIXME: check trailing garbage is handled
return lexical_cast<::uint64_t>(str);
diff --git a/base/application.h b/base/application.h
index b799eaf..f071533 100644
--- a/base/application.h
+++ b/base/application.h
@@ -19,7 +19,7 @@ namespace base {
virtual ~command() {}
void die(std::string const &msg);
- uint64_t parse_uint64(std::string const &str, std::string const &desc);
+ uint64_t parse_uint64(char const *str, char const *desc);
virtual void usage(std::ostream &out) const = 0;
diff --git a/thin-provisioning/thin_dump.cc b/thin-provisioning/thin_dump.cc
index 74cfa91..c0e73e6 100644
--- a/thin-provisioning/thin_dump.cc
+++ b/thin-provisioning/thin_dump.cc
@@ -143,7 +143,6 @@ thin_dump_cmd::run(int argc, char **argv)
int c;
char const *output = NULL;
const char shortopts[] = "hm::o:f:rV";
- char *end_ptr;
block_address metadata_snap = 0;
::uint64_t dev_id;
struct flags flags;
@@ -181,13 +180,7 @@ thin_dump_cmd::run(int argc, char **argv)
flags.use_metadata_snap = true;
if (optarg) {
// FIXME: deprecate this option
- metadata_snap = strtoull(optarg, &end_ptr, 10);
- if (end_ptr == optarg) {
- cerr << "couldn't parse <metadata-snap>" << endl;
- usage(cerr);
- return 1;
- }
-
+ metadata_snap = parse_uint64(optarg, "metadata-snap");
flags.snap_location = metadata_snap;
}
break;
@@ -197,12 +190,7 @@ thin_dump_cmd::run(int argc, char **argv)
break;
case 1:
- dev_id = strtoull(optarg, &end_ptr, 10);
- if (end_ptr == optarg) {
- cerr << "couldn't parse <dev-id>\n";
- usage(cerr);
- return 1;
- }
+ dev_id = parse_uint64(optarg, "dev-id");
flags.opts.select_dev(dev_id);
break;
--
1.8.3.1

View File

@ -0,0 +1,34 @@
From e6659ff342516f1861cdb1f365dfb4f79bb45c54 Mon Sep 17 00:00:00 2001
From: mulhern <amulhern@redhat.com>
Date: Sun, 7 Jan 2024 20:17:13 -0500
Subject: [PATCH 08/10] thin_metadata_pack: Allow long format for input and
output
The options match the man pages that way.
(cherry picked from commit b5e7028effc51ad1c303424a9f1d161d2f7b0c7c)
---
src/commands/thin_metadata_pack.rs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/commands/thin_metadata_pack.rs b/src/commands/thin_metadata_pack.rs
index 5aad973c..265439c9 100644
--- a/src/commands/thin_metadata_pack.rs
+++ b/src/commands/thin_metadata_pack.rs
@@ -26,11 +26,13 @@ impl ThinMetadataPackCommand {
.help("Specify thinp metadata binary device/file")
.required(true)
.short('i')
+ .long("input")
.value_name("DEV"))
.arg(Arg::new("OUTPUT")
.help("Specify packed output file")
.required(true)
.short('o')
+ .long("output")
.value_name("FILE"))
}
}
--
2.43.0

View File

@ -1,52 +0,0 @@
From 1c50c406ddda77f4c0b20e7bf3cc985e84526f51 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Wed, 2 Jun 2021 13:14:30 +0800
Subject: [PATCH 09/10] [build] Remove unused sources from the regular build
---
Makefile.in | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index b1fd4aa..9b13001 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -96,10 +96,7 @@ SOURCE=\
persistent-data/transaction_manager.cc \
persistent-data/validators.cc \
thin-provisioning/commands.cc \
- thin-provisioning/cache_stream.cc \
- thin-provisioning/chunk_stream.cc \
thin-provisioning/device_tree.cc \
- thin-provisioning/fixed_chunk_stream.cc \
thin-provisioning/human_readable_format.cc \
thin-provisioning/mapping_tree.cc \
thin-provisioning/metadata.cc \
@@ -107,7 +104,6 @@ SOURCE=\
thin-provisioning/metadata_counter.cc \
thin-provisioning/metadata_dumper.cc \
thin-provisioning/override_emitter.cc \
- thin-provisioning/pool_stream.cc \
thin-provisioning/restore_emitter.cc \
thin-provisioning/rmap_visitor.cc \
thin-provisioning/superblock.cc \
@@ -124,7 +120,11 @@ SOURCE=\
thin-provisioning/xml_format.cc
DEVTOOLS_SOURCE=\
+ thin-provisioning/cache_stream.cc \
+ thin-provisioning/chunk_stream.cc \
thin-provisioning/damage_generator.cc \
+ thin-provisioning/fixed_chunk_stream.cc \
+ thin-provisioning/pool_stream.cc \
thin-provisioning/thin_journal.cc \
thin-provisioning/thin_journal_check.cc \
thin-provisioning/thin_ll_dump.cc \
@@ -374,4 +374,3 @@ test: functional-test unit-test
endif
-include $(DEPEND_FILES)
-
--
1.8.3.1

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +0,0 @@
From 9e94a4349186f7353e0d7b536b46bfa4df2483d0 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Wed, 2 Jun 2021 14:59:29 +0800
Subject: [PATCH 10/10] [all] Remove unreachable code
---
block-cache/io_engine.cc | 3 ---
caching/hint_array.cc | 6 ------
2 files changed, 9 deletions(-)
diff --git a/block-cache/io_engine.cc b/block-cache/io_engine.cc
index 2fe4082..0158723 100644
--- a/block-cache/io_engine.cc
+++ b/block-cache/io_engine.cc
@@ -174,9 +174,6 @@ aio_engine::wait_(timespec *ts)
cbs_.free(cb);
return optional<wait_result>(make_pair(false, context));
}
-
- // shouldn't get here
- return optional<wait_result>(make_pair(false, 0));
}
struct timespec
diff --git a/caching/hint_array.cc b/caching/hint_array.cc
index 6514968..e133c5c 100644
--- a/caching/hint_array.cc
+++ b/caching/hint_array.cc
@@ -56,9 +56,6 @@ namespace {
default:
throw runtime_error("invalid hint width");
}
-
- // never get here
- return std::shared_ptr<array_base>();
}
//--------------------------------
@@ -93,9 +90,6 @@ namespace {
default:
throw runtime_error("invalid hint width");
}
-
- // never get here
- return std::shared_ptr<array_base>();
}
//--------------------------------
--
1.8.3.1

View File

@ -0,0 +1,109 @@
From a557bc55ef3c136b1fca3f27cd55fdb0014dc6e7 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Fri, 23 Feb 2024 20:20:01 +0800
Subject: [PATCH 10/10] [thin_dump] Do not print error messages on BrokenPipe
(EPIPE)
Handle the case that doesn't write through quick_xml,
e.g., thin_dump --format human_readable
(cherry picked from commit b3e05f2eb9b704af897f14215536dadde5c13b2d)
---
src/commands/utils.rs | 7 +++++--
tests/thin_dump.rs | 34 +++++++++++++++++++++++++++-------
2 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/src/commands/utils.rs b/src/commands/utils.rs
index 38751603..82b2529e 100644
--- a/src/commands/utils.rs
+++ b/src/commands/utils.rs
@@ -165,8 +165,11 @@ pub fn to_exit_code<T>(report: &Report, result: anyhow::Result<T>) -> exitcode::
let root_cause = e.root_cause();
let is_broken_pipe = root_cause
.downcast_ref::<Arc<std::io::Error>>() // quick_xml::Error::Io wraps io::Error in Arc
- .map(|err| err.kind() == std::io::ErrorKind::BrokenPipe)
- .unwrap_or(false);
+ .map_or_else(
+ || root_cause.downcast_ref::<std::io::Error>(),
+ |err| Some(err.as_ref()),
+ )
+ .map_or(false, |err| err.kind() == std::io::ErrorKind::BrokenPipe);
if !is_broken_pipe {
if e.chain().len() > 1 {
diff --git a/tests/thin_dump.rs b/tests/thin_dump.rs
index 6e2cd3db..81982188 100644
--- a/tests/thin_dump.rs
+++ b/tests/thin_dump.rs
@@ -142,8 +142,7 @@ fn no_stderr_on_success() -> Result<()> {
//------------------------------------------
// test no stderr on broken pipe errors
-#[test]
-fn no_stderr_on_broken_pipe() -> Result<()> {
+fn test_no_stderr_on_broken_pipe(extra_args: &[&std::ffi::OsStr]) -> Result<()> {
use anyhow::ensure;
let mut td = TestDir::new()?;
@@ -157,7 +156,9 @@ fn no_stderr_on_broken_pipe() -> Result<()> {
ensure!(libc::pipe2(pipefd.as_mut_slice().as_mut_ptr(), libc::O_CLOEXEC) == 0);
}
- let cmd = thin_dump_cmd(args![&md])
+ let mut args = args![&md].to_vec();
+ args.extend_from_slice(extra_args);
+ let cmd = thin_dump_cmd(args)
.to_expr()
.stdout_file(pipefd[1])
.stderr_capture();
@@ -179,7 +180,16 @@ fn no_stderr_on_broken_pipe() -> Result<()> {
}
#[test]
-fn no_stderr_on_broken_fifo() -> Result<()> {
+fn no_stderr_on_broken_pipe_xml() -> Result<()> {
+ test_no_stderr_on_broken_pipe(&[])
+}
+
+#[test]
+fn no_stderr_on_broken_pipe_humanreadable() -> Result<()> {
+ test_no_stderr_on_broken_pipe(&args!["--format", "human_readable"])
+}
+
+fn test_no_stderr_on_broken_fifo(extra_args: &[&std::ffi::OsStr]) -> Result<()> {
use anyhow::ensure;
let mut td = TestDir::new()?;
@@ -194,9 +204,9 @@ fn no_stderr_on_broken_fifo() -> Result<()> {
ensure!(libc::mkfifo(c_str.as_ptr(), 0o666) == 0);
};
- let cmd = thin_dump_cmd(args![&md, "-o", &out_fifo])
- .to_expr()
- .stderr_capture();
+ let mut args = args![&md, "-o", &out_fifo].to_vec();
+ args.extend_from_slice(extra_args);
+ let cmd = thin_dump_cmd(args).to_expr().stderr_capture();
let handle = cmd.unchecked().start()?;
let fifo = std::fs::File::open(out_fifo)?;
@@ -209,6 +219,16 @@ fn no_stderr_on_broken_fifo() -> Result<()> {
Ok(())
}
+#[test]
+fn no_stderr_on_broken_fifo_xml() -> Result<()> {
+ test_no_stderr_on_broken_fifo(&[])
+}
+
+#[test]
+fn no_stderr_on_broken_fifo_humanreadable() -> Result<()> {
+ test_no_stderr_on_broken_fifo(&args!["--format", "human_readable"])
+}
+
//------------------------------------------
// test dump metadata snapshot from a live metadata
// here we use a corrupted metadata to ensure that "thin_dump -m" reads the
--
2.43.0

View File

@ -1,24 +0,0 @@
From 677fa789e4136dbdd589c1e65efc7cdaad7506ac Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Fri, 4 Jun 2021 21:37:02 +0800
Subject: [PATCH 1/2] [file_utils] Fix resource leak
---
base/file_utils.cc | 1 +
1 file changed, 1 insertion(+)
diff --git a/base/file_utils.cc b/base/file_utils.cc
index 8253660..e6095f7 100644
--- a/base/file_utils.cc
+++ b/base/file_utils.cc
@@ -159,6 +159,7 @@ file_utils::zero_superblock(std::string const &path)
free(buffer);
throw runtime_error("couldn't zero superblock");
}
+ free(buffer);
}
//----------------------------------------------------------------
--
1.8.3.1

View File

@ -1,224 +0,0 @@
From 2e755c67064c0157e646acfa57fbcc738905f7d4 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Tue, 20 Oct 2020 15:18:06 +0800
Subject: [PATCH 2/2] [thin_delta] Clean up duplicated code
---
thin-provisioning/thin_delta.cc | 105 ++++++++++++----------------------------
1 file changed, 31 insertions(+), 74 deletions(-)
diff --git a/thin-provisioning/thin_delta.cc b/thin-provisioning/thin_delta.cc
index ee48dea..2ff3e69 100644
--- a/thin-provisioning/thin_delta.cc
+++ b/thin-provisioning/thin_delta.cc
@@ -22,47 +22,7 @@ using namespace thin_provisioning;
//----------------------------------------------------------------
-namespace local {
- class application {
- public:
- application(string const &cmd)
- : cmd_(cmd) {
- }
-
- void usage(ostream &out) {
- out << "Usage: " << cmd_ << " [options] <device or file>\n"
- << "Options:\n"
- << " {--thin1, --snap1}\n"
- << " {--thin2, --snap2}\n"
- << " {-m, --metadata-snap} [block#]\n"
- << " {--verbose}\n"
- << " {-h|--help}\n"
- << " {-V|--version}" << endl;
- }
-
- void die(string const &msg) {
- cerr << msg << endl;
- usage(cerr);
- exit(1);
- }
-
- uint64_t parse_int(string const &str, string const &desc) {
- try {
- return boost::lexical_cast<uint64_t>(str);
-
- } catch (...) {
- ostringstream out;
- out << "Couldn't parse " << desc << ": '" << str << "'";
- die(out.str());
- }
-
- return 0; // never get here
- }
-
- private:
- string cmd_;
- };
-
+namespace {
struct flags {
flags()
: verbose(false),
@@ -96,13 +56,6 @@ namespace local {
uint64_t vbegin_, dbegin_, len_;
};
- ostream &operator <<(ostream &out, mapping const &m) {
- out << "mapping[vbegin = " << m.vbegin_
- << ", dbegin = " << m.dbegin_
- << ", len = " << m.len_ << "]";
- return out;
- }
-
//--------------------------------
template <typename Container>
@@ -542,7 +495,7 @@ namespace local {
out << "</diff>\n";
}
- void delta_(application &app, flags const &fs) {
+ void delta_(flags const &fs) {
mapping_recorder mr1;
mapping_recorder mr2;
damage_visitor damage_v;
@@ -560,7 +513,7 @@ namespace local {
if (!snap1_root) {
ostringstream out;
out << "Unable to find mapping tree for snap1 (" << *fs.snap1 << ")";
- app.die(out.str());
+ throw std::runtime_error(out.str());
}
single_mapping_tree snap1(*md->tm_, *snap1_root,
@@ -572,7 +525,7 @@ namespace local {
if (!snap2_root) {
ostringstream out;
out << "Unable to find mapping tree for snap2 (" << *fs.snap2 << ")";
- app.die(out.str());
+ throw std::runtime_error(out.str());
}
single_mapping_tree snap2(*md->tm_, *snap2_root,
@@ -609,12 +562,12 @@ namespace local {
end_superblock(is);
}
- int delta(application &app, flags const &fs) {
+ int delta(flags const &fs) {
try {
- delta_(app, fs);
+ delta_(fs);
} catch (exception const &e) {
- app.die(e.what());
- return 1; // never get here
+ cerr << e.what() << endl;
+ return 1;
}
return 0;
@@ -633,27 +586,31 @@ thin_delta_cmd::thin_delta_cmd()
void
thin_delta_cmd::usage(std::ostream &out) const
{
- // FIXME: finish
+ out << "Usage: " << get_name() << " [options] <device or file>\n"
+ << "Options:\n"
+ << " {--thin1, --snap1}\n"
+ << " {--thin2, --snap2}\n"
+ << " {-m, --metadata-snap} [block#]\n"
+ << " {--verbose}\n"
+ << " {-h|--help}\n"
+ << " {-V|--version}" << endl;
}
int
thin_delta_cmd::run(int argc, char **argv)
{
- using namespace local;
-
int c;
flags fs;
- local::application app(basename(argv[0]));
char const shortopts[] = "hVm::";
option const longopts[] = {
{ "help", no_argument, NULL, 'h' },
+ { "metadata-snap", optional_argument, NULL, 'm' },
{ "version", no_argument, NULL, 'V' },
{ "thin1", required_argument, NULL, 1 },
{ "snap1", required_argument, NULL, 1 },
{ "thin2", required_argument, NULL, 2 },
{ "snap2", required_argument, NULL, 2 },
- { "metadata-snap", optional_argument, NULL, 'm' },
{ "verbose", no_argument, NULL, 4 },
{ NULL, no_argument, NULL, 0 }
};
@@ -661,25 +618,25 @@ thin_delta_cmd::run(int argc, char **argv)
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
switch (c) {
case 'h':
- app.usage(cout);
+ usage(cout);
return 0;
+ case 'm':
+ fs.use_metadata_snap = true;
+ if (optarg)
+ fs.metadata_snap = parse_uint64(optarg, "metadata snapshot block");
+ break;
+
case 'V':
cout << THIN_PROVISIONING_TOOLS_VERSION << endl;
return 0;
case 1:
- fs.snap1 = app.parse_int(optarg, "thin id 1");
+ fs.snap1 = parse_uint64(optarg, "thin id 1");
break;
case 2:
- fs.snap2 = app.parse_int(optarg, "thin id 2");
- break;
-
- case 'm':
- fs.use_metadata_snap = true;
- if (optarg)
- fs.metadata_snap = app.parse_int(optarg, "metadata snapshot block");
+ fs.snap2 = parse_uint64(optarg, "thin id 2");
break;
case 4:
@@ -687,23 +644,23 @@ thin_delta_cmd::run(int argc, char **argv)
break;
default:
- app.usage(cerr);
+ usage(cerr);
return 1;
}
}
if (argc == optind)
- app.die("No input device provided.");
+ die("No input device provided.");
else
fs.dev = argv[optind];
if (!fs.snap1)
- app.die("--snap1 not specified.");
+ die("--snap1 not specified.");
if (!fs.snap2)
- app.die("--snap2 not specified.");
+ die("--snap2 not specified.");
- return delta(app, fs);
+ return delta(fs);
}
//----------------------------------------------------------------
--
1.8.3.1

View File

@ -1,16 +0,0 @@
Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.in b/Makefile.in
index b1fd4aa..77c467d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -173,7 +173,7 @@ CXXFLAGS+=@CXXDEBUG_FLAG@
CXXFLAGS+=@CXX_STRERROR_FLAG@
CXXFLAGS+=@LFS_FLAGS@
INCLUDES+=-I$(TOP_BUILDDIR) -I$(TOP_DIR) -I$(TOP_DIR)/thin-provisioning
-LIBS:=-laio -lexpat -lboost_iostreams -ldl
+LIBS:=-laio -lexpat -ldl
ifeq ("@DEVTOOLS@", "yes")
LIBS+=-lncurses

View File

@ -1,848 +0,0 @@
From 0a061474ee8f8183bded35a7c680739c9b75ad4b Mon Sep 17 00:00:00 2001
From: Marian Csontos <mcsontos@redhat.com>
Date: Mon, 28 Jun 2021 13:14:37 +0200
Subject: [PATCH] cargo update
---
Cargo.lock | 486 +++++++++++++++++++++++++++++++++----------------------------
1 file changed, 264 insertions(+), 222 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index d42d598..9dc0b8a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,567 +1,609 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
-name = "adler32"
-version = "1.0.4"
+name = "adler"
+version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "aho-corasick"
-version = "0.7.10"
+version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
- "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr",
]
[[package]]
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
- "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi",
]
[[package]]
name = "anyhow"
-version = "1.0.31"
+version = "1.0.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "15af2628f6890fe2609a3b91bef4c83450512802e59489f9c1cb1fa5df064a61"
[[package]]
name = "arrayvec"
-version = "0.4.12"
+version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
-]
+checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
- "hermit-abi 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "hermit-abi",
+ "libc",
+ "winapi",
]
[[package]]
name = "autocfg"
-version = "1.0.0"
+version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "byteorder"
-version = "1.3.4"
+version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "cc"
-version = "1.0.54"
+version = "1.0.68"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
+
+[[package]]
+name = "cfg-if"
+version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
-version = "0.1.9"
+version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
-version = "2.33.1"
+version = "2.33.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
dependencies = [
- "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "vec_map 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ansi_term",
+ "atty",
+ "bitflags",
+ "strsim",
+ "textwrap",
+ "unicode-width",
+ "vec_map",
]
[[package]]
name = "crc32c"
-version = "0.4.0"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "210cdf933e6a81212bfabf90cd8762f471b5922e5f6b709547673ad8e04b9448"
+dependencies = [
+ "rustc_version",
+]
[[package]]
name = "crc32fast"
-version = "1.2.0"
+version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
dependencies = [
- "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 1.0.0",
]
[[package]]
name = "env_logger"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
dependencies = [
- "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "log",
+ "regex",
]
[[package]]
name = "fixedbitset"
-version = "0.3.0"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "45e780567ed7abc415d12fd464571d265eb4a5710ddc97cdb1a31a4c35bb479d"
[[package]]
name = "flate2"
-version = "1.0.14"
+version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0"
dependencies = [
- "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
- "miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 1.0.0",
+ "crc32fast",
+ "libc",
+ "miniz_oxide",
]
[[package]]
name = "getrandom"
-version = "0.1.14"
+version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
- "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
- "wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 1.0.0",
+ "libc",
+ "wasi 0.9.0+wasi-snapshot-preview1",
]
[[package]]
-name = "hermit-abi"
-version = "0.1.13"
+name = "getrandom"
+version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
dependencies = [
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 1.0.0",
+ "libc",
+ "wasi 0.10.2+wasi-snapshot-preview1",
]
[[package]]
-name = "lazy_static"
-version = "1.4.0"
+name = "hermit-abi"
+version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
+dependencies = [
+ "libc",
+]
[[package]]
name = "lexical-core"
-version = "0.6.7"
+version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe"
dependencies = [
- "arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "static_assertions 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "arrayvec",
+ "bitflags",
+ "cfg-if 1.0.0",
+ "ryu",
+ "static_assertions",
]
[[package]]
name = "libc"
-version = "0.2.71"
+version = "0.2.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
[[package]]
name = "log"
-version = "0.4.8"
+version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
- "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 1.0.0",
]
[[package]]
name = "memchr"
-version = "2.3.3"
+version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
[[package]]
name = "miniz_oxide"
-version = "0.3.6"
+version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
dependencies = [
- "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "adler",
+ "autocfg",
]
[[package]]
name = "nix"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363"
dependencies = [
- "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "cc 1.0.54 (registry+https://github.com/rust-lang/crates.io-index)",
- "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
- "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags",
+ "cc",
+ "cfg-if 0.1.10",
+ "libc",
+ "void",
]
[[package]]
-name = "nodrop"
-version = "0.1.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
name = "nom"
-version = "5.1.1"
+version = "5.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
dependencies = [
- "lexical-core 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lexical-core",
+ "memchr",
+ "version_check",
]
[[package]]
name = "num-derive"
-version = "0.3.0"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d"
dependencies = [
- "proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
name = "num-traits"
-version = "0.2.11"
+version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
- "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "autocfg",
]
[[package]]
name = "num_cpus"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
dependencies = [
- "hermit-abi 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
+ "hermit-abi",
+ "libc",
]
[[package]]
name = "ppv-lite86"
-version = "0.2.8"
+version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
[[package]]
name = "proc-macro2"
-version = "1.0.18"
+version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
dependencies = [
- "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-xid",
]
[[package]]
name = "quick-xml"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3cc440ee4802a86e357165021e3e255a9143724da31db1e2ea540214c96a0f82"
dependencies = [
- "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr",
]
[[package]]
name = "quickcheck"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f"
dependencies = [
- "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "env_logger",
+ "log",
+ "rand 0.7.3",
+ "rand_core 0.5.1",
]
[[package]]
name = "quickcheck_macros"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "608c156fd8e97febc07dc9c2e2c80bf74cfc6ef26893eae3daf8bc2bc94a4b7f"
dependencies = [
- "proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2",
+ "quote",
+ "syn",
]
[[package]]
name = "quote"
-version = "1.0.6"
+version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
dependencies = [
- "proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2",
]
[[package]]
name = "rand"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
- "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "getrandom 0.1.16",
+ "libc",
+ "rand_chacha 0.2.2",
+ "rand_core 0.5.1",
+ "rand_hc 0.2.0",
+]
+
+[[package]]
+name = "rand"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
+dependencies = [
+ "libc",
+ "rand_chacha 0.3.1",
+ "rand_core 0.6.3",
+ "rand_hc 0.3.1",
]
[[package]]
name = "rand_chacha"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [
- "ppv-lite86 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ppv-lite86",
+ "rand_core 0.5.1",
+]
+
+[[package]]
+name = "rand_chacha"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
+dependencies = [
+ "ppv-lite86",
+ "rand_core 0.6.3",
]
[[package]]
name = "rand_core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
- "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "getrandom 0.1.16",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
+dependencies = [
+ "getrandom 0.2.3",
]
[[package]]
name = "rand_hc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
+dependencies = [
+ "rand_core 0.5.1",
+]
+
+[[package]]
+name = "rand_hc"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [
- "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core 0.6.3",
]
[[package]]
name = "redox_syscall"
-version = "0.1.56"
+version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee"
+dependencies = [
+ "bitflags",
+]
[[package]]
name = "regex"
-version = "1.3.9"
+version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
- "aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
]
[[package]]
name = "regex-syntax"
-version = "0.6.18"
+version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
- "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi",
]
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [
- "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "semver",
]
[[package]]
name = "ryu"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
- "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "semver-parser",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "static_assertions"
-version = "0.3.4"
+version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "syn"
-version = "1.0.30"
+version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
dependencies = [
- "proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
]
[[package]]
name = "tempfile"
-version = "3.1.0"
+version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
dependencies = [
- "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
- "remove_dir_all 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if 1.0.0",
+ "libc",
+ "rand 0.8.4",
+ "redox_syscall",
+ "remove_dir_all",
+ "winapi",
]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
- "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-width",
]
[[package]]
name = "thinp"
version = "0.1.0"
dependencies = [
- "anyhow 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)",
- "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "clap 2.33.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "crc32c 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "fixedbitset 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "flate2 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
- "nix 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "nom 5.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "num-derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "quick-xml 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "quickcheck 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "quickcheck_macros 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "thread_local"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "anyhow",
+ "byteorder",
+ "clap",
+ "crc32c",
+ "fixedbitset",
+ "flate2",
+ "libc",
+ "nix",
+ "nom",
+ "num-derive",
+ "num-traits",
+ "num_cpus",
+ "quick-xml",
+ "quickcheck",
+ "quickcheck_macros",
+ "rand 0.7.3",
+ "tempfile",
]
[[package]]
name = "unicode-width"
-version = "0.1.7"
+version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]]
name = "unicode-xid"
-version = "0.2.0"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
-version = "0.9.2"
+version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
[[package]]
name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
+
+[[package]]
+name = "wasi"
+version = "0.10.2+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "winapi"
-version = "0.3.8"
+version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
- "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[metadata]
-"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2"
-"checksum aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada"
-"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
-"checksum anyhow 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f"
-"checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9"
-"checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
-"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
-"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
-"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
-"checksum cc 1.0.54 (registry+https://github.com/rust-lang/crates.io-index)" = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311"
-"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
-"checksum clap 2.33.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129"
-"checksum crc32c 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77ba37ef26c12988c1cee882d522d65e1d5d2ad8c3864665b88ee92767ed84c5"
-"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
-"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
-"checksum fixedbitset 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4fcacf5cd3681968f6524ea159383132937739c6c40dabab9e37ed515911b"
-"checksum flate2 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42"
-"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
-"checksum hermit-abi 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71"
-"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
-"checksum lexical-core 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f86d66d380c9c5a685aaac7a11818bdfa1f733198dfd9ec09c70b762cd12ad6f"
-"checksum libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49"
-"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
-"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
-"checksum miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5"
-"checksum nix 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363"
-"checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
-"checksum nom 5.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b471253da97532da4b61552249c521e01e736071f71c1a4f7ebbfbf0a06aad6"
-"checksum num-derive 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0c8b15b261814f992e33760b1fca9fe8b693d8a65299f20c9901688636cfb746"
-"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
-"checksum num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
-"checksum ppv-lite86 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
-"checksum proc-macro2 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
-"checksum quick-xml 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3cc440ee4802a86e357165021e3e255a9143724da31db1e2ea540214c96a0f82"
-"checksum quickcheck 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f"
-"checksum quickcheck_macros 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "608c156fd8e97febc07dc9c2e2c80bf74cfc6ef26893eae3daf8bc2bc94a4b7f"
-"checksum quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea"
-"checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
-"checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
-"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
-"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
-"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
-"checksum regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
-"checksum regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
-"checksum remove_dir_all 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
-"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
-"checksum ryu 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
-"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
-"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
-"checksum static_assertions 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3"
-"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
-"checksum syn 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "93a56fabc59dce20fe48b6c832cc249c713e7ed88fa28b0ee0a3bfcaae5fe4e2"
-"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
-"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
-"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
-"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
-"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
-"checksum vec_map 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
-"checksum version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
-"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
-"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
-"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
-"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
-"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
--
1.8.3.1

View File

@ -1,197 +0,0 @@
From 637fc5ec0869145d1b5272ee0e1e51e21517be79 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Mon, 7 Jun 2021 14:54:04 +0800
Subject: [PATCH] [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
(cherry picked from commit 62536defc86f12363e4178ee5a2cefc40fa416d9)
---
ft-lib/bcache.c | 20 ++++++++++---
functional-tests/thin-functional-tests.scm | 46 ++++++++++++++++++++++++++++++
functional-tests/thin/xml.scm | 4 +--
thin-provisioning/restore_emitter.cc | 2 +-
4 files changed, 65 insertions(+), 7 deletions(-)
diff --git a/ft-lib/bcache.c b/ft-lib/bcache.c
index ee5b6c5..1c63377 100644
--- a/ft-lib/bcache.c
+++ b/ft-lib/bcache.c
@@ -201,8 +201,10 @@ static int engine_issue(struct io_engine *e, int fd, enum dir d,
cb_array[0] = &cb->cb;
r = io_submit(e->aio_context, 1, cb_array);
- if (r < 0)
+ if (r < 0) {
+ warn("io_submit failed, ret=%d\n", r);
cb_free(e->cbs, cb);
+ }
return r;
}
@@ -219,7 +221,7 @@ static int engine_wait(struct io_engine *e, struct timespec *ts, complete_fn fn)
memset(&event, 0, sizeof(event));
r = io_getevents(e->aio_context, 1, MAX_IO, event, ts);
if (r < 0) {
- warn("io_getevents failed");
+ warn("io_getevents failed, ret=%d\n", r);
return r;
}
@@ -514,12 +516,22 @@ static void relink(struct block *b)
*/
static int issue_low_level(struct block *b, enum dir d)
{
+ int r;
struct bcache *cache = b->cache;
sector_t sb = b->index * cache->block_sectors;
sector_t se = sb + cache->block_sectors;
set_flags(b, BF_IO_PENDING);
+ cache->nr_io_pending++;
+ list_add_tail(&b->list, &cache->io_pending);
- return engine_issue(cache->engine, cache->fd, d, sb, se, b->data, b);
+ r = engine_issue(cache->engine, cache->fd, d, sb, se, b->data, b);
+ if (r < 0) {
+ list_del(&b->list);
+ cache->nr_io_pending--;
+ clear_flags(b, BF_IO_PENDING);
+ return r;
+ }
+ return 0;
}
static void issue_read(struct block *b)
@@ -709,7 +721,7 @@ struct bcache *bcache_simple(const char *path, unsigned nr_cache_blocks)
int r;
struct stat info;
struct bcache *cache;
- int fd = open(path, O_DIRECT | O_EXCL | O_RDONLY);
+ int fd = open(path, O_DIRECT | O_EXCL | O_RDWR);
uint64_t s;
if (fd < 0) {
diff --git a/functional-tests/thin-functional-tests.scm b/functional-tests/thin-functional-tests.scm
index 55b0e60..fcabddf 100644
--- a/functional-tests/thin-functional-tests.scm
+++ b/functional-tests/thin-functional-tests.scm
@@ -12,6 +12,7 @@
(process)
(scenario-string-constants)
(temp-file)
+ (thin metadata)
(thin xml)
(srfi s8 receive))
@@ -30,6 +31,12 @@
(with-temp-file-containing ((v "thin.xml" (fmt #f (generate-xml 10 1000))))
b1 b2 ...))))
+ (define-syntax with-needs-check-thin-xml
+ (syntax-rules ()
+ ((_ (v) b1 b2 ...)
+ (with-temp-file-containing ((v "thin.xml" (fmt #f (generate-xml 10 1000 1))))
+ b1 b2 ...))))
+
(define-syntax with-valid-metadata
(syntax-rules ()
((_ (md) b1 b2 ...)
@@ -63,6 +70,28 @@
(damage-superblock md)
b1 b2 ...))))
+ (define superblock-salt 160774)
+ (define (set-needs-check-flag md)
+ (with-bcache (cache md 1)
+ (with-block (b cache 0 (get-flags dirty))
+ (let ((sb (block->superblock b)))
+ (ftype-set! ThinSuperblock (flags) sb 1)
+ ;;;;;; Update the csum manually since the block validator for ft-lib is not ready
+ (let ((csum (checksum-block b (ftype-sizeof unsigned-32) superblock-salt)))
+ (ftype-set! ThinSuperblock (csum) sb csum))))))
+
+ (define (get-superblock-flags md)
+ (with-bcache (cache md 1)
+ (with-block (b cache 0 (get-flags))
+ (let ((sb (block->superblock b)))
+ (ftype-ref ThinSuperblock (flags) sb)))))
+
+ (define (assert-metadata-needs-check md)
+ (assert-equal (get-superblock-flags md) 1))
+
+ (define (assert-metadata-clean md)
+ (assert-equal (get-superblock-flags md) 0))
+
;; We have to export something that forces all the initialisation expressions
;; to run.
(define (register-thin-tests) #t)
@@ -173,6 +202,13 @@
;;;-----------------------------------------------------------
;;; thin_restore scenarios
;;;-----------------------------------------------------------
+ (define-scenario (thin-restore clear-needs-check-flag)
+ "thin_restore should clear the needs-check flag"
+ (with-empty-metadata (md)
+ (with-needs-check-thin-xml (xml)
+ (run-ok-rcv (stdout _) (thin-restore "-i" xml "-o" md "-q")
+ (assert-eof stdout)))
+ (assert-metadata-clean md)))
(define-scenario (thin-restore print-version-v)
"print help (-V)"
@@ -439,6 +475,16 @@
;;;-----------------------------------------------------------
;;; thin_repair scenarios
;;;-----------------------------------------------------------
+ (define-scenario (thin-repair clear-needs-check-flag)
+ "thin_repair should clear the needs-check flag"
+ (with-valid-metadata (md1)
+ (set-needs-check-flag md1)
+ (assert-metadata-needs-check md1)
+ (with-empty-metadata (md2)
+ (run-ok-rcv (stdout stderr) (thin-repair "-i" md1 "-o" md2)
+ (assert-eof stderr))
+ (assert-metadata-clean md2))))
+
(define-scenario (thin-repair dont-repair-xml)
"Fails gracefully if run on XML rather than metadata"
(with-thin-xml (xml)
diff --git a/functional-tests/thin/xml.scm b/functional-tests/thin/xml.scm
index 551a536..7d9314b 100644
--- a/functional-tests/thin/xml.scm
+++ b/functional-tests/thin/xml.scm
@@ -22,7 +22,7 @@
(length . ,nr-mappings)
(time . 1)))))
- (define (generate-xml max-thins max-mappings)
+ (define (generate-xml max-thins max-mappings . needs-check)
(let ((nr-thins ((make-uniform-generator 1 max-thins)))
(nr-mappings-g (make-uniform-generator (div-down max-mappings 2)
max-mappings)))
@@ -30,7 +30,7 @@
(tag 'superblock `((uuid . "")
(time . 1)
(transaction . 1)
- (flags . 0)
+ (flags . ,(if (null? needs-check) 0 (car needs-check)))
(version . 2)
(data-block-size . 128)
(nr-data-blocks . ,(apply + nr-mappings)))
diff --git a/thin-provisioning/restore_emitter.cc b/thin-provisioning/restore_emitter.cc
index 6e95a53..114ba4f 100644
--- a/thin-provisioning/restore_emitter.cc
+++ b/thin-provisioning/restore_emitter.cc
@@ -57,7 +57,7 @@ namespace {
memcpy(&sb.uuid_, uuid.c_str(), std::min(sizeof(sb.uuid_), uuid.length()));
sb.time_ = time;
sb.trans_id_ = trans_id;
- sb.flags_ = flags ? *flags : 0;
+ sb.flags_ = 0;
sb.version_ = version ? *version : 1;
sb.data_block_size_ = data_block_size;
sb.metadata_snap_ = metadata_snap ? *metadata_snap : 0;
--
1.8.3.1

View File

@ -1,72 +0,0 @@
From 9388ab17da885dbd99d8b68217b282646ce9d73d Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Mon, 16 Aug 2021 18:16:29 +0800
Subject: [PATCH 1/3] [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.
(cherry picked from commit 371df963113e7af7b97d2158757e35c44804ccb4)
---
thin-provisioning/metadata_dumper.cc | 37 +++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/thin-provisioning/metadata_dumper.cc b/thin-provisioning/metadata_dumper.cc
index 665c762..37c6969 100644
--- a/thin-provisioning/metadata_dumper.cc
+++ b/thin-provisioning/metadata_dumper.cc
@@ -252,26 +252,33 @@ namespace {
bool cmp_time_counts(pair<node_info, node_info> const &lhs_pair,
pair<node_info, node_info> const &rhs_pair) {
- auto const &lhs = lhs_pair.first.time_counts;
- auto const &rhs = rhs_pair.first.time_counts;
+ auto const &lhs = lhs_pair.second.time_counts;
+ auto const &rhs = rhs_pair.second.time_counts;
- for (auto lhs_it = lhs.crbegin(); lhs_it != lhs.crend(); lhs_it++) {
- for (auto rhs_it = rhs.crbegin(); rhs_it != rhs.crend(); rhs_it++) {
- if (lhs_it->first > rhs_it->first)
- return true;
- else if (rhs_it->first > lhs_it->first)
- return false;
+ auto lhs_it = lhs.crbegin();
+ auto rhs_it = rhs.crbegin();
+ while (lhs_it != lhs.crend() && rhs_it != rhs.crend()) {
- else if (lhs_it->second > rhs_it->second)
- return true;
+ auto lhs_time = lhs_it->first;
+ auto rhs_time = rhs_it->first;
+ auto lhs_count = lhs_it->second;
+ auto rhs_count = rhs_it->second;
- else if (rhs_it->second > lhs_it->second)
- return false;
- }
- }
+ if (lhs_time > rhs_time)
+ return true;
+ else if (rhs_time > lhs_time)
+ return false;
+ else if (lhs_count > rhs_count)
+ return true;
+ else if (rhs_count > lhs_count)
+ return false;
+
+ lhs_it++;
+ rhs_it++;
+ }
- return true;
+ return (lhs_it != lhs.crend()) ? true : false;
}
class gatherer {
--
1.8.3.1

View File

@ -1,122 +0,0 @@
From 4a2b112e98fe4c66f805eb690bfe1ae7ba342e5b Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Thu, 19 Aug 2021 18:38:23 +0800
Subject: [PATCH 2/3] [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.
(cherry picked from commit d3f796f5e35162b0867ee2ba8de781f14ad35c61)
---
functional-tests/thin-functional-tests.scm | 53 +++++++++++++++++++++++++++++-
thin-provisioning/metadata_dumper.cc | 8 +++++
2 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/functional-tests/thin-functional-tests.scm b/functional-tests/thin-functional-tests.scm
index fcabddf..d06a5a3 100644
--- a/functional-tests/thin-functional-tests.scm
+++ b/functional-tests/thin-functional-tests.scm
@@ -14,7 +14,8 @@
(temp-file)
(thin metadata)
(thin xml)
- (srfi s8 receive))
+ (srfi s8 receive)
+ (xml))
(define-tool thin-check)
(define-tool thin-delta)
@@ -96,6 +97,32 @@
;; to run.
(define (register-thin-tests) #t)
+ ;; XML of metadata with empty thins
+ (define xml-with-empty-thins
+ (fmt #f
+ (tag 'superblock `((uuid . "")
+ (time . 0)
+ (transaction . 1)
+ (flags . 0)
+ (version . 2)
+ (data-block-size . 128)
+ (nr-data-blocks . 1024))
+ (tag 'device `((dev-id . 1)
+ (mapped-blocks . 16)
+ (transaction . 0)
+ (creation-time . 0)
+ (snap-time . 0))
+ (tag 'range-mapping `((origin-begin . 0)
+ (data-begin . 0)
+ (length . 16)
+ (time . 0))))
+ (tag 'device `((dev-id . 2)
+ (mapped-blocks . 0)
+ (transaction . 0)
+ (creation-time . 0)
+ (snap-time . 0))
+ " "))))
+
;;;-----------------------------------------------------------
;;; thin_check scenarios
;;;-----------------------------------------------------------
@@ -376,6 +403,17 @@
(run-fail-rcv (_ stderr) (thin-dump "--repair" "--transaction-id=5" "--data-block-size=128" md)
(assert-matches ".*nr data blocks.*" stderr))))
+ (define-scenario (thin-dump repair-superblock with-empty-devices)
+ "metadata with empty devices could be recovered"
+ (with-temp-file-sized ((md "thin.bin" (meg 4)))
+ (with-temp-file-containing ((xml "thin.xml" xml-with-empty-thins))
+ (run-ok (thin-restore "-i" xml "-o" md)))
+ (run-ok-rcv (expected-xml _) (thin-dump md)
+ (damage-superblock md)
+ (run-ok-rcv (repaired-xml stderr) (thin-dump "--repair" "--transaction-id=1" "--data-block-size=128" "--nr-data-blocks=1024" md)
+ (assert-eof stderr)
+ (assert-equal expected-xml repaired-xml)))))
+
;;;-----------------------------------------------------------
;;; thin_rmap scenarios
;;;-----------------------------------------------------------
@@ -572,6 +610,19 @@
(run-fail-rcv (_ stderr) (thin-repair "--transaction-id=5" "--data-block-size=128" "-i" md1 "-o" md2)
(assert-matches ".*nr data blocks.*" stderr)))))
+ (define-scenario (thin-repair superblock with-empty-devices)
+ "metadata with empty devices could be recovered"
+ (with-temp-file-sized ((md1 "thin.bin" (meg 4)))
+ (with-temp-file-containing ((xml "thin.xml" xml-with-empty-thins))
+ (run-ok (thin-restore "-i" xml "-o" md1)))
+ (run-ok-rcv (expected-xml _) (thin-dump md1)
+ (damage-superblock md1)
+ (with-empty-metadata (md2)
+ (run-ok-rcv (_ stderr) (thin-repair "--transaction-id=1" "--data-block-size=128" "--nr-data-blocks=1024" "-i" md1 "-o" md2)
+ (assert-eof stderr))
+ (run-ok-rcv (repaired-xml stderr) (thin-dump md2)
+ (assert-eof stderr)
+ (assert-equal expected-xml repaired-xml))))))
;;;-----------------------------------------------------------
;;; thin_metadata_pack scenarios
diff --git a/thin-provisioning/metadata_dumper.cc b/thin-provisioning/metadata_dumper.cc
index 37c6969..d169c27 100644
--- a/thin-provisioning/metadata_dumper.cc
+++ b/thin-provisioning/metadata_dumper.cc
@@ -438,6 +438,14 @@ namespace {
// in the bottom 24 bits. This means every block/time apart from block 0
// will result in a value that's outside the range of the metadata device.
bool is_top_level(node_ref<uint64_traits> &n) {
+ // A leaf node of value-size 8 and without mappings should be
+ // treated as a bottom-level leaf, so that it could be referenced
+ // by top-level nodes, if any. On the other hand, an empty
+ // top-level leaf doesn't help repairing.
+ if (!n.get_nr_entries()) {
+ return false;
+ }
+
auto nr_metadata_blocks = bm_.get_nr_blocks();
for (unsigned i = 0; i < n.get_nr_entries(); i++)
--
1.8.3.1

View File

@ -1,129 +0,0 @@
From 992bb5feeb9e1994d4c31b4b13dbae594dd3c87a Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Tue, 24 Aug 2021 16:20:50 +0800
Subject: [PATCH 3/3] [thin_repair/thin_dump] Check consistency of thin_ids
before running a regular dump
(cherry picked from commit 73dda15b5977dfa45cbfa36edddf4c19d279767b)
---
functional-tests/thin-functional-tests.scm | 56 ++++++++++++++++++++++++++++++
thin-provisioning/metadata_dumper.cc | 8 +++--
2 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/functional-tests/thin-functional-tests.scm b/functional-tests/thin-functional-tests.scm
index d06a5a3..37d3df9 100644
--- a/functional-tests/thin-functional-tests.scm
+++ b/functional-tests/thin-functional-tests.scm
@@ -81,6 +81,15 @@
(let ((csum (checksum-block b (ftype-sizeof unsigned-32) superblock-salt)))
(ftype-set! ThinSuperblock (csum) sb csum))))))
+ (define (tamper-mapping-root md mapping-root)
+ (with-bcache (cache md 1)
+ (with-block (b cache 0 (get-flags dirty))
+ (let ((sb (block->superblock b)))
+ (ftype-set! ThinSuperblock (data-mapping-root) sb mapping-root)
+ ;;;;;; Update the csum manually since the block validator for ft-lib is not ready
+ (let ((csum (checksum-block b (ftype-sizeof unsigned-32) superblock-salt)))
+ (ftype-set! ThinSuperblock (csum) sb csum))))))
+
(define (get-superblock-flags md)
(with-bcache (cache md 1)
(with-block (b cache 0 (get-flags))
@@ -97,6 +106,26 @@
;; to run.
(define (register-thin-tests) #t)
+ ;; An deterministic simple XML for testing
+ (define simple-thin-xml
+ (fmt #f
+ (tag 'superblock `((uuid . "")
+ (time . 0)
+ (transaction . 1)
+ (flags . 0)
+ (version . 2)
+ (data-block-size . 128)
+ (nr-data-blocks . 1024))
+ (tag 'device `((dev-id . 1)
+ (mapped-blocks . 16)
+ (transaction . 0)
+ (creation-time . 0)
+ (snap-time . 0))
+ (tag 'range-mapping `((origin-begin . 0)
+ (data-begin . 0)
+ (length . 16)
+ (time . 0)))))))
+
;; XML of metadata with empty thins
(define xml-with-empty-thins
(fmt #f
@@ -414,6 +443,18 @@
(assert-eof stderr)
(assert-equal expected-xml repaired-xml)))))
+ (define-scenario (thin-dump repair-superblock inconsistent-device-ids)
+ "metadata with inconsistent device ids should be repaired"
+ (with-temp-file-sized ((md "thin.bin" (meg 4)))
+ (with-temp-file-containing ((xml "thin.xml" simple-thin-xml))
+ (run-ok (thin-restore "-i" xml "-o" md)))
+ (run-ok-rcv (expected-xml _) (thin-dump md)
+ ;;;;;; simulate multiple activation by replacing the mapping root with a bottom-level leaf
+ (tamper-mapping-root md 10)
+ (run-ok-rcv (repaired-xml stderr) (thin-dump "--repair" md)
+ (assert-eof stderr)
+ (assert-equal expected-xml repaired-xml)))))
+
;;;-----------------------------------------------------------
;;; thin_rmap scenarios
;;;-----------------------------------------------------------
@@ -624,6 +665,21 @@
(assert-eof stderr)
(assert-equal expected-xml repaired-xml))))))
+ (define-scenario (thin-repair superblock inconsistent-device-ids)
+ "metadata with inconsistent device ids should be repaired"
+ (with-temp-file-sized ((md1 "thin.bin" (meg 4)))
+ (with-temp-file-containing ((xml "thin.xml" simple-thin-xml))
+ (run-ok (thin-restore "-i" xml "-o" md1)))
+ (run-ok-rcv (expected-xml _) (thin-dump md1)
+ ;;;;;; simulate multiple activation by replacing the mapping root with a bottom-level leaf
+ (tamper-mapping-root md1 10)
+ (with-empty-metadata (md2)
+ (run-ok-rcv (_ stderr) (thin-repair "-i" md1 "-o" md2)
+ (assert-eof stderr))
+ (run-ok-rcv (repaired-xml stderr) (thin-dump md2)
+ (assert-eof stderr)
+ (assert-equal expected-xml repaired-xml))))))
+
;;;-----------------------------------------------------------
;;; thin_metadata_pack scenarios
;;;-----------------------------------------------------------
diff --git a/thin-provisioning/metadata_dumper.cc b/thin-provisioning/metadata_dumper.cc
index d169c27..0ca4afe 100644
--- a/thin-provisioning/metadata_dumper.cc
+++ b/thin-provisioning/metadata_dumper.cc
@@ -412,6 +412,9 @@ namespace {
if (rhs == ms.end())
continue;
+ if (lhs->second != rhs->second)
+ continue;
+
filtered.push_back(make_pair(p.first.b, p.second.b));
}
@@ -886,8 +889,9 @@ namespace {
auto tm = open_tm(bm, superblock_detail::SUPERBLOCK_LOCATION);
- if (!get_dev_ids(*tm, msb->device_details_root_) ||
- !get_map_ids(*tm, msb->data_mapping_root_))
+ auto maybe_dev_ids = get_dev_ids(*tm, msb->device_details_root_);
+ auto maybe_map_ids = get_map_ids(*tm, msb->data_mapping_root_);
+ if (!maybe_dev_ids || !maybe_map_ids || (*maybe_dev_ids) != (*maybe_map_ids))
find_better_roots_(bm, *msb);
emit_trees_(bm, *msb, e, opts);
--
1.8.3.1

View File

@ -1,338 +0,0 @@
From 6ce838b83c28d9b64f34cf0c68cfebaf9affac11 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Fri, 21 Aug 2020 18:26:48 +0800
Subject: [PATCH] [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
(cherry picked from commit f4675e3f32aad3d1518869e4f3824e05230c6a5d)
---
functional-tests/thin-functional-tests.scm | 65 +++++++++++++---
thin-provisioning/metadata_checker.cc | 88 +++++++++++-----------
thin-provisioning/metadata_checker.h | 5 +-
thin-provisioning/thin_check.cc | 2 +-
4 files changed, 106 insertions(+), 54 deletions(-)
diff --git a/functional-tests/thin-functional-tests.scm b/functional-tests/thin-functional-tests.scm
index 37d3df9..5b1423c 100644
--- a/functional-tests/thin-functional-tests.scm
+++ b/functional-tests/thin-functional-tests.scm
@@ -189,15 +189,6 @@
(run-fail (thin-check "--auto-repair" "--skip-mappings" md))
(run-fail (thin-check "--auto-repair" "--ignore-non-fatal-errors" md))))
- (define-scenario (thin-check incompatible-options clear-needs-check-flag)
- "Incompatible options should cause failure"
- (with-valid-metadata (md)
- (run-fail (thin-check "--clear-needs-check-flag" "-m" md))
- (run-fail (thin-check "--clear-needs-check-flag" "--override-mapping-root 123" md))
- (run-fail (thin-check "--clear-needs-check-flag" "--super-block-only" md))
- (run-fail (thin-check "--clear-needs-check-flag" "--skip-mappings" md))
- (run-fail (thin-check "--clear-needs-check-flag" "--ignore-non-fatal-errors" md))))
-
(define-scenario (thin-check superblock-only-valid)
"--super-block-only check passes on valid metadata"
(with-valid-metadata (md)
@@ -230,6 +221,62 @@
(with-valid-metadata (md)
(run-ok (thin-check "--clear-needs-check-flag" md))))
+ (define-scenario (thin-check mixing-clear-needs-check-flag super-block-only-should-pass)
+ "Accepts --clear-needs-check and --super-block-only"
+ (with-valid-metadata (md)
+ (run-ok (thin-check "--clear-needs-check-flag" "--super-block-only" md))))
+
+ (define-scenario (thin-check mixing-clear-needs-check-flag skip-mappings-should-pass)
+ "Accepts --clear-needs-check and --skip-mappings"
+ (with-valid-metadata (md)
+ (run-ok (thin-check "--clear-needs-check-flag" "--skip-mappings" md))))
+
+ (define-scenario (thin-check mixing-clear-needs-check-flag ignore-non-fatal-errors-should-pass)
+ "Accepts --clear-needs-check and --ignore-non-fatal-errors"
+ (with-valid-metadata (md)
+ (run-ok (thin-check "--clear-needs-check-flag" "--ignore-non-fatal-errors" md))))
+
+ (define-scenario (thin-check try-clear-needs-check-flag super-block-only-should-clear)
+ "--clear-needs-check is a noop while using --super-block-only"
+ (with-valid-metadata (md)
+ (set-needs-check-flag md)
+ (assert-metadata-needs-check md)
+ (run-ok (thin-check "--clear-needs-check-flag" "--super-block-only" md))
+ (assert-metadata-clean md)))
+
+ (define-scenario (thin-check try-clear-needs-check-flag skip-mappings-should-clear)
+ "--clear-needs-check is a noop while using --skip-mappings"
+ (with-valid-metadata (md)
+ (set-needs-check-flag md)
+ (assert-metadata-needs-check md)
+ (run-ok (thin-check "--clear-needs-check-flag" "--skip-mappings" md))
+ (assert-metadata-clean md)))
+
+ (define-scenario (thin-check try-clear-needs-check-flag ignore-non-fatal-errors-should-clear)
+ "--clear-needs-check works while using --ignore-non-fatal-errors"
+ (with-valid-metadata (md)
+ (set-needs-check-flag md)
+ (assert-metadata-needs-check md)
+ (run-ok (thin-check "--clear-needs-check-flag" "--ignore-non-fatal-errors" md))
+ (assert-metadata-clean md)))
+
+ (define-scenario (thin-check try-clear-needs-check-flag no-errors-should-clear)
+ "--clear-needs-check works if there's no errors"
+ (with-valid-metadata (md)
+ (set-needs-check-flag md)
+ (assert-metadata-needs-check md)
+ (run-ok (thin-check "--clear-needs-check-flag" md))
+ (assert-metadata-clean md)))
+
+ (define-scenario (thin-check try-clear-needs-check-flag fatal-errors-should-keep)
+ "--clear-needs-check is a noop if there's fatal errors"
+ (with-valid-metadata (md)
+ (set-needs-check-flag md)
+ (tamper-mapping-root md 10)
+ (assert-metadata-needs-check md)
+ (run-fail (thin-check "--clear-needs-check-flag" md))
+ (assert-metadata-needs-check md)))
+
(define-scenario (thin-check auto-repair)
"Accepts --auto-repair"
(with-valid-metadata (md)
diff --git a/thin-provisioning/metadata_checker.cc b/thin-provisioning/metadata_checker.cc
index e81e22c..1c9734e 100644
--- a/thin-provisioning/metadata_checker.cc
+++ b/thin-provisioning/metadata_checker.cc
@@ -371,7 +371,8 @@ namespace {
out_(cerr, 2),
info_out_(cout, 0),
expected_rc_(true), // set stop on the first error
- err_(NO_ERROR) {
+ err_(NO_ERROR),
+ metadata_checked_(false) {
if (output_opts == OUTPUT_QUIET) {
out_.disable();
@@ -381,7 +382,29 @@ namespace {
sb_location_ = get_superblock_location();
}
- void check() {
+ void check_and_repair() {
+ if (!check())
+ return;
+
+ if (!options_.use_metadata_snap_ &&
+ !options_.override_mapping_root_) {
+ if (options_.sm_opts_ == check_options::SPACE_MAP_FULL &&
+ options_.fix_metadata_leaks_)
+ fix_metadata_leaks(options_.open_transaction_);
+ if (options_.clear_needs_check_)
+ clear_needs_check_flag();
+ }
+ }
+
+ bool get_status() const {
+ if (options_.ignore_non_fatal_)
+ return (err_ == FATAL) ? false : true;
+
+ return (err_ == NO_ERROR) ? true : false;
+ }
+
+ private:
+ bool check() {
block_manager::ptr bm = open_bm(path_, block_manager::READ_ONLY,
!options_.use_metadata_snap_);
@@ -389,7 +412,7 @@ namespace {
if (err_ == FATAL) {
if (check_for_xml(bm))
out_ << "This looks like XML. thin_check only checks the binary metadata format." << end_message();
- return;
+ return false;
}
transaction_manager::ptr tm = open_tm(bm, sb_location_);
@@ -407,7 +430,7 @@ namespace {
err_ << examine_data_mappings(tm, sb, options_.data_mapping_opts_, out_, core_sm);
if (err_ == FATAL)
- return;
+ return false;
// if we're checking everything, and there were no errors,
// then we should check the space maps too.
@@ -419,10 +442,14 @@ namespace {
} else
err_ << examine_data_mappings(tm, sb, options_.data_mapping_opts_, out_,
optional<space_map::ptr>());
+
+ metadata_checked_ = true;
+
+ return true;
}
bool fix_metadata_leaks(bool open_transaction) {
- if (!verify_preconditions_before_fixing()) {
+ if (!metadata_checked_) {
out_ << "metadata has not been fully examined" << end_message();
return false;
}
@@ -458,12 +485,13 @@ namespace {
}
bool clear_needs_check_flag() {
- if (!verify_preconditions_before_fixing()) {
+ if (!metadata_checked_) {
out_ << "metadata has not been fully examined" << end_message();
return false;
}
- if (err_ != NO_ERROR)
+ if (err_ == FATAL ||
+ (err_ == NON_FATAL && !options_.ignore_non_fatal_))
return false;
block_manager::ptr bm = open_bm(path_, block_manager::READ_WRITE);
@@ -480,14 +508,6 @@ namespace {
return true;
}
- bool get_status() const {
- if (options_.ignore_non_fatal_)
- return (err_ == FATAL) ? false : true;
-
- return (err_ == NO_ERROR) ? true : false;
- }
-
- private:
block_address
get_superblock_location() {
block_address sb_location = superblock_detail::SUPERBLOCK_LOCATION;
@@ -545,19 +565,6 @@ namespace {
return err;
}
- bool verify_preconditions_before_fixing() const {
- if (options_.use_metadata_snap_ ||
- !!options_.override_mapping_root_ ||
- options_.sm_opts_ != check_options::SPACE_MAP_FULL ||
- options_.data_mapping_opts_ != check_options::DATA_MAPPING_LEVEL2)
- return false;
-
- if (!expected_rc_.get_counts().size())
- return false;
-
- return true;
- }
-
std::string const &path_;
check_options options_;
nested_output out_;
@@ -565,6 +572,7 @@ namespace {
block_address sb_location_;
block_counter expected_rc_;
base::error_state err_; // metadata state
+ bool metadata_checked_;
};
}
@@ -603,8 +611,9 @@ void check_options::set_ignore_non_fatal() {
ignore_non_fatal_ = true;
}
-void check_options::set_fix_metadata_leaks() {
+void check_options::set_auto_repair() {
fix_metadata_leaks_ = true;
+ clear_needs_check_ = true;
}
void check_options::set_clear_needs_check() {
@@ -612,7 +621,7 @@ void check_options::set_clear_needs_check() {
}
bool check_options::check_conformance() {
- if (fix_metadata_leaks_ || clear_needs_check_) {
+ if (fix_metadata_leaks_) {
if (ignore_non_fatal_) {
cerr << "cannot perform fix by ignoring non-fatal errors" << endl;
return false;
@@ -627,12 +636,12 @@ bool check_options::check_conformance() {
cerr << "cannot perform fix with an overridden mapping root" << endl;
return false;
}
+ }
- if (data_mapping_opts_ != DATA_MAPPING_LEVEL2 ||
- sm_opts_ != SPACE_MAP_FULL) {
- cerr << "cannot perform fix without a full examination" << endl;
- return false;
- }
+ if (fix_metadata_leaks_ &&
+ (data_mapping_opts_ != DATA_MAPPING_LEVEL2 || sm_opts_ != SPACE_MAP_FULL)) {
+ cerr << "cannot perform fix without a full examination" << endl;
+ return false;
}
return true;
@@ -646,14 +655,7 @@ thin_provisioning::check_metadata(std::string const &path,
output_options output_opts)
{
metadata_checker checker(path, check_opts, output_opts);
-
- checker.check();
- if (check_opts.fix_metadata_leaks_)
- checker.fix_metadata_leaks(check_opts.open_transaction_);
- if (check_opts.fix_metadata_leaks_ ||
- check_opts.clear_needs_check_)
- checker.clear_needs_check_flag();
-
+ checker.check_and_repair();
return checker.get_status();
}
diff --git a/thin-provisioning/metadata_checker.h b/thin-provisioning/metadata_checker.h
index 5569d27..ea66dc3 100644
--- a/thin-provisioning/metadata_checker.h
+++ b/thin-provisioning/metadata_checker.h
@@ -45,14 +45,17 @@ namespace thin_provisioning {
void set_override_mapping_root(bcache::block_address b);
void set_metadata_snap();
void set_ignore_non_fatal();
- void set_fix_metadata_leaks();
+ void set_auto_repair();
void set_clear_needs_check();
+ // flags for checking
bool use_metadata_snap_;
data_mapping_options data_mapping_opts_;
space_map_options sm_opts_;
boost::optional<bcache::block_address> override_mapping_root_;
bool ignore_non_fatal_;
+
+ // flags for repairing
bool fix_metadata_leaks_;
bool clear_needs_check_;
bool open_transaction_;
diff --git a/thin-provisioning/thin_check.cc b/thin-provisioning/thin_check.cc
index 60f7838..e3c9db3 100644
--- a/thin-provisioning/thin_check.cc
+++ b/thin-provisioning/thin_check.cc
@@ -166,7 +166,7 @@ thin_check_cmd::run(int argc, char **argv)
case 6:
// auto-repair
- fs.check_opts.set_fix_metadata_leaks();
+ fs.check_opts.set_auto_repair();
break;
default:
--
2.31.1

View File

@ -1,25 +0,0 @@
From 54ea2ba0098a5fbacf0b8f4fc5f9e4aa13e4b743 Mon Sep 17 00:00:00 2001
From: Ming-Hung Tsai <mtsai@redhat.com>
Date: Tue, 24 Aug 2021 20:59:47 +0800
Subject: [PATCH] [thin_repair/thin_dump] Exclude unwanted btree nodes
---
thin-provisioning/metadata_dumper.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/thin-provisioning/metadata_dumper.cc b/thin-provisioning/metadata_dumper.cc
index 0ca4afed..ffdeb04c 100644
--- a/thin-provisioning/metadata_dumper.cc
+++ b/thin-provisioning/metadata_dumper.cc
@@ -597,6 +597,8 @@ namespace {
info.nr_mappings = n.get_nr_entries();
}
+ } else {
+ fail(info, "not the value size of interest");
}
return info;
--
2.34.3

View File

@ -1,15 +0,0 @@
Makefile.in | 1 -
1 file changed, 1 deletion(-)
diff --git a/Makefile.in b/Makefile.in
index 0aa9401..0f4f7cb 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -262,7 +262,6 @@ MANPAGES:=$(patsubst %,man8/%.8,$(TOOLS))
install: bin/pdata_tools $(MANPAGES)
$(INSTALL_DIR) $(BINDIR)
$(INSTALL_PROGRAM) bin/pdata_tools $(BINDIR)
- $(STRIP) $(BINDIR)/pdata_tools
ln -s -f pdata_tools $(BINDIR)/cache_check
ln -s -f pdata_tools $(BINDIR)/cache_dump
ln -s -f pdata_tools $(BINDIR)/cache_metadata_size

View File

@ -1,59 +1,38 @@
#
# Copyright (C) 2011-2017 Red Hat, Inc
#
%bcond_without check
%global debug_package %{nil}
# The suffix for tarball and directory:
#%%global version_suffix -rc2
# The release suffix for RPMs:
#%%global release_suffix .test3
Summary: Device-mapper Persistent Data Tools
Name: device-mapper-persistent-data
Version: 0.9.0
Release: 7%{?dist}%{?release_suffix}
Version: 1.0.9
Release: 3%{?dist}%{?release_suffix}
License: GPLv3+
URL: https://github.com/jthornber/thin-provisioning-tools
#Source0: https://github.com/jthornber/thin-provisioning-tools/archive/thin-provisioning-tools-%%{version}.tar.gz
Source0: https://github.com/jthornber/thin-provisioning-tools/archive/v%{version}%{?version_suffix}.tar.gz
Source1: dmpd090-vendor3.tar.gz
Patch0: device-mapper-persistent-data-avoid-strip.patch
Patch1: 0001-Update-dependencies.patch
Patch2: 0001-all-Fix-resource-leaks.patch
Patch3: 0002-thin_show_metadata-Fix-out-of-bounds-access.patch
Patch4: 0003-build-Fix-customized-emitter-linkage.patch
Patch5: 0004-thin_dump-Fix-leaked-shared-object-handle.patch
Patch6: 0005-thin_show_duplicates-Fix-potential-errors.patch
Patch7: 0006-thin_metadata_size-Fix-potential-string-overflow.patch
Patch8: 0007-all-Fix-uninitialized-class-members.patch
Patch9: 0008-thin_dump-Fix-warnings-on-potential-NULL-pointer.patch
Patch10: 0009-build-Remove-unused-sources-from-the-regular-build.patch
Patch11: 0010-all-Remove-unreachable-code.patch
Patch12: 0011-file_utils-Fix-resource-leak.patch
Patch13: 0012-thin_delta-Clean-up-duplicated-code.patch
# BZ 1974781:
Patch14: 0013-build-Remove-lboost_iostreams-linker-flag.patch
# Fix usize vs u32 compilation issues with rust 1.53:
Patch15: 0014-cargo-update.patch
# BZ 1993290:
Patch16: 0015-thin-Clear-superblock-flags-in-restored-metadata.patch
# BZ 2001000:
Patch17: 0016-thin_repair-thin_dump-Fix-sorting-of-data-mapping-ca.patch
# BZ 2000896:
Patch18: 0017-thin_repair-thin_dump-Change-the-label-type-for-empt.patch
# BZ 2000981:
Patch19: 0018-thin_repair-thin_dump-Check-consistency-of-thin_ids-.patch
# BZ 2028905:
Patch20: 0019-thin_check-Allow-using-clear-needs-check-and-skip-ma.patch
# BZ 2100178:
Patch21: 0020-thin_repair-thin_dump-Exclude-unwanted-btree-nodes.patch
Source1: dmpd109-vendor.tar.gz
Patch1: 0001-Tweak-cargo.toml-to-work-with-vendor-directory.patch
Patch2: 0002-space-map-Fix-incorrect-index_entry.nr_free-while-ex.patch
Patch3: 0003-thin_repair-Fix-child-keys-checking-on-the-node-with.patch
Patch4: 0004-space_map-Allow-non-zero-values-in-unused-index-bloc.patch
Patch5: 0005-cache_check-Fix-boundary-check-on-the-bitset-for-cac.patch
Patch6: 0006-thin-cache_check-Print-suggestive-hints-for-improvin.patch
# RHEL-26521:
Patch7: 0007-thin_dump-Do-not-print-error-messages-on-BrokenPipe-.patch
# RHEL-26520:
Patch8: 0008-thin_metadata_pack-Allow-long-format-for-input-and-o.patch
Patch9: 0009-commands-Fix-version-string-compatibility-issue-with.patch
# RHEL-26521:
Patch10: 0010-thin_dump-Do-not-print-error-messages-on-BrokenPipe-.patch
BuildRequires: autoconf, expat-devel, libaio-devel, libstdc++-devel, boost-devel, gcc-c++
Requires: expat
%ifarch %{rust_arches}
BuildRequires: rust-toolset
BuildRequires: rust-packaging
BuildRequires: rust >= 1.35
BuildRequires: cargo
%endif
BuildRequires: make
%description
@ -65,10 +44,7 @@ are included and era check, dump, restore and invalidate to manage
snapshot eras
%prep
%setup -q -n thin-provisioning-tools-%{version}%{?version_suffix}
%ifarch %{rust_arches}
%patch1 -p1 -b .toml_update
%patch15 -p1 -b .backup15
%autosetup -p1 -n thin-provisioning-tools-%{version}%{?version_suffix}
#%%cargo_prep
#%%cargo_generate_buildrequires
tar xf %{SOURCE1}
@ -81,45 +57,23 @@ replace-with = "vendored-sources"
directory = "vendor"
END
%endif
%patch0 -p1 -b .avoid_strip
%patch2 -p1 -b .backup2
%patch3 -p1 -b .backup3
%patch4 -p1 -b .backup4
%patch5 -p1 -b .backup5
%patch6 -p1 -b .backup6
%patch7 -p1 -b .backup7
%patch8 -p1 -b .backup8
%patch9 -p1 -b .backup9
%patch10 -p1 -b .backup10
%patch11 -p1 -b .backup11
%patch12 -p1 -b .backup12
%patch13 -p1 -b .backup13
%patch14 -p1 -b .backup14
# NOTE: patch 15 is above at the rust setup
%patch16 -p1 -b .backup16
%patch17 -p1 -b .backup17
%patch18 -p1 -b .backup18
%patch19 -p1 -b .backup19
%patch20 -p1 -b .backup20
%patch21 -p1 -b .backup21
echo %{version}-%{release} > VERSION
%generate_buildrequires
%build
autoconf
%configure --with-optimisation=
make %{?_smp_mflags} V=
%ifarch %{rust_arches}
%cargo_build
%if %{with check}
%check
# aarch64 is failing, but only in brew environment, tests are passing when
# running locally
#%%cargo_test
RUST_BACKTRACE=1 %%cargo_test -- --nocapture --test-threads=1 || true
%endif
%install
make DESTDIR=%{buildroot} MANDIR=%{_mandir} install
%ifarch %{rust_arches}
make DESTDIR=%{buildroot} MANDIR=%{_mandir} install-rust-tools
# cargo_install installs into /usr/bin
#%%cargo_install
%endif
%files
%doc COPYING README.md
@ -142,10 +96,8 @@ make DESTDIR=%{buildroot} MANDIR=%{_mandir} install-rust-tools
%{_mandir}/man8/thin_restore.8.gz
%{_mandir}/man8/thin_rmap.8.gz
%{_mandir}/man8/thin_trim.8.gz
%ifarch %{rust_arches}
%{_mandir}/man8/thin_metadata_pack.8.gz
%{_mandir}/man8/thin_metadata_unpack.8.gz
%endif
%{_sbindir}/pdata_tools
%{_sbindir}/cache_check
%{_sbindir}/cache_dump
@ -166,50 +118,100 @@ make DESTDIR=%{buildroot} MANDIR=%{_mandir} install-rust-tools
%{_sbindir}/thin_restore
%{_sbindir}/thin_rmap
%{_sbindir}/thin_trim
%ifarch %{rust_arches}
%{_sbindir}/thin_metadata_pack
%{_sbindir}/thin_metadata_unpack
%endif
#% {_sbindir}/thin_show_duplicates
%changelog
* Thu Jun 23 2022 Marian Csontos <mcsontos@redhat.com> - 0.9.0-7
* Mon Mar 04 2024 Marian Csontos <mcsontos@redhat.com> - 1.0.9-3
- Fix --version string compatibility with LVM tools.
- Fix confusing Broken pipe warning when used in lvconvert --repair.
* Thu Feb 08 2024 Marian Csontos <mcsontos@redhat.com> - 1.0.9-2
- Allow non-zero values in unused index block entries.
- Fix boundary check on the bitset for cached blocks.
- Fix incorrect index_entry.nr_free on expansion affecting free space estimate.
- Fix thin_repair checking keys on a node with a zero key.
- Enhance error message in cache_check suggesting fix when applicable.
* Wed Dec 13 2023 Marian Csontos <mcsontos@redhat.com> - 1.0.9-1
- Update to latest upstream release 1.0.9.
* Wed Aug 09 2023 Marian Csontos <mcsontos@redhat.com> - 1.0.6-1
- Update to latest upstream release 1.0.6.
* Thu Jul 27 2023 Marian Csontos <mcsontos@redhat.com> - 1.0.5-1
- Update to latest upstream release 1.0.5.
* Fri Apr 28 2023 Marian Csontos <mcsontos@redhat.com> - 1.0.4-1
- Update to latest upstream release 1.0.4.
* Wed Jun 22 2022 Marian Csontos <mcsontos@redhat.com> - 0.9.0-13
- Improve duration of thin_repair on very large metadata devices.
* Wed Dec 08 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-6
* Fri Dec 10 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-12
- Allows --clear-needs-check with --super-block-only or --skip-mappings.
* Tue Sep 07 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-5
* Fri Nov 05 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-11
- Fix several corner cases in thin_repair.
* Tue Aug 16 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-4
- Fix thin_repair clearing needs_check flag in repaired metadata.
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 0.9.0-10
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Mon Jun 28 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-3
- Fix rust-1.53 compilation issues.
* Fri Jul 23 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-9
- Fix gating tests.
* Thu Jun 24 2021 Jonathan Wakely <jwakely@redhat.com> - 0.9.0-2
- Remove libboost_iostreams dependency.
* Thu Jul 22 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-8
- Fix rust compilation issues.
* Mon Jun 14 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-1
- Update to upstream version 0.9.0.
* Thu Jun 10 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-6
- Remove rust-packaging dependency.
- Fix gating test syntax.
* Mon Jun 07 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-5
- Fix important issues found by static analysis.
- Update crc32c to version 0.5 supporting non x86 architectures.
- New tools thin_metadata_pack and thin_metadata_unpack.
* Fri Aug 21 2020 Marian Csontos <mcsontos@redhat.com> - 0.8.5-4
- Under-populated btree nodes are non fatal to thin_check.
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com> - 0.9.0-4
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Wed Nov 27 2019 Marian Csontos <mcsontos@redhat.com> - 0.8.5-3
- Remove obsolete pool-inactive option from thin_trim man page.
- Check input file exists eralier, and prevent writing incorrect metadata.
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Jun 04 2019 Marian Csontos <mcsontos@redhat.com> - 0.8.5-2
- Bump release
* Mon Sep 21 2020 Marian Csontos <mcsontos@redhat.com> - 0.9.0-2
- Update crc32c to version 0.5 supporting non x86 architectures
* Thu Sep 17 2020 Marian Csontos <mcsontos@redhat.com> - 0.9.0-1
- Update to latest upstream version
- New tools thin_metadata_pack and thin_metadata_unpack
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.8.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Tue Jun 04 2019 Marian Csontos <mcsontos@redhat.com> - 0.8.5-1
- Update to latest upstream version
* Sat May 04 2019 Marian Csontos <mcsontos@redhat.com> - 0.8.1-1
- Fix thin_repair should not require --repair option.
* Mon Apr 29 2019 Marian Csontos <mcsontos@redhat.com> - 0.8.0-1
- Update to latest upstream version
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.6-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Fri Jan 25 2019 Jonathan Wakely <jwakely@redhat.com> - 0.7.6-3
- Rebuilt for Boost 1.69
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Apr 24 2018 Marian Csontos <mcsontos@redhat.com> - 0.7.6-1
- Update to latest upstream version