From c950fe5f288e3f2bbb2cccb6f87b3379d8978286 Mon Sep 17 00:00:00 2001 From: Marian Csontos Date: Mon, 11 Dec 2023 16:43:41 +0100 Subject: [PATCH] Update to version 1.0.9 --- .gitignore | 2 + ...o.toml-to-work-with-vendor-directory.patch | 22 +- ...he-ioctl-request-code-for-the-powerp.patch | 217 ------------------ ...s-Verify-ioctl-request-code-in-tests.patch | 120 ---------- device-mapper-persistent-data.spec | 46 +++- sources | 4 +- 6 files changed, 51 insertions(+), 360 deletions(-) delete mode 100644 0002-file_utils-Fix-the-ioctl-request-code-for-the-powerp.patch delete mode 100644 0003-file_utils-Verify-ioctl-request-code-in-tests.patch diff --git a/.gitignore b/.gitignore index 1540d23..4b9fa80 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,5 @@ /dmpd105-vendor.tar.gz /v1.0.6.tar.gz /dmpd106-vendor.tar.gz +/v1.0.9.tar.gz +/dmpd109-vendor.tar.gz diff --git a/0001-Tweak-cargo.toml-to-work-with-vendor-directory.patch b/0001-Tweak-cargo.toml-to-work-with-vendor-directory.patch index 2e51e47..1bdbce3 100644 --- a/0001-Tweak-cargo.toml-to-work-with-vendor-directory.patch +++ b/0001-Tweak-cargo.toml-to-work-with-vendor-directory.patch @@ -1,4 +1,4 @@ -From 732ff5861a1525944a927439d1c075ac269788ce Mon Sep 17 00:00:00 2001 +From 0d5347bd771e960294cd0c2f083d96448613ab9c Mon Sep 17 00:00:00 2001 From: Marian Csontos Date: Thu, 27 Jul 2023 11:37:01 +0200 Subject: [PATCH] Tweak cargo.toml to work with vendor directory @@ -7,24 +7,16 @@ 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 | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) + Cargo.toml | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml -index c2b496ac..562c40d3 100644 +index 500345a4..d4aa38a6 100644 --- a/Cargo.toml +++ b/Cargo.toml -@@ -11,6 +11,7 @@ anyhow = "1.0" - base64 = "0.21" - byteorder = "1.4" - clap = { version = "4.3", default-features = false, features = ["std", "help", "usage", "error-context", "suggestions"] } -+#crc32c = { git = "https://github.com/zowens/crc32c", branch = "master" } - crc32c = "0.6" - data-encoding = "2.4" - exitcode = "1.1.2" -@@ -27,7 +28,8 @@ quick-xml = "0.29" +@@ -27,7 +27,8 @@ quick-xml = "0.29" rand = "0.8" - rangemap = "1.3" + 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 } @@ -33,5 +25,5 @@ index c2b496ac..562c40d3 100644 threadpool = "1.8" thiserror = "1.0" -- -2.41.0 +2.43.0 diff --git a/0002-file_utils-Fix-the-ioctl-request-code-for-the-powerp.patch b/0002-file_utils-Fix-the-ioctl-request-code-for-the-powerp.patch deleted file mode 100644 index e2a6f0e..0000000 --- a/0002-file_utils-Fix-the-ioctl-request-code-for-the-powerp.patch +++ /dev/null @@ -1,217 +0,0 @@ -From 6de336c0e974989010c32693c9540180d4f28f0b Mon Sep 17 00:00:00 2001 -From: Ming-Hung Tsai -Date: Sat, 26 Aug 2023 18:19:15 +0800 -Subject: [PATCH 2/3] [file_utils] Fix the ioctl request code for the powerpc - architecture - -The PowerPC architecture employees a different bitwise layout in the -request code than other platforms, resulting in different request code -values. - -(cherry picked from commit afcbcd7d85902fc7f1e51fc5302230851303ab85) ---- - src/file_utils.rs | 14 ++---- - src/ioctl.rs | 106 ++++++++++++++++++++++++++++++++++++++++++++++ - src/lib.rs | 1 + - src/thin/trim.rs | 11 ++--- - 4 files changed, 115 insertions(+), 17 deletions(-) - create mode 100644 src/ioctl.rs - -diff --git a/src/file_utils.rs b/src/file_utils.rs -index 81d4a8a7..97400272 100644 ---- a/src/file_utils.rs -+++ b/src/file_utils.rs -@@ -5,6 +5,8 @@ use std::os::unix::ffi::OsStrExt; - use std::os::unix::io::AsRawFd; - use std::path::Path; - -+use crate::ioctl::{self, *}; -+ - //--------------------------------------- - - fn test_bit(mode: u32, flag: u32) -> bool { -@@ -41,10 +43,7 @@ pub fn is_file(path: &Path) -> io::Result { - - //--------------------------------------- - --#[cfg(target_pointer_width = "32")] --const BLKGETSIZE64: u32 = 0x80041272; --#[cfg(target_pointer_width = "64")] --const BLKGETSIZE64: u32 = 0x80081272; -+const BLKGETSIZE64: ioctl::RequestType = crate::request_code_read!(0x12, 114, usize); - - pub fn fail(msg: &str) -> io::Result { - let e = io::Error::new(io::ErrorKind::Other, msg); -@@ -56,13 +55,8 @@ fn get_device_size>(path: P) -> io::Result { - let fd = file.as_raw_fd(); - let mut cap = 0u64; - -- #[cfg(target_env = "musl")] -- type RequestType = libc::c_int; -- #[cfg(not(target_env = "musl"))] -- type RequestType = libc::c_ulong; -- - unsafe { -- if libc::ioctl(fd, BLKGETSIZE64 as RequestType, &mut cap) == 0 { -+ if libc::ioctl(fd, BLKGETSIZE64, &mut cap) == 0 { - Ok(cap) - } else { - Err(io::Error::last_os_error()) -diff --git a/src/ioctl.rs b/src/ioctl.rs -new file mode 100644 -index 00000000..84933648 ---- /dev/null -+++ b/src/ioctl.rs -@@ -0,0 +1,106 @@ -+/* Rust port of kernel include/uapi/asm-generic/ioctl.h */ -+ -+//------------------------------------------ -+ -+#[cfg(target_env = "musl")] -+pub type RequestType = libc::c_int; -+#[cfg(not(target_env = "musl"))] -+pub type RequestType = libc::c_ulong; -+ -+#[cfg(any( -+ target_arch = "mips", -+ target_arch = "mips64", -+ target_arch = "powerpc", -+ target_arch = "powerpc64", -+ target_arch = "powerpc64le", -+ target_arch = "sparc", -+ target_arch = "sparc64" -+))] -+mod defs { -+ use super::RequestType; -+ pub const IOC_NONE: RequestType = 1; -+ pub const IOC_READ: RequestType = 2; -+ pub const IOC_WRITE: RequestType = 4; -+ pub const IOC_DIRBITS: RequestType = 3; -+ pub const IOC_SIZEBITS: RequestType = 13; -+} -+ -+#[cfg(not(any( -+ target_arch = "mips", -+ target_arch = "mips64", -+ target_arch = "powerpc", -+ target_arch = "powerpc64", -+ target_arch = "powerpc64le", -+ target_arch = "sparc", -+ target_arch = "sparc64" -+)))] -+mod defs { -+ use super::RequestType; -+ pub const IOC_NONE: RequestType = 0; -+ pub const IOC_WRITE: RequestType = 1; -+ pub const IOC_READ: RequestType = 2; -+ pub const IOC_DIRBITS: RequestType = 2; -+ pub const IOC_SIZEBITS: RequestType = 14; -+} -+ -+pub use defs::*; -+ -+pub const IOC_NRBITS: RequestType = 8; -+pub const IOC_TYPEBITS: RequestType = 8; -+ -+pub const IOC_NRMASK: RequestType = (1 << IOC_NRBITS) - 1; -+pub const IOC_TYPEMASK: RequestType = (1 << IOC_TYPEBITS) - 1; -+pub const IOC_SIZEMASK: RequestType = (1 << IOC_SIZEBITS) - 1; -+pub const IOC_DIRMASK: RequestType = (1 << IOC_DIRBITS) - 1; -+ -+pub const IOC_NRSHIFT: RequestType = 0; -+pub const IOC_TYPESHIFT: RequestType = IOC_NRSHIFT + IOC_NRBITS; -+pub const IOC_SIZESHIFT: RequestType = IOC_TYPESHIFT + IOC_TYPEBITS; -+pub const IOC_DIRSHIFT: RequestType = IOC_SIZESHIFT + IOC_SIZEBITS; -+ -+#[macro_export] -+macro_rules! ioc { -+ ($dir: expr, $typ: expr, $nr: expr, $size: expr) => { -+ (($dir as RequestType & IOC_DIRMASK) << IOC_DIRSHIFT) -+ | (($typ as RequestType & IOC_TYPEMASK) << IOC_TYPESHIFT) -+ | (($nr as RequestType & IOC_NRMASK) << IOC_NRSHIFT) -+ | (($size as RequestType & IOC_SIZEMASK) << IOC_SIZESHIFT) -+ }; -+} -+ -+//------------------------------------------ -+ -+#[macro_export] -+macro_rules! request_code_none { -+ ($typ: expr, $nr: expr) => { -+ $crate::ioc!(IOC_NONE, $typ, $nr, 0) -+ }; -+} -+ -+#[macro_export] -+macro_rules! request_code_read { -+ ($typ: expr, $nr: expr, $size_type: ty) => { -+ $crate::ioc!(IOC_READ, $typ, $nr, ::std::mem::size_of::<$size_type>()) -+ }; -+} -+ -+#[macro_export] -+macro_rules! request_code_write { -+ ($typ: expr, $nr: expr, $size_type: ty) => { -+ $crate::ioc!(IOC_WRITE, $typ, $nr, ::std::mem::size_of::<$size_type>()) -+ }; -+} -+ -+#[macro_export] -+macro_rules! request_code_readwrite { -+ ($typ: expr, $nr: expr, $size_type: ty) => { -+ $crate::ioc!( -+ IOC_READ | IOC_WRITE, -+ $typ, -+ $nr, -+ ::std::mem::size_of::<$size_type>() -+ ) -+ }; -+} -+ -+//------------------------------------------ -diff --git a/src/lib.rs b/src/lib.rs -index b12146ef..1371baac 100644 ---- a/src/lib.rs -+++ b/src/lib.rs -@@ -14,6 +14,7 @@ pub mod era; - pub mod file_utils; - pub mod grid_layout; - pub mod io_engine; -+pub mod ioctl; - pub mod math; - pub mod pack; - pub mod pdata; -diff --git a/src/thin/trim.rs b/src/thin/trim.rs -index 0d1fb590..b92a4bbd 100644 ---- a/src/thin/trim.rs -+++ b/src/thin/trim.rs -@@ -8,6 +8,7 @@ use std::sync::Arc; - use crate::commands::engine::*; - use crate::file_utils::file_size; - use crate::io_engine::*; -+use crate::ioctl::{self, *}; - use crate::pdata::btree_walker::*; - use crate::pdata::space_map::common::*; - use crate::pdata::unpack::unpack; -@@ -132,15 +133,11 @@ impl<'a> Iterator for RangeIterator<'a> { - - //------------------------------------------ - --const BLKDISCARD: u32 = 0x1277; --fn ioctl_blkdiscard(fd: i32, range: &[u64; 2]) -> std::io::Result<()> { -- #[cfg(target_env = "musl")] -- type RequestType = libc::c_int; -- #[cfg(not(target_env = "musl"))] -- type RequestType = libc::c_ulong; -+const BLKDISCARD: ioctl::RequestType = crate::request_code_none!(0x12, 119); - -+fn ioctl_blkdiscard(fd: i32, range: &[u64; 2]) -> std::io::Result<()> { - unsafe { -- if libc::ioctl(fd, BLKDISCARD as RequestType, range) == 0 { -+ if libc::ioctl(fd, BLKDISCARD, range) == 0 { - Ok(()) - } else { - Err(std::io::Error::last_os_error()) --- -2.41.0 - diff --git a/0003-file_utils-Verify-ioctl-request-code-in-tests.patch b/0003-file_utils-Verify-ioctl-request-code-in-tests.patch deleted file mode 100644 index 7e37307..0000000 --- a/0003-file_utils-Verify-ioctl-request-code-in-tests.patch +++ /dev/null @@ -1,120 +0,0 @@ -From 38e497f4200a0d2fcb043941d4a5792c76e47bbb Mon Sep 17 00:00:00 2001 -From: Ming-Hung Tsai -Date: Wed, 30 Aug 2023 18:11:45 +0800 -Subject: [PATCH 3/3] [file_utils] Verify ioctl request code in tests - -(cherry picked from commit f049fda90bbf74ab26bfd38e26e7c92de8f50e30) ---- - src/ioctl.rs | 3 ++ - src/ioctl/tests.rs | 86 ++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 89 insertions(+) - create mode 100644 src/ioctl/tests.rs - -diff --git a/src/ioctl.rs b/src/ioctl.rs -index 84933648..221bd4e9 100644 ---- a/src/ioctl.rs -+++ b/src/ioctl.rs -@@ -1,5 +1,8 @@ - /* Rust port of kernel include/uapi/asm-generic/ioctl.h */ - -+#[cfg(test)] -+mod tests; -+ - //------------------------------------------ - - #[cfg(target_env = "musl")] -diff --git a/src/ioctl/tests.rs b/src/ioctl/tests.rs -new file mode 100644 -index 00000000..17a395df ---- /dev/null -+++ b/src/ioctl/tests.rs -@@ -0,0 +1,86 @@ -+use crate::ioctl::*; -+ -+//------------------------------------------ -+ -+#[cfg(any( -+ target_arch = "mips", -+ target_arch = "mips64", -+ target_arch = "powerpc", -+ target_arch = "powerpc64", -+ target_arch = "powerpc64le", -+ target_arch = "sparc", -+ target_arch = "sparc64" -+))] -+mod expected { -+ use super::RequestType; -+ pub const BLKDISCARD: RequestType = 0x20001277; -+ -+ #[cfg(target_pointer_width = "32")] -+ mod sized { -+ use super::RequestType; -+ pub const BLKBSZSET: RequestType = 0x80041271; -+ pub const BLKGETSIZE64: RequestType = 0x40041272; -+ } -+ -+ #[cfg(target_pointer_width = "64")] -+ mod sized { -+ use super::RequestType; -+ pub const BLKBSZSET: RequestType = 0x80081271; -+ pub const BLKGETSIZE64: RequestType = 0x40081272; -+ } -+ -+ pub use sized::*; -+} -+ -+#[cfg(not(any( -+ target_arch = "mips", -+ target_arch = "mips64", -+ target_arch = "powerpc", -+ target_arch = "powerpc64", -+ target_arch = "powerpc64le", -+ target_arch = "sparc", -+ target_arch = "sparc64" -+)))] -+mod expected { -+ use super::RequestType; -+ pub const BLKDISCARD: RequestType = 0x1277; -+ -+ #[cfg(target_pointer_width = "32")] -+ mod sized { -+ use super::RequestType; -+ pub const BLKBSZSET: RequestType = 0x40041271; -+ pub const BLKGETSIZE64: RequestType = 0x80041272; -+ } -+ -+ #[cfg(target_pointer_width = "64")] -+ mod sized { -+ use super::RequestType; -+ pub const BLKBSZSET: RequestType = 0x40081271; -+ pub const BLKGETSIZE64: RequestType = 0x80081272; -+ } -+ -+ pub use sized::*; -+} -+ -+#[test] -+fn test_ioc_none() { -+ assert_eq!(crate::request_code_none!(0x12, 119), expected::BLKDISCARD); -+} -+ -+#[test] -+fn test_ioc_read_usize() { -+ assert_eq!( -+ crate::request_code_read!(0x12, 114, usize), -+ expected::BLKGETSIZE64 -+ ); -+} -+ -+#[test] -+fn test_ioc_write_usize() { -+ assert_eq!( -+ crate::request_code_write!(0x12, 113, usize), -+ expected::BLKBSZSET -+ ); -+} -+ -+//------------------------------------------ --- -2.41.0 - diff --git a/device-mapper-persistent-data.spec b/device-mapper-persistent-data.spec index 75e4952..9f1d981 100644 --- a/device-mapper-persistent-data.spec +++ b/device-mapper-persistent-data.spec @@ -9,17 +9,15 @@ Summary: Device-mapper Persistent Data Tools Name: device-mapper-persistent-data -Version: 1.0.6 -Release: 2%{?dist}%{?release_suffix} +Version: 1.0.9 +Release: 1%{?dist}%{?release_suffix} License: GPLv3+ #ExcludeArch: %%{ix86} 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: dmpd106-vendor.tar.gz +Source1: dmpd109-vendor.tar.gz Patch1: 0001-Tweak-cargo.toml-to-work-with-vendor-directory.patch -Patch2: 0002-file_utils-Fix-the-ioctl-request-code-for-the-powerp.patch -Patch3: 0003-file_utils-Verify-ioctl-request-code-in-tests.patch %if %{defined rhel} BuildRequires: rust-toolset @@ -44,7 +42,39 @@ snapshot eras #%%cargo_generate_buildrequires tar xf %{SOURCE1} mkdir -p .cargo -cat > .cargo/config < .cargo/config << EOF +[build] +rustc = "/usr/bin/rustc" +rustdoc = "/usr/bin/rustdoc" + +[profile.rpm] +inherits = "release" +opt-level = 3 +codegen-units = 1 +debug = 2 +strip = "none" + +[env] +CFLAGS = "-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer " +CXXFLAGS = "-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer " +LDFLAGS = "-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 " + +[install] +root = "/home/mcsontos/rpmbuild/BUILDROOT/%{NAME}-%{VERSION}-%{RELEASE}.x86_64/usr" + +[term] +verbose = true +EOF + +# Our own part: +cat >> .cargo/config < VERSION %generate_buildrequires @@ -118,6 +149,9 @@ make DESTDIR=%{buildroot} MANDIR=%{_mandir} install #% {_sbindir}/thin_show_duplicates %changelog +* Mon Dec 11 2023 Marian Csontos - 1.0.9-1 +- Update to latest upstream release 1.0.9. + * Thu Aug 31 2023 Marian Csontos - 1.0.6-2 - Fix broken installation on ppc64le caused by incorrect ioctl call. diff --git a/sources b/sources index c46e38d..dc3f053 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (v1.0.6.tar.gz) = b6a778048315fa83b8ffae797a406facd2be1552516f96abd0da5d02892be73f27c54e4e0a674b2f0253aa6fcdac187fc40d7a455eddfb25bc30f55a5e435b00 -SHA512 (dmpd106-vendor.tar.gz) = df7d77c83e6c6d3843ea61a0f0bfd414d0eef404a21046f04bd56f764f20cb33b3807b1606cf9eb6e2ee3fd0d5311b3582defbcf61692f3d10c4cd70769625d1 +SHA512 (v1.0.9.tar.gz) = c7d137b82cce4286d43f49af039f8026d7d7746e96affebc82e8243173ba9a014e3b462fc4b55850067ecfbcc6113c49f009c1285e272a4d64455715d11a9da1 +SHA512 (dmpd109-vendor.tar.gz) = f2a581da80e4137c6ecab9237587ec42141fdfe8c1bfae2ab5b431b64c100ea6c65cfadbbdd10d665101364731d7c5e61780490b9cfd5231df3f463483890747