Compare commits

..

51 commits

Author SHA1 Message Date
Andrea Mazzoleni
8350e7bb0f Update CHECKSUMS
Some checks failed
Build / build-mac (push) Has been cancelled
Build / build-linux (push) Has been cancelled
Build / build-arm32 (push) Has been cancelled
Build / build-win (push) Has been cancelled
Build / build-freebsd (push) Has been cancelled
Build / build-musl (push) Has been cancelled
CodeQL Advanced / Analyze (c-cpp) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
2026-11-16 09:44:22 +01:00
Andrea Mazzoleni
47e439ddff Skip devices without a backing block device (network/virtual filesystems) in device operations 2026-11-11 21:58:59 +01:00
Andrea Mazzoleni
487305a760 Use ubuntu-26.04 build server 2026-11-10 23:45:46 +01:00
Andrea Mazzoleni
4e8ed5cdbd Update HISTORY 2026-11-10 23:21:15 +01:00
Andrea Mazzoleni
83f3bee5d0 Fix typos in Windows error messages 2026-11-10 23:18:42 +01:00
Andrea Mazzoleni
029c3940fe Avoid creating a redundant Windows Job Object when already running inside an existing job 2026-11-10 22:49:46 +01:00
Andrea Mazzoleni
ccf095a6f8 Log OS function failure diagnostics at error level 2026-11-10 22:27:01 +01:00
Andrea Mazzoleni
5871fd4da3 Update CHECKSUMS
Some checks failed
Build / build-mac (push) Has been cancelled
Build / build-linux (push) Has been cancelled
Build / build-arm32 (push) Has been cancelled
Build / build-win (push) Has been cancelled
Build / build-freebsd (push) Has been cancelled
Build / build-musl (push) Has been cancelled
CodeQL Advanced / Analyze (c-cpp) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
2026-10-23 11:05:30 +02:00
Andrea Mazzoleni
4054832c7e Add best-effort Linux disk instance mappings using boot_id and diskseq
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-10-22 21:40:07 +02:00
Andrea Mazzoleni
7275872c80 Pin build-linux runner to ubuntu-24.04 for zfs kernel modules 2026-10-22 20:18:52 +02:00
Andrea Mazzoleni
e27d221793 Update HISTORY
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-10-22 18:50:18 +02:00
Andrea Mazzoleni
819bb75eaa Make test and doc variables in Makefile.am compatible with BSD make
Some checks failed
Build / build-mac (push) Has been cancelled
Build / build-linux (push) Has been cancelled
Build / build-arm32 (push) Has been cancelled
Build / build-win (push) Has been cancelled
Build / build-freebsd (push) Has been cancelled
Build / build-musl (push) Has been cancelled
CodeQL Advanced / Analyze (c-cpp) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
2026-10-18 22:33:32 +02:00
Andrea Mazzoleni
7878bc3d3d Update TODO 2026-10-18 22:19:56 +02:00
Andrea Mazzoleni
8a5b2adb75 Remove unused checked_read state flag
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-10-18 11:23:04 +02:00
Andrea Mazzoleni
a0d6bc288a Fix touch abort before the first sync when no content file exists 2026-10-18 11:07:41 +02:00
Andrea Mazzoleni
20e081d5ac Update CHECKSUMS
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-10-17 21:23:59 +02:00
Andrea Mazzoleni
4a9871d087 Use mulhash for integer keys while retaining inthash_u64 on 32-bit architectures
Some checks failed
Build / build-mac (push) Has been cancelled
Build / build-linux (push) Has been cancelled
Build / build-arm32 (push) Has been cancelled
Build / build-win (push) Has been cancelled
Build / build-freebsd (push) Has been cancelled
Build / build-musl (push) Has been cancelled
CodeQL Advanced / Analyze (c-cpp) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
2026-10-15 15:35:31 +02:00
Andrea Mazzoleni
25c86bc1e7 Remove leading double underscores from header include guards 2026-10-15 15:35:31 +02:00
Andrea Mazzoleni
cc18ed39c6 Keep generic license texts without embedded copyright notices 2026-10-15 15:35:31 +02:00
Andrea Mazzoleni
f775075bc5 Synchronize file metadata for new and modified files during scan on Windows 2026-10-15 15:35:31 +02:00
Andrea Mazzoleni
3b8c8c10e7 Use 64-bit TommyDS hash functions on 64-bit architectures 2026-10-15 15:35:31 +02:00
Andrea Mazzoleni
88c54f041e Update to TommyDS v4.0 2026-10-15 15:35:31 +02:00
Andrea Mazzoleni
a39fb132f8 Normalize comment style
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-10-07 09:14:01 +02:00
Andrea Mazzoleni
8fe9331f42 Limit unsynced parity sweep to the invalid window tracked during content parsing
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-10-06 10:49:24 +02:00
Andrea Mazzoleni
2a60279674 Avoid strlen in deferred pathset insertion by pre-caching path hash in pathset.index 2026-10-06 09:17:23 +02:00
Andrea Mazzoleni
6ae014d6ed Align integer gen and rec loops to 64 bytes
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-10-05 15:41:01 +02:00
Andrea Mazzoleni
143813a90e Store initial file path inline with struct snapraid_file 2026-10-05 15:41:01 +02:00
Andrea Mazzoleni
9f24ca00d1 Use atomic operations instead of mutex for memory allocation counter 2026-10-05 15:41:01 +02:00
Andrea Mazzoleni
8589327114 Defer file hash table insertions and pre-reserve bucket capacity in state_read_content 2026-10-05 15:41:01 +02:00
Andrea Mazzoleni
93c39d5526 Add tommy_hashdyn_reserve to pre-allocate hash buckets for expected elements 2026-10-05 15:41:01 +02:00
Andrea Mazzoleni
0d2f466b11 Count unsynced blocks using an extent event sweep instead of per-block lookups 2026-10-05 15:41:01 +02:00
Andrea Mazzoleni
3d7a722ab2 Avoid redundant strlen and duplicate traversals when loading content strings 2026-10-05 15:41:01 +02:00
Andrea Mazzoleni
969cb5ca31 Make sgetbs() return the number of characters read on success 2026-10-05 15:41:01 +02:00
Andrea Mazzoleni
97419fb67f Cache BLOCK_HASH_SIZE in local variable in block run read and write loops 2026-10-05 14:04:15 +02:00
Andrea Mazzoleni
94c7d3ef9a Avoid memory preinitialization in malloc_nofail and use calloc directly in calloc_nofail 2026-10-05 14:04:15 +02:00
Andrea Mazzoleni
ec71f519b0 Align critical loops to 64 bytes using __align_loops attribute 2026-10-05 14:04:12 +02:00
Andrea Mazzoleni
91761768a0 Document rare occurrence of missing info branch in content loading 2026-10-05 00:11:51 +02:00
Andrea Mazzoleni
0ad0913ef2 Use os_tick_ns() monotonic timer and add compiler memory barriers
Some checks failed
Build / build-mac (push) Has been cancelled
Build / build-linux (push) Has been cancelled
Build / build-arm32 (push) Has been cancelled
Build / build-win (push) Has been cancelled
Build / build-freebsd (push) Has been cancelled
Build / build-musl (push) Has been cancelled
CodeQL Advanced / Analyze (c-cpp) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
2026-10-02 11:09:42 +02:00
Andrea Mazzoleni
dcb3c7db37 Add CONFIG_NEON/32 defines 2026-10-02 10:43:11 +02:00
Andrea Mazzoleni
a7a85a259c Add os_tick_us() and os_tick_ns() monotonic high-resolution timers 2026-10-02 10:38:05 +02:00
Andrea Mazzoleni
68b94bfdf5 Document interaction between filesystem snapshots and external backup tools 2026-10-02 09:56:51 +02:00
Andrea Mazzoleni
e42876e620 Update HISTORY 2026-10-01 19:10:19 +02:00
Andrea Mazzoleni
0b930b8a31 Add unique descriptive log_fatal messages with field names to all decoding_error calls
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-10-01 09:30:38 +02:00
Andrea Mazzoleni
70947d4054 Print abort stacktrace to stderr and exit with code 134 on Windows 2026-10-01 08:55:44 +02:00
Andrea Mazzoleni
5b402fc462 Normalize legacy out-of-range content nanoseconds to STAT_NSEC_INVALID 2026-10-01 08:43:59 +02:00
Andrea Mazzoleni
edb3cacb77 Optimize hash performance with custom unroll 2026-10-01 00:43:48 +02:00
Andrea Mazzoleni
31570ae473 Document MuseAir and SpookyHash collision analysis 2026-10-01 00:09:22 +02:00
Andrea Mazzoleni
426f6dc0bc Treat ENOTDIR as missing file in filter_existence and handle_open_create
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-09-30 16:07:36 +02:00
Andrea Mazzoleni
eb75cef0fe Avoid touch failing on missing files deleted or moved since the last sync 2026-09-30 16:07:36 +02:00
Andrea Mazzoleni
66ae70481c Update TODO
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
2026-09-29 10:59:57 +02:00
Andrea Mazzoleni
baa833f13c Update CHECKSUMS 2026-09-29 09:33:22 +02:00
129 changed files with 6014 additions and 1857 deletions

View file

@ -20,16 +20,16 @@ jobs:
- run: make all -j$(sysctl -n hw.ncpu) - run: make all -j$(sysctl -n hw.ncpu)
- run: make dist check - run: make dist check
build-linux: build-linux:
runs-on: ubuntu-latest runs-on: ubuntu-26.04
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v5
- run: | - run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y \ sudo apt-get install -y \
linux-modules-extra-$(uname -r) \ linux-main-modules-zfs-$(uname -r) \
zfsutils-linux zfsutils-linux
sudo modprobe zfs sudo modprobe zfs
zfs version sudo zfs version
- run: autoreconf -i - run: autoreconf -i
- run: ./configure --enable-warning-as-error - run: ./configure --enable-warning-as-error
- run: make all -j$(nproc) - run: make all -j$(nproc)
@ -90,12 +90,12 @@ jobs:
with: with:
usesh: true usesh: true
prepare: | prepare: |
pkg install -y autoconf automake gmake pkg install -y autoconf automake
run: | run: |
autoreconf -i autoreconf -i
./configure --enable-warning-as-error MAKE=gmake ./configure --enable-warning-as-error
gmake all -j$(sysctl -n hw.ncpu) make all -j$(sysctl -n hw.ncpu)
gmake dist check make dist check
build-musl: build-musl:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: alpine:latest container: alpine:latest

View file

@ -105,9 +105,9 @@ SnapRAID is designed to recover from an interruption, including `SIGKILL`, at an
- **Format**: Enforce via `uncrustify -c uncrustify.cfg --no-backup *.c *.h` (or `uncrustify -c linux.cfg --no-backup *.c *.h` for `raid/` directory and subdirectories) - **Format**: Enforce via `uncrustify -c uncrustify.cfg --no-backup *.c *.h` (or `uncrustify -c linux.cfg --no-backup *.c *.h` for `raid/` directory and subdirectories)
- **Naming**: Snake_case for functions, UPPER_CASE for macros/constants - **Naming**: Snake_case for functions, UPPER_CASE for macros/constants
- **Indentation**: Tabs for indentation, no alignment (existing codebase style) - **Indentation**: Tabs for indentation, no alignment (existing codebase style)
- **Comments**: C-style `/** */` for multiline comments; C `/* first letter lowercase */` for single-line inline notes - **Comments**: Use `/** ... */` for multiline top comments preceding declarations and `/* ... */` for multiline comments within code. Use `/* first letter lowercase */` for single-line inline notes.
- **Critical Comments**: Always add a comment at non-obvious critical points, especially around data-integrity invariants, crash recovery, fallback behavior, concurrency, and fatal versus best-effort error handling. Explain why the logic is required, not merely what the code does. - **Critical Comments**: Always add a comment at non-obvious critical points, especially around data-integrity invariants, crash recovery, fallback behavior, concurrency, and fatal versus best-effort error handling. Explain why the logic is required, not merely what the code does.
- **Headers**: All `.h` files have include guards (`#ifndef __NAME_H`) - **Headers**: All `.h` files have include guards (`#ifndef NAME_H`)
- **Preferences**: Use 0 instead of NULL and '\0' - **Preferences**: Use 0 instead of NULL and '\0'
- **Preferences**: Use prefix ++variable and --variable instead of postfix variable++ and variable-- where both are equivalent - **Preferences**: Use prefix ++variable and --variable instead of postfix variable++ and variable-- where both are equivalent
- **Safety Checks**: Avoid adding safety checks for conditions that never happen - **Safety Checks**: Avoid adding safety checks for conditions that never happen

View file

@ -215,6 +215,30 @@ e11c452e2adec376e6fcaee9ff2ec4de4e943c35690229c9c67056c5eaed52a1 snapraid-14.9-
84af790cd25c8f2d773386bca7320cb5cf81706f850eb1fda33d4b9ff4e0d692 snapraid-14.9-windows-x64.zip 84af790cd25c8f2d773386bca7320cb5cf81706f850eb1fda33d4b9ff4e0d692 snapraid-14.9-windows-x64.zip
7ec39de0cf7cabd09061bfc54848084b4505e77b27556850fc53cb5f23080003 snapraid-14.9-windows-x86.zip 7ec39de0cf7cabd09061bfc54848084b4505e77b27556850fc53cb5f23080003 snapraid-14.9-windows-x86.zip
40cee688cb1a322810eaac4e3655313c0075b791e18783bec2588084a9e47f09 snapraid-14.9-x86_64-1_am.txz 40cee688cb1a322810eaac4e3655313c0075b791e18783bec2588084a9e47f09 snapraid-14.9-x86_64-1_am.txz
27be09151c8e779019da7d9e0501b03f56ae83da489cdaf5cd85463075cec9a2 snapraid-14.10.tar.gz
6f5a31ee04649c9b2b7b0612619f401f160c4f1a4a56947ff50381cc6036b8cc snapraid-14.10-1-x86_64.pkg.tar.zst
461778095cd40e9ef1231999dd4924499c1f6cab23e233ab811f37e29b81aefe snapraid-14.10-1.x86_64.rpm
6e8892175bfe240ae7828d513342180a249511a2d5baf8c003ae8b2bb82e0f46 snapraid-14.10-windows-x64.zip
1ec0572359fb31f2827702d792db0bdf6a95161eb9e2a6deff2bdc7e1f5b794b snapraid-14.10-windows-x86.zip
6930d629c73b5307ec32277310ed13887b1bd051e30dc41c75b4752040032d1c snapraid-14.10-x86_64-1_am.txz
ceba44e15566386d923d6895ecab81f7437848b03a4cf9585c02d3636197ce19 snapraid-15.0.tar.gz
9d55d0308ce41beb29956b59f9d2e32d419c930118266d3e08b15f658119f4fb snapraid-15.0-1-x86_64.pkg.tar.zst
ad66c0b4c016775c9a759adf2a5202bebb357d319b0063b9cf68befde9a67363 snapraid-15.0-1.x86_64.rpm
704706c21b432719c4da8cd237c1f26327af89c86604dc339a38d63574004a22 snapraid-15.0-windows-x64.zip
58b3ed90307e41b7a6e862d2dc070204c98b5c3ac24718e2fb9fe03e275bc2ce snapraid-15.0-windows-x86.zip
9483df5a39a8b59c32433331ac92a4eef54dcff4722694a5bc5e89bcefb6b3b0 snapraid-15.0-x86_64-1_am.txz
fb2d6a9cf9c8ea30c6962f4a48764dc9012fe61d6e23f40a8d959dadea02278b snapraid-15.1.tar.gz
5e627e08caa8d7647fd40e5288b8d59846d1f3d65d586bae74a57cd99a23f497 snapraid-15.1-1-x86_64.pkg.tar.zst
8922234dd566c876b17cbaadad6a22690d05240250455e504513906d933e16dd snapraid-15.1-1.x86_64.rpm
64849f463986d0d80b948dbb07e9af6402bed230a9cf17dbd1110199aca56486 snapraid-15.1-windows-x64.zip
f7be230f7849d89941a280dc8c2cc6e158844e0fe6f00adbb6aa9ac0f65322b8 snapraid-15.1-windows-x86.zip
4dbd01ab2582a74fab4d7ee8f9b11966d4188fba9eedcd31fcc0a5588cd0c702 snapraid-15.1-x86_64-1_am.txz
0740169f66c506c29846a5aef57d2b11ffe5c354c5bb0ba260f2b5f328f985c5 snapraid-15.2.tar.gz
208a5d99c94889e2357f0211d716bababcfb8289907167220563f734fb936e96 snapraid-15.2-1-x86_64.pkg.tar.zst
f1c37fa43beea8445858520a5cd514198d8c0c0ac5a5ab588adcd02e872ee681 snapraid-15.2-1.x86_64.rpm
882334e5102b418ace0753f9335a99783fc784e149429c29911247b56f04e438 snapraid-15.2-windows-x64.zip
942157645a532e2a280ca404625476c42591436f2292491b1faedb9d48efd07e snapraid-15.2-windows-x86.zip
7bb455cb77586dd2d90f6868c66dd9cdf6774aa89c099f1026a851407ac7adac snapraid-15.2-x86_64-1_am.txz
128b5b0f80a6a0911e77ed3b5d9d81529f5ea1d8fffbb5112e3af3467d80464a snapraid_14.0-1_amd64.deb 128b5b0f80a6a0911e77ed3b5d9d81529f5ea1d8fffbb5112e3af3467d80464a snapraid_14.0-1_amd64.deb
b9c41ae2e8edbc413abd3172b7ed2da2cba7fa0e631d0f47fc1dafccf7c6e92c snapraid_14.1-1_amd64.deb b9c41ae2e8edbc413abd3172b7ed2da2cba7fa0e631d0f47fc1dafccf7c6e92c snapraid_14.1-1_amd64.deb
e6456b926bb053d34645e31e5e3d8363e952c9869e873eb348abb1149598d331 snapraid_14.2-1_amd64.deb e6456b926bb053d34645e31e5e3d8363e952c9869e873eb348abb1149598d331 snapraid_14.2-1_amd64.deb
@ -225,3 +249,7 @@ b71b556da4be6263a904fb8ac489933875467adbb920dd3911e54d87e9637ca3 snapraid_14.6-
35b156fc4d5c34339eed7e7d73e22a76e646879ecf6846b5ca20f7992ff55640 snapraid_14.7-1_amd64.deb 35b156fc4d5c34339eed7e7d73e22a76e646879ecf6846b5ca20f7992ff55640 snapraid_14.7-1_amd64.deb
c0e00a25b9bce40ff74f5a55401c3bfedac1881fd99aaa90a692f5858d417f7d snapraid_14.8-1_amd64.deb c0e00a25b9bce40ff74f5a55401c3bfedac1881fd99aaa90a692f5858d417f7d snapraid_14.8-1_amd64.deb
09064689a64d965ac33ee89fb8b2cc14dfec0745f2b3b86a78f377fc353b7e07 snapraid_14.9-1_amd64.deb 09064689a64d965ac33ee89fb8b2cc14dfec0745f2b3b86a78f377fc353b7e07 snapraid_14.9-1_amd64.deb
15f5fd9f639912c94daae9d75d3567b7a3fc0e18475880f972acd8d8e9e0992c snapraid_14.10-1_amd64.deb
845091e7eeb2495fc3899dc6e8fab2c3fe7a5945f345c767a7603dab90e2cb84 snapraid_15.0-1_amd64.deb
974cd45fc8f44d5642b49bd9b30e81aca2bcd7689877f9fa73d1e58d3f1b5bda snapraid_15.1-1_amd64.deb
9c78f158347cc0340ed5c9877724bb4f3b5e5fb48b43332ee7e0e7b6a63642d9 snapraid_15.2-1_amd64.deb

34
HISTORY
View file

@ -1,8 +1,36 @@
SnapRAID HISTORY SnapRAID HISTORY
================ ================
15.0 (Work in Progress) 15.2 2026/11
======================= ============
* Avoid creating a redundant Windows Job Object when SnapRAID is
already running inside an existing job (such as under SnapRAID
Daemon). This prevents potential execution failures of child
processes (such as smartctl) on systems where nested job objects are
not supported.
* Skip disks on network or virtual filesystems (such as NFS, CIFS,
FUSE, or tmpfs) in device operations like 'up', 'down', 'smart',
and 'probe' on Linux, instead of failing with an error. If no
physical device remains, the operation completes successfully with
an informational message.
15.1 2026/10
============
* Add synthetic device IDs on Linux, allowing SnapRAID Daemon to
preserve history for devices without unique hardware IDs while
they remain connected within the same boot.
* Fix a failed internal inconsistency check when '--gui-touch-before'
is used before the first sync when no content file exists yet.
Also ensure that commands that can save the content file ('touch',
'scrub', 'rehash', 'rewrite') fail with a clear error message if the
array has not been synced yet. This fix is required by
SnapRAID-Daemon.
* Make test and doc variables in Makefile.am compatible with BSD make,
allowing builds, tests, and documentation generation on BSD systems
without requiring GNU make.
15.0 2026/10
============
* Added support for automated filesystem snapshots to ensure data * Added support for automated filesystem snapshots to ensure data
consistency and improve recovery reliability. consistency and improve recovery reliability.
When the 'snapshot' option is enabled, SnapRAID transparently manages When the 'snapshot' option is enabled, SnapRAID transparently manages
@ -40,7 +68,7 @@ SnapRAID HISTORY
behaviour is preserved. Primarily intended for NixOS and other behaviour is preserved. Primarily intended for NixOS and other
non-FHS systems. non-FHS systems.
* Removed the 512 TiB limitation on hard disk size (when using the * Removed the 512 TiB limitation on hard disk size (when using the
default 128 KiB blocks). default 256 KiB blocks).
* Added support for a custom info options tag `[info: ...]` in the * Added support for a custom info options tag `[info: ...]` in the
`smartctl` configuration option. This allows replacing the default `smartctl` configuration option. This allows replacing the default
`-a` command line argument used to retrieve SMART attributes with a `-a` command line argument used to retrieve SMART attributes with a

View file

@ -1,5 +1,3 @@
Copyright (c) 2010, Andrea Mazzoleni. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
are met: are met:

View file

@ -217,7 +217,10 @@ $(CLI_PREFIX)sync.$(OBJEXT): $(CLI_INCLUDES)
$(CLI_PREFIX)thermal.$(OBJEXT): $(CLI_INCLUDES) $(CLI_PREFIX)thermal.$(OBJEXT): $(CLI_INCLUDES)
$(CLI_PREFIX)touch.$(OBJEXT): $(CLI_INCLUDES) $(CLI_PREFIX)touch.$(OBJEXT): $(CLI_INCLUDES)
$(CLI_PREFIX)unixapp.$(OBJEXT): $(CLI_INCLUDES) $(CLI_PREFIX)unixapp.$(OBJEXT): $(CLI_INCLUDES)
$(CLI_PREFIX)util.$(OBJEXT): $(CLI_INCLUDES) $(CLI_PREFIX)util.$(OBJEXT): $(CLI_INCLUDES) \
$(srcdir)/cmdline/murmur3.c \
$(srcdir)/cmdline/spooky2.c \
$(srcdir)/cmdline/museair.c
# Add the .version file in the distribution # Add the .version file in the distribution
dist-hook: dist-hook:
@ -225,13 +228,28 @@ dist-hook:
LANG_CODES = de es fr it ja ko pl pt ro ru sv uk zh LANG_CODES = de es fr it ja ko pl pt ro ru sv uk zh
LIST_D = doc/snapraid.d doc/snapraid_log.d $(patsubst %, doc/snapraid-%.d, $(LANG_CODES)) LIST_LANG_D = \
doc/snapraid-de.d \
doc/snapraid-es.d \
doc/snapraid-fr.d \
doc/snapraid-it.d \
doc/snapraid-ja.d \
doc/snapraid-ko.d \
doc/snapraid-pl.d \
doc/snapraid-pt.d \
doc/snapraid-ro.d \
doc/snapraid-ru.d \
doc/snapraid-sv.d \
doc/snapraid-uk.d \
doc/snapraid-zh.d
LIST_MAN = doc/snapraid.1 doc/snapraid_log.1 $(patsubst %, doc/snapraid-%.1, $(LANG_CODES)) LIST_D = doc/snapraid.d doc/snapraid_log.d $(LIST_LANG_D)
LIST_TXT = doc/snapraid.txt doc/snapraid_log.txt $(patsubst %, doc/snapraid-%.txt, $(LANG_CODES)) LIST_MAN = $(LIST_D:.d=.1)
LIST_XML = doc/snapraid.xml doc/snapraid_log.xml $(patsubst %, doc/snapraid-%.xml, $(LANG_CODES)) LIST_TXT = $(LIST_D:.d=.txt)
LIST_XML = $(LIST_D:.d=.xml)
EXTRA_DIST = \ EXTRA_DIST = \
autogen.sh autover.sh valgrind.supp \ autogen.sh autover.sh valgrind.supp \
@ -382,8 +400,13 @@ else # HAVE_POSIX
CHECKCOUNT_DEFAULT = 500 CHECKCOUNT_DEFAULT = 500
endif # HAVE_POSIX endif # HAVE_POSIX
CHECKCOUNT = $(if $(filter 1,$(SHORTCHECK)),500,$(CHECKCOUNT_DEFAULT)) CHECKCOUNT_0 = $(CHECKCOUNT_DEFAULT)
CHECKSIZE = $(if $(filter 1,$(SHORTCHECK)),100,4000) CHECKCOUNT_1 = 500
CHECKCOUNT = $(CHECKCOUNT_$(SHORTCHECK))
CHECKSIZE_0 = 4000
CHECKSIZE_1 = 100
CHECKSIZE = $(CHECKSIZE_$(SHORTCHECK))
CONF = $(srcdir)/test/test-par6.conf CONF = $(srcdir)/test/test-par6.conf
THERMAL = $(srcdir)/test/test-par6-thermal.conf THERMAL = $(srcdir)/test/test-par6-thermal.conf

17
TODO
View file

@ -6,19 +6,23 @@ This is the list of TODO items for SnapRAID.
16.x Releases 16.x Releases
============= =============
* Use statx() instead of lstat() when scanning directories. * Support a `[power_control: off]` tag in `smartctl` options to disable power
management (`up` and `down`) on specific disks (e.g. for SAS drives that
fail to wake up on write). Emit an attribute tag in probe for snapraid-daemon.
* Enable MuseAir and disable random seed
* Add a new 'restore' command, similar to 'fix', that recovers a whole disk * Add a new 'restore' command, similar to 'fix', that recovers a whole disk
using the same multithreaded approach as sync/scrub. using the same multithreaded approach as sync/scrub.
* Use statx() instead of lstat() when scanning directories.
* Integration with MergerFS ? * Integration with MergerFS ?
* Restore ownership and permissions, at least in Unix. * Restore ownership and permissions, at least in Unix.
* Restore directory timestamps. * Restore directory timestamps.
* Enable MuseAir and disable random seed
* Check Reliability Test. We can derive Failure probability from MBTF * Check Reliability Test. We can derive Failure probability from MBTF
https://github.com/linuxhw/SMART https://github.com/linuxhw/SMART
https://github.com/linuxhw/EnterpriseDrive https://github.com/linuxhw/EnterpriseDrive
@ -40,6 +44,13 @@ Future
- Major - Major
* Optimize `sync` on Btrfs by using `btrfs send -p <prev> <curr> --no-data`
to identify modified files and extent offsets, avoiding a full filesystem
metadata scan. Parity recomputation still reads from the latest snapshot.
Store the Btrfs snapshot generation (and UUID) in the content file to verify
that the parent snapshot strictly matches the content state before diffing,
falling back to a full scan if mismatched.
* Size-Based Checkpointing (autosave) using a write-ahead log (WAL). * Size-Based Checkpointing (autosave) using a write-ahead log (WAL).
Instead of writing the full content file periodically (autosave), write incremental Instead of writing the full content file periodically (autosave), write incremental
updates to companion `.wal` files. Use the existing bit-efficient `STREAM` updates to companion `.wal` files. Use the existing bit-efficient `STREAM`

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2026 Andrea Mazzoleni // Copyright (C) 2026 Andrea Mazzoleni
#ifndef __APP_H #ifndef APP_H
#define __APP_H #define APP_H
#include "os/os.h" #include "os/os.h"
@ -87,7 +87,7 @@ int fsinfo(const char* path, int* has_persistent_inode, int* has_syncronized_har
#define SNAPSHOT_SCAN "scan" #define SNAPSHOT_SCAN "scan"
#define SNAPSHOT_RETIRING_SUFFIX ".retiring" #define SNAPSHOT_RETIRING_SUFFIX ".retiring"
/* /**
* Snapshots context * Snapshots context
*/ */
struct fssnapshot_struct { struct fssnapshot_struct {
@ -213,7 +213,7 @@ int fssnapshot_replace(struct fssnapshot_struct* fss, const char* old_name, cons
*/ */
int fssnapshot_path(const struct fssnapshot_struct* fss, const char* name, char* path, size_t path_size); int fssnapshot_path(const struct fssnapshot_struct* fss, const char* name, char* path, size_t path_size);
/* /**
* Log file. * Log file.
* *
* This stream if fully buffered. * This stream if fully buffered.
@ -257,7 +257,7 @@ extern int exit_degraded;
*/ */
#define SMART_FLAGS 256 #define SMART_FLAGS 256
/* /**
* Counts command, transport, or controller-level errors reported by the device. * Counts command, transport, or controller-level errors reported by the device.
* These reflect failed I/O operations not directly caused by media defects * These reflect failed I/O operations not directly caused by media defects
* (for example interface, firmware, or power-related errors). * (for example interface, firmware, or power-related errors).
@ -266,7 +266,7 @@ extern int exit_degraded;
*/ */
#define SMART_ERROR_PROTOCOL 257 #define SMART_ERROR_PROTOCOL 257
/* /**
* Counts media-level errors where data could not be reliably read or written. * Counts media-level errors where data could not be reliably read or written.
* These indicate actual storage surface or flash failures and may imply data loss. * These indicate actual storage surface or flash failures and may imply data loss.
* This counter is cumulative and never resets to zero, even if the underlying * This counter is cumulative and never resets to zero, even if the underlying
@ -387,7 +387,7 @@ struct devinfo_struct {
char name[PATH_MAX]; /**< Name of the disk combined with the split index if any */ char name[PATH_MAX]; /**< Name of the disk combined with the split index if any */
char mount[PATH_MAX]; /**< Mount point or other contained directory. */ char mount[PATH_MAX]; /**< Mount point or other contained directory. */
char smartctl[SMARTCTL_MAX]; /**< Custom option for smartctl. Empty means auto. */ char smartctl[SMARTCTL_MAX]; /**< Custom option for smartctl. Empty means auto. */
char smartctl_info[SMARTCTL_MAX]; /* Info options for smartctl. Empty means -a. */ char smartctl_info[SMARTCTL_MAX]; /**< Info options for smartctl. Empty means -a. */
struct smartignore_struct smartignore[SMART_IGNORE_MAX]; /**< Attributes to ignore */ struct smartignore_struct smartignore[SMART_IGNORE_MAX]; /**< Attributes to ignore */
char file[PATH_MAX]; /**< File device. */ char file[PATH_MAX]; /**< File device. */
#ifdef _WIN32 #ifdef _WIN32

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2016 Andrea Mazzoleni // Copyright (C) 2016 Andrea Mazzoleni
#ifndef __BW_H #ifndef BW_H
#define __BW_H #define BW_H
#include "state.h" #include "state.h"
#include "support.h" #include "support.h"

View file

@ -14,7 +14,7 @@
#include "raid/raid.h" #include "raid/raid.h"
#include "raid/combo.h" #include "raid/combo.h"
/* /**
* SnapRAID check/fix model * SnapRAID check/fix model
* *
* Check verifies the data described by the content file against the files * Check verifies the data described by the content file against the files
@ -841,11 +841,9 @@ static int repair(struct snapraid_state* state, int rehash, block_off_t pos, uns
* distinction disappears. * distinction disappears.
*/ */
/************************************************************************/
/* First strategy: parity represents CURRENT data. */
/************************************************************************/
/* /*
* First strategy: parity represents CURRENT data.
*
* Under the CURRENT hypothesis: * Under the CURRENT hypothesis:
* *
* BLK hash CURRENT, parity normally synchronized * BLK hash CURRENT, parity normally synchronized
@ -1129,11 +1127,9 @@ static int repair(struct snapraid_state* state, int rehash, block_off_t pos, uns
else else
log_tag("recover_sync:%" PRIu64 ":%u: Failed with %d attempts\n", pos, n, ret); log_tag("recover_sync:%" PRIu64 ":%u: Failed with %d attempts\n", pos, n, ret);
/************************************************************************/
/* Second strategy: parity still represents OLD data. */
/************************************************************************/
/* /*
* Second strategy: parity still represents OLD data.
*
* The CURRENT attempt failed, so retry under the opposite history * The CURRENT attempt failed, so retry under the opposite history
* hypothesis: physical parity still represents the state before the * hypothesis: physical parity still represents the state before the
* interrupted sync. * interrupted sync.
@ -1964,7 +1960,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
*/ */
valid_parity = 1; valid_parity = 1;
/* If the parity is used by at least one file */ /* if the parity is used by at least one file */
used_parity = 0; used_parity = 0;
/* keep track of the number of failed blocks */ /* keep track of the number of failed blocks */

View file

@ -43,12 +43,12 @@ void device_name_set(devinfo_t* dev, const char* name, int index)
*/ */
#define SMART_MEASURES 256 #define SMART_MEASURES 256
/* /**
* Divider for SMART attribute 5 * Divider for SMART attribute 5
*/ */
static unsigned SMART_5_STEP = 1; static unsigned SMART_5_STEP = 1;
/* /**
* Failure rate for 30 days, for a disk * Failure rate for 30 days, for a disk
* with SMART attribute 5 at a given value. * with SMART attribute 5 at a given value.
*/ */
@ -107,12 +107,12 @@ static double SMART_5_R[SMART_MEASURES] = {
0.4249, 0.4249,
}; };
/* /**
* Divider for SMART attribute 187 * Divider for SMART attribute 187
*/ */
static unsigned SMART_187_STEP = 1; static unsigned SMART_187_STEP = 1;
/* /**
* Failure rate for 30 days, for a disk * Failure rate for 30 days, for a disk
* with SMART attribute 187 at a given value. * with SMART attribute 187 at a given value.
*/ */
@ -171,12 +171,12 @@ static double SMART_187_R[SMART_MEASURES] = {
3.4520, 3.4520,
}; };
/* /**
* Divider for SMART attribute 188 * Divider for SMART attribute 188
*/ */
static unsigned SMART_188_STEP = 1; static unsigned SMART_188_STEP = 1;
/* /**
* Failure rate for 30 days, for a disk * Failure rate for 30 days, for a disk
* with SMART attribute 188 at a given value. * with SMART attribute 188 at a given value.
*/ */
@ -235,12 +235,12 @@ static double SMART_188_R[SMART_MEASURES] = {
1.3731, 1.3731,
}; };
/* /**
* Divider for SMART attribute 197 * Divider for SMART attribute 197
*/ */
static unsigned SMART_197_STEP = 1; static unsigned SMART_197_STEP = 1;
/* /**
* Failure rate for 30 days, for a disk * Failure rate for 30 days, for a disk
* with SMART attribute 197 at a given value. * with SMART attribute 197 at a given value.
*/ */
@ -299,12 +299,12 @@ static double SMART_197_R[SMART_MEASURES] = {
4.1131, 4.1131,
}; };
/* /**
* Divider for SMART attribute 198 * Divider for SMART attribute 198
*/ */
static unsigned SMART_198_STEP = 1; static unsigned SMART_198_STEP = 1;
/* /**
* Failure rate for 30 days, for a disk * Failure rate for 30 days, for a disk
* with SMART attribute 198 at a given value. * with SMART attribute 198 at a given value.
*/ */
@ -423,7 +423,7 @@ static double smart_afr(devinfo_t* devinfo)
} }
if ( if (
/** /*
* Don't check Command_Timeout (188) for Seagate disks. * Don't check Command_Timeout (188) for Seagate disks.
* *
* It's reported by users that for Archive SMR (Shingled Magnetic Recording) * It's reported by users that for Archive SMR (Shingled Magnetic Recording)
@ -1237,13 +1237,16 @@ int state_device_force(struct snapraid_state* state, int operation, tommy_list*
} }
} }
/* distinguish skipped devices from unsupported device queries */
if (ret == 0 && tommy_list_empty(&low)) { if (ret == 0 && tommy_list_empty(&low)) {
ret = -1;
if (tommy_list_empty(&high)) { if (tommy_list_empty(&high)) {
ret = -1;
log_error(ESOFT, "No accessible devices selected for this operation.\n"); log_error(ESOFT, "No accessible devices selected for this operation.\n");
goto bail; goto bail;
} }
/* not an error, the selected disks are on network or virtual filesystems without a block device to manage */
msg_info("No physical devices found for the selected disks, nothing to do.\n");
goto bail;
} }
if (ret != 0) { if (ret != 0) {

View file

@ -70,9 +70,13 @@ struct snapraid_hash* hash_alloc(struct snapraid_state* state, struct snapraid_d
return hash; return hash;
} }
static inline tommy_uint32_t hash_hash(struct snapraid_hash* hash) static inline tommy_hash_t hash_hash(struct snapraid_hash* hash)
{ {
#if TOMMY_SIZE_BIT == 64
return tommy_hash_u64(0, hash->hash, HASH_MAX);
#else
return tommy_hash_u32(0, hash->hash, HASH_MAX); return tommy_hash_u32(0, hash->hash, HASH_MAX);
#endif
} }
static void hash_free(void* void_hash) static void hash_free(void* void_hash)
@ -112,7 +116,7 @@ void state_dup(struct snapraid_state* state)
for (j = disk->filelist; j != 0; j = j->next) { for (j = disk->filelist; j != 0; j = j->next) {
struct snapraid_file* file = j->data; struct snapraid_file* file = j->data;
struct snapraid_hash* hash; struct snapraid_hash* hash;
tommy_hash_t hash32; tommy_hash_t hash_val;
/* if empty, skip it */ /* if empty, skip it */
if (file->size == 0) if (file->size == 0)
@ -124,9 +128,9 @@ void state_dup(struct snapraid_state* state)
if (!hash) if (!hash)
continue; continue;
hash32 = hash_hash(hash); hash_val = hash_hash(hash);
struct snapraid_hash* found = tommy_hashdyn_search(&hashset, hash_compare, hash->hash, hash32); struct snapraid_hash* found = tommy_hashdyn_search(&hashset, hash_compare, hash->hash, hash_val);
if (found) { if (found) {
++count; ++count;
size += found->file->size; size += found->file->size;
@ -134,7 +138,7 @@ void state_dup(struct snapraid_state* state)
printf("%12" PRIu64 " %s = %s\n", file->size, fmt_term(disk, file->sub), fmt_term(found->disk, found->file->sub)); printf("%12" PRIu64 " %s = %s\n", file->size, fmt_term(disk, file->sub), fmt_term(found->disk, found->file->sub));
hash_free(hash); hash_free(hash);
} else { } else {
tommy_hashdyn_insert(&hashset, &hash->node, hash, hash32); tommy_hashdyn_insert(&hashset, &hash->node, hash, hash_val);
} }
} }
} }

View file

@ -291,7 +291,7 @@ static int filter_element(tommy_list* filterlist, struct snapraid_filter** reaso
{ {
tommy_node* i; tommy_node* i;
/** /*
* The rule is that the latest filter defines the behaviour of paths * The rule is that the latest filter defines the behaviour of paths
* that doesn't match any filter. * that doesn't match any filter.
* *
@ -375,7 +375,7 @@ int filter_existence(int filter_missing, const char* dir, const char* sub)
if (lstat(path, &st) != 0) { if (lstat(path, &st) != 0) {
/* if the file doesn't exist, we don't filter it out */ /* if the file doesn't exist, we don't filter it out */
if (errno == ENOENT) if (errno == ENOENT || errno == ENOTDIR)
return 0; return 0;
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(errno, "Error in stat file '%s'. %s.\n", path, strerror(errno)); log_fatal(errno, "Error in stat file '%s'. %s.\n", path, strerror(errno));
@ -470,7 +470,7 @@ int filter_snapshot(int enable, const char* sub, const char* name)
return 0; return 0;
} }
struct snapraid_file* file_alloc(unsigned block_size, const char* sub, data_off_t size, uint64_t mtime_sec, int mtime_nsec, uint64_t inode) struct snapraid_file* file_alloc_len(unsigned block_size, const char* sub, size_t sub_len, data_off_t size, uint64_t mtime_sec, int mtime_nsec, uint64_t inode)
{ {
struct snapraid_file* file; struct snapraid_file* file;
block_off_t blockmax; block_off_t blockmax;
@ -488,8 +488,10 @@ struct snapraid_file* file_alloc(unsigned block_size, const char* sub, data_off_
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
file = malloc_nofail(sizeof(struct snapraid_file)); file = malloc_nofail(sizeof(struct snapraid_file) + sub_len + 1);
file->sub = strdup_nofail(sub); file->sub = file->sub_inline;
memcpy(file->sub, sub, sub_len);
file->sub[sub_len] = 0;
file->size = size; file->size = size;
file->blockmax = blockmax; file->blockmax = blockmax;
file->mtime_sec = mtime_sec; file->mtime_sec = mtime_sec;
@ -505,6 +507,7 @@ struct snapraid_file* file_dup(struct snapraid_file* copy)
{ {
struct snapraid_file* file; struct snapraid_file* file;
block_off_t i; block_off_t i;
size_t sub_len;
if (copy->blockmax > BLOCK_MAX) { if (copy->blockmax > BLOCK_MAX) {
#if SIZE_MAX == UINT32_MAX #if SIZE_MAX == UINT32_MAX
@ -515,8 +518,11 @@ struct snapraid_file* file_dup(struct snapraid_file* copy)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
file = malloc_nofail(sizeof(struct snapraid_file)); sub_len = strlen(copy->sub);
file->sub = strdup_nofail(copy->sub); file = malloc_nofail(sizeof(struct snapraid_file) + sub_len + 1);
file->sub = file->sub_inline;
memcpy(file->sub, copy->sub, sub_len);
file->sub[sub_len] = 0;
file->size = copy->size; file->size = copy->size;
file->blockmax = copy->blockmax; file->blockmax = copy->blockmax;
file->mtime_sec = copy->mtime_sec; file->mtime_sec = copy->mtime_sec;
@ -539,7 +545,8 @@ void file_free(void* void_file)
{ {
struct snapraid_file* file = void_file; struct snapraid_file* file = void_file;
free(file->sub); if (file->sub != file->sub_inline)
free(file->sub);
file->sub = 0; file->sub = 0;
free(file->blockvec); free(file->blockvec);
file->blockvec = 0; file->blockvec = 0;
@ -548,7 +555,9 @@ void file_free(void* void_file)
void file_rename(struct snapraid_file* file, const char* sub) void file_rename(struct snapraid_file* file, const char* sub)
{ {
free(file->sub); if (file->sub != file->sub_inline)
free(file->sub);
file->sub = strdup_nofail(sub); file->sub = strdup_nofail(sub);
} }
@ -758,6 +767,7 @@ void extent_free(void* void_extent)
free(extent); free(extent);
} }
__aligned(32)
int extent_parity_compare(const void* void_a, const void* void_b) int extent_parity_compare(const void* void_a, const void* void_b)
{ {
const struct snapraid_extent* arg_a = void_a; const struct snapraid_extent* arg_a = void_a;
@ -771,6 +781,7 @@ int extent_parity_compare(const void* void_a, const void* void_b)
return 0; return 0;
} }
__aligned(32)
int extent_file_compare(const void* void_a, const void* void_b) int extent_file_compare(const void* void_a, const void* void_b)
{ {
const struct snapraid_extent* arg_a = void_a; const struct snapraid_extent* arg_a = void_a;
@ -792,13 +803,13 @@ int extent_file_compare(const void* void_a, const void* void_b)
return 0; return 0;
} }
struct snapraid_link* link_alloc(const char* sub, const char* linkto, unsigned link_flag) struct snapraid_link* link_alloc_len(const char* sub, size_t sub_len, const char* linkto, size_t linkto_len, unsigned link_flag)
{ {
struct snapraid_link* slink; struct snapraid_link* slink;
slink = malloc_nofail(sizeof(struct snapraid_link)); slink = malloc_nofail(sizeof(struct snapraid_link));
slink->sub = strdup_nofail(sub); slink->sub = strndup_nofail(sub, sub_len);
slink->linkto = strdup_nofail(linkto); slink->linkto = strndup_nofail(linkto, linkto_len);
slink->flag = link_flag; slink->flag = link_flag;
return slink; return slink;
@ -829,12 +840,12 @@ int link_alpha_compare(const void* void_a, const void* void_b)
return strcmp(slink_a->sub, slink_b->sub); return strcmp(slink_a->sub, slink_b->sub);
} }
struct snapraid_dir* dir_alloc(const char* sub) struct snapraid_dir* dir_alloc_len(const char* sub, size_t sub_len)
{ {
struct snapraid_dir* dir; struct snapraid_dir* dir;
dir = malloc_nofail(sizeof(struct snapraid_dir)); dir = malloc_nofail(sizeof(struct snapraid_dir));
dir->sub = strdup_nofail(sub); dir->sub = strndup_nofail(sub, sub_len);
dir->flag = 0; dir->flag = 0;
return dir; return dir;
@ -856,7 +867,7 @@ int dir_name_compare(const void* void_arg, const void* void_data)
return strcmp(arg, dir->sub); return strcmp(arg, dir->sub);
} }
struct snapraid_dealloc* dealloc_alloc(unsigned block_size, const char* sub, data_off_t size, int64_t mtime_sec, int32_t mtime_nsec) struct snapraid_dealloc* dealloc_alloc_len(unsigned block_size, const char* sub, size_t sub_len, data_off_t size, int64_t mtime_sec, int32_t mtime_nsec)
{ {
struct snapraid_dealloc* dealloc; struct snapraid_dealloc* dealloc;
block_off_t blockmax; block_off_t blockmax;
@ -875,7 +886,7 @@ struct snapraid_dealloc* dealloc_alloc(unsigned block_size, const char* sub, dat
} }
dealloc = malloc_nofail(sizeof(struct snapraid_dealloc) + blockmax * sizeof(struct snapraid_dealloc_block)); dealloc = malloc_nofail(sizeof(struct snapraid_dealloc) + blockmax * sizeof(struct snapraid_dealloc_block));
dealloc->sub = strdup_nofail(sub); dealloc->sub = strndup_nofail(sub, sub_len);
dealloc->size = size; dealloc->size = size;
dealloc->mtime_sec = mtime_sec; dealloc->mtime_sec = mtime_sec;
dealloc->mtime_nsec = mtime_nsec; dealloc->mtime_nsec = mtime_nsec;
@ -904,7 +915,7 @@ void dealloc_import(tommy_arrayblkof* infoarr, struct snapraid_disk* disk, struc
if (parity_pos == POS_NULL) { if (parity_pos == POS_NULL) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Internal inconsistency: Missing parity position for dealloc block %" PRIu64 "\n", i); log_fatal(EINTERNAL, "Internal inconsistency: Missing parity position for dealloc block %" PRIu64 "\n", i);
exit(EXIT_FAILURE); os_abort();
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
@ -920,7 +931,7 @@ void dealloc_import(tommy_arrayblkof* infoarr, struct snapraid_disk* disk, struc
default : default :
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Internal inconsistency: State for dealloc block %" PRIu64 " state %u\n", i, block_state); log_fatal(EINTERNAL, "Internal inconsistency: State for dealloc block %" PRIu64 " state %u\n", i, block_state);
exit(EXIT_FAILURE); os_abort();
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
} }
@ -1378,6 +1389,20 @@ static int extent_parity_inside_compare_unlock(const void* void_a, const void* v
return 0; return 0;
} }
struct snapraid_extent* fs_par2extent_find_next(struct snapraid_disk* disk, block_off_t parity_pos)
{
struct extent_parity_inside arg = { parity_pos };
struct snapraid_extent* extent;
fs_lock(disk);
/* non-overlapping extents let this search find the containing extent or the next one */
extent = tommy_tree_search_greater_equal_compare(&disk->fs_parity, extent_parity_inside_compare_unlock, &arg);
fs_unlock(disk);
return extent;
}
/** /**
* Search the extent at the specified parity position. * Search the extent at the specified parity position.
* The search is optimized for sequential accesses. * The search is optimized for sequential accesses.
@ -1579,8 +1604,8 @@ void fs_allocate(struct snapraid_disk* disk, block_off_t parity_pos, struct snap
extent = extent_alloc(parity_pos, file, file_pos, count); extent = extent_alloc(parity_pos, file, file_pos, count);
/* insert the extent in the trees */ /* insert the extent in the trees */
parity_extent = tommy_tree_insert(&disk->fs_parity, &extent->parity_node, extent); parity_extent = tommy_tree_insert_unique(&disk->fs_parity, &extent->parity_node, extent);
file_extent = tommy_tree_insert(&disk->fs_file, &extent->file_node, extent); file_extent = tommy_tree_insert_unique(&disk->fs_file, &extent->file_node, extent);
if (parity_extent != extent || file_extent != extent) { if (parity_extent != extent || file_extent != extent) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -1664,8 +1689,8 @@ void fs_deallocate(struct snapraid_disk* disk, block_off_t parity_pos)
second_extent = extent_alloc(extent->parity_pos + first_count + 1, extent->file, extent->file_pos + first_count + 1, second_count); second_extent = extent_alloc(extent->parity_pos + first_count + 1, extent->file, extent->file_pos + first_count + 1, second_count);
/* insert the extent in the trees */ /* insert the extent in the trees */
parity_extent = tommy_tree_insert(&disk->fs_parity, &second_extent->parity_node, second_extent); parity_extent = tommy_tree_insert_unique(&disk->fs_parity, &second_extent->parity_node, second_extent);
file_extent = tommy_tree_insert(&disk->fs_file, &second_extent->file_node, second_extent); file_extent = tommy_tree_insert_unique(&disk->fs_file, &second_extent->file_node, second_extent);
if (parity_extent != second_extent || file_extent != second_extent) { if (parity_extent != second_extent || file_extent != second_extent) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -1748,7 +1773,7 @@ void bucket_free(void* void_bucket)
void bucket_insert(tommy_hashdyn* bucket_hash, time_t time_at, block_off_t count, int justsynced) void bucket_insert(tommy_hashdyn* bucket_hash, time_t time_at, block_off_t count, int justsynced)
{ {
tommy_hash_t hash = tommy_inthash_u64(time_at); tommy_hash_t hash = bucket_time_hash(time_at);
tommy_node* i = tommy_hashdyn_bucket(bucket_hash, hash); tommy_node* i = tommy_hashdyn_bucket(bucket_hash, hash);
while (i) { while (i) {
struct snapraid_bucket* entry = i->data; struct snapraid_bucket* entry = i->data;

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2011 Andrea Mazzoleni // Copyright (C) 2011 Andrea Mazzoleni
#ifndef __ELEM_H #ifndef ELEM_H
#define __ELEM_H #define ELEM_H
#include "util.h" #include "util.h"
#include "support.h" #include "support.h"
@ -16,7 +16,7 @@
/****************************************************************************/ /****************************************************************************/
/* snapraid */ /* snapraid */
/* /**
* Maximum number of block positions in a data/parity disk span. * Maximum number of block positions in a data/parity disk span.
* *
* With the default 256 KiB block size, this limits the maximum supported * With the default 256 KiB block size, this limits the maximum supported
@ -341,6 +341,8 @@ struct snapraid_file {
tommy_hashdyn_node nodeset; tommy_hashdyn_node nodeset;
tommy_hashdyn_node pathset; tommy_hashdyn_node pathset;
tommy_hashdyn_node stampset; tommy_hashdyn_node stampset;
char sub_inline[]; /**< Inline storage for the initial sub path. */
}; };
/** /**
@ -413,7 +415,7 @@ struct snapraid_extra {
char name[PATH_MAX]; /**< Name of the disk. */ char name[PATH_MAX]; /**< Name of the disk. */
char dir[PATH_MAX]; /**< Mount point of the disk. It always terminates with /. */ char dir[PATH_MAX]; /**< Mount point of the disk. It always terminates with /. */
char smartctl[SMARTCTL_MAX]; /**< Custom option for smartctl. Empty means auto. */ char smartctl[SMARTCTL_MAX]; /**< Custom option for smartctl. Empty means auto. */
char smartctl_info[SMARTCTL_MAX]; /* Info options for smartctl. Empty means -a. */ char smartctl_info[SMARTCTL_MAX]; /**< Info options for smartctl. Empty means -a. */
struct smartignore_struct smartignore[SMART_IGNORE_MAX]; /**< Smart attributes to ignore for this device. */ struct smartignore_struct smartignore[SMART_IGNORE_MAX]; /**< Smart attributes to ignore for this device. */
char uuid[UUID_MAX]; /**< UUID of the disk. They are probed during the config reading. */ char uuid[UUID_MAX]; /**< UUID of the disk. They are probed during the config reading. */
char fstype[FSINFO_MAX]; /**< Filesystem type */ char fstype[FSINFO_MAX]; /**< Filesystem type */
@ -452,7 +454,7 @@ struct snapraid_disk {
struct fssnapshot_struct fss; struct fssnapshot_struct fss;
char smartctl[SMARTCTL_MAX]; /**< Custom option for smartctl. Empty means auto. */ char smartctl[SMARTCTL_MAX]; /**< Custom option for smartctl. Empty means auto. */
char smartctl_info[SMARTCTL_MAX]; /* Info options for smartctl. Empty means -a. */ char smartctl_info[SMARTCTL_MAX]; /**< Info options for smartctl. Empty means -a. */
struct smartignore_struct smartignore[SMART_IGNORE_MAX]; /**< Smart attributes to ignore for this device. */ struct smartignore_struct smartignore[SMART_IGNORE_MAX]; /**< Smart attributes to ignore for this device. */
char uuid[UUID_MAX]; /**< UUID of the disk. They are probed during the config reading. */ char uuid[UUID_MAX]; /**< UUID of the disk. They are probed during the config reading. */
char fstype[FSINFO_MAX]; /**< Filesystem type */ char fstype[FSINFO_MAX]; /**< Filesystem type */
@ -595,7 +597,7 @@ struct snapraid_parity {
struct snapraid_split split_map[SPLIT_MAX]; /**< Parity splits. */ struct snapraid_split split_map[SPLIT_MAX]; /**< Parity splits. */
unsigned split_mac; /**< Number of parity splits. */ unsigned split_mac; /**< Number of parity splits. */
char smartctl[SMARTCTL_MAX]; /**< Custom option for smartctl. Empty means auto. */ char smartctl[SMARTCTL_MAX]; /**< Custom option for smartctl. Empty means auto. */
char smartctl_info[SMARTCTL_MAX]; /* Info options for smartctl. Empty means -a. */ char smartctl_info[SMARTCTL_MAX]; /**< Info options for smartctl. Empty means -a. */
struct smartignore_struct smartignore[SMART_IGNORE_MAX]; /**< Smart attributes to ignore for this device. */ struct smartignore_struct smartignore[SMART_IGNORE_MAX]; /**< Smart attributes to ignore for this device. */
block_off_t total_blocks; /**< Number of total blocks. */ block_off_t total_blocks; /**< Number of total blocks. */
block_off_t free_blocks; /**< Number of free blocks at the last sync. */ block_off_t free_blocks; /**< Number of free blocks at the last sync. */
@ -908,7 +910,11 @@ static inline void file_flag_clear(struct snapraid_file* file, unsigned mask)
/** /**
* Allocate a file without initializing its blocks. * Allocate a file without initializing its blocks.
*/ */
struct snapraid_file* file_alloc(unsigned block_size, const char* sub, data_off_t size, uint64_t mtime_sec, int mtime_nsec, uint64_t inode); struct snapraid_file* file_alloc_len(unsigned block_size, const char* sub, size_t sub_len, data_off_t size, uint64_t mtime_sec, int mtime_nsec, uint64_t inode);
static inline struct snapraid_file* file_alloc(unsigned block_size, const char* sub, data_off_t size, uint64_t mtime_sec, int mtime_nsec, uint64_t inode)
{
return file_alloc_len(block_size, sub, strlen(sub), size, mtime_sec, mtime_nsec, inode);
}
/** /**
* Duplicate a file. * Duplicate a file.
@ -976,9 +982,14 @@ int file_path_compare(const void* void_a, const void* void_b);
/** /**
* Compute the hash of a file inode. * Compute the hash of a file inode.
*/ */
static inline tommy_uint32_t file_inode_hash(uint64_t inode) static inline tommy_hash_t file_inode_hash(uint64_t inode)
{ {
return (tommy_uint32_t)tommy_inthash_u64(inode); #if TOMMY_SIZE_BIT == 64
return tommy_mulhash_u64(inode);
#else
/* avoid expensive 64-bit multiplications on 32-bit architectures */
return tommy_inthash_u64(inode);
#endif
} }
/** /**
@ -994,20 +1005,46 @@ int file_stamp_compare(const void* void_a, const void* void_b);
int file_namestamp_compare(const void* void_a, const void* void_b); int file_namestamp_compare(const void* void_a, const void* void_b);
int file_pathstamp_compare(const void* void_a, const void* void_b); int file_pathstamp_compare(const void* void_a, const void* void_b);
/**
* Compute the hash of a file path with known length.
*/
static inline tommy_hash_t file_path_hash_len(const char* sub, size_t len)
{
#if TOMMY_SIZE_BIT == 64
return tommy_hash_u64(0, sub, len);
#else
return tommy_hash_u32(0, sub, len);
#endif
}
/** /**
* Compute the hash of a file path. * Compute the hash of a file path.
*/ */
static inline tommy_uint32_t file_path_hash(const char* sub) static inline tommy_hash_t file_path_hash(const char* sub)
{ {
return tommy_hash_u32(0, sub, strlen(sub)); return file_path_hash_len(sub, strlen(sub));
} }
/** /**
* Compute the hash of a file stamp. * Compute the hash of a file stamp.
*/ */
static inline tommy_uint32_t file_stamp_hash(data_off_t size, int64_t mtime_sec, int mtime_nsec) static inline tommy_hash_t file_stamp_hash(data_off_t size, int64_t mtime_sec, int mtime_nsec)
{ {
return tommy_inthash_u32((tommy_uint32_t)size ^ tommy_inthash_u32((tommy_uint32_t)mtime_sec ^ tommy_inthash_u32(mtime_nsec))); tommy_uint32_t nsec = mtime_nsec;
#if TOMMY_SIZE_BIT == 64
tommy_uint64_t size_key = size;
tommy_uint64_t sec_key = mtime_sec;
tommy_uint64_t nsec_key = nsec;
/* valid nanoseconds use 30 bits above contemporary seconds; -1 stays distinct */
return tommy_mulhash_u64(size_key ^ tommy_mulhash_u64(sec_key ^ (nsec_key << 34)));
#else
tommy_uint32_t size_key = size;
tommy_uint32_t sec_key = mtime_sec;
return tommy_mulhash_u32(size_key ^ tommy_mulhash_u32(sec_key) ^ tommy_mulhash_u32(nsec));
#endif
} }
/** /**
@ -1059,7 +1096,11 @@ static inline unsigned link_flag_get(struct snapraid_link* slink, unsigned mask)
/** /**
* Allocate a link. * Allocate a link.
*/ */
struct snapraid_link* link_alloc(const char* name, const char* slink, unsigned link_flag); struct snapraid_link* link_alloc_len(const char* name, size_t name_len, const char* slink, size_t slink_len, unsigned link_flag);
static inline struct snapraid_link* link_alloc(const char* name, const char* slink, unsigned link_flag)
{
return link_alloc_len(name, strlen(name), slink, strlen(slink), link_flag);
}
/** /**
* Deallocate a link. * Deallocate a link.
@ -1076,12 +1117,24 @@ int link_name_compare_to_arg(const void* void_arg, const void* void_data);
*/ */
int link_alpha_compare(const void* void_a, const void* void_b); int link_alpha_compare(const void* void_a, const void* void_b);
/**
* Compute the hash of a link name with known length.
*/
static inline tommy_hash_t link_name_hash_len(const char* name, size_t len)
{
#if TOMMY_SIZE_BIT == 64
return tommy_hash_u64(0, name, len);
#else
return tommy_hash_u32(0, name, len);
#endif
}
/** /**
* Compute the hash of a link name. * Compute the hash of a link name.
*/ */
static inline tommy_uint32_t link_name_hash(const char* name) static inline tommy_hash_t link_name_hash(const char* name)
{ {
return tommy_hash_u32(0, name, strlen(name)); return link_name_hash_len(name, strlen(name));
} }
static inline int dir_flag_has(const struct snapraid_dir* dir, unsigned mask) static inline int dir_flag_has(const struct snapraid_dir* dir, unsigned mask)
@ -1102,7 +1155,11 @@ static inline void dir_flag_clear(struct snapraid_dir* dir, unsigned mask)
/** /**
* Allocate a dir. * Allocate a dir.
*/ */
struct snapraid_dir* dir_alloc(const char* name); struct snapraid_dir* dir_alloc_len(const char* name, size_t name_len);
static inline struct snapraid_dir* dir_alloc(const char* name)
{
return dir_alloc_len(name, strlen(name));
}
/** /**
* Deallocate a dir. * Deallocate a dir.
@ -1114,18 +1171,34 @@ void dir_free(void* void_dir);
*/ */
int dir_name_compare(const void* void_arg, const void* void_data); int dir_name_compare(const void* void_arg, const void* void_data);
/**
* Compute the hash of a dir name with known length.
*/
static inline tommy_hash_t dir_name_hash_len(const char* name, size_t len)
{
#if TOMMY_SIZE_BIT == 64
return tommy_hash_u64(0, name, len);
#else
return tommy_hash_u32(0, name, len);
#endif
}
/** /**
* Compute the hash of a dir name. * Compute the hash of a dir name.
*/ */
static inline tommy_uint32_t dir_name_hash(const char* name) static inline tommy_hash_t dir_name_hash(const char* name)
{ {
return tommy_hash_u32(0, name, strlen(name)); return dir_name_hash_len(name, strlen(name));
} }
/** /**
* Allocate a dealloc. * Allocate a dealloc.
*/ */
struct snapraid_dealloc* dealloc_alloc(unsigned block_size, const char* sub, data_off_t size, int64_t mtime_sec, int32_t mtime_nsec); struct snapraid_dealloc* dealloc_alloc_len(unsigned block_size, const char* sub, size_t sub_len, data_off_t size, int64_t mtime_sec, int32_t mtime_nsec);
static inline struct snapraid_dealloc* dealloc_alloc(unsigned block_size, const char* sub, data_off_t size, int64_t mtime_sec, int32_t mtime_nsec)
{
return dealloc_alloc_len(block_size, sub, strlen(sub), size, mtime_sec, mtime_nsec);
}
/** /**
* Deallocate a dealloc. * Deallocate a dealloc.
@ -1201,6 +1274,13 @@ void fs_deallocate(struct snapraid_disk* disk, block_off_t pos);
*/ */
struct snapraid_block* fs_file2block_get(struct snapraid_file* file, block_off_t file_pos); struct snapraid_block* fs_file2block_get(struct snapraid_file* file, block_off_t file_pos);
/**
* Find the first extent ending after the specified parity position.
* Return 0 if no such extent exists. The caller must ensure that the extent
* trees remain unchanged while using the returned extent or its tree node.
*/
struct snapraid_extent* fs_par2extent_find_next(struct snapraid_disk* disk, block_off_t parity_pos);
/** /**
* Get the file position from the parity position. * Get the file position from the parity position.
* Return 0 if no file is using it. * Return 0 if no file is using it.
@ -1410,6 +1490,7 @@ static inline snapraid_info info_get(tommy_arrayblkof* array, block_off_t pos)
* Grow the array once and process each internal block directly, avoiding the * Grow the array once and process each internal block directly, avoiding the
* per-position grow and lookup performed by info_set(). * per-position grow and lookup performed by info_set().
*/ */
__aligned_loops(64)
static inline void info_set_run(tommy_arrayblkof* array, block_off_t pos, block_off_t count, snapraid_info info) static inline void info_set_run(tommy_arrayblkof* array, block_off_t pos, block_off_t count, snapraid_info info)
{ {
tommy_arrayblkof_grow(array, pos + count); tommy_arrayblkof_grow(array, pos + count);
@ -1490,6 +1571,19 @@ struct snapraid_bucket {
void bucket_free(void* void_bucket); void bucket_free(void* void_bucket);
/**
* Compute the hash of a bucket time.
*/
static inline tommy_hash_t bucket_time_hash(time_t time_at)
{
#if TOMMY_SIZE_BIT == 64
return tommy_mulhash_u64(time_at);
#else
/* avoid expensive 64-bit multiplications on 32-bit architectures */
return tommy_inthash_u64(time_at);
#endif
}
/** /**
* Insert an bucket record into the hashtable * Insert an bucket record into the hashtable
*/ */

View file

@ -113,7 +113,7 @@ int handle_open_create(struct snapraid_handle* handle, struct snapraid_file* fil
* If creation was not requested, a missing file is an expected condition, * If creation was not requested, a missing file is an expected condition,
* not a fatal error. * not a fatal error.
*/ */
if (create || errno != ENOENT) { if (create || (errno != ENOENT && errno != ENOTDIR)) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(errno, "Error opening file '%s'. %s.\n", handle->path, strerror(errno)); log_fatal(errno, "Error opening file '%s'. %s.\n", handle->path, strerror(errno));
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2011 Andrea Mazzoleni // Copyright (C) 2011 Andrea Mazzoleni
#ifndef __HANDLE_H #ifndef HANDLE_H
#define __HANDLE_H #define HANDLE_H
#include "state.h" #include "state.h"
#include "support.h" #include "support.h"

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2013 Andrea Mazzoleni // Copyright (C) 2013 Andrea Mazzoleni
#ifndef __IMPORT_H #ifndef IMPORT_H
#define __IMPORT_H #define IMPORT_H
#include "elem.h" #include "elem.h"
#include "state.h" #include "state.h"

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2016 Andrea Mazzoleni // Copyright (C) 2016 Andrea Mazzoleni
#ifndef __IO_H #ifndef IO_H
#define __IO_H #define IO_H
#include "state.h" #include "state.h"
#include "support.h" #include "support.h"

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2026 Andrea Mazzoleni // Copyright (C) 2026 Andrea Mazzoleni
#ifndef __LOCATE_H #ifndef LOCATE_H
#define __LOCATE_H #define LOCATE_H
/****************************************************************************/ /****************************************************************************/
/* snapraid */ /* snapraid */

View file

@ -63,7 +63,7 @@ static int needs_quote(const WCHAR* arg)
cmd[pos++] = (c); \ cmd[pos++] = (c); \
} while (0) } while (0)
/* /**
* Append one argument using the Microsoft C runtime command-line * Append one argument using the Microsoft C runtime command-line
* quoting rules. Use this when building a normal CreateProcessW() * quoting rules. Use this when building a normal CreateProcessW()
* command line that the target process will parse back into argv[]. * command line that the target process will parse back into argv[].
@ -146,10 +146,10 @@ static char* argutf8(const WCHAR* arg)
return utf8_arg; return utf8_arg;
} }
/* Global variable to store child process handle */ /* global variable to store child process handle */
static void* volatile child_process = NULL; static void* volatile child_process = NULL;
/* /**
* Safe atomic access helpers for child_process. * Safe atomic access helpers for child_process.
* *
* The console_handler runs concurrently on an OS-managed thread created by * The console_handler runs concurrently on an OS-managed thread created by
@ -169,7 +169,7 @@ static void child_process_write(HANDLE handle)
InterlockedExchangePointer(&child_process, handle); InterlockedExchangePointer(&child_process, handle);
} }
/* Console control handler - forwards Ctrl+C, Ctrl+Break to child */ /* console control handler - forwards Ctrl+C, Ctrl+Break to child */
static BOOL WINAPI console_handler(DWORD ctrl_type) static BOOL WINAPI console_handler(DWORD ctrl_type)
{ {
/* if no child, default behavior */ /* if no child, default behavior */

View file

@ -14,28 +14,45 @@
*/ */
static size_t mcounter; static size_t mcounter;
#if HAVE_THREAD
static int memory_is_single_thread;
void memory_single_thread(int single_thread)
{
memory_is_single_thread = single_thread;
}
static inline void malloc_counter_inc(size_t inc)
{
if (tommy_likely(memory_is_single_thread))
mcounter += inc;
else
__atomic_fetch_add(&mcounter, inc, __ATOMIC_RELAXED);
}
size_t malloc_counter_get(void) size_t malloc_counter_get(void)
{ {
size_t ret; if (tommy_likely(memory_is_single_thread))
return mcounter;
lock_memory(); return __atomic_load_n(&mcounter, __ATOMIC_RELAXED);
ret = mcounter;
unlock_memory();
return ret;
} }
#else
static void malloc_counter_inc(size_t inc) void memory_single_thread(int single_thread)
{ {
lock_memory(); (void)single_thread;
mcounter += inc;
unlock_memory();
} }
static inline void malloc_counter_inc(size_t inc)
{
mcounter += inc;
}
size_t malloc_counter_get(void)
{
return mcounter;
}
#endif
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
static ssize_t malloc_print(int f, const char* str) static ssize_t malloc_print(int f, const char* str)
{ {
@ -97,23 +114,28 @@ void* malloc_nofail(size_t size)
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
#ifndef CHECKER /* Don't preinitialize when running for valgrind */
/*
* Here we preinitialize the memory to ensure that the OS is really allocating it
* and not only reserving the addressable space.
* Otherwise we are risking that the OOM (Out Of Memory) killer in Linux will kill the process.
* Filling the memory doesn't ensure to disable OOM, but it increase a lot the chances to
* get a real error from malloc() instead than a process killed.
* Note that calloc() doesn't have the same effect.
*/
memset(ptr, 0xA5, size);
#endif
malloc_counter_inc(size); malloc_counter_inc(size);
return ptr; return ptr;
} }
void* realloc_nofail(void* ptr, size_t size)
{
/* keep zero-size requests allocated, as in malloc_nofail() */
void* new_ptr = realloc(ptr, size ? size : 1);
if (!new_ptr) {
/* LCOV_EXCL_START */
malloc_fail(size);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
malloc_counter_inc(size);
return new_ptr;
}
void* nalloc_nofail(size_t count, size_t size) void* nalloc_nofail(size_t count, size_t size)
{ {
if (size != 0 && count > SIZE_MAX / size) { if (size != 0 && count > SIZE_MAX / size) {
@ -123,7 +145,6 @@ void* nalloc_nofail(size_t count, size_t size)
size *= count; size *= count;
/* see the note in malloc_nofail() of why we don't use calloc() */
void* ptr = malloc(size ? size : 1); void* ptr = malloc(size ? size : 1);
if (!ptr) { if (!ptr) {
@ -140,9 +161,21 @@ void* nalloc_nofail(size_t count, size_t size)
void* calloc_nofail(size_t count, size_t size) void* calloc_nofail(size_t count, size_t size)
{ {
void* ptr = nalloc_nofail(count, size); if (size != 0 && count > SIZE_MAX / size) {
log_fatal(EINTERNAL, "Allocation size overflow\n");
os_abort();
}
memset(ptr, 0, count * size); void* ptr = calloc(count ? count : 1, size ? size : 1);
if (!ptr) {
/* LCOV_EXCL_START */
malloc_fail(count * size);
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
malloc_counter_inc(count * size);
return ptr; return ptr;
} }
@ -158,3 +191,13 @@ char* strdup_nofail(const char* str)
return ptr; return ptr;
} }
char* strndup_nofail(const char* str, size_t size)
{
char* ptr = malloc_nofail(size + 1);
memcpy(ptr, str, size);
ptr[size] = 0;
return ptr;
}

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2011 Andrea Mazzoleni // Copyright (C) 2011 Andrea Mazzoleni
#ifndef __MEMORY_H #ifndef MEMORY_H
#define __MEMORY_H #define MEMORY_H
/****************************************************************************/ /****************************************************************************/
/* memory */ /* memory */
@ -12,12 +12,23 @@
*/ */
size_t malloc_counter_get(void); size_t malloc_counter_get(void);
/**
* Enable or disable single-thread mode for memory counters.
*/
void memory_single_thread(int single_thread);
/** /**
* Safe malloc. * Safe malloc.
* If no memory is available, it aborts. * If no memory is available, it aborts.
*/ */
void* malloc_nofail(size_t size); void* malloc_nofail(size_t size);
/**
* Safe realloc.
* If no memory is available, it aborts.
*/
void* realloc_nofail(void* ptr, size_t size);
/** /**
* Safe malloc with calloc calling arguments. * Safe malloc with calloc calling arguments.
* If no memory is available, it aborts. * If no memory is available, it aborts.
@ -36,6 +47,12 @@ void* calloc_nofail(size_t count, size_t size);
*/ */
char* strdup_nofail(const char* str); char* strdup_nofail(const char* str);
/**
* Safe strndup with known length.
* If no memory is available, it aborts.
*/
char* strndup_nofail(const char* str, size_t size);
/** /**
* Helper for printing an error about a failed allocation. * Helper for printing an error about a failed allocation.
*/ */

View file

@ -3,7 +3,7 @@
#include "os/portable.h" #include "os/portable.h"
#ifdef __MINGW32__ /* Only for MingW */ #ifdef __MINGW32__ /* only for MingW */
#include "support.h" #include "support.h"
#include "raid/cpu.h" #include "raid/cpu.h"
@ -82,7 +82,7 @@ int fsinfo(const char* path, int* has_persistent_inode, int* has_syncronized_har
if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) { if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) {
char* slash = strrchr(dir, '/'); char* slash = strrchr(dir, '/');
/** /*
* Cut the file name, but leave the last slash. * Cut the file name, but leave the last slash.
* *
* This is done because a MSDN comment about using of UNC paths. * This is done because a MSDN comment about using of UNC paths.
@ -135,7 +135,7 @@ int fsinfo(const char* path, int* has_persistent_inode, int* has_syncronized_har
if (has_persistent_inode) { if (has_persistent_inode) {
*has_persistent_inode = 0; *has_persistent_inode = 0;
/** /*
* Reuse stored file IDs across scans only for filesystems known to * Reuse stored file IDs across scans only for filesystems known to
* provide stable and unique IDs. An unknown or unavailable filesystem * provide stable and unique IDs. An unknown or unavailable filesystem
* must be treated as volatile: a false negative only loses inode-based * must be treated as volatile: a false negative only loses inode-based
@ -250,7 +250,7 @@ static int base64_encode(const unsigned char* in, size_t in_len, char* out, size
return 0; return 0;
} }
/* /**
* PowerShell helper * PowerShell helper
* *
* Runs a PowerShell one-liner via os_spawn() and captures the first line * Runs a PowerShell one-liner via os_spawn() and captures the first line
@ -2411,7 +2411,7 @@ void machineinfo(struct machineinfo_struct* info)
info->memory_page_size = si.dwPageSize; info->memory_page_size = si.dwPageSize;
info->cpu_cores_logical = GetActiveProcessorCount(ALL_PROCESSOR_GROUPS); info->cpu_cores_logical = GetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
/* Query processor topology and cache hierarchy via GetLogicalProcessorInformationEx */ /* query processor topology and cache hierarchy via GetLogicalProcessorInformationEx */
DWORD len = 0; DWORD len = 0;
GetLogicalProcessorInformationEx(RelationAll, 0, &len); GetLogicalProcessorInformationEx(RelationAll, 0, &len);
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER && len > 0) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER && len > 0) {

View file

@ -144,7 +144,7 @@ void test(int advise_mode)
char copy[STR_MAX]; char copy[STR_MAX];
memset(str, ' ' + j, j - 1); memset(str, ' ' + j, j - 1);
str[j - 1] = 0; str[j - 1] = 0;
if (sgetbs(s, copy, sizeof(copy)) != 0 || strcmp(copy, str) != 0) { if (sgetbs(s, copy, sizeof(copy)) != (ssize_t)(j - 1) || strcmp(copy, str) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */

View file

@ -14,7 +14,7 @@
// MurmurHash3 was written by Austin Appleby, and is placed in the public // MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code. // domain. The author hereby disclaims copyright to this source code.
/* Finalization mix - force all bits of a hash block to avalanche */ /* finalization mix - force all bits of a hash block to avalanche */
static inline uint32_t fmix32(uint32_t h) static inline uint32_t fmix32(uint32_t h)
{ {
h ^= h >> 16; h ^= h >> 16;
@ -25,43 +25,17 @@ static inline uint32_t fmix32(uint32_t h)
return h; return h;
} }
/* /**
* Warning! * Non-static variables are intentionally used instead of static const
* Don't declare these variables static, otherwise the gcc optimizer * because keeping these constants in CPU registers yields measurably
* may generate very slow code for multiplication with these constants, * higher throughput than using 32-bit immediate constants in imul.
* like:
-> .cpp
k1 *= c1;
-> .asm
152: 8d 14 80 lea (%eax,%eax,4),%edx
155: 8d 14 90 lea (%eax,%edx,4),%edx
158: c1 e2 03 shl $0x3,%edx
15b: 29 c2 sub %eax,%edx
15d: 8d 14 d2 lea (%edx,%edx,8),%edx
160: 8d 14 90 lea (%eax,%edx,4),%edx
163: 8d 14 d0 lea (%eax,%edx,8),%edx
166: 8d 14 90 lea (%eax,%edx,4),%edx
169: 8d 14 50 lea (%eax,%edx,2),%edx
16c: 8d 14 90 lea (%eax,%edx,4),%edx
16f: 8d 14 92 lea (%edx,%edx,4),%edx
172: 8d 14 50 lea (%eax,%edx,2),%edx
175: 8d 04 d0 lea (%eax,%edx,8),%eax
178: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
17f: 29 d0 sub %edx,%eax
* resulting in speeds of 500 MB/s instead of 3000 MB/s.
*
* Verified with gcc 4.4.4 compiling with :
*
* g++ -g -c -O2 MurmurHash3.cpp -o MurmurHash3.o
*/ */
uint32_t c1 = 0x239b961b; uint32_t c1 = 0x239b961b;
uint32_t c2 = 0xab0e9789; uint32_t c2 = 0xab0e9789;
uint32_t c3 = 0x38b34ae5; uint32_t c3 = 0x38b34ae5;
uint32_t c4 = 0xa1e38b93; uint32_t c4 = 0xa1e38b93;
void MurmurHash3_x86_128(const void* data, size_t size, const uint8_t* seed, void* digest) static void MurmurHash3_x86_128(const void* data, size_t size, const uint8_t* seed, void* digest)
{ {
const uint8_t* p; const uint8_t* p;
const uint8_t* end; const uint8_t* end;
@ -77,6 +51,11 @@ void MurmurHash3_x86_128(const void* data, size_t size, const uint8_t* seed, voi
end = p + (size & ~15); end = p + (size & ~15);
/* body */ /* body */
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC unroll 8
#elif defined(__clang__)
#pragma unroll 8
#endif
while (p < end) { while (p < end) {
uint32_t k1 = util_read32(p + 0); uint32_t k1 = util_read32(p + 0);
uint32_t k2 = util_read32(p + 4); uint32_t k2 = util_read32(p + 4);

View file

@ -20,7 +20,7 @@
* of this license, visit: https://creativecommons.org/publicdomain/zero/1.0/ * of this license, visit: https://creativecommons.org/publicdomain/zero/1.0/
*/ */
/* /**
* Analysis of the BFast variant and blinding multiplication * Analysis of the BFast variant and blinding multiplication
* *
* Many fast non-cryptographic hashes (wyhash, rapidhash) use "folding * Many fast non-cryptographic hashes (wyhash, rapidhash) use "folding
@ -150,7 +150,7 @@ static const uint64_t MUSEAIR_CONSTANT[13] = {
do { \ do { \
l = a; \ l = a; \
h = b; \ h = b; \
util_mum(&l, &h); \ tommy_mum(&l, &h); \
} while (0) } while (0)
#define likely(a) tommy_likely(a) #define likely(a) tommy_likely(a)
@ -190,6 +190,11 @@ static void MuseAirLoong(const void* bytes, size_t len, const uint8_t* seed, uin
state[5] ^= seed_b & MASK_K; state[5] ^= seed_b & MASK_K;
if (unlikely(q > u64x(12))) { if (unlikely(q > u64x(12))) {
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC unroll 2
#elif defined(__clang__)
#pragma unroll 2
#endif
do { do {
state[0] ^= util_read64(p + u64x(0)); state[0] ^= util_read64(p + u64x(0));
state[1] ^= util_read64(p + u64x(1)); state[1] ^= util_read64(p + u64x(1));

View file

@ -220,7 +220,7 @@ int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_p
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/** /*
* If the parity size is not yet set, set it now. * If the parity size is not yet set, set it now.
* This happens when adding a new parity level or split that has * This happens when adding a new parity level or split that has
* no persisted size yet. * no persisted size yet.
@ -625,7 +625,7 @@ int parity_restore(struct snapraid_parity_handle* handle, data_off_t size, uint3
if ((run & block_mask) != 0) { if ((run & block_mask) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
errno = ENXIO; errno = ENXIO;
log_fatal(EINTERNAL, "Internal inconsistency in split '%s' size with extra '%" PRIu64 "' bytes.\n", split->path, run & block_mask); log_fatal(EINTERNAL, "Split '%s' size with extra '%" PRIu64 "' bytes.\n", split->path, run & block_mask);
return -1; return -1;
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
@ -731,7 +731,7 @@ int parity_chsize(struct snapraid_parity_handle* handle, struct snapraid_parity*
if ((run & block_mask) != 0) { if ((run & block_mask) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
errno = ENXIO; errno = ENXIO;
log_fatal(EINTERNAL, "Internal inconsistency in split '%s' size with extra '%" PRIu64 "' bytes.\n", split->path, run & block_mask); log_fatal(EINTERNAL, "Split '%s' size with extra '%" PRIu64 "' bytes.\n", split->path, run & block_mask);
return -1; return -1;
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
@ -884,7 +884,7 @@ int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_par
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/** /*
* If the parity size is not yet set, set it now. * If the parity size is not yet set, set it now.
* This happens when adding a new parity level or split that has * This happens when adding a new parity level or split that has
* no persisted size yet. * no persisted size yet.

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2011 Andrea Mazzoleni // Copyright (C) 2011 Andrea Mazzoleni
#ifndef __PARITY_H #ifndef PARITY_H
#define __PARITY_H #define PARITY_H
#include "support.h" #include "support.h"
#include "bw.h" #include "bw.h"

View file

@ -30,9 +30,13 @@ struct snapraid_pool* pool_alloc(const char* dir, const char* name, const char*
return pool; return pool;
} }
static inline tommy_uint32_t pool_hash(const char* file) static inline tommy_hash_t pool_hash(const char* file)
{ {
#if TOMMY_SIZE_BIT == 64
return tommy_hash_u64(0, file, strlen(file));
#else
return tommy_hash_u32(0, file, strlen(file)); return tommy_hash_u32(0, file, strlen(file));
#endif
} }
static void pool_free(void* void_pool) static void pool_free(void* void_pool)

View file

@ -20,8 +20,8 @@ static const char* es(int err)
* If the file metadata (size and timestamp) is known to be synchronized with disk. * If the file metadata (size and timestamp) is known to be synchronized with disk.
* *
* Always set on POSIX where stat()/lstat() returns coherent metadata. On Windows NTFS, * Always set on POSIX where stat()/lstat() returns coherent metadata. On Windows NTFS,
* directory enumeration may return stale size/mtime for hardlinks until synchronized * directory enumeration may return stale size/mtime for open/modified files and hardlinks
* via lstat_sync() (GetFileInformationByHandle). * until synchronized via lstat_sync() (GetFileInformationByHandle).
*/ */
#define DISCOVERY_IS_SCAN_SYNCED 0x1 #define DISCOVERY_IS_SCAN_SYNCED 0x1
@ -1021,7 +1021,7 @@ static void scan_file_apply(void* void_scan, void* void_disc)
* in such case we have a "copy" over an "update" * in such case we have a "copy" over an "update"
*/ */
if (!state->opt.force_nocopy) { if (!state->opt.force_nocopy) {
tommy_uint32_t hash = file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec); tommy_hash_t hash = file_stamp_hash(file->size, file->mtime_sec, file->mtime_nsec);
/* search for a file with the same name and stamp in all the disks */ /* search for a file with the same name and stamp in all the disks */
for (i = state->disklist; i != 0; i = i->next) { for (i = state->disklist; i != 0; i = i->next) {
@ -1153,7 +1153,7 @@ static void scan_file_discover(struct snapraid_scan* scan, const char* sub, stru
disc = discovery_alloc(sub, st); disc = discovery_alloc(sub, st);
/* Hardlink collision detection */ /* hardlink collision detection */
if (disc->inode != INODE_INVALID) { if (disc->inode != INODE_INVALID) {
struct snapraid_discovery* rep = tommy_hashdyn_search(&scan->file_discovery_inodeset, discovery_inode_compare_to_arg, &disc->inode, file_inode_hash(disc->inode)); struct snapraid_discovery* rep = tommy_hashdyn_search(&scan->file_discovery_inodeset, discovery_inode_compare_to_arg, &disc->inode, file_inode_hash(disc->inode));
if (!rep) { if (!rep) {
@ -1161,7 +1161,7 @@ static void scan_file_discover(struct snapraid_scan* scan, const char* sub, stru
disc->flag |= DISCOVERY_IS_CANONICAL; disc->flag |= DISCOVERY_IS_CANONICAL;
tommy_hashdyn_insert(&scan->file_discovery_inodeset, &disc->nodeset, disc, file_inode_hash(disc->inode)); tommy_hashdyn_insert(&scan->file_discovery_inodeset, &disc->nodeset, disc, file_inode_hash(disc->inode));
} else { } else {
/* Inode collision detected! */ /* inode collision detected! */
#if HAVE_LSTAT_SYNC #if HAVE_LSTAT_SYNC
if (disk->has_volatile_hardlinks && !(rep->flag & DISCOVERY_IS_SCAN_SYNCED)) { if (disk->has_volatile_hardlinks && !(rep->flag & DISCOVERY_IS_SCAN_SYNCED)) {
char path_next[PATH_MAX]; char path_next[PATH_MAX];
@ -1655,13 +1655,24 @@ static int scan_sub(struct snapraid_scan* scan, int level, int is_diff, char* pa
if (!st) if (!st)
st = DSTAT(path_next, dd, &st_buf); st = DSTAT(path_next, dd, &st_buf);
existing = tommy_hashdyn_search(&disk->pathset, file_path_compare_to_arg, sub_next, file_path_hash(sub_next));
if (existing)
file_flag_set(existing, FILE_IS_DISCOVERED);
#if HAVE_LSTAT_SYNC #if HAVE_LSTAT_SYNC
/* /*
* In Windows fast directory enumeration, st_ino may be missing (0). * In Windows fast directory enumeration, st_ino may be missing (0).
* Only st_ino is required for file identity and hardlink tracking; * In addition, directory enumeration may report stale size and mtime
* we call lstat_sync() only when st_ino is missing to avoid expensive file opens. * for files currently open or being written to.
* Refresh via lstat_sync() if st_ino is missing, or if the metadata
* is not synchronized and the file is new or modified.
*/ */
if (st->st_ino == INODE_INVALID) { if (st->st_ino == INODE_INVALID
|| (st->st_sync == 0
&& (!existing
|| existing->size != st->st_size
|| existing->mtime_sec != st->st_mtime
|| existing->mtime_nsec != STAT_NSEC(st)))) {
if (lstat_sync(path_next, st, 0) != 0) { if (lstat_sync(path_next, st, 0) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_tag("%s:%u:%s:%s: Stat error. %s.\n", es(errno), 0, disk->name, esc_tag(path_next), strerror(errno)); log_tag("%s:%u:%s:%s: Stat error. %s.\n", es(errno), 0, disk->name, esc_tag(path_next), strerror(errno));
@ -1672,10 +1683,6 @@ static int scan_sub(struct snapraid_scan* scan, int level, int is_diff, char* pa
} }
#endif #endif
existing = tommy_hashdyn_search(&disk->pathset, file_path_compare_to_arg, sub_next, file_path_hash(sub_next));
if (existing)
file_flag_set(existing, FILE_IS_DISCOVERED);
scan_file_discover(scan, sub_next, st); scan_file_discover(scan, sub_next, st);
processed = 1; processed = 1;
} else { } else {
@ -1937,8 +1944,8 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
* - Each disk is read only by its scan thread, enumerating files and populating * - Each disk is read only by its scan thread, enumerating files and populating
* file_discovery_list without observable SnapRAID classification side effects. * file_discovery_list without observable SnapRAID classification side effects.
* - No old file, link, directory, or parity allocation is removed. * - No old file, link, directory, or parity allocation is removed.
* - Inode collisions on volatile-hardlink filesystems trigger selective lstat_sync() * - New/modified files and inode collisions on volatile filesystems trigger selective
* to normalize authoritative metadata across hardlink groups before Apply. * lstat_sync() to obtain authoritative metadata before Apply.
*/ */
for (i = scanlist; i != 0; i = i->next) { for (i = scanlist; i != 0; i = i->next) {
struct snapraid_scan* scan = i->data; struct snapraid_scan* scan = i->data;

View file

@ -11,7 +11,7 @@
#include "io.h" #include "io.h"
#include "raid/raid.h" #include "raid/raid.h"
/* /**
* SnapRAID scrub model * SnapRAID scrub model
* *
* Scrub periodically verifies data and parity without modifying either of * Scrub periodically verifies data and parity without modifying either of

View file

@ -22,7 +22,7 @@ static const char* es(int err)
static void search_file(struct snapraid_state* state, const char* path, data_off_t size, int64_t mtime_sec, int mtime_nsec) static void search_file(struct snapraid_state* state, const char* path, data_off_t size, int64_t mtime_sec, int mtime_nsec)
{ {
struct snapraid_search_file* file; struct snapraid_search_file* file;
tommy_uint32_t file_hash; tommy_hash_t file_hash;
file = malloc_nofail(sizeof(struct snapraid_search_file)); file = malloc_nofail(sizeof(struct snapraid_search_file));
file->path = strdup_nofail(path); file->path = strdup_nofail(path);
@ -133,7 +133,7 @@ int search_file_compare(const void* void_arg, const void* void_data)
int state_search_fetch(struct snapraid_state* state, int prevhash, struct snapraid_file* missing_file, block_off_t missing_file_pos, struct snapraid_block* missing_block, unsigned char* buffer) int state_search_fetch(struct snapraid_state* state, int prevhash, struct snapraid_file* missing_file, block_off_t missing_file_pos, struct snapraid_block* missing_block, unsigned char* buffer)
{ {
struct snapraid_search_file* file; struct snapraid_search_file* file;
tommy_uint32_t file_hash; tommy_hash_t file_hash;
struct search_file_compare_arg arg; struct search_file_compare_arg arg;
arg.state = state; arg.state = state;

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2014 Andrea Mazzoleni // Copyright (C) 2014 Andrea Mazzoleni
#ifndef __SEARCH_H #ifndef SEARCH_H
#define __SEARCH_H #define SEARCH_H
#include "elem.h" #include "elem.h"
#include "state.h" #include "state.h"

View file

@ -51,25 +51,25 @@ struct hash_test_vector {
* Test vectors for tommy_hash32 * Test vectors for tommy_hash32
*/ */
static struct hash32_test_vector TEST_HASH32[] = { static struct hash32_test_vector TEST_HASH32[] = {
{ "", 0, 0x8614384c, 0xa766795d }, { "", 0, 0xaffe48d7, 0xa766795d },
{ "a", 1, 0x12c16c36, 0xa766795d }, { "a", 1, 0x2ae4a38d, 0xa766795d },
{ "abc", 3, 0xc58e8af5, 0xa766795d }, { "abc", 3, 0x0aefd0ef, 0xa766795d },
{ "message digest", 14, 0x006b32f1, 0xa766795d }, { "message digest", 14, 0x828c4a8a, 0xa766795d },
{ "abcdefghijklmnopqrstuvwxyz", 26, 0x7e6fcfe0, 0xa766795d }, { "abcdefghijklmnopqrstuvwxyz", 26, 0xc8072ea9, 0xa766795d },
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0x8604adf8, 0xa766795d }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0xe8e24812, 0xa766795d },
{ "The quick brown fox jumps over the lazy dog", 43, 0xdeba3d3a, 0xa766795d }, { "The quick brown fox jumps over the lazy dog", 43, 0xae34960f, 0xa766795d },
{ "\x00", 1, 0x4a7d1c33, 0xa766795d }, { "\x00", 1, 0xac5373be, 0xa766795d },
{ "\x16\x27", 2, 0x8b50899b, 0xa766795d }, { "\x16\x27", 2, 0x321c4629, 0xa766795d },
{ "\xe2\x56\xb4", 3, 0x60406493, 0xa766795d }, { "\xe2\x56\xb4", 3, 0x66b8fbd8, 0xa766795d },
{ "\xc9\x4d\x9c\xda", 4, 0xa049144a, 0xa766795d }, { "\xc9\x4d\x9c\xda", 4, 0xbc37eb40, 0xa766795d },
{ "\x79\xf1\x29\x69\x5d", 5, 0x4da2c2f1, 0xa766795d }, { "\x79\xf1\x29\x69\x5d", 5, 0xb96d1628, 0xa766795d },
{ "\x00\x7e\xdf\x1e\x31\x1c", 6, 0x59de30cf, 0xa766795d }, { "\x00\x7e\xdf\x1e\x31\x1c", 6, 0x760cf131, 0xa766795d },
{ "\x2a\x4c\xe1\xff\x9e\x6f\x53", 7, 0x219e149c, 0xa766795d }, { "\x2a\x4c\xe1\xff\x9e\x6f\x53", 7, 0xd1d5a37a, 0xa766795d },
{ "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 8, 0x25067520, 0xa766795d }, { "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 8, 0x995d591f, 0xa766795d },
{ "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0xa1f368d8, 0xa766795d }, { "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0x8c7cfa48, 0xa766795d },
{ "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0x805fc63d, 0xa766795d }, { "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0xaa8fa306, 0xa766795d },
{ "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0x7f75dd0f, 0xa766795d }, { "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0x9c1d4af8, 0xa766795d },
{ "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0xb9154382, 0xa766795d }, { "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0x1a2214ec, 0xa766795d },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
@ -77,29 +77,29 @@ static struct hash32_test_vector TEST_HASH32[] = {
* Test vectors for tommy_strhash32 * Test vectors for tommy_strhash32
*/ */
struct strhash32_test_vector TEST_STRHASH32[] = { struct strhash32_test_vector TEST_STRHASH32[] = {
{ "", 0x0af1416d, 0xa766795d }, { "", 0xaffe48d7, 0xa766795d },
{ "a", 0x68fa0f3f, 0xa766795d }, { "a", 0x2ae4a38d, 0xa766795d },
{ "abc", 0xfc68ffc5, 0xa766795d }, { "abc", 0x0aefd0ef, 0xa766795d },
{ "message digest", 0x08477b63, 0xa766795d }, { "message digest", 0x828c4a8a, 0xa766795d },
{ "abcdefghijklmnopqrstuvwxyz", 0x5b9c25e5, 0xa766795d }, { "abcdefghijklmnopqrstuvwxyz", 0xc8072ea9, 0xa766795d },
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 0x1e530ce7, 0xa766795d }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 0xe8e24812, 0xa766795d },
{ "The quick brown fox jumps over the lazy dog", 0xaf93eefe, 0xa766795d }, { "The quick brown fox jumps over the lazy dog", 0xae34960f, 0xa766795d },
{ "\xff", 0xfc88801b, 0xa766795d }, { "\xff", 0x9ab96198, 0xa766795d },
{ "\x16\x27", 0xcd7216db, 0xa766795d }, { "\x16\x27", 0x321c4629, 0xa766795d },
{ "\xe2\x56\xb4", 0x05f98d02, 0xa766795d }, { "\xe2\x56\xb4", 0x66b8fbd8, 0xa766795d },
{ "\xc9\x4d\x9c\xda", 0xf65206f8, 0xa766795d }, { "\xc9\x4d\x9c\xda", 0xbc37eb40, 0xa766795d },
{ "\x79\xf1\x29\x69\x5d", 0x72bd6bda, 0xa766795d }, { "\x79\xf1\x29\x69\x5d", 0xb96d1628, 0xa766795d },
{ "\xff\x7e\xdf\x1e\x31\x1c", 0x57dfb9b4, 0xa766795d }, { "\xff\x7e\xdf\x1e\x31\x1c", 0xaf63217b, 0xa766795d },
{ "\x2a\x4c\xe1\xff\x9e\x6f\x53", 0x499ff634, 0xa766795d }, { "\x2a\x4c\xe1\xff\x9e\x6f\x53", 0xd1d5a37a, 0xa766795d },
{ "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 0xe896b7ce, 0xa766795d }, { "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 0x995d591f, 0xa766795d },
{ "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 0xfe3939f0, 0xa766795d }, { "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 0x8c7cfa48, 0xa766795d },
{ "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 0x4351d482, 0xa766795d }, { "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 0xaa8fa306, 0xa766795d },
{ "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\xff\xb7\xae", 0x88e92135, 0xa766795d }, { "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\xff\xb7\xae", 0x59437055, 0xa766795d },
{ "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 0x01109c16, 0xa766795d }, { "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 0x1a2214ec, 0xa766795d },
{ "\x87\xd8\x61\x61\x4c\x89\x17\x4e\xa1\xa4\xef\x13\xa9", 0xbcb050dc, 0xa766795d }, { "\x87\xd8\x61\x61\x4c\x89\x17\x4e\xa1\xa4\xef\x13\xa9", 0xb5d1be68, 0xa766795d },
{ "\xfe\xa6\x5b\xc2\xda\xe8\x95\xd4\x64\xab\x4c\x39\x58\x29", 0xbe5e1fd5, 0xa766795d }, { "\xfe\xa6\x5b\xc2\xda\xe8\x95\xd4\x64\xab\x4c\x39\x58\x29", 0xb2475cc8, 0xa766795d },
{ "\x94\x49\xc0\x78\xa0\x80\xda\xc7\x71\x4e\x17\x37\xa9\x7c\x40", 0x70d8c97f, 0xa766795d }, { "\x94\x49\xc0\x78\xa0\x80\xda\xc7\x71\x4e\x17\x37\xa9\x7c\x40", 0x3cf85197, 0xa766795d },
{ "\x53\x7e\x36\xb4\x2e\xc9\xb9\xcc\x18\x3e\x9a\x5f\xfc\xb7\xb0\x61", 0x957440a9, 0xa766795d }, { "\x53\x7e\x36\xb4\x2e\xc9\xb9\xcc\x18\x3e\x9a\x5f\xfc\xb7\xb0\x61", 0x8ec35c09, 0xa766795d },
{ 0, 0, 0 } { 0, 0, 0 }
}; };
@ -107,25 +107,25 @@ struct strhash32_test_vector TEST_STRHASH32[] = {
* Test vectors for tommy_hash64 * Test vectors for tommy_hash64
*/ */
static struct hash64_test_vector TEST_HASH64[] = { static struct hash64_test_vector TEST_HASH64[] = {
{ "", 0, 0x8614384cb5165fbfULL, 0x2f022773a766795dULL }, { "", 0, 0xf64d2d2164ca4e35ULL, 0x2f022773a766795dULL },
{ "a", 1, 0x1a2e0298a8e94a3dULL, 0x2f022773a766795dULL }, { "a", 1, 0xcb0b7863fd912608ULL, 0x2f022773a766795dULL },
{ "abc", 3, 0x7555796b7a7d21ebULL, 0x2f022773a766795dULL }, { "abc", 3, 0x023adbd4412dfbc2ULL, 0x2f022773a766795dULL },
{ "message digest", 14, 0x9411a57d04b92fb4ULL, 0x2f022773a766795dULL }, { "message digest", 14, 0x8d16f620b58a030eULL, 0x2f022773a766795dULL },
{ "abcdefghijklmnopqrstuvwxyz", 26, 0x3ca3f8d2b4e69832ULL, 0x2f022773a766795dULL }, { "abcdefghijklmnopqrstuvwxyz", 26, 0xa615ea6b87f2b63fULL, 0x2f022773a766795dULL },
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0x6dae542ba0015a4dULL, 0x2f022773a766795dULL }, { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 62, 0xb9f145676ebdb4fcULL, 0x2f022773a766795dULL },
{ "The quick brown fox jumps over the lazy dog", 43, 0xe06d8cbb3d2ea1a6ULL, 0x2f022773a766795dULL }, { "The quick brown fox jumps over the lazy dog", 43, 0x99b05c9548b523dcULL, 0x2f022773a766795dULL },
{ "\x00", 1, 0x201e664fb5f2c021ULL, 0x2f022773a766795dULL }, { "\x00", 1, 0x432204e0ea8617fbULL, 0x2f022773a766795dULL },
{ "\x16\x27", 2, 0xef42fa8032c4b775ULL, 0x2f022773a766795dULL }, { "\x16\x27", 2, 0x5118c58166c6ab3eULL, 0x2f022773a766795dULL },
{ "\xe2\x56\xb4", 3, 0x6e6c498a6688466cULL, 0x2f022773a766795dULL }, { "\xe2\x56\xb4", 3, 0x29484604a9976acbULL, 0x2f022773a766795dULL },
{ "\xc9\x4d\x9c\xda", 4, 0x5195005419905423ULL, 0x2f022773a766795dULL }, { "\xc9\x4d\x9c\xda", 4, 0xf000ac44a9f98f4aULL, 0x2f022773a766795dULL },
{ "\x79\xf1\x29\x69\x5d", 5, 0x221235b48afee7c1ULL, 0x2f022773a766795dULL }, { "\x79\xf1\x29\x69\x5d", 5, 0x9603fc74ec52e5aaULL, 0x2f022773a766795dULL },
{ "\x00\x7e\xdf\x1e\x31\x1c", 6, 0x1b1f18b9266f095bULL, 0x2f022773a766795dULL }, { "\x00\x7e\xdf\x1e\x31\x1c", 6, 0xd39f549b363c8e2bULL, 0x2f022773a766795dULL },
{ "\x2a\x4c\xe1\xff\x9e\x6f\x53", 7, 0x2cbafa8e741d49caULL, 0x2f022773a766795dULL }, { "\x2a\x4c\xe1\xff\x9e\x6f\x53", 7, 0x1be47d9f53a2a31dULL, 0x2f022773a766795dULL },
{ "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 8, 0x4677f04c06e0758dULL, 0x2f022773a766795dULL }, { "\xba\x02\xab\x18\x30\xc5\x0e\x8a", 8, 0xe3fa24e31af8c4ebULL, 0x2f022773a766795dULL },
{ "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0x5afe09e8214e2163ULL, 0x2f022773a766795dULL }, { "\xec\x4e\x7a\x72\x1e\x71\x2a\xc9\x33", 9, 0xef8c3dcec426a25dULL, 0x2f022773a766795dULL },
{ "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0x115b6276d209fab6ULL, 0x2f022773a766795dULL }, { "\xfd\xe2\x9c\x0f\x72\xb7\x08\xea\xd0\x78", 10, 0xed0be01a88bde7cbULL, 0x2f022773a766795dULL },
{ "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0xd0636d2f01cf3a3eULL, 0x2f022773a766795dULL }, { "\x65\xc4\x8a\xb8\x80\x86\x9a\x79\x00\xb7\xae", 11, 0xf9b50d9db5dfa543ULL, 0x2f022773a766795dULL },
{ "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0x6d259f5fef74f93eULL, 0x2f022773a766795dULL }, { "\x77\xe9\xd7\x80\x0e\x3f\x5c\x43\xc8\xc2\x46\x39", 12, 0x695329dad2094e8aULL, 0x2f022773a766795dULL },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
@ -188,6 +188,13 @@ static void test_hash(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
digest = tommy_hash_u32(TEST_STRHASH32[i].seed, buffer_aligned, strlen(TEST_STRHASH32[i].data));
if (digest != TEST_STRHASH32[i].digest) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed strhash32 test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
} }
for (i = 0; TEST_HASH64[i].data; ++i) { for (i = 0; TEST_HASH64[i].data; ++i) {
@ -456,7 +463,7 @@ static void test_tommy(void)
tommy_arrayblkof_init(&arrayblkof, sizeof(unsigned)); tommy_arrayblkof_init(&arrayblkof, sizeof(unsigned));
for (i = 0; i < TOMMY_SIZE; ++i) { for (i = 0; i < TOMMY_SIZE; ++i) {
tommy_array_insert(&array, &node[i]); tommy_array_insert_tail(&array, &node[i]);
tommy_arrayblkof_grow(&arrayblkof, i + 1); tommy_arrayblkof_grow(&arrayblkof, i + 1);
*(unsigned*)tommy_arrayblkof_ref(&arrayblkof, i) = i; *(unsigned*)tommy_arrayblkof_ref(&arrayblkof, i) = i;
} }
@ -584,7 +591,11 @@ static void test_tommy(void)
tommy_tree_insert(&tree, &node[i], (void*)(uintptr_t)(i + 1)); tommy_tree_insert(&tree, &node[i], (void*)(uintptr_t)(i + 1));
/* try to insert a duplicate, count should not change */ /* try to insert a duplicate, count should not change */
tommy_tree_insert(&tree, &node[TOMMY_SIZE], (void*)(uintptr_t)1); if (tommy_tree_insert_unique(&tree, &node[TOMMY_SIZE], (void*)(uintptr_t)1) != (void*)(uintptr_t)1) {
/* LCOV_EXCL_START */
goto bail;
/* LCOV_EXCL_STOP */
}
if (tommy_tree_count(&tree) != TOMMY_SIZE) { if (tommy_tree_count(&tree) != TOMMY_SIZE) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -1979,13 +1990,13 @@ static void test_smart_ignore(void)
memset(&state, 0, sizeof(state)); memset(&state, 0, sizeof(state));
memset(&devinfo, 0, sizeof(devinfo)); memset(&devinfo, 0, sizeof(devinfo));
/* Initialize devinfo attributes with mock data */ /* initialize devinfo attributes with mock data */
for (i = 0; i < SMART_COUNT; ++i) { for (i = 0; i < SMART_COUNT; ++i) {
devinfo.smart[i].raw = 100; devinfo.smart[i].raw = 100;
devinfo.smart[i].norm = 100; devinfo.smart[i].norm = 100;
snprintf(devinfo.smart[i].name, sizeof(devinfo.smart[i].name), "Attr_%d", i); snprintf(devinfo.smart[i].name, sizeof(devinfo.smart[i].name), "Attr_%d", i);
} }
/* Special name for test */ /* special name for test */
pathcpy(devinfo.smart[5].name, sizeof(devinfo.smart[5].name), "Reallocated_Sector_Ct"); pathcpy(devinfo.smart[5].name, sizeof(devinfo.smart[5].name), "Reallocated_Sector_Ct");
pathcpy(devinfo.smart[197].name, sizeof(devinfo.smart[197].name), "Current_Pending_Sector"); pathcpy(devinfo.smart[197].name, sizeof(devinfo.smart[197].name), "Current_Pending_Sector");
@ -2007,7 +2018,7 @@ static void test_smart_ignore(void)
state_smart_ignore(&state, &devinfo); state_smart_ignore(&state, &devinfo);
/* Check that ignored attributes are set to SMART_UNASSIGNED */ /* check that ignored attributes are set to SMART_UNASSIGNED */
if (devinfo.smart[5].raw != SMART_UNASSIGNED || devinfo.smart[5].norm != SMART_UNASSIGNED) { if (devinfo.smart[5].raw != SMART_UNASSIGNED || devinfo.smart[5].norm != SMART_UNASSIGNED) {
log_fatal(EINTERNAL, "test_smart_ignore: numerical global ignore failed\n"); log_fatal(EINTERNAL, "test_smart_ignore: numerical global ignore failed\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -2025,7 +2036,7 @@ static void test_smart_ignore(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Check that non-ignored attributes are still present */ /* check that non-ignored attributes are still present */
if (devinfo.smart[6].raw != 100) { if (devinfo.smart[6].raw != 100) {
log_fatal(EINTERNAL, "test_smart_ignore: unmodified attribute was cleared\n"); log_fatal(EINTERNAL, "test_smart_ignore: unmodified attribute was cleared\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -2183,6 +2194,30 @@ static void test_stream(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* sgetbs test */
unsigned char buf_bs[] = { 0x85, 'h', 'e', 'l', 'l', 'o' };
char str_bs[16];
memset(&f, 0, sizeof(f));
f.pos = buf_bs;
f.end = buf_bs + sizeof(buf_bs);
if (sgetbs(&f, str_bs, sizeof(str_bs)) != 5 || strcmp(str_bs, "hello") != 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "test_stream: sgetbs valid string failed\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* sgetbs buffer too small test */
memset(&f, 0, sizeof(f));
f.pos = buf_bs;
f.end = buf_bs + sizeof(buf_bs);
if (sgetbs(&f, str_bs, 5) >= 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "test_stream: sgetbs small buffer accepted\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
} }
static void test_extent_run(void) static void test_extent_run(void)
@ -2221,6 +2256,135 @@ static void test_extent_run(void)
file_free(file); file_free(file);
} }
static void test_unsynced_sweep(void)
{
struct snapraid_state state;
struct snapraid_disk* disk1;
struct snapraid_disk* disk2;
struct snapraid_file* file1;
struct snapraid_file* file2;
struct snapraid_file* file3;
struct snapraid_file* file4;
struct snapraid_file* del;
block_off_t i;
static const struct {
block_off_t blockmax;
uint64_t unsynced;
} bounds[] = {
{ 0, 0 }, { 10, 0 }, { 15, 0 }, { 16, 1 }, { 19, 4 },
{ 20, 5 }, { 21, 5 }, { 22, 6 }, { 23, 7 }, { 29, 7 },
{ 30, 7 }, { 31, 8 }, { 32, 9 }, { 33, 10 }, { 34, 11 },
{ 100, 11 }
};
memset(&state, 0, sizeof(state));
state.block_size = 4096;
tommy_list_init(&state.disklist);
if (fs_count_unsynced(&state, 0, 100) != 0) {
log_fatal(EINTERNAL, "test_unsynced_sweep: no disks failed\n");
exit(EXIT_FAILURE);
}
disk1 = disk_alloc("d1", "", 0, "", 0);
disk2 = disk_alloc("d2", "", 0, "", 0);
tommy_list_insert_tail(&state.disklist, &disk1->node, disk1);
tommy_list_insert_tail(&state.disklist, &disk2->node, disk2);
/* initially both disks are empty */
if (fs_count_unsynced(&state, 10, 100) != 0) {
log_fatal(EINTERNAL, "test_unsynced_sweep: empty disks failed\n");
exit(EXIT_FAILURE);
}
/* file1 on disk1: 10 blocks at parity 10..19 (first 5 BLK, next 5 CHG) */
file1 = file_alloc(4096, "f1", 10 * 4096, 0, 0, 0);
for (i = 0; i < 5; ++i)
block_state_set(file_block(file1, i), BLOCK_STATE_BLK);
for (i = 5; i < 10; ++i)
block_state_set(file_block(file1, i), BLOCK_STATE_CHG);
fs_allocate(disk1, 10, file1, 0, 10);
/* file2 on disk2: 20 blocks at parity 0..19 (all BLK) */
file2 = file_alloc(4096, "f2", 20 * 4096, 0, 0, 0);
for (i = 0; i < 20; ++i)
block_state_set(file_block(file2, i), BLOCK_STATE_BLK);
fs_allocate(disk2, 0, file2, 0, 20);
/* parity 0..14 has only BLK or EMPTY; parity 15..19 has CHG on disk1 and BLK on disk2 -> 5 unsynced */
if (fs_count_unsynced(&state, 15, 20) != 5) {
log_fatal(EINTERNAL, "test_unsynced_sweep: mixed block run failed\n");
exit(EXIT_FAILURE);
}
/* deleted run on disk1: 3 blocks at parity 20..22 */
del = file_alloc(4096, "<deleted>", 3 * 4096, 0, 0, 0);
for (i = 0; i < 3; ++i)
block_state_set(file_block(del, i), BLOCK_STATE_DELETED);
fs_allocate(disk1, 20, del, 0, 3);
/* disk2 is empty at 20..22 -> DELETED alone does not count as unsynced */
if (fs_count_unsynced(&state, 15, 23) != 5) {
log_fatal(EINTERNAL, "test_unsynced_sweep: deleted without other file failed\n");
exit(EXIT_FAILURE);
}
/* file3 on disk2: first 2 blocks at parity 21..22 (BLK) */
file3 = file_alloc(4096, "f3", 6 * 4096, 0, 0, 0);
for (i = 0; i < 2; ++i)
block_state_set(file_block(file3, i), BLOCK_STATE_BLK);
block_state_set(file_block(file3, 2), BLOCK_STATE_REP);
block_state_set(file_block(file3, 3), BLOCK_STATE_REP);
block_state_set(file_block(file3, 4), BLOCK_STATE_BLK);
block_state_set(file_block(file3, 5), BLOCK_STATE_REBUILD);
fs_allocate(disk2, 21, file3, 0, 2);
/* parity 20: DELETED on d1, empty on d2 -> not unsynced;
* parity 21..22: DELETED on d1, BLK on d2 -> unsynced (2 blocks). Total 5 + 2 = 7 */
if (fs_count_unsynced(&state, 15, 23) != 7) {
log_fatal(EINTERNAL, "test_unsynced_sweep: deleted with file failed\n");
exit(EXIT_FAILURE);
}
/* the second extent of file3 starts at a nonzero file offset after a gap */
fs_allocate(disk2, 30, file3, 2, 4);
/* file4 shares extent boundaries with file3 and changes flags at 32 and 33 */
file4 = file_alloc(4096, "f4", 4 * 4096, 0, 0, 0);
for (i = 0; i < 4; ++i)
block_state_set(file_block(file4, i), BLOCK_STATE_BLK);
block_state_set(file_block(file4, 2), BLOCK_STATE_CHG);
fs_allocate(disk1, 30, file4, 0, 4);
/*
* Positions 30..33 are all unsynced: REP, REP, CHG, REBUILD respectively.
* At 32 and 33 the invalid block changes disks at the same event boundary;
* count each position once using the refreshed flags from both disks.
* Check every window between limits in gaps, within extents and runs,
* and at their boundaries, including empty windows and nonzero starts.
*/
for (i = 0; i < sizeof(bounds) / sizeof(bounds[0]); ++i) {
block_off_t j;
for (j = 0; j <= i; ++j) {
uint64_t expected = bounds[i].unsynced - bounds[j].unsynced;
uint64_t count = fs_count_unsynced(&state, bounds[j].blockmax, bounds[i].blockmax);
if (count != expected) {
log_fatal(EINTERNAL, "test_unsynced_sweep: window [%" PRIu64 ", %" PRIu64 ") expected %" PRIu64 ", got %" PRIu64 "\n",
bounds[j].blockmax, bounds[i].blockmax, expected, count);
exit(EXIT_FAILURE);
}
}
}
file_free(file1);
file_free(file2);
file_free(file3);
file_free(file4);
file_free(del);
disk_free(disk1);
disk_free(disk2);
}
static void test_raid(void) static void test_raid(void)
{ {
/* vandermonde raid parity generation with 32 data disks */ /* vandermonde raid parity generation with 32 data disks */
@ -2941,6 +3105,9 @@ void test(int argc, char* argv[])
/* extent-aware file-to-parity run lookup */ /* extent-aware file-to-parity run lookup */
test_extent_run(); test_extent_run();
/* extent sweep for unsynced parity blocks */
test_unsynced_sweep();
/* wildcard and path pattern matching */ /* wildcard and path pattern matching */
test_wnmatch(); test_wnmatch();

View file

@ -311,152 +311,152 @@ static struct option long_options[] = {
{ "gui-threshold-removes", 1, 0, OPT_GUI_THRESHOLD_REMOVES }, /* undocumented GUI, abort sync if too many removed files */ { "gui-threshold-removes", 1, 0, OPT_GUI_THRESHOLD_REMOVES }, /* undocumented GUI, abort sync if too many removed files */
{ "gui-threshold-updates", 1, 0, OPT_GUI_THRESHOLD_UPDATES }, /* undocumented GUI, abort sync if too many updated files */ { "gui-threshold-updates", 1, 0, OPT_GUI_THRESHOLD_UPDATES }, /* undocumented GUI, abort sync if too many updated files */
/* The following are test specific options, DO NOT USE! */ /* the following are test specific options, DO NOT USE! */
/* After syncing, do not write the new content file */ /* after syncing, do not write the new content file */
{ "test-kill-after-sync", 0, 0, OPT_TEST_KILL_AFTER_SYNC }, { "test-kill-after-sync", 0, 0, OPT_TEST_KILL_AFTER_SYNC },
/* Do not execute syncing after resizing parity files, before the normal post-resize content write */ /* do not execute syncing after resizing parity files, before the normal post-resize content write */
{ "test-kill-after-resize", 0, 0, OPT_TEST_KILL_AFTER_RESIZE }, { "test-kill-after-resize", 0, 0, OPT_TEST_KILL_AFTER_RESIZE },
/* Do not execute syncing after writing the new initial content file */ /* do not execute syncing after writing the new initial content file */
{ "test-kill-before-sync", 0, 0, OPT_TEST_KILL_BEFORE_SYNC }, { "test-kill-before-sync", 0, 0, OPT_TEST_KILL_BEFORE_SYNC },
/* Exit with failure if after check/fix there ARE NOT unrecoverable errors. */ /* exit with failure if after check/fix there ARE NOT unrecoverable errors. */
{ "test-expect-unrecoverable", 0, 0, OPT_TEST_EXPECT_UNRECOVERABLE }, { "test-expect-unrecoverable", 0, 0, OPT_TEST_EXPECT_UNRECOVERABLE },
/* Exit with failure if after check/fix there ARE NOT recoverable errors. */ /* exit with failure if after check/fix there ARE NOT recoverable errors. */
{ "test-expect-recoverable", 0, 0, OPT_TEST_EXPECT_RECOVERABLE }, { "test-expect-recoverable", 0, 0, OPT_TEST_EXPECT_RECOVERABLE },
/* Skip the initial self test */ /* skip the initial self test */
{ "test-skip-self", 0, 0, OPT_TEST_SKIP_SELF }, { "test-skip-self", 0, 0, OPT_TEST_SKIP_SELF },
/* Skip the initial sign check when reading the content file */ /* skip the initial sign check when reading the content file */
{ "test-skip-sign", 0, 0, OPT_TEST_SKIP_SIGN }, { "test-skip-sign", 0, 0, OPT_TEST_SKIP_SIGN },
/* Skip the fallocate() when growing the parity files */ /* skip the fallocate() when growing the parity files */
{ "test-skip-fallocate", 0, 0, OPT_TEST_SKIP_FALLOCATE }, { "test-skip-fallocate", 0, 0, OPT_TEST_SKIP_FALLOCATE },
/* Skip the device check */ /* skip the device check */
{ "test-skip-device", 0, 0, OPT_TEST_SKIP_DEVICE }, { "test-skip-device", 0, 0, OPT_TEST_SKIP_DEVICE },
/* Force Murmur3 hash */ /* force Murmur3 hash */
{ "test-force-murmur3", 0, 0, OPT_TEST_FORCE_MURMUR3 }, { "test-force-murmur3", 0, 0, OPT_TEST_FORCE_MURMUR3 },
/* Force Spooky2 hash */ /* force Spooky2 hash */
{ "test-force-spooky2", 0, 0, OPT_TEST_FORCE_SPOOKY2 }, { "test-force-spooky2", 0, 0, OPT_TEST_FORCE_SPOOKY2 },
/* Skip the use of lock file */ /* skip the use of lock file */
{ "test-skip-lock", 0, 0, OPT_TEST_SKIP_LOCK }, { "test-skip-lock", 0, 0, OPT_TEST_SKIP_LOCK },
/* Force a sort order for files */ /* force a sort order for files */
{ "test-force-order-inode", 0, 0, OPT_TEST_FORCE_ORDER_INODE }, { "test-force-order-inode", 0, 0, OPT_TEST_FORCE_ORDER_INODE },
{ "test-force-order-alpha", 0, 0, OPT_TEST_FORCE_ORDER_ALPHA }, { "test-force-order-alpha", 0, 0, OPT_TEST_FORCE_ORDER_ALPHA },
{ "test-force-order-dir", 0, 0, OPT_TEST_FORCE_ORDER_DIR }, { "test-force-order-dir", 0, 0, OPT_TEST_FORCE_ORDER_DIR },
/* Force scrub of the specified number of blocks */ /* force scrub of the specified number of blocks */
{ "test-force-scrub-at", 1, 0, OPT_TEST_FORCE_SCRUB_AT }, { "test-force-scrub-at", 1, 0, OPT_TEST_FORCE_SCRUB_AT },
/* Force scrub of all the even blocks. This is really for testing, don't try it */ /* force scrub of all the even blocks. This is really for testing, don't try it */
{ "test-force-scrub-even", 0, 0, OPT_TEST_FORCE_SCRUB_EVEN }, { "test-force-scrub-even", 0, 0, OPT_TEST_FORCE_SCRUB_EVEN },
/* Force write of the content file even if no modification is done */ /* force write of the content file even if no modification is done */
{ "test-force-content-write", 0, 0, OPT_TEST_FORCE_CONTENT_WRITE }, { "test-force-content-write", 0, 0, OPT_TEST_FORCE_CONTENT_WRITE },
/* Relax the checks done at the content file */ /* relax the checks done at the content file */
{ "test-skip-content-check", 0, 0, OPT_TEST_SKIP_CONTENT_CHECK }, { "test-skip-content-check", 0, 0, OPT_TEST_SKIP_CONTENT_CHECK },
/* Skip the parity access */ /* skip the parity access */
{ "test-skip-parity-access", 0, 0, OPT_TEST_SKIP_PARITY_ACCESS }, { "test-skip-parity-access", 0, 0, OPT_TEST_SKIP_PARITY_ACCESS },
/* Exit generic failure */ /* exit generic failure */
{ "test-expect-failure", 0, 0, OPT_TEST_EXPECT_FAILURE }, { "test-expect-failure", 0, 0, OPT_TEST_EXPECT_FAILURE },
/* Exit generic need sync */ /* exit generic need sync */
{ "test-expect-need-sync", 0, 0, OPT_TEST_EXPECT_NEED_SYNC }, { "test-expect-need-sync", 0, 0, OPT_TEST_EXPECT_NEED_SYNC },
#if HAVE_CHECKER #if HAVE_CHECKER
/* Run some command after loading the state and before the command */ /* run some command after loading the state and before the command */
{ "test-run", 1, 0, OPT_TEST_RUN }, { "test-run", 1, 0, OPT_TEST_RUN },
#endif #endif
/* Use the FindFirst/Next approach in Windows to list files */ /* use the FindFirst/Next approach in Windows to list files */
{ "test-force-scan-winfind", 0, 0, OPT_TEST_FORCE_SCAN_WINFIND }, { "test-force-scan-winfind", 0, 0, OPT_TEST_FORCE_SCAN_WINFIND },
/* Alternative import working by data */ /* alternative import working by data */
{ "test-import-content", 1, 0, OPT_TEST_IMPORT_CONTENT }, { "test-import-content", 1, 0, OPT_TEST_IMPORT_CONTENT },
/* Force immediate progress state update */ /* force immediate progress state update */
{ "test-force-progress", 0, 0, OPT_TEST_FORCE_PROGRESS }, { "test-force-progress", 0, 0, OPT_TEST_FORCE_PROGRESS },
/* Skip the disk access */ /* skip the disk access */
{ "test-skip-disk-access", 0, 0, OPT_TEST_SKIP_DISK_ACCESS }, { "test-skip-disk-access", 0, 0, OPT_TEST_SKIP_DISK_ACCESS },
/* Force autosave at the specified block */ /* force autosave at the specified block */
{ "test-force-autosave-at", 1, 0, OPT_TEST_FORCE_AUTOSAVE_AT }, { "test-force-autosave-at", 1, 0, OPT_TEST_FORCE_AUTOSAVE_AT },
/* Fake device data */ /* fake device data */
{ "test-fake-device", 0, 0, OPT_TEST_FAKE_DEVICE }, { "test-fake-device", 0, 0, OPT_TEST_FAKE_DEVICE },
/* Fake UUID */ /* fake UUID */
{ "test-fake-uuid", 0, 0, OPT_TEST_FAKE_UUID }, { "test-fake-uuid", 0, 0, OPT_TEST_FAKE_UUID },
/* Match first UUID */ /* match first UUID */
{ "test-match-first-uuid", 0, 0, OPT_TEST_MATCH_FIRST_UUID }, { "test-match-first-uuid", 0, 0, OPT_TEST_MATCH_FIRST_UUID },
/* Force parity update even if all the data hash is already matching */ /* force parity update even if all the data hash is already matching */
{ "test-force-parity-update", 0, 0, OPT_TEST_FORCE_PARITY_UPDATE }, { "test-force-parity-update", 0, 0, OPT_TEST_FORCE_PARITY_UPDATE },
/* Number of IO buffers */ /* number of IO buffers */
{ "test-io-cache", 1, 0, OPT_TEST_IO_CACHE }, { "test-io-cache", 1, 0, OPT_TEST_IO_CACHE },
/* Print IO stats */ /* print IO stats */
{ "test-io-stats", 0, 0, OPT_TEST_IO_STATS }, /* now replaced by -A, --stats */ { "test-io-stats", 0, 0, OPT_TEST_IO_STATS }, /* now replaced by -A, --stats */
/* Signal condition variable outside the mutex */ /* signal condition variable outside the mutex */
{ "test-cond-signal-outside", 0, 0, OPT_TEST_COND_SIGNAL_OUTSIDE }, { "test-cond-signal-outside", 0, 0, OPT_TEST_COND_SIGNAL_OUTSIDE },
/* Set the io advise to none */ /* set the io advise to none */
{ "test-io-advise-none", 0, 0, OPT_TEST_IO_ADVISE_NONE }, { "test-io-advise-none", 0, 0, OPT_TEST_IO_ADVISE_NONE },
/* Set the io advise to sequential */ /* set the io advise to sequential */
{ "test-io-advise-sequential", 0, 0, OPT_TEST_IO_ADVISE_SEQUENTIAL }, { "test-io-advise-sequential", 0, 0, OPT_TEST_IO_ADVISE_SEQUENTIAL },
/* Set the io advise to flush */ /* set the io advise to flush */
{ "test-io-advise-flush", 0, 0, OPT_TEST_IO_ADVISE_FLUSH }, { "test-io-advise-flush", 0, 0, OPT_TEST_IO_ADVISE_FLUSH },
/* Set the io advise to flush window */ /* set the io advise to flush window */
{ "test-io-advise-flush-window", 0, 0, OPT_TEST_IO_ADVISE_FLUSH_WINDOW }, { "test-io-advise-flush-window", 0, 0, OPT_TEST_IO_ADVISE_FLUSH_WINDOW },
/* Set the io advise to discard */ /* set the io advise to discard */
{ "test-io-advise-discard", 0, 0, OPT_TEST_IO_ADVISE_DISCARD }, { "test-io-advise-discard", 0, 0, OPT_TEST_IO_ADVISE_DISCARD },
/* Set the io advise to discard window */ /* set the io advise to discard window */
{ "test-io-advise-discard-window", 0, 0, OPT_TEST_IO_ADVISE_DISCARD_WINDOW }, { "test-io-advise-discard-window", 0, 0, OPT_TEST_IO_ADVISE_DISCARD_WINDOW },
/* Set the io advise to direct */ /* set the io advise to direct */
{ "test-io-advise-direct", 0, 0, OPT_TEST_IO_ADVISE_DIRECT }, { "test-io-advise-direct", 0, 0, OPT_TEST_IO_ADVISE_DIRECT },
/* Set an artificial parity limit */ /* set an artificial parity limit */
{ "test-parity-limit", 1, 0, OPT_TEST_PARITY_LIMIT }, { "test-parity-limit", 1, 0, OPT_TEST_PARITY_LIMIT },
/* Skip content write */ /* skip content write */
{ "test-skip-content-write", 0, 0, OPT_TEST_SKIP_CONTENT_WRITE }, { "test-skip-content-write", 0, 0, OPT_TEST_SKIP_CONTENT_WRITE },
/* Skip space holder file in parity disks */ /* skip space holder file in parity disks */
{ "test-skip-space-holder", 0, 0, OPT_TEST_SKIP_SPACE_HOLDER }, { "test-skip-space-holder", 0, 0, OPT_TEST_SKIP_SPACE_HOLDER },
/* Set the output format */ /* set the output format */
{ "test-fmt", 1, 0, OPT_TEST_FORMAT }, { "test-fmt", 1, 0, OPT_TEST_FORMAT },
/* Skip thread in disk scan */ /* skip thread in disk scan */
{ "test-skip-multi-scan", 0, 0, OPT_TEST_SKIP_MULTI_SCAN }, { "test-skip-multi-scan", 0, 0, OPT_TEST_SKIP_MULTI_SCAN },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
#endif #endif
/* /**
* Free letters: gIjJkKMnPQruxXz * Free letters: gIjJkKMnPQruxXz
* *
* The 's' letter is used in main.c * The 's' letter is used in main.c
@ -1530,7 +1530,8 @@ int snapraid_main(int argc, char* argv[])
if (state.opt.force_realloc) if (state.opt.force_realloc)
state_locate_mark_tail_blocks_for_resync(&state, opt.parity_tail); state_locate_mark_tail_blocks_for_resync(&state, opt.parity_tail);
if (opt.gui_touch_before) { /* skip touch itself until content is loaded and sync has initialized parity sizes */
if (opt.gui_touch_before && state_is_write_ready(&state)) {
ret = state_touch(&state); ret = state_touch(&state);
/* save the new state if required */ /* save the new state if required */
@ -1627,6 +1628,9 @@ int snapraid_main(int argc, char* argv[])
} else if (operation == OPERATION_REHASH) { } else if (operation == OPERATION_REHASH) {
state_read(&state); state_read(&state);
/* prevent saving content with uninitialized parity split sizes */
state_require_write_ready(&state);
state_rehash(&state); state_rehash(&state);
/* /*
@ -1645,6 +1649,9 @@ int snapraid_main(int argc, char* argv[])
} else if (operation == OPERATION_SCRUB) { } else if (operation == OPERATION_SCRUB) {
state_read(&state); state_read(&state);
/* prevent saving content with uninitialized parity split sizes */
state_require_write_ready(&state);
/* refresh the size info before the content write */ /* refresh the size info before the content write */
state_refresh(&state); state_refresh(&state);
@ -1667,6 +1674,9 @@ int snapraid_main(int argc, char* argv[])
} else if (operation == OPERATION_REWRITE) { } else if (operation == OPERATION_REWRITE) {
state_read(&state); state_read(&state);
/* prevent saving content with uninitialized parity split sizes */
state_require_write_ready(&state);
/* intercept signals while operating */ /* intercept signals while operating */
os_signal_init(app_signal_handler, app_signal_handler); os_signal_init(app_signal_handler, app_signal_handler);
@ -1682,6 +1692,9 @@ int snapraid_main(int argc, char* argv[])
} else if (operation == OPERATION_TOUCH) { } else if (operation == OPERATION_TOUCH) {
state_read(&state); state_read(&state);
/* prevent saving content with uninitialized parity split sizes */
state_require_write_ready(&state);
memory(); memory();
ret = state_touch(&state); ret = state_touch(&state);
@ -1696,6 +1709,7 @@ int snapraid_main(int argc, char* argv[])
*/ */
os_signal_init(app_signal_handler, app_signal_handler); os_signal_init(app_signal_handler, app_signal_handler);
/* save the new state if required */
if (state.need_write) if (state.need_write)
state_write(&state); state_write(&state);
} else if (operation == OPERATION_SPINUP) { } else if (operation == OPERATION_SPINUP) {

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2011 Andrea Mazzoleni // Copyright (C) 2011 Andrea Mazzoleni
#ifndef __SNAPRAID_H #ifndef SNAPRAID_H
#define __SNAPRAID_H #define SNAPRAID_H
/****************************************************************************/ /****************************************************************************/
/* snapraid */ /* snapraid */

View file

@ -11,18 +11,11 @@
#include "raid/memory.h" #include "raid/memory.h"
#include "state.h" #include "state.h"
/** #if HAVE_ASSEMBLY
* Differential us of two timeval. #define SPEED_BARRIER() __asm__ __volatile__ ("" : : : "memory")
*/ #else
static int64_t diffgettimeofday(struct timeval* start, struct timeval* stop) #define SPEED_BARRIER() do { } while (0)
{ #endif
int64_t d;
d = 1000000LL * (stop->tv_sec - start->tv_sec);
d += stop->tv_usec - start->tv_usec;
return d;
}
#define SPEED_START \ #define SPEED_START \
{ \ { \
@ -30,15 +23,17 @@ static int64_t diffgettimeofday(struct timeval* start, struct timeval* stop)
int64_t elapsed_ = 0; \ int64_t elapsed_ = 0; \
int64_t best_dt_ = INT64_MAX; \ int64_t best_dt_ = INT64_MAX; \
do { \ do { \
struct timeval start; \ SPEED_BARRIER(); \
struct timeval stop; \ uint64_t start_ = os_tick_ns(); \
gettimeofday(&start, 0); \ SPEED_BARRIER(); \
for (int i_ = 0; i_ < speed_delta_; ++i_) for (int i_ = 0; i_ < speed_delta_; ++i_)
#define SPEED_STOP \ #define SPEED_STOP \
gettimeofday(&stop, 0); \ SPEED_BARRIER(); \
dt = diffgettimeofday(&start, &stop); \ uint64_t stop_ = os_tick_ns(); \
if (dt < 1000 && speed_delta_ <= INT_MAX / 2) { \ SPEED_BARRIER(); \
dt = stop_ > start_ ? stop_ - start_ : 0; \
if (dt < 1000000 && speed_delta_ <= INT_MAX / 2) { \
speed_delta_ *= 2; \ speed_delta_ *= 2; \
elapsed_ = 0; \ elapsed_ = 0; \
best_dt_ = INT64_MAX; \ best_dt_ = INT64_MAX; \
@ -47,8 +42,8 @@ static int64_t diffgettimeofday(struct timeval* start, struct timeval* stop)
elapsed_ += dt; \ elapsed_ += dt; \
if (dt < best_dt_) \ if (dt < best_dt_) \
best_dt_ = dt; \ best_dt_ = dt; \
} while (elapsed_ < period * 1000LL); \ } while (elapsed_ < period * 1000000LL); \
ds = size * (int64_t)speed_delta_ * nd; \ ds = size * (int64_t)speed_delta_ * nd * 1000LL; \
dt = best_dt_; \ dt = best_dt_; \
} }

View file

@ -96,7 +96,7 @@
// //
#define sc_const 0xdeadbeefdeadbeefULL #define sc_const 0xdeadbeefdeadbeefULL
void SpookyHash128(const void* data, size_t size, const uint8_t* seed, uint8_t* digest) static void SpookyHash128(const void* data, size_t size, const uint8_t* seed, uint8_t* digest)
{ {
uint64_t h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11; uint64_t h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11;
uint8_t buf[sc_blockSize]; uint8_t buf[sc_blockSize];
@ -117,6 +117,11 @@ void SpookyHash128(const void* data, size_t size, const uint8_t* seed, uint8_t*
end = p + nblocks * sc_blockSize; end = p + nblocks * sc_blockSize;
/* body */ /* body */
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC unroll 1
#elif defined(__clang__)
#pragma unroll 1
#endif
while (p < end) { while (p < end) {
Mix(p, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); Mix(p, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11);
p += sc_blockSize; p += sc_blockSize;

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2011 Andrea Mazzoleni // Copyright (C) 2011 Andrea Mazzoleni
#ifndef __STATE_H #ifndef STATE_H
#define __STATE_H #define STATE_H
#include "elem.h" #include "elem.h"
@ -130,7 +130,6 @@ struct snapraid_state {
uint64_t autosave; /**< Autosave after the specified amount of data. 0 to disable. */ uint64_t autosave; /**< Autosave after the specified amount of data. 0 to disable. */
int need_write; /**< If the state is changed. */ int need_write; /**< If the state is changed. */
int written; /**< If the state was written at least one time */ int written; /**< If the state was written at least one time */
int checked_read; /**< If the state was read and checked. */
uint32_t block_size; /**< Block size in bytes. */ uint32_t block_size; /**< Block size in bytes. */
unsigned raid_mode; /**< Raid mode to use. RAID_MODE_DEFAULT or RAID_MODE_ALTERNATE. */ unsigned raid_mode; /**< Raid mode to use. RAID_MODE_DEFAULT or RAID_MODE_ALTERNATE. */
int file_mode; /**< File access mode. Combination of ADVISE_* flags. */ int file_mode; /**< File access mode. Combination of ADVISE_* flags. */
@ -167,7 +166,7 @@ struct snapraid_state {
tommy_list bucketlist; /**< Sorted list of info bucket. Derived from infoarr, but updated only state_read()/state_write() */ tommy_list bucketlist; /**< Sorted list of info bucket. Derived from infoarr, but updated only state_read()/state_write() */
block_off_t bucketcount; /**< Sum of all the counts of the list */ block_off_t bucketcount; /**< Sum of all the counts of the list */
/* Thermal */ /* thermal */
tommy_list thermallist; /**< List of all thermal state */ tommy_list thermallist; /**< List of all thermal state */
int thermal_stop_gathering; /**< If thermal data gathering is stopped */ int thermal_stop_gathering; /**< If thermal data gathering is stopped */
int thermal_system_temperature; /**< System temperature. 0 if not available */ int thermal_system_temperature; /**< System temperature. 0 if not available */
@ -240,6 +239,23 @@ void state_probe(struct snapraid_state* state);
*/ */
void state_read(struct snapraid_state* state); void state_read(struct snapraid_state* state);
/**
* Check if all configured parity splits have persistent sizes.
*/
int state_is_write_ready(struct snapraid_state* state);
/**
* Require initialized parity split sizes before commands that can save content.
*/
void state_require_write_ready(struct snapraid_state* state);
/**
* Count the number of unsynced parity positions using an event sweep across extents.
* Counts positions in [blockmin, blockmax). The caller must ensure that the disk list,
* extent trees, and block states remain unchanged for the duration of the call.
*/
uint64_t fs_count_unsynced(struct snapraid_state* state, block_off_t blockmin, block_off_t blockmax);
/** /**
* Write the new state. * Write the new state.
*/ */

View file

@ -493,7 +493,7 @@ static inline int is_wild_escape(char c)
#endif #endif
} }
/* /**
* Match with the previous pattern character provided in prev. * Match with the previous pattern character provided in prev.
* *
* An initial '**' needs to know if it was preceded by '/' to distinguish * An initial '**' needs to know if it was preceded by '/' to distinguish

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2025 Andrea Mazzoleni // Copyright (C) 2025 Andrea Mazzoleni
#ifndef __STR_H #ifndef STR_H
#define __STR_H #define STR_H
#include "app.h" #include "app.h"
#include "str.h" #include "str.h"
@ -97,7 +97,7 @@ char* strtrim(char* s);
*/ */
char* strlwr(char* s); char* strlwr(char* s);
/* /**
* Find the first occurrence of 'needle' in 'haystack' only if it * Find the first occurrence of 'needle' in 'haystack' only if it
* appears as a separate word (space, number or string boundaries). * appears as a separate word (space, number or string boundaries).
* *
@ -127,7 +127,7 @@ unsigned long long strtonll(const char* nptr, char** endptr, int base);
/****************************************************************************/ /****************************************************************************/
/* match */ /* match */
/* /**
* Wild match function. * Wild match function.
* *
* If match_sub is !=0, it matches sub directory. Specifically it matches if the * If match_sub is !=0, it matches sub directory. Specifically it matches if the

View file

@ -691,7 +691,7 @@ int sgetble32(STREAM* f, uint32_t* value)
return 0; return 0;
} }
int sgetbs(STREAM* f, char* str, size_t size) ssize_t sgetbs(STREAM* f, char* str, size_t size)
{ {
uint64_t len; uint64_t len;
@ -709,7 +709,13 @@ int sgetbs(STREAM* f, char* str, size_t size)
str[len] = 0; str[len] = 0;
return sread(f, str, len); if (sread(f, str, len) != 0) {
/* LCOV_EXCL_START */
return -1;
/* LCOV_EXCL_STOP */
}
return len;
} }
int swrite_uncached(const void* void_data, size_t size, STREAM* f) int swrite_uncached(const void* void_data, size_t size, STREAM* f)

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2011 Andrea Mazzoleni // Copyright (C) 2011 Andrea Mazzoleni
#ifndef __STREAM_H #ifndef STREAM_H
#define __STREAM_H #define STREAM_H
#include "support.h" #include "support.h"
#include "util.h" #include "util.h"
@ -329,7 +329,7 @@ int sgetble32(STREAM* f, uint32_t* value);
* Read a binary string. * Read a binary string.
* Return -1 on error or if the buffer is too small, or the number of chars read. * Return -1 on error or if the buffer is too small, or the number of chars read.
*/ */
int sgetbs(STREAM* f, char* str, size_t size); ssize_t sgetbs(STREAM* f, char* str, size_t size);
/****************************************************************************/ /****************************************************************************/
/* put */ /* put */

View file

@ -52,7 +52,6 @@ char* esc_buf(void)
*/ */
#if HAVE_THREAD #if HAVE_THREAD
static thread_mutex_t msg_lock; static thread_mutex_t msg_lock;
static thread_mutex_t memory_lock;
static thread_mutex_t random_lock; static thread_mutex_t random_lock;
#endif #endif
@ -70,20 +69,6 @@ void unlock_msg(void)
#endif #endif
} }
void lock_memory(void)
{
#if HAVE_THREAD
thread_mutex_lock(&memory_lock);
#endif
}
void unlock_memory(void)
{
#if HAVE_THREAD
thread_mutex_unlock(&memory_lock);
#endif
}
void lock_random(void) void lock_random(void)
{ {
#if HAVE_THREAD #if HAVE_THREAD
@ -103,7 +88,6 @@ void lock_init(void)
#if HAVE_THREAD #if HAVE_THREAD
/* initialize the locks as first operation as log_fatal depends on them */ /* initialize the locks as first operation as log_fatal depends on them */
thread_mutex_init(&msg_lock); thread_mutex_init(&msg_lock);
thread_mutex_init(&memory_lock);
thread_mutex_init(&random_lock); thread_mutex_init(&random_lock);
thread_key_create(&esc_key, esc_pool_free); thread_key_create(&esc_key, esc_pool_free);
#endif #endif
@ -119,7 +103,6 @@ void lock_done(void)
} }
thread_key_delete(esc_key); thread_key_delete(esc_key);
thread_mutex_destroy(&msg_lock); thread_mutex_destroy(&msg_lock);
thread_mutex_destroy(&memory_lock);
thread_mutex_destroy(&random_lock); thread_mutex_destroy(&random_lock);
#endif #endif
} }
@ -150,7 +133,7 @@ unsigned char random_u8(void)
return random_u64() & 0xFF; return random_u64() & 0xFF;
} }
/* /**
* SplitMix64 * SplitMix64
* *
* - Zero-safe: Any 64-bit seed is valid (even 0). * - Zero-safe: Any 64-bit seed is valid (even 0).
@ -310,7 +293,7 @@ unsigned log_hardware_errors(void)
return count; return count;
} }
/* /**
* Note that in the following functions we always flush both * Note that in the following functions we always flush both
* stdout and stderr, because we want to ensure that they mixes * stdout and stderr, because we want to ensure that they mixes
* well when redirected to files * well when redirected to files
@ -412,7 +395,7 @@ void vlog_fatal(int err, const char* format, va_list ap, const char* post)
log_failed = 1; log_failed = 1;
} }
/* A failed tagged write must retain stderr as the only usable fatal diagnostic. */ /* a failed tagged write must retain stderr as the only usable fatal diagnostic. */
if (!stdlog || log_failed || msg_fatal_stderr) { if (!stdlog || log_failed || msg_fatal_stderr) {
va_list ap_copy2; va_list ap_copy2;
va_copy(ap_copy2, ap); va_copy(ap_copy2, ap);
@ -1125,7 +1108,7 @@ void pathimport(char* dst, size_t size, const char* src)
pathcpy(dst, size, src); pathcpy(dst, size, src);
#ifdef _WIN32 #ifdef _WIN32
/* Convert the Windows dir separator '\' to C '/' */ /* convert the Windows dir separator '\' to C '/' */
while (*dst) { while (*dst) {
if (*dst == '\\') if (*dst == '\\')
*dst = '/'; *dst = '/';
@ -1139,7 +1122,7 @@ void pathexport(char* dst, size_t size, const char* src)
pathcpy(dst, size, src); pathcpy(dst, size, src);
#ifdef _WIN32 #ifdef _WIN32
/* Convert C '/' to Windows dir separator '\' */ /* convert C '/' to Windows dir separator '\' */
while (*dst) { while (*dst) {
if (*dst == '/') if (*dst == '/')
*dst = '\\'; *dst = '\\';
@ -1945,7 +1928,7 @@ int is_sep(char c)
|| c == (char)0xa0; /* french */ || c == (char)0xa0; /* french */
} }
/* /**
* snumber() * snumber()
* *
* Matches a literal prefix (the second argument), then parses the following * Matches a literal prefix (the second argument), then parses the following

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2011 Andrea Mazzoleni // Copyright (C) 2011 Andrea Mazzoleni
#ifndef __SUPPORT_H #ifndef SUPPORT_H
#define __SUPPORT_H #define SUPPORT_H
#include "app.h" #include "app.h"
#include "memory.h" #include "memory.h"
@ -36,12 +36,6 @@ void lock_done(void);
void lock_msg(void); void lock_msg(void);
void unlock_msg(void); void unlock_msg(void);
/**
* Lock used for memory counter.
*/
void lock_memory(void);
void unlock_memory(void);
/****************************************************************************/ /****************************************************************************/
/* random */ /* random */

View file

@ -11,7 +11,7 @@
#include "io.h" #include "io.h"
#include "raid/raid.h" #include "raid/raid.h"
/* /**
* SnapRAID sync model * SnapRAID sync model
* *
* Sync brings the stored parity and content metadata in line with the data * Sync brings the stored parity and content metadata in line with the data
@ -1921,7 +1921,7 @@ bail_abort:
return 0; return 0;
} }
/* /**
* Make a forced full parity rebuild persistent. * Make a forced full parity rebuild persistent.
* *
* REBUILD means that the current data and hash are known, but physical parity * REBUILD means that the current data and hash are known, but physical parity
@ -1959,7 +1959,7 @@ static void state_sync_mark_rebuild(struct snapraid_state* state)
state->need_write = 1; state->need_write = 1;
} }
/* /**
* Initialize persistent parity split sizes resolved while opening parity. * Initialize persistent parity split sizes resolved while opening parity.
* *
* parity_create() resolves PARITY_SIZE_INVALID in the parity handles using * parity_create() resolves PARITY_SIZE_INVALID in the parity handles using
@ -2208,7 +2208,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
/* after resizing parity files, refresh again the free info */ /* after resizing parity files, refresh again the free info */
state_refresh(state); state_refresh(state);
/** /*
* Save the new state before the sync but after the hashing phase * Save the new state before the sync but after the hashing phase
* *
* This allows to recover after an aborted sync, and at the same time * This allows to recover after an aborted sync, and at the same time

View file

@ -30,7 +30,7 @@ void thermal_free(void* void_thermal)
free(thermal); free(thermal);
} }
/* /**
* Fit exponential heating model to data using least squares * Fit exponential heating model to data using least squares
*/ */
struct snapraid_thermal_params fit_thermal_model(const struct snapraid_thermal_point* points, int n_points, double t_ambient) struct snapraid_thermal_params fit_thermal_model(const struct snapraid_thermal_point* points, int n_points, double t_ambient)

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2025 Andrea Mazzoleni // Copyright (C) 2025 Andrea Mazzoleni
#ifndef __THERMAL_H #ifndef THERMAL_H
#define __THERMAL_H #define THERMAL_H
#include "elem.h" #include "elem.h"

View file

@ -90,6 +90,14 @@ int state_touch(struct snapraid_state* state)
} }
#endif #endif
if (f == -1) { if (f == -1) {
/*
* Ignore missing files because they may have been deleted
* or moved since the last sync. Also ignore symbolic links
* which fail with ELOOP due to O_NOFOLLOW.
*/
if (errno == ENOENT || errno == ENOTDIR || errno == ELOOP)
continue;
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_error(errno, "Error opening file '%s'. %s.\n", path, strerror(errno)); log_error(errno, "Error opening file '%s'. %s.\n", path, strerror(errno));
++error; ++error;
@ -112,11 +120,12 @@ int state_touch(struct snapraid_state* state)
} }
/* /*
* Touch only files that are still unchanged compared to * Touch only regular files that are still unchanged compared to
* the content file. Otherwise changing the timestamp here * the content file. Otherwise changing the timestamp here
* could hide a modification from the following scan. * could hide a modification from the following scan.
*/ */
if (st.st_size != file->size if (!S_ISREG(st.st_mode)
|| st.st_size != file->size
|| st.st_mtime != file->mtime_sec || st.st_mtime != file->mtime_sec
|| STAT_NSEC(&st) != file->mtime_nsec || STAT_NSEC(&st) != file->mtime_nsec
) { ) {

View file

@ -3,7 +3,7 @@
#include "os/portable.h" #include "os/portable.h"
#ifndef __MINGW32__ /* Only for Unix */ #ifndef __MINGW32__ /* only for Unix */
#include "app.h" #include "app.h"
#include "support.h" #include "support.h"
@ -64,7 +64,7 @@ static inline unsigned statfs_type(const struct statfs* sfs)
#if HAVE_LINUX_DEVICE #if HAVE_LINUX_DEVICE
static const char* const bcachefs_paths[] = { static const char* const bcachefs_paths[] = {
#ifdef BCACHEFS_PATH #ifdef BCACHEFS_PATH
/* Path configured at build time (e.g. on NixOS). */ /* path configured at build time (e.g. on NixOS). */
BCACHEFS_PATH, BCACHEFS_PATH,
#else #else
"/usr/sbin/bcachefs", "/usr/sbin/bcachefs",
@ -96,7 +96,7 @@ static const char* find_bcachefs(void)
#if HAVE_LINUX_DEVICE #if HAVE_LINUX_DEVICE
static const char* const zfs_paths[] = { static const char* const zfs_paths[] = {
#ifdef ZFS_PATH #ifdef ZFS_PATH
/* Path configured at build time (e.g. on NixOS). */ /* path configured at build time (e.g. on NixOS). */
ZFS_PATH, ZFS_PATH,
#else #else
"/usr/sbin/zfs", "/usr/sbin/zfs",
@ -125,7 +125,7 @@ static const char* find_zfs(void)
static const char* const zpool_paths[] = { static const char* const zpool_paths[] = {
#ifdef ZPOOL_PATH #ifdef ZPOOL_PATH
/* Path configured at build time (e.g. on NixOS). */ /* path configured at build time (e.g. on NixOS). */
ZPOOL_PATH, ZPOOL_PATH,
#else #else
"/usr/sbin/zpool", "/usr/sbin/zpool",
@ -157,7 +157,7 @@ static const char* find_zpool(void)
static const char* smartctl_paths[] = { static const char* smartctl_paths[] = {
#ifdef SMARTCTL_PATH #ifdef SMARTCTL_PATH
/* Path configured at build time (e.g. on NixOS). */ /* path configured at build time (e.g. on NixOS). */
SMARTCTL_PATH, SMARTCTL_PATH,
#else #else
/* Linux & BSD */ /* Linux & BSD */
@ -228,7 +228,7 @@ static ssize_t sysread(const char* path, char* buf, size_t buf_size)
#endif #endif
#if HAVE_LINUX_DEVICE #if HAVE_LINUX_DEVICE
/* /**
* sysattr_vpd_pg80 — parse raw binary VPD page 0x80 (Unit Serial Number) * sysattr_vpd_pg80 — parse raw binary VPD page 0x80 (Unit Serial Number)
* from a sysfs vpd_pg80 file. * from a sysfs vpd_pg80 file.
*/ */
@ -291,7 +291,7 @@ static int sysattr_vpd_pg80(const char* path, char* dst, size_t dst_size)
} }
#endif #endif
/* /**
* sysread_vpd_pg83 — parse raw binary VPD page 0x83 (Device Identification) * sysread_vpd_pg83 — parse raw binary VPD page 0x83 (Device Identification)
* from a sysfs vpd_pg83 file and extract the first NAA (Network Address * from a sysfs vpd_pg83 file and extract the first NAA (Network Address
* Authority) designator for the Logical Unit (ASSOCIATION == 0x00). * Authority) designator for the Logical Unit (ASSOCIATION == 0x00).
@ -418,7 +418,7 @@ static int sysattr_vpd_pg83(const char* path, char* dst, size_t dst_size)
switch (naa) { switch (naa) {
case 0x1 : /* IEEE Extended */ case 0x1 : /* IEEE Extended */
case 0x2 : /* Locally Assigned */ case 0x2 : /* locally assigned */
case 0x3 : /* IEEE Registered */ case 0x3 : /* IEEE Registered */
case 0x5 : /* IEEE Registered */ case 0x5 : /* IEEE Registered */
expected = 8; expected = 8;
@ -503,7 +503,7 @@ static long long syslong(const char* path)
return v; return v;
} }
/* /**
* Parse Linux cpulist format (e.g. "0-3,5,8-11") into an array of CPU IDs. * Parse Linux cpulist format (e.g. "0-3,5,8-11") into an array of CPU IDs.
* *
* Returns the total number of CPUs in the list. Stores up to max_cpus entries. * Returns the total number of CPUs in the list. Stores up to max_cpus entries.
@ -553,7 +553,7 @@ static unsigned parse_cpulist(const char* str, unsigned* cpus, unsigned max_cpus
return count; return count;
} }
/* /**
* Read online CPU IDs from /sys/devices/system/cpu/online. * Read online CPU IDs from /sys/devices/system/cpu/online.
* *
* Falls back to consecutive 0..N-1 IDs if sysfs is unavailable. * Falls back to consecutive 0..N-1 IDs if sysfs is unavailable.
@ -584,7 +584,7 @@ static unsigned read_online_cpus(unsigned* cpus, unsigned max_cpus)
return count; return count;
} }
/* /**
* Returns 1 if the specified cpu is the lowest-numbered logical CPU in its * Returns 1 if the specified cpu is the lowest-numbered logical CPU in its
* physical core's SMT sibling set. * physical core's SMT sibling set.
*/ */
@ -2737,7 +2737,7 @@ static int fssnapshot_stat_fs(const struct fssnapshot_struct* fss, const char* n
} }
#endif #endif
/* /**
* Native ZFS snapshots use a SnapRAID-specific prefix to avoid * Native ZFS snapshots use a SnapRAID-specific prefix to avoid
* deleting or renaming unrelated user snapshots with generic * deleting or renaming unrelated user snapshots with generic
* names such as @scan, @pending, or @stable. * names such as @scan, @pending, or @stable.
@ -2772,7 +2772,7 @@ static int fssnapshot_stat_zfs(const struct fssnapshot_struct* fss, const char*
return -1; return -1;
} }
/** /*
* When verifying if a ZFS snapshot has been successfully deleted, a direct * When verifying if a ZFS snapshot has been successfully deleted, a direct
* path lookup (stat, access, open) is unreliable. A directory listing * path lookup (stat, access, open) is unreliable. A directory listing
* (readdir) of the .zfs/snapshot directory must be used instead. * (readdir) of the .zfs/snapshot directory must be used instead.
@ -4375,6 +4375,16 @@ int devquery(tommy_list* high, tommy_list* low)
struct dev_struct* dev = j->data; struct dev_struct* dev = j->data;
uint64_t access_stat; uint64_t access_stat;
/*
* Major 0 is an anonymous superblock (NFS, CIFS, FUSE, tmpfs, overlay, ...)
* not backed by a block device. Btrfs/Bcachefs/ZFS are already dereferenced
* to their member devices, so what remains has no physical disk to manage.
*/
if (major(dev->device) == 0) {
log_tag("device:%s:skip:%u:%u: no block device\n", esc_tag(devinfo->name), major(dev->device), minor(dev->device));
continue;
}
/* retrieve access stat for the high level device */ /* retrieve access stat for the high level device */
if (devstat(dev->device, &access_stat) == 0) { if (devstat(dev->device, &access_stat) == 0) {
/* cumulate access stat in the first split */ /* cumulate access stat in the first split */
@ -4420,6 +4430,9 @@ int devquery(tommy_list* high, tommy_list* low)
#else #else
(void)high; (void)high;
(void)low; (void)low;
/* device operations are unsupported in this platform */
failed = 1;
#endif #endif
return failed ? -1 : degraded ? 1 : 0; return failed ? -1 : degraded ? 1 : 0;
@ -4447,6 +4460,7 @@ int devmap(void)
{ {
#if HAVE_LINUX_DEVICE #if HAVE_LINUX_DEVICE
char path[PATH_MAX]; char path[PATH_MAX];
char boot_id[64];
DIR* d = opendir("/sys/block"); DIR* d = opendir("/sys/block");
if (!d) { if (!d) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
@ -4454,6 +4468,22 @@ int devmap(void)
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
/* optional boot identity: failure must not affect hardware mappings */
if (sysattr("/proc/sys/kernel/random/boot_id", boot_id, sizeof(boot_id)) != 0 || strlen(boot_id) != 36) {
boot_id[0] = 0;
} else {
for (unsigned i = 0; i < 36; ++i) {
if (i == 8 || i == 13 || i == 18 || i == 23) {
if (boot_id[i] == '-')
continue;
} else if (hexval(boot_id[i]) >= 0) {
continue;
}
boot_id[0] = 0;
break;
}
}
struct dirent* dd; struct dirent* dd;
while (1) { while (1) {
char buf[256]; char buf[256];
@ -4517,6 +4547,20 @@ int devmap(void)
if (sysattr(path, buf, sizeof(buf)) == 0 && buf[0] != 0) { if (sysattr(path, buf, sizeof(buf)) == 0 && buf[0] != 0) {
log_tag("map:/dev/%s:%s\n", dd->d_name, esc_tag(buf)); log_tag("map:/dev/%s:%s\n", dd->d_name, esc_tag(buf));
} }
/*
* This identifies the kernel device instance within one boot, not
* persistent hardware across reconnections. Missing attributes are optional.
*/
if (boot_id[0] != 0) {
pathprint(path, sizeof(path), "/sys/block/%s/diskseq", dd->d_name);
if (sysattr(path, buf, sizeof(buf)) == 0) {
char* end;
unsigned long long diskseq = strtonll(buf, &end, 10);
if (buf[0] >= '0' && buf[0] <= '9' && diskseq != 0 && end != buf && *end == 0)
log_tag("map:/dev/%s:linux-diskseq.%s.%llu\n", esc_tag(dd->d_name), esc_tag(boot_id), diskseq);
}
}
} }
closedir(d); closedir(d);
@ -4530,7 +4574,7 @@ int devmap(void)
#if HAVE_LINUX_DEVICE #if HAVE_LINUX_DEVICE
/* List of possible ambient temperature labels */ /* list of possible ambient temperature labels */
const char* AMBIENT_LABEL[] = { const char* AMBIENT_LABEL[] = {
"systin", "systin",
"auxtin", "auxtin",
@ -4976,7 +5020,7 @@ void machineinfo(struct machineinfo_struct* info)
} }
} }
/* Fallback if sysfs cpufreq is unavailable (e.g. Cloud VM) */ /* fallback if sysfs cpufreq is unavailable (e.g. Cloud VM) */
if (info->cpu_clock[0] == 0) { if (info->cpu_clock[0] == 0) {
#ifdef CONFIG_X86 #ifdef CONFIG_X86
raid_cpuid(0, 0, reg); raid_cpuid(0, 0, reg);

View file

@ -7,6 +7,7 @@
#include "util.h" #include "util.h"
#include "raid/cpu.h" #include "raid/cpu.h"
#include "raid/memory.h" #include "raid/memory.h"
#include "tommyds/tommyhash.h"
/****************************************************************************/ /****************************************************************************/
/* memory */ /* memory */
@ -433,7 +434,7 @@ static void crc32c_skip_init(uint32_t table[8][16], size_t size)
unsigned i; unsigned i;
unsigned j; unsigned j;
/* Collapse each fixed-size shift into eight nibble table lookups. */ /* collapse each fixed-size shift into eight nibble table lookups. */
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
for (j = 0; j < 16; ++j) for (j = 0; j < 16; ++j)
table[i][j] = crc32c_shift((uint32_t)j << (4 * i), size); table[i][j] = crc32c_shift((uint32_t)j << (4 * i), size);
@ -453,6 +454,7 @@ uint32_t crc32c_gen(uint32_t crc, const unsigned char* ptr, size_t size)
} }
#if CONFIG_X86 #if CONFIG_X86
__aligned_loops(64)
uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, size_t size) uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, size_t size)
{ {
crc ^= CRC_IV; crc ^= CRC_IV;
@ -466,6 +468,7 @@ uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, size_t size)
#endif #endif
#if CONFIG_ARM_CRC #if CONFIG_ARM_CRC
__aligned_loops(64)
uint32_t crc32c_arm64(uint32_t crc, const unsigned char* ptr, size_t size) uint32_t crc32c_arm64(uint32_t crc, const unsigned char* ptr, size_t size)
{ {
crc ^= CRC_IV; crc ^= CRC_IV;
@ -512,7 +515,7 @@ void crc32c_init(void)
/****************************************************************************/ /****************************************************************************/
/* byte operations */ /* byte operations */
/* /**
* Rotate left. * Rotate left.
* In x86/x64/ARM they are optimized with a single assembler instruction. * In x86/x64/ARM they are optimized with a single assembler instruction.
*/ */
@ -526,7 +529,7 @@ static inline uint64_t util_rotl64(uint64_t x, unsigned r)
return (x << (r & 63)) | (x >> ((-r) & 63)); return (x << (r & 63)) | (x >> ((-r) & 63));
} }
/* /**
* Rotate right. * Rotate right.
* In x86/x64/ARM they are optimized with a single assembler instruction. * In x86/x64/ARM they are optimized with a single assembler instruction.
*/ */
@ -608,112 +611,6 @@ static inline void util_write64(void* ptr, uint64_t v)
memcpy(ptr, &v, sizeof(v)); memcpy(ptr, &v, sizeof(v));
} }
/*
* 64*64 -> 128bit multiply function.
*
* @param A Address of 64-bit number.
* @param B Address of 64-bit number.
*
* Calculates 128-bit C = *A * *B.
*
* Overwrites A contents with C's low 64 bits.
* Overwrites B contents with C's high 64 bits.
*/
#if defined(__x86_64__) || defined(_M_X64)
/*
* This is intentionally placed before the __SIZEOF_INT128__ implementation.
*
* This implementation happens to generate more efficient code.
* While this likely depends only on the compiler, as long as it remains faster,
* we will keep it in this order.
*/
static inline void util_mum(uint64_t* A, uint64_t* B)
{
uint64_t a = *A;
uint64_t b = *B;
uint64_t low, high;
__asm__ (
"mulq %3"
: "=a" (low), "=d" (high)
: "a" (a), "rm" (b)
: "cc"
);
*A = low;
*B = high;
}
#elif defined(__SIZEOF_INT128__)
static inline void util_mum(uint64_t* A, uint64_t* B)
{
__uint128_t product = ((__uint128_t)*A) * ((__uint128_t)*B);
*A = (uint64_t)product;
*B = (uint64_t)(product >> 64);
}
#elif defined(__aarch64__) || defined(_M_ARM64)
/*
* This is intentionally placed after the __SIZEOF_INT128__ implementation.
*
* Although the code looks correct, there is a report of this
* implementation failing the self-test on macOS (Darwin 25.4.0, arm64)
* with Apple clang 21.0.0 (clang-2100.0.123.102).
*
* See: https://github.com/amadvance/snapraid/issues/43
*
* Note that the implementation is the same of OpenSSL:
*
* #elif defined(__aarch64__) && defined(SIXTY_FOUR_BIT_LONG)
* #if defined(__GNUC__) && __GNUC__ >= 2
* #define BN_UMULT_HIGH(a, b) ({ \
* register BN_ULONG ret; \
* asm ("umulh %0,%1,%2" \
* : "=r"(ret) \
* : "r"(a), "r"(b)); \
* ret; })
* #endif
* #endif
*
* See: https://github.com/openssl/openssl/blob/0463cbf185680e66a3a8960f10cd33001377d28e/crypto/bn/bn_local.h#L439
*/
static inline void util_mum(uint64_t* A, uint64_t* B)
{
uint64_t a = *A;
uint64_t b = *B;
uint64_t low = a * b;
uint64_t high;
__asm__ (
"umulh %0, %1, %2"
: "=r" (high)
: "r" (a), "r" (b)
);
*A = low;
*B = high;
}
#else
static inline void util_mum(uint64_t* A, uint64_t* B)
{
uint64_t a = *A;
uint64_t b = *B;
uint64_t a_lo = (uint32_t)a;
uint64_t a_hi = a >> 32;
uint64_t b_lo = (uint32_t)b;
uint64_t b_hi = b >> 32;
uint64_t p0 = a_lo * b_lo;
uint64_t p1 = a_lo * b_hi;
uint64_t p2 = a_hi * b_lo;
uint64_t p3 = a_hi * b_hi;
uint64_t middle = p1 + (p0 >> 32) + (uint32_t)p2;
uint64_t low = (middle << 32) | (uint32_t)p0;
uint64_t high = p3 + (middle >> 32) + (p2 >> 32);
*A = low;
*B = high;
}
#endif
int util_selftest(void) int util_selftest(void)
{ {
/* rotate left 32-bit */ /* rotate left 32-bit */
@ -746,33 +643,33 @@ int util_selftest(void)
if (util_rotr64(0x123456789ABCDEF0ULL, 0) != 0x123456789ABCDEF0ULL) return -1; if (util_rotr64(0x123456789ABCDEF0ULL, 0) != 0x123456789ABCDEF0ULL) return -1;
if (util_rotr64(0x123456789ABCDEF0ULL, 64) != 0x123456789ABCDEF0ULL) return -1; if (util_rotr64(0x123456789ABCDEF0ULL, 64) != 0x123456789ABCDEF0ULL) return -1;
/* util_mum tests */ /* tommy_mum tests */
uint64_t a, b; uint64_t a, b;
/* small values */ /* small values */
a = 3; b = 4; a = 3; b = 4;
util_mum(&a, &b); tommy_mum(&a, &b);
if (a != 12 || b != 0) return -1; if (a != 12 || b != 0) return -1;
/* 1 * anything */ /* 1 * anything */
a = 0xFFFFFFFFFFFFFFFFULL; b = 1; a = 0xFFFFFFFFFFFFFFFFULL; b = 1;
util_mum(&a, &b); tommy_mum(&a, &b);
if (a != 0xFFFFFFFFFFFFFFFFULL || b != 0) return -1; if (a != 0xFFFFFFFFFFFFFFFFULL || b != 0) return -1;
/* (2^32) * (2^32) = 2^64 */ /* (2^32) * (2^32) = 2^64 */
a = 1ULL << 32; b = 1ULL << 32; a = 1ULL << 32; b = 1ULL << 32;
util_mum(&a, &b); tommy_mum(&a, &b);
if (a != 0 || b != 1) return -1; if (a != 0 || b != 1) return -1;
/* max uint64 * max uint64 */ /* max uint64 * max uint64 */
a = 0xFFFFFFFFFFFFFFFFULL; b = 0xFFFFFFFFFFFFFFFFULL; a = 0xFFFFFFFFFFFFFFFFULL; b = 0xFFFFFFFFFFFFFFFFULL;
util_mum(&a, &b); tommy_mum(&a, &b);
if (a != 1 || b != 0xFFFFFFFFFFFFFFFEULL) return -1; if (a != 1 || b != 0xFFFFFFFFFFFFFFFEULL) return -1;
/* larger random-ish test */ /* larger random-ish test */
a = 0x0123456789ABCDEFULL; a = 0x0123456789ABCDEFULL;
b = 0xFEDCBA9876543210ULL; b = 0xFEDCBA9876543210ULL;
util_mum(&a, &b); tommy_mum(&a, &b);
if (a != 0x2236D88FE5618CF0ULL || b != 0x121FA00AD77D742ULL) return -1; if (a != 0x2236D88FE5618CF0ULL || b != 0x121FA00AD77D742ULL) return -1;
return 0; return 0;
@ -826,7 +723,7 @@ void memhash(unsigned kind, const unsigned char* seed, void* digest, const void*
default : default :
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Internal inconsistency in hash function %u\n", kind); log_fatal(EINTERNAL, "Internal inconsistency in hash function %u\n", kind);
exit(EXIT_FAILURE); os_abort();
break; break;
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2011 Andrea Mazzoleni // Copyright (C) 2011 Andrea Mazzoleni
#ifndef __UTIL_H #ifndef UTIL_H
#define __UTIL_H #define UTIL_H
#include "tommyds/tommytypes.h" #include "tommyds/tommytypes.h"
@ -110,6 +110,11 @@ uint32_t crc32c_shift(uint32_t crc, size_t size);
*/ */
static inline uint32_t crc32c_gen_plain(uint32_t crc, const unsigned char* ptr, size_t size) static inline uint32_t crc32c_gen_plain(uint32_t crc, const unsigned char* ptr, size_t size)
{ {
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC unroll 1
#elif defined(__clang__)
#pragma unroll 1
#endif
while (size >= 4) { while (size >= 4) {
crc ^= ptr[0] | (uint32_t)ptr[1] << 8 | (uint32_t)ptr[2] << 16 | (uint32_t)ptr[3] << 24; crc ^= ptr[0] | (uint32_t)ptr[1] << 8 | (uint32_t)ptr[2] << 16 | (uint32_t)ptr[3] << 24;
crc = CRC32C_3[crc & 0xff] ^ CRC32C_2[(crc >> 8) & 0xff] ^ CRC32C_1[(crc >> 16) & 0xff] ^ CRC32C_0[crc >> 24]; crc = CRC32C_3[crc & 0xff] ^ CRC32C_2[(crc >> 8) & 0xff] ^ CRC32C_1[(crc >> 16) & 0xff] ^ CRC32C_0[crc >> 24];
@ -143,6 +148,7 @@ static __always_inline uint32_t crc32c_x86_64_skip(uint32_t crc, const uint32_t
^ table[7][crc >> 28]; ^ table[7][crc >> 28];
} }
__aligned_loops(64)
static __always_inline uint32_t crc32c_x86_64_3lane(uint32_t crc, const unsigned char* ptr, size_t lane_size, const uint32_t table[8][16]) static __always_inline uint32_t crc32c_x86_64_3lane(uint32_t crc, const unsigned char* ptr, size_t lane_size, const uint32_t table[8][16])
{ {
const unsigned char* ptr0 = ptr; const unsigned char* ptr0 = ptr;
@ -175,6 +181,7 @@ static __always_inline uint32_t crc32c_x86_64_3lane(uint32_t crc, const unsigned
} }
#endif #endif
__aligned_loops(64)
static __always_inline uint32_t crc32c_x86_plain(uint32_t crc, const unsigned char* ptr, size_t size) static __always_inline uint32_t crc32c_x86_plain(uint32_t crc, const unsigned char* ptr, size_t size)
{ {
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64

View file

@ -71,7 +71,7 @@ AC_HEADER_ASSERT
AC_HEADER_SYS_WAIT AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([dirent.h stdint.h inttypes.h unistd.h math.h execinfo.h strings.h getopt.h syslog.h grp.h pwd.h io.h alloca.h]) AC_CHECK_HEADERS([dirent.h stdint.h inttypes.h unistd.h math.h execinfo.h strings.h getopt.h syslog.h grp.h pwd.h io.h alloca.h])
AC_CHECK_HEADERS([sys/file.h sys/sysctl.h sys/ioctl.h sys/time.h sys/types.h sys/mkdev.h sys/sysmacros.h sys/stat.h sys/prctl.h sys/sysinfo.h sys/utsname.h]) AC_CHECK_HEADERS([sys/file.h sys/sysctl.h sys/ioctl.h sys/time.h sys/types.h sys/mkdev.h sys/sysmacros.h sys/stat.h sys/prctl.h sys/sysinfo.h sys/utsname.h])
AC_CHECK_HEADERS([linux/fs.h linux/btrfs.h linux/fiemap.h mach/mach_time.h]) AC_CHECK_HEADERS([linux/fs.h linux/btrfs.h linux/fiemap.h])
# Check for the close_range(...,CLOSE_RANGE_CLOEXEC) # Check for the close_range(...,CLOSE_RANGE_CLOEXEC)
AC_CHECK_HEADERS([linux/close_range.h]) AC_CHECK_HEADERS([linux/close_range.h])
@ -126,7 +126,6 @@ AC_CHECK_FUNCS([fsync posix_fadvise sync_file_range syncfs])
AC_CHECK_FUNCS([getc_unlocked ferror_unlocked]) AC_CHECK_FUNCS([getc_unlocked ferror_unlocked])
AC_CHECK_FUNCS([futimes futimens futimesat localtime_r lutimes utimensat]) AC_CHECK_FUNCS([futimes futimens futimesat localtime_r lutimes utimensat])
AC_CHECK_FUNCS([fstatat flock renameat statx]) AC_CHECK_FUNCS([fstatat flock renameat statx])
AC_CHECK_FUNCS([mach_absolute_time])
AC_CHECK_FUNCS([backtrace backtrace_symbols]) AC_CHECK_FUNCS([backtrace backtrace_symbols])
AC_SEARCH_LIBS([clock_gettime], [rt]) AC_SEARCH_LIBS([clock_gettime], [rt])
AC_CHECK_FUNCS([clock_gettime]) AC_CHECK_FUNCS([clock_gettime])

View file

@ -2075,6 +2075,37 @@ Wenn ein \`sync\` jedoch unterbrochen wird, vermeiden Sie es, Dateien zu
die aus dem vom unterbrochenen Sync verwendeten Snapshot berechnet wurden. die aus dem vom unterbrochenen Sync verwendeten Snapshot berechnet wurden.
Ein späterer Sync könnte diesen Snapshot ersetzen, wodurch Zwischenversionen Ein späterer Sync könnte diesen Snapshot ersetzen, wodurch Zwischenversionen
von Dateien für die Wiederherstellung nicht mehr verfügbar sind. von Dateien für die Wiederherstellung nicht mehr verfügbar sind.
.SS Externe Sicherungen mit Dateisystem\-Snapshots (External backups with filesystem snapshots)
Wenn Dateisystem\-Snapshots aktiviert sind, greift SnapRAID auf Snapshots
an der Wurzel jedes Daten\-Subvolumes, Volumes oder Datasets zu oder erstellt
diese dort.
.PP
Ein einfacher Weg, um jegliche Beeinträchtigung durch externe Tools zu
vermeiden, besteht darin, die \`data\`\-Konfiguration auf ein reguläres
Unterverzeichnis innerhalb des Subvolumes oder Volumes verweisen zu lassen
(beispielsweise \`/mnt/subvol/data\` statt \`/mnt/subvol\`). SnapRAID erstellt
das Snapshot\-Verzeichnis immer an der Wurzel des Subvolumes (beispielsweise
\`/mnt/subvol/.snapraid/\`), wodurch das Datenunterverzeichnis sauber bleibt
und Snapshots außerhalb und unsichtbar für Sicherungswerkzeuge bleiben, die
darin arbeiten.
.PP
Wenn das konfigurierte \`data\`\-Verzeichnis hingegen selbst die Wurzel des
Subvolumes oder Volumes ist, erstellt SnapRAID ein \`.snapraid/\`\-Verzeichnis
direkt darin (auf Btrfs, Bcachefs und NTFS). Während SnapRAID dieses
Verzeichnis bei seinen eigenen Scans automatisch ausschließt, werden
externe Sicherungs\- oder Synchronisationswerkzeuge darauf stoßen. Wenn es
nicht ausgeschlossen wird, könnten sie in die Snapshots oder Verknüpfungen
eindringen und den gesamten eingefrorenen Datenbaum kopieren, was Daten
dupliziert und den Sicherungsspeicherplatz erschöpfen kann. Konfigurieren
Sie externe Sicherungswerkzeuge immer so, dass sie das Verzeichnis
\`.snapraid/\` ausschließen.
.PP
Bei ZFS werden Snapshots über das standardmäßige virtuelle Verzeichnis
\`.zfs/snapshot/\` anstelle von \`.snapraid/\` bereitgestellt. Standardmäßig
(\`snapdir=hidden\`) blendet ZFS dieses Verzeichnis in Verzeichnislisten aus,
sodass externe Sicherungswerkzeuge es nicht durchlaufen. Wenn Sie
\`snapdir=visible\` aktiviert haben, stellen Sie sicher, dass Ihre
Sicherungswerkzeuge das Verzeichnis \`.zfs/\` ausschließen.
.SH MUSTER (PATTERN) .SH MUSTER (PATTERN)
Muster bieten eine flexible Möglichkeit, Dateien für die Einbeziehung oder Muster bieten eine flexible Möglichkeit, Dateien für die Einbeziehung oder
den Ausschluss zu filtern. Durch die Verwendung von Globbing\-Zeichen können Sie Regeln definieren, den Ausschluss zu filtern. Durch die Verwendung von Globbing\-Zeichen können Sie Regeln definieren,

View file

@ -1669,6 +1669,38 @@ Lebenszyklus von Snapshots (Snapshots Lifecycle)
Ein späterer Sync könnte diesen Snapshot ersetzen, wodurch Zwischenversionen Ein späterer Sync könnte diesen Snapshot ersetzen, wodurch Zwischenversionen
von Dateien für die Wiederherstellung nicht mehr verfügbar sind. von Dateien für die Wiederherstellung nicht mehr verfügbar sind.
Externe Sicherungen mit Dateisystem-Snapshots (External backups with filesystem snapshots)
Wenn Dateisystem-Snapshots aktiviert sind, greift SnapRAID auf Snapshots
an der Wurzel jedes Daten-Subvolumes, Volumes oder Datasets zu oder erstellt
diese dort.
Ein einfacher Weg, um jegliche Beeinträchtigung durch externe Tools zu
vermeiden, besteht darin, die `data`-Konfiguration auf ein reguläres
Unterverzeichnis innerhalb des Subvolumes oder Volumes verweisen zu lassen
(beispielsweise `/mnt/subvol/data` statt `/mnt/subvol`). SnapRAID erstellt
das Snapshot-Verzeichnis immer an der Wurzel des Subvolumes (beispielsweise
`/mnt/subvol/.snapraid/`), wodurch das Datenunterverzeichnis sauber bleibt
und Snapshots außerhalb und unsichtbar für Sicherungswerkzeuge bleiben, die
darin arbeiten.
Wenn das konfigurierte `data`-Verzeichnis hingegen selbst die Wurzel des
Subvolumes oder Volumes ist, erstellt SnapRAID ein `.snapraid/`-Verzeichnis
direkt darin (auf Btrfs, Bcachefs und NTFS). Während SnapRAID dieses
Verzeichnis bei seinen eigenen Scans automatisch ausschließt, werden
externe Sicherungs- oder Synchronisationswerkzeuge darauf stoßen. Wenn es
nicht ausgeschlossen wird, könnten sie in die Snapshots oder Verknüpfungen
eindringen und den gesamten eingefrorenen Datenbaum kopieren, was Daten
dupliziert und den Sicherungsspeicherplatz erschöpfen kann. Konfigurieren
Sie externe Sicherungswerkzeuge immer so, dass sie das Verzeichnis
`.snapraid/` ausschließen.
Bei ZFS werden Snapshots über das standardmäßige virtuelle Verzeichnis
`.zfs/snapshot/` anstelle von `.snapraid/` bereitgestellt. Standardmäßig
(`snapdir=hidden`) blendet ZFS dieses Verzeichnis in Verzeichnislisten aus,
sodass externe Sicherungswerkzeuge es nicht durchlaufen. Wenn Sie
`snapdir=visible` aktiviert haben, stellen Sie sicher, dass Ihre
Sicherungswerkzeuge das Verzeichnis `.zfs/` ausschließen.
Muster (Pattern) Muster (Pattern)
Muster bieten eine flexible Möglichkeit, Dateien für die Einbeziehung oder Muster bieten eine flexible Möglichkeit, Dateien für die Einbeziehung oder
den Ausschluss zu filtern. Durch die Verwendung von Globbing-Zeichen können Sie Regeln definieren, den Ausschluss zu filtern. Durch die Verwendung von Globbing-Zeichen können Sie Regeln definieren,

View file

@ -1779,6 +1779,40 @@ die aus dem vom unterbrochenen Sync verwendeten Snapshot berechnet wurden.
Ein späterer Sync könnte diesen Snapshot ersetzen, wodurch Zwischenversionen Ein späterer Sync könnte diesen Snapshot ersetzen, wodurch Zwischenversionen
von Dateien für die Wiederherstellung nicht mehr verfügbar sind. von Dateien für die Wiederherstellung nicht mehr verfügbar sind.
9.1 Externe Sicherungen mit Dateisystem-Snapshots (External backups with filesystem snapshots)
----------------------------------------------------------------------------------------------
Wenn Dateisystem-Snapshots aktiviert sind, greift SnapRAID auf Snapshots
an der Wurzel jedes Daten-Subvolumes, Volumes oder Datasets zu oder erstellt
diese dort.
Ein einfacher Weg, um jegliche Beeinträchtigung durch externe Tools zu
vermeiden, besteht darin, die `data`-Konfiguration auf ein reguläres
Unterverzeichnis innerhalb des Subvolumes oder Volumes verweisen zu lassen
(beispielsweise `/mnt/subvol/data` statt `/mnt/subvol`). SnapRAID erstellt
das Snapshot-Verzeichnis immer an der Wurzel des Subvolumes (beispielsweise
`/mnt/subvol/.snapraid/`), wodurch das Datenunterverzeichnis sauber bleibt
und Snapshots außerhalb und unsichtbar für Sicherungswerkzeuge bleiben, die
darin arbeiten.
Wenn das konfigurierte `data`-Verzeichnis hingegen selbst die Wurzel des
Subvolumes oder Volumes ist, erstellt SnapRAID ein `.snapraid/`-Verzeichnis
direkt darin (auf Btrfs, Bcachefs und NTFS). Während SnapRAID dieses
Verzeichnis bei seinen eigenen Scans automatisch ausschließt, werden
externe Sicherungs- oder Synchronisationswerkzeuge darauf stoßen. Wenn es
nicht ausgeschlossen wird, könnten sie in die Snapshots oder Verknüpfungen
eindringen und den gesamten eingefrorenen Datenbaum kopieren, was Daten
dupliziert und den Sicherungsspeicherplatz erschöpfen kann. Konfigurieren
Sie externe Sicherungswerkzeuge immer so, dass sie das Verzeichnis
`.snapraid/` ausschließen.
Bei ZFS werden Snapshots über das standardmäßige virtuelle Verzeichnis
`.zfs/snapshot/` anstelle von `.snapraid/` bereitgestellt. Standardmäßig
(`snapdir=hidden`) blendet ZFS dieses Verzeichnis in Verzeichnislisten aus,
sodass externe Sicherungswerkzeuge es nicht durchlaufen. Wenn Sie
`snapdir=visible` aktiviert haben, stellen Sie sicher, dass Ihre
Sicherungswerkzeuge das Verzeichnis `.zfs/` ausschließen.
10 MUSTER (PATTERN) 10 MUSTER (PATTERN)
=================== ===================

View file

@ -2034,6 +2034,36 @@ con éxito. La paridad aún puede contener bloques calculados a partir de
la instantánea utilizada por el sync interrumpido. Un sync posterior puede la instantánea utilizada por el sync interrumpido. Un sync posterior puede
reemplazar esa instantánea, haciendo que las versiones intermedias de los reemplazar esa instantánea, haciendo que las versiones intermedias de los
archivos no estén disponibles para la recuperación. archivos no estén disponibles para la recuperación.
.SS Copias de seguridad externas con instantáneas del sistema de archivos (External backups with filesystem snapshots)
Cuando las instantáneas del sistema de archivos están habilitadas, SnapRAID
accede o crea instantáneas en la raíz de cada subvolumen, volumen o conjunto
de datos (dataset).
.PP
Una forma sencilla de evitar interferencias con herramientas externas es
apuntar la configuración \`data\` a un subdirectorio normal dentro del
subvolumen o volumen (por ejemplo, \`/mnt/subvol/data\` en lugar de
\`/mnt/subvol\`). SnapRAID siempre crea el directorio de instantáneas en la
raíz del subvolumen (por ejemplo, \`/mnt/subvol/.snapraid/\`), dejando limpio
el subdirectorio de datos para que las instantáneas permanezcan fuera e
invisibles para las herramientas de copia de seguridad que operan dentro
de él.
.PP
De lo contrario, si el directorio \`data\` configurado es en sí mismo la raíz
del subvolumen o volumen, SnapRAID crea un directorio \`.snapraid/\`
directamente dentro de él (en Btrfs, Bcachefs y NTFS). Aunque SnapRAID
excluye automáticamente este directorio de su propio escaneo, las
herramientas externas de copia de seguridad o sincronización de archivos lo
encontrarán. Si no se excluye, pueden acceder a las instantáneas o enlaces
de directorio y copiar todo el árbol de datos congelado, duplicando datos y
agotando el almacenamiento de respaldo. Configure siempre las herramientas
de copia de seguridad externas para excluir el directorio \`.snapraid/\`.
.PP
En ZFS, las instantáneas se exponen a través del directorio virtual estándar
\`.zfs/snapshot/\` en lugar de \`.snapraid/\`. De forma predeterminada
(\`snapdir=hidden\`), ZFS oculta este directorio de los listados, por lo que
las herramientas externas de copia de seguridad no lo recorrerán. Si ha
habilitado \`snapdir=visible\`, asegúrese de que sus herramientas de copia
de seguridad excluyan el directorio \`.zfs/\`.
.SH PATRONES (PATTERN) .SH PATRONES (PATTERN)
Los patrones proporcionan una forma flexible de filtrar archivos para su inclusión o Los patrones proporcionan una forma flexible de filtrar archivos para su inclusión o
exclusión. Al usar caracteres de globbing, puede definir reglas que coincidan con exclusión. Al usar caracteres de globbing, puede definir reglas que coincidan con

View file

@ -1639,6 +1639,37 @@ Ciclo de vida de las instantáneas (Snapshots Lifecycle)
reemplazar esa instantánea, haciendo que las versiones intermedias de los reemplazar esa instantánea, haciendo que las versiones intermedias de los
archivos no estén disponibles para la recuperación. archivos no estén disponibles para la recuperación.
Copias de seguridad externas con instantáneas del sistema de archivos (External backups with filesystem snapshots)
Cuando las instantáneas del sistema de archivos están habilitadas, SnapRAID
accede o crea instantáneas en la raíz de cada subvolumen, volumen o conjunto
de datos (dataset).
Una forma sencilla de evitar interferencias con herramientas externas es
apuntar la configuración `data` a un subdirectorio normal dentro del
subvolumen o volumen (por ejemplo, `/mnt/subvol/data` en lugar de
`/mnt/subvol`). SnapRAID siempre crea el directorio de instantáneas en la
raíz del subvolumen (por ejemplo, `/mnt/subvol/.snapraid/`), dejando limpio
el subdirectorio de datos para que las instantáneas permanezcan fuera e
invisibles para las herramientas de copia de seguridad que operan dentro
de él.
De lo contrario, si el directorio `data` configurado es en sí mismo la raíz
del subvolumen o volumen, SnapRAID crea un directorio `.snapraid/`
directamente dentro de él (en Btrfs, Bcachefs y NTFS). Aunque SnapRAID
excluye automáticamente este directorio de su propio escaneo, las
herramientas externas de copia de seguridad o sincronización de archivos lo
encontrarán. Si no se excluye, pueden acceder a las instantáneas o enlaces
de directorio y copiar todo el árbol de datos congelado, duplicando datos y
agotando el almacenamiento de respaldo. Configure siempre las herramientas
de copia de seguridad externas para excluir el directorio `.snapraid/`.
En ZFS, las instantáneas se exponen a través del directorio virtual estándar
`.zfs/snapshot/` en lugar de `.snapraid/`. De forma predeterminada
(`snapdir=hidden`), ZFS oculta este directorio de los listados, por lo que
las herramientas externas de copia de seguridad no lo recorrerán. Si ha
habilitado `snapdir=visible`, asegúrese de que sus herramientas de copia
de seguridad excluyan el directorio `.zfs/`.
Patrones (Pattern) Patrones (Pattern)
Los patrones proporcionan una forma flexible de filtrar archivos para su inclusión o Los patrones proporcionan una forma flexible de filtrar archivos para su inclusión o
exclusión. Al usar caracteres de globbing, puede definir reglas que coincidan con exclusión. Al usar caracteres de globbing, puede definir reglas que coincidan con

View file

@ -1749,6 +1749,39 @@ la instantánea utilizada por el sync interrumpido. Un sync posterior puede
reemplazar esa instantánea, haciendo que las versiones intermedias de los reemplazar esa instantánea, haciendo que las versiones intermedias de los
archivos no estén disponibles para la recuperación. archivos no estén disponibles para la recuperación.
9.1 Copias de seguridad externas con instantáneas del sistema de archivos (External backups with filesystem snapshots)
----------------------------------------------------------------------------------------------------------------------
Cuando las instantáneas del sistema de archivos están habilitadas, SnapRAID
accede o crea instantáneas en la raíz de cada subvolumen, volumen o conjunto
de datos (dataset).
Una forma sencilla de evitar interferencias con herramientas externas es
apuntar la configuración `data` a un subdirectorio normal dentro del
subvolumen o volumen (por ejemplo, `/mnt/subvol/data` en lugar de
`/mnt/subvol`). SnapRAID siempre crea el directorio de instantáneas en la
raíz del subvolumen (por ejemplo, `/mnt/subvol/.snapraid/`), dejando limpio
el subdirectorio de datos para que las instantáneas permanezcan fuera e
invisibles para las herramientas de copia de seguridad que operan dentro
de él.
De lo contrario, si el directorio `data` configurado es en sí mismo la raíz
del subvolumen o volumen, SnapRAID crea un directorio `.snapraid/`
directamente dentro de él (en Btrfs, Bcachefs y NTFS). Aunque SnapRAID
excluye automáticamente este directorio de su propio escaneo, las
herramientas externas de copia de seguridad o sincronización de archivos lo
encontrarán. Si no se excluye, pueden acceder a las instantáneas o enlaces
de directorio y copiar todo el árbol de datos congelado, duplicando datos y
agotando el almacenamiento de respaldo. Configure siempre las herramientas
de copia de seguridad externas para excluir el directorio `.snapraid/`.
En ZFS, las instantáneas se exponen a través del directorio virtual estándar
`.zfs/snapshot/` en lugar de `.snapraid/`. De forma predeterminada
(`snapdir=hidden`), ZFS oculta este directorio de los listados, por lo que
las herramientas externas de copia de seguridad no lo recorrerán. Si ha
habilitado `snapdir=visible`, asegúrese de que sus herramientas de copia
de seguridad excluyan el directorio `.zfs/`.
10 PATRONES (PATTERN) 10 PATRONES (PATTERN)
===================== =====================

View file

@ -2071,6 +2071,36 @@ avec succès. La parité peut encore contenir des blocs calculés à partir de
l\'instantané utilisé par le sync interrompu. Un sync ultérieur peut remplacer l\'instantané utilisé par le sync interrompu. Un sync ultérieur peut remplacer
cet instantané, rendant les versions intermédiaires des fichiers indisponibles cet instantané, rendant les versions intermédiaires des fichiers indisponibles
pour la récupération. pour la récupération.
.SS Sauvegardes externes avec les instantanés de système de fichiers (External backups with filesystem snapshots)
Lorsque les instantanés de système de fichiers sont activés, SnapRAID accède
aux instantanés ou les crée à la racine de chaque sous\-volume, volume ou
jeu de données (dataset).
.PP
Un moyen simple d\'éviter toute interférence avec les outils externes
consiste à faire pointer la configuration \`data\` vers un sous\-répertoire
ordinaire au sein du sous\-volume ou du volume (par exemple
\`/mnt/subvol/data\` au lieu de \`/mnt/subvol\`). SnapRAID crée toujours le
répertoire d\'instantanés à la racine du sous\-volume (par exemple
\`/mnt/subvol/.snapraid/\`), laissant le sous\-répertoire de données propre de
sorte que les instantanés restent à l\'extérieur et invisibles pour les
outils de sauvegarde opérant à l\'intérieur.
.PP
Sinon, si votre répertoire \`data\` configuré est lui\-même la racine du
sous\-volume ou du volume, SnapRAID crée un répertoire \`.snapraid/\`
directement à l\'intérieur (sur Btrfs, Bcachefs et NTFS). Bien que SnapRAID
exclue automatiquement ce répertoire de ses propres analyses, les outils
de sauvegarde externes ou les synchroniseurs de fichiers le rencontreront.
S\'il n\'est pas exclu, ils peuvent traverser les instantanés ou les liens de
répertoires et copier l\'ensemble de l\'arborescence figée, dupliquant les
données et risquant d\'épuiser l\'espace de sauvegarde. Configurez toujours
les outils de sauvegarde externes pour exclure le répertoire \`.snapraid/\`.
.PP
Sur ZFS, les instantanés sont exposés via le répertoire virtuel standard
\`.zfs/snapshot/\` plutôt que \`.snapraid/\`. Par défaut (\`snapdir=hidden\`), ZFS
masque ce répertoire des listes de fichiers, de sorte que les outils de
sauvegarde externes ne le parcourront pas. Si vous avez activé
\`snapdir=visible\`, veillez à ce que vos outils de sauvegarde excluent le
répertoire \`.zfs/\`.
.SH MOTIF (PATTERN) .SH MOTIF (PATTERN)
Les motifs offrent un moyen flexible de filtrer les fichiers à inclure ou Les motifs offrent un moyen flexible de filtrer les fichiers à inclure ou
à exclure. En utilisant des caractères de \[dq]globbing\[dq], vous pouvez définir des règles qui à exclure. En utilisant des caractères de \[dq]globbing\[dq], vous pouvez définir des règles qui

View file

@ -1676,6 +1676,37 @@ Cycle de vie des instantanés (Snapshots Lifecycle)
cet instantané, rendant les versions intermédiaires des fichiers indisponibles cet instantané, rendant les versions intermédiaires des fichiers indisponibles
pour la récupération. pour la récupération.
Sauvegardes externes avec les instantanés de système de fichiers (External backups with filesystem snapshots)
Lorsque les instantanés de système de fichiers sont activés, SnapRAID accède
aux instantanés ou les crée à la racine de chaque sous-volume, volume ou
jeu de données (dataset).
Un moyen simple d'éviter toute interférence avec les outils externes
consiste à faire pointer la configuration `data` vers un sous-répertoire
ordinaire au sein du sous-volume ou du volume (par exemple
`/mnt/subvol/data` au lieu de `/mnt/subvol`). SnapRAID crée toujours le
répertoire d'instantanés à la racine du sous-volume (par exemple
`/mnt/subvol/.snapraid/`), laissant le sous-répertoire de données propre de
sorte que les instantanés restent à l'extérieur et invisibles pour les
outils de sauvegarde opérant à l'intérieur.
Sinon, si votre répertoire `data` configuré est lui-même la racine du
sous-volume ou du volume, SnapRAID crée un répertoire `.snapraid/`
directement à l'intérieur (sur Btrfs, Bcachefs et NTFS). Bien que SnapRAID
exclue automatiquement ce répertoire de ses propres analyses, les outils
de sauvegarde externes ou les synchroniseurs de fichiers le rencontreront.
S'il n'est pas exclu, ils peuvent traverser les instantanés ou les liens de
répertoires et copier l'ensemble de l'arborescence figée, dupliquant les
données et risquant d'épuiser l'espace de sauvegarde. Configurez toujours
les outils de sauvegarde externes pour exclure le répertoire `.snapraid/`.
Sur ZFS, les instantanés sont exposés via le répertoire virtuel standard
`.zfs/snapshot/` plutôt que `.snapraid/`. Par défaut (`snapdir=hidden`), ZFS
masque ce répertoire des listes de fichiers, de sorte que les outils de
sauvegarde externes ne le parcourront pas. Si vous avez activé
`snapdir=visible`, veillez à ce que vos outils de sauvegarde excluent le
répertoire `.zfs/`.
Motif (Pattern) Motif (Pattern)
Les motifs offrent un moyen flexible de filtrer les fichiers à inclure ou Les motifs offrent un moyen flexible de filtrer les fichiers à inclure ou
à exclure. En utilisant des caractères de "globbing", vous pouvez définir des règles qui à exclure. En utilisant des caractères de "globbing", vous pouvez définir des règles qui

View file

@ -1786,6 +1786,39 @@ l'instantané utilisé par le sync interrompu. Un sync ultérieur peut remplacer
cet instantané, rendant les versions intermédiaires des fichiers indisponibles cet instantané, rendant les versions intermédiaires des fichiers indisponibles
pour la récupération. pour la récupération.
9.1 Sauvegardes externes avec les instantanés de système de fichiers (External backups with filesystem snapshots)
-----------------------------------------------------------------------------------------------------------------
Lorsque les instantanés de système de fichiers sont activés, SnapRAID accède
aux instantanés ou les crée à la racine de chaque sous-volume, volume ou
jeu de données (dataset).
Un moyen simple d'éviter toute interférence avec les outils externes
consiste à faire pointer la configuration `data` vers un sous-répertoire
ordinaire au sein du sous-volume ou du volume (par exemple
`/mnt/subvol/data` au lieu de `/mnt/subvol`). SnapRAID crée toujours le
répertoire d'instantanés à la racine du sous-volume (par exemple
`/mnt/subvol/.snapraid/`), laissant le sous-répertoire de données propre de
sorte que les instantanés restent à l'extérieur et invisibles pour les
outils de sauvegarde opérant à l'intérieur.
Sinon, si votre répertoire `data` configuré est lui-même la racine du
sous-volume ou du volume, SnapRAID crée un répertoire `.snapraid/`
directement à l'intérieur (sur Btrfs, Bcachefs et NTFS). Bien que SnapRAID
exclue automatiquement ce répertoire de ses propres analyses, les outils
de sauvegarde externes ou les synchroniseurs de fichiers le rencontreront.
S'il n'est pas exclu, ils peuvent traverser les instantanés ou les liens de
répertoires et copier l'ensemble de l'arborescence figée, dupliquant les
données et risquant d'épuiser l'espace de sauvegarde. Configurez toujours
les outils de sauvegarde externes pour exclure le répertoire `.snapraid/`.
Sur ZFS, les instantanés sont exposés via le répertoire virtuel standard
`.zfs/snapshot/` plutôt que `.snapraid/`. Par défaut (`snapdir=hidden`), ZFS
masque ce répertoire des listes de fichiers, de sorte que les outils de
sauvegarde externes ne le parcourront pas. Si vous avez activé
`snapdir=visible`, veillez à ce que vos outils de sauvegarde excluent le
répertoire `.zfs/`.
10 MOTIF (PATTERN) 10 MOTIF (PATTERN)
================== ==================

View file

@ -2055,6 +2055,34 @@ con successo. La parità potrebbe ancora contenere blocchi calcolati dallo
snapshot utilizzato dal sync interrotto. Un sync successivo potrebbe sostituire snapshot utilizzato dal sync interrotto. Un sync successivo potrebbe sostituire
tale snapshot, rendendo le versioni intermedie dei file non disponibili per il tale snapshot, rendendo le versioni intermedie dei file non disponibili per il
recupero. recupero.
.SS Backup esterni con snapshot del filesystem (External backups with filesystem snapshots)
Quando gli snapshot del filesystem sono abilitati, SnapRAID accede o crea
gli snapshot alla radice di ciascun sottovolume, volume o dataset di dati.
.PP
Un modo semplice per evitare interferenze con gli strumenti esterni consiste
nel far puntare la configurazione \`data\` a una sottodirectory ordinaria
all\'interno del subvolume o del volume (ad esempio \`/mnt/subvol/data\` invece
di \`/mnt/subvol\`). SnapRAID crea sempre la directory degli snapshot alla
radice del subvolume (ad esempio \`/mnt/subvol/.snapraid/\`), lasciando pulita
la sottodirectory dei dati in modo che gli snapshot rimangano all\'esterno
e invisibili agli strumenti di backup che operano al suo interno.
.PP
Altrimenti, se la directory \`data\` configurata è essa stessa la radice del
subvolume o del volume, SnapRAID crea una directory \`.snapraid/\` direttamente
al suo interno (su Btrfs, Bcachefs e NTFS). Sebbene SnapRAID escluda
automaticamente questa directory dalla propria scansione, gli strumenti di
backup esterni o i programmi di sincronizzazione dei file la incontreranno.
Se non viene esclusa, potrebbero entrare negli snapshot o nei collegamenti
di directory e copiare l\'intero albero dei dati congelato, duplicando i dati
ed esaurendo lo spazio di archiviazione dei backup. Configurare sempre gli
strumenti di backup esterni in modo da escludere la directory \`.snapraid/\`.
.PP
Su ZFS, gli snapshot sono esposti tramite la directory virtuale standard
\`.zfs/snapshot/\` anziché \`.snapraid/\`. Di default (\`snapdir=hidden\`), ZFS
nasconde questa directory dall\'elenco delle directory, quindi gli strumenti
di backup esterni non la attraverseranno. Se è stato abilitato
\`snapdir=visible\`, assicurarsi che gli strumenti di backup escludano la
directory \`.zfs/\`.
.SH PATTERN .SH PATTERN
I pattern offrono un modo flessibile per filtrare i file da includere o I pattern offrono un modo flessibile per filtrare i file da includere o
escludere. Usando i caratteri globbing, è possibile definire regole che escludere. Usando i caratteri globbing, è possibile definire regole che

View file

@ -1649,6 +1649,35 @@ Ciclo di vita degli snapshot (Snapshots Lifecycle)
tale snapshot, rendendo le versioni intermedie dei file non disponibili per il tale snapshot, rendendo le versioni intermedie dei file non disponibili per il
recupero. recupero.
Backup esterni con snapshot del filesystem (External backups with filesystem snapshots)
Quando gli snapshot del filesystem sono abilitati, SnapRAID accede o crea
gli snapshot alla radice di ciascun sottovolume, volume o dataset di dati.
Un modo semplice per evitare interferenze con gli strumenti esterni consiste
nel far puntare la configurazione `data` a una sottodirectory ordinaria
all'interno del subvolume o del volume (ad esempio `/mnt/subvol/data` invece
di `/mnt/subvol`). SnapRAID crea sempre la directory degli snapshot alla
radice del subvolume (ad esempio `/mnt/subvol/.snapraid/`), lasciando pulita
la sottodirectory dei dati in modo che gli snapshot rimangano all'esterno
e invisibili agli strumenti di backup che operano al suo interno.
Altrimenti, se la directory `data` configurata è essa stessa la radice del
subvolume o del volume, SnapRAID crea una directory `.snapraid/` direttamente
al suo interno (su Btrfs, Bcachefs e NTFS). Sebbene SnapRAID escluda
automaticamente questa directory dalla propria scansione, gli strumenti di
backup esterni o i programmi di sincronizzazione dei file la incontreranno.
Se non viene esclusa, potrebbero entrare negli snapshot o nei collegamenti
di directory e copiare l'intero albero dei dati congelato, duplicando i dati
ed esaurendo lo spazio di archiviazione dei backup. Configurare sempre gli
strumenti di backup esterni in modo da escludere la directory `.snapraid/`.
Su ZFS, gli snapshot sono esposti tramite la directory virtuale standard
`.zfs/snapshot/` anziché `.snapraid/`. Di default (`snapdir=hidden`), ZFS
nasconde questa directory dall'elenco delle directory, quindi gli strumenti
di backup esterni non la attraverseranno. Se è stato abilitato
`snapdir=visible`, assicurarsi che gli strumenti di backup escludano la
directory `.zfs/`.
Pattern Pattern
I pattern offrono un modo flessibile per filtrare i file da includere o I pattern offrono un modo flessibile per filtrare i file da includere o
escludere. Usando i caratteri globbing, è possibile definire regole che escludere. Usando i caratteri globbing, è possibile definire regole che

View file

@ -1759,6 +1759,37 @@ snapshot utilizzato dal sync interrotto. Un sync successivo potrebbe sostituire
tale snapshot, rendendo le versioni intermedie dei file non disponibili per il tale snapshot, rendendo le versioni intermedie dei file non disponibili per il
recupero. recupero.
9.1 Backup esterni con snapshot del filesystem (External backups with filesystem snapshots)
-------------------------------------------------------------------------------------------
Quando gli snapshot del filesystem sono abilitati, SnapRAID accede o crea
gli snapshot alla radice di ciascun sottovolume, volume o dataset di dati.
Un modo semplice per evitare interferenze con gli strumenti esterni consiste
nel far puntare la configurazione `data` a una sottodirectory ordinaria
all'interno del subvolume o del volume (ad esempio `/mnt/subvol/data` invece
di `/mnt/subvol`). SnapRAID crea sempre la directory degli snapshot alla
radice del subvolume (ad esempio `/mnt/subvol/.snapraid/`), lasciando pulita
la sottodirectory dei dati in modo che gli snapshot rimangano all'esterno
e invisibili agli strumenti di backup che operano al suo interno.
Altrimenti, se la directory `data` configurata è essa stessa la radice del
subvolume o del volume, SnapRAID crea una directory `.snapraid/` direttamente
al suo interno (su Btrfs, Bcachefs e NTFS). Sebbene SnapRAID escluda
automaticamente questa directory dalla propria scansione, gli strumenti di
backup esterni o i programmi di sincronizzazione dei file la incontreranno.
Se non viene esclusa, potrebbero entrare negli snapshot o nei collegamenti
di directory e copiare l'intero albero dei dati congelato, duplicando i dati
ed esaurendo lo spazio di archiviazione dei backup. Configurare sempre gli
strumenti di backup esterni in modo da escludere la directory `.snapraid/`.
Su ZFS, gli snapshot sono esposti tramite la directory virtuale standard
`.zfs/snapshot/` anziché `.snapraid/`. Di default (`snapdir=hidden`), ZFS
nasconde questa directory dall'elenco delle directory, quindi gli strumenti
di backup esterni non la attraverseranno. Se è stato abilitato
`snapdir=visible`, assicurarsi che gli strumenti di backup escludano la
directory `.zfs/`.
10 PATTERN 10 PATTERN
========== ==========

View file

@ -1833,6 +1833,31 @@ ZFSでは標準の \`.zfs/snapshot/\` が使用されます。
パリティには、中断された sync で使用されたスナップショットから計算されたブロックが パリティには、中断された sync で使用されたスナップショットから計算されたブロックが
まだ含まれている可能性があります。その後の sync によりそのスナップショットが まだ含まれている可能性があります。その後の sync によりそのスナップショットが
置き換えられ、中間バージョンのファイルが復元できなくなる可能性があります。 置き換えられ、中間バージョンのファイルが復元できなくなる可能性があります。
.SS ファイルシステムスナップショットと外部バックアップ (External backups with filesystem snapshots)
ファイルシステムスナップショットが有効な場合、SnapRAIDは各データサブボリューム、
ボリューム、またはデータセットのルートにあるスナップショットにアクセスまたは作成します。
.PP
外部ツールとの干渉を避ける簡単な方法は、\`data\` 設定をサブボリュームまたは
ボリューム内の通常のサブディレクトリ(例えば \`/mnt/subvol\` の代わりに
\`/mnt/subvol/data\`)に指定することです。SnapRAIDは常にサブボリュームのルートに
スナップショットディレクトリを作成するため(例えば \`/mnt/subvol/.snapraid/\`)、
データサブディレクトリがクリーンに保たれ、スナップショットはそのディレクトリ内で
動作するバックアップツールから見えない状態のままになります。
.PP
一方、設定された \`data\` ディレクトリ自体がサブボリュームまたはボリュームの
ルートである場合、SnapRAIDはその直下に \`.snapraid/\` ディレクトリを作成します(Btrfs、
Bcachefs、およびNTFS)。SnapRAID自身のスキャンからは自動的に除外されますが、
外部のバックアップツールやファイル同期ツールはそのディレクトリを検出します。
除外設定を行わない場合、スナップショットやディレクトリリンク内を走査して凍結された
データツリー全体をコピーしてしまい、データが重複してバックアップストレージを使い果たす
可能性があります。外部バックアップツールでは、必ず \`.snapraid/\` ディレクトリを
除外するように設定してください。
.PP
ZFSでは、スナップショットは \`.snapraid/\` ではなく標準の仮想ディレクトリ
\`.zfs/snapshot/\` 経由で公開されます。デフォルト(\`snapdir=hidden\`)では、ZFSはこの
ディレクトリを一覧表示から隠すため、外部バックアップツールが走査することはありません。
\`snapdir=visible\` を有効にしている場合は、バックアップツールが \`.zfs/\` ディレクトリを
除外するように設定してください。
.SH パターン (PATTERN) .SH パターン (PATTERN)
パターンは、含めるファイルまたは除外するファイルをフィルタリングするための柔軟な方法を パターンは、含めるファイルまたは除外するファイルをフィルタリングするための柔軟な方法を
提供します。グロブ文字を使用することで、すべてのパスを手動でリストすることなく、 提供します。グロブ文字を使用することで、すべてのパスを手動でリストすることなく、

View file

@ -1438,6 +1438,32 @@ Name{number}
まだ含まれている可能性があります。その後の sync によりそのスナップショットが まだ含まれている可能性があります。その後の sync によりそのスナップショットが
置き換えられ、中間バージョンのファイルが復元できなくなる可能性があります。 置き換えられ、中間バージョンのファイルが復元できなくなる可能性があります。
ファイルシステムスナップショットと外部バックアップ (External backups with filesystem snapshots)
ファイルシステムスナップショットが有効な場合、SnapRAIDは各データサブボリューム、
ボリューム、またはデータセットのルートにあるスナップショットにアクセスまたは作成します。
外部ツールとの干渉を避ける簡単な方法は、`data` 設定をサブボリュームまたは
ボリューム内の通常のサブディレクトリ(例えば `/mnt/subvol` の代わりに
`/mnt/subvol/data`)に指定することです。SnapRAIDは常にサブボリュームのルートに
スナップショットディレクトリを作成するため(例えば `/mnt/subvol/.snapraid/`)、
データサブディレクトリがクリーンに保たれ、スナップショットはそのディレクトリ内で
動作するバックアップツールから見えない状態のままになります。
一方、設定された `data` ディレクトリ自体がサブボリュームまたはボリュームの
ルートである場合、SnapRAIDはその直下に `.snapraid/` ディレクトリを作成します(Btrfs、
Bcachefs、およびNTFS)。SnapRAID自身のスキャンからは自動的に除外されますが、
外部のバックアップツールやファイル同期ツールはそのディレクトリを検出します。
除外設定を行わない場合、スナップショットやディレクトリリンク内を走査して凍結された
データツリー全体をコピーしてしまい、データが重複してバックアップストレージを使い果たす
可能性があります。外部バックアップツールでは、必ず `.snapraid/` ディレクトリを
除外するように設定してください。
ZFSでは、スナップショットは `.snapraid/` ではなく標準の仮想ディレクトリ
`.zfs/snapshot/` 経由で公開されます。デフォルト(`snapdir=hidden`)では、ZFSはこの
ディレクトリを一覧表示から隠すため、外部バックアップツールが走査することはありません。
`snapdir=visible` を有効にしている場合は、バックアップツールが `.zfs/` ディレクトリを
除外するように設定してください。
パターン (Pattern) パターン (Pattern)
パターンは、含めるファイルまたは除外するファイルをフィルタリングするための柔軟な方法を パターンは、含めるファイルまたは除外するファイルをフィルタリングするための柔軟な方法を
提供します。グロブ文字を使用することで、すべてのパスを手動でリストすることなく、 提供します。グロブ文字を使用することで、すべてのパスを手動でリストすることなく、

View file

@ -1548,6 +1548,34 @@ ZFSでは標準の `.zfs/snapshot/` が使用されます。
まだ含まれている可能性があります。その後の sync によりそのスナップショットが まだ含まれている可能性があります。その後の sync によりそのスナップショットが
置き換えられ、中間バージョンのファイルが復元できなくなる可能性があります。 置き換えられ、中間バージョンのファイルが復元できなくなる可能性があります。
9.1 ファイルシステムスナップショットと外部バックアップ (External backups with filesystem snapshots)
--------------------------------------------------------------------------
ファイルシステムスナップショットが有効な場合、SnapRAIDは各データサブボリューム、
ボリューム、またはデータセットのルートにあるスナップショットにアクセスまたは作成します。
外部ツールとの干渉を避ける簡単な方法は、`data` 設定をサブボリュームまたは
ボリューム内の通常のサブディレクトリ(例えば `/mnt/subvol` の代わりに
`/mnt/subvol/data`)に指定することです。SnapRAIDは常にサブボリュームのルートに
スナップショットディレクトリを作成するため(例えば `/mnt/subvol/.snapraid/`)、
データサブディレクトリがクリーンに保たれ、スナップショットはそのディレクトリ内で
動作するバックアップツールから見えない状態のままになります。
一方、設定された `data` ディレクトリ自体がサブボリュームまたはボリュームの
ルートである場合、SnapRAIDはその直下に `.snapraid/` ディレクトリを作成します(Btrfs、
Bcachefs、およびNTFS)。SnapRAID自身のスキャンからは自動的に除外されますが、
外部のバックアップツールやファイル同期ツールはそのディレクトリを検出します。
除外設定を行わない場合、スナップショットやディレクトリリンク内を走査して凍結された
データツリー全体をコピーしてしまい、データが重複してバックアップストレージを使い果たす
可能性があります。外部バックアップツールでは、必ず `.snapraid/` ディレクトリを
除外するように設定してください。
ZFSでは、スナップショットは `.snapraid/` ではなく標準の仮想ディレクトリ
`.zfs/snapshot/` 経由で公開されます。デフォルト(`snapdir=hidden`)では、ZFSはこの
ディレクトリを一覧表示から隠すため、外部バックアップツールが走査することはありません。
`snapdir=visible` を有効にしている場合は、バックアップツールが `.zfs/` ディレクトリを
除外するように設定してください。
10 パターン (PATTERN) 10 パターン (PATTERN)
================= =================

View file

@ -1877,6 +1877,28 @@ ZFS에서는 표준 \`.zfs/snapshot/\` 이 사용됩니다.
패리티에는 중단된 sync에서 사용된 스냅샷에서 계산된 블록이 패리티에는 중단된 sync에서 사용된 스냅샷에서 계산된 블록이
여전히 포함되어 있을 수 있습니다. 이후의 sync로 인해 해당 스냅샷이 여전히 포함되어 있을 수 있습니다. 이후의 sync로 인해 해당 스냅샷이
교체되어 복구에 필요한 중간 버전의 파일을 사용할 수 없게 될 수 있습니다. 교체되어 복구에 필요한 중간 버전의 파일을 사용할 수 없게 될 수 있습니다.
.SS 파일 시스템 스냅샷을 사용한 외부 백업 (External backups with filesystem snapshots)
파일 시스템 스냅샷이 활성화되면 SnapRAID는 각 데이터 서브볼륨, 볼륨 또는
데이터셋의 루트에서 스냅샷에 접근하거나 생성합니다.
.PP
외부 도구와의 간섭을 피하는 간단한 방법은 서브볼륨이나 볼륨 내의 일반
하위 디렉터리(예: \`/mnt/subvol\` 대신 \`/mnt/subvol/data\`)를 가리키도록
\`data\` 를 설정하는 것입니다. SnapRAID는 항상 서브볼륨 루트에 스냅샷 디렉터리를
생성하므로(예: \`/mnt/subvol/.snapraid/\`), 데이터 하위 디렉터리를 깨끗하게
유지하여 해당 디렉터리 내에서 작동하는 백업 도구에 스냅샷이 노출되지 않도록 합니다.
.PP
그렇지 않고 설정된 \`data\` 디렉터리 자체가 서브볼륨이나 볼륨 루트인 경우,
SnapRAID는 해당 디렉터리 바로 안에 \`.snapraid/\` 디렉터리를 생성합니다(Btrfs,
Bcachefs 및 NTFS). SnapRAID 자체 스캔에서는 이 디렉터리가 자동으로 제외되지만,
외부 백업 도구나 파일 동기화 도구는 이를 발견하게 됩니다. 제외하지 않으면
스냅샷이나 디렉터리 링크를 탐색하여 동결된 전체 데이터 트리를 복사함으로써
데이터를 중복 생성하고 백업 저장 공간을 고갈시킬 수 있습니다. 항상 외부 백업
도구에서 \`.snapraid/\` 디렉터리를 제외하도록 구성하십시오.
.PP
ZFS에서는 스냅샷이 \`.snapraid/\` 대신 표준 가상 디렉터리인 \`.zfs/snapshot/\` 을
통해 노출됩니다. 기본값(\`snapdir=hidden\`)에서는 ZFS가 디렉터리 목록에서 이
디렉터리를 숨기므로 외부 백업 도구가 이를 탐색하지 않습니다. \`snapdir=visible\` 로
설정한 경우 백업 도구에서 \`.zfs/\` 디렉터리를 제외하도록 하십시오.
.SH 패턴 (PATTERN) .SH 패턴 (PATTERN)
패턴은 포함하거나 제외할 파일을 필터링하는 유연한 방법을 제공합니다. 패턴은 포함하거나 제외할 파일을 필터링하는 유연한 방법을 제공합니다.
글로빙(globbing) 문자를 사용하면 모든 경로를 일일이 나열하지 않고도 글로빙(globbing) 문자를 사용하면 모든 경로를 일일이 나열하지 않고도

View file

@ -1482,6 +1482,29 @@ Name{number}
여전히 포함되어 있을 수 있습니다. 이후의 sync로 인해 해당 스냅샷이 여전히 포함되어 있을 수 있습니다. 이후의 sync로 인해 해당 스냅샷이
교체되어 복구에 필요한 중간 버전의 파일을 사용할 수 없게 될 수 있습니다. 교체되어 복구에 필요한 중간 버전의 파일을 사용할 수 없게 될 수 있습니다.
파일 시스템 스냅샷을 사용한 외부 백업 (External backups with filesystem snapshots)
파일 시스템 스냅샷이 활성화되면 SnapRAID는 각 데이터 서브볼륨, 볼륨 또는
데이터셋의 루트에서 스냅샷에 접근하거나 생성합니다.
외부 도구와의 간섭을 피하는 간단한 방법은 서브볼륨이나 볼륨 내의 일반
하위 디렉터리(예: `/mnt/subvol` 대신 `/mnt/subvol/data`)를 가리키도록
`data` 를 설정하는 것입니다. SnapRAID는 항상 서브볼륨 루트에 스냅샷 디렉터리를
생성하므로(예: `/mnt/subvol/.snapraid/`), 데이터 하위 디렉터리를 깨끗하게
유지하여 해당 디렉터리 내에서 작동하는 백업 도구에 스냅샷이 노출되지 않도록 합니다.
그렇지 않고 설정된 `data` 디렉터리 자체가 서브볼륨이나 볼륨 루트인 경우,
SnapRAID는 해당 디렉터리 바로 안에 `.snapraid/` 디렉터리를 생성합니다(Btrfs,
Bcachefs 및 NTFS). SnapRAID 자체 스캔에서는 이 디렉터리가 자동으로 제외되지만,
외부 백업 도구나 파일 동기화 도구는 이를 발견하게 됩니다. 제외하지 않으면
스냅샷이나 디렉터리 링크를 탐색하여 동결된 전체 데이터 트리를 복사함으로써
데이터를 중복 생성하고 백업 저장 공간을 고갈시킬 수 있습니다. 항상 외부 백업
도구에서 `.snapraid/` 디렉터리를 제외하도록 구성하십시오.
ZFS에서는 스냅샷이 `.snapraid/` 대신 표준 가상 디렉터리인 `.zfs/snapshot/` 을
통해 노출됩니다. 기본값(`snapdir=hidden`)에서는 ZFS가 디렉터리 목록에서 이
디렉터리를 숨기므로 외부 백업 도구가 이를 탐색하지 않습니다. `snapdir=visible` 로
설정한 경우 백업 도구에서 `.zfs/` 디렉터리를 제외하도록 하십시오.
패턴 (Pattern) 패턴 (Pattern)
패턴은 포함하거나 제외할 파일을 필터링하는 유연한 방법을 제공합니다. 패턴은 포함하거나 제외할 파일을 필터링하는 유연한 방법을 제공합니다.
글로빙(globbing) 문자를 사용하면 모든 경로를 일일이 나열하지 않고도 글로빙(globbing) 문자를 사용하면 모든 경로를 일일이 나열하지 않고도

View file

@ -1592,6 +1592,31 @@ ZFS에서는 표준 `.zfs/snapshot/` 이 사용됩니다.
여전히 포함되어 있을 수 있습니다. 이후의 sync로 인해 해당 스냅샷이 여전히 포함되어 있을 수 있습니다. 이후의 sync로 인해 해당 스냅샷이
교체되어 복구에 필요한 중간 버전의 파일을 사용할 수 없게 될 수 있습니다. 교체되어 복구에 필요한 중간 버전의 파일을 사용할 수 없게 될 수 있습니다.
9.1 파일 시스템 스냅샷을 사용한 외부 백업 (External backups with filesystem snapshots)
----------------------------------------------------------------------
파일 시스템 스냅샷이 활성화되면 SnapRAID는 각 데이터 서브볼륨, 볼륨 또는
데이터셋의 루트에서 스냅샷에 접근하거나 생성합니다.
외부 도구와의 간섭을 피하는 간단한 방법은 서브볼륨이나 볼륨 내의 일반
하위 디렉터리(예: `/mnt/subvol` 대신 `/mnt/subvol/data`)를 가리키도록
`data` 를 설정하는 것입니다. SnapRAID는 항상 서브볼륨 루트에 스냅샷 디렉터리를
생성하므로(예: `/mnt/subvol/.snapraid/`), 데이터 하위 디렉터리를 깨끗하게
유지하여 해당 디렉터리 내에서 작동하는 백업 도구에 스냅샷이 노출되지 않도록 합니다.
그렇지 않고 설정된 `data` 디렉터리 자체가 서브볼륨이나 볼륨 루트인 경우,
SnapRAID는 해당 디렉터리 바로 안에 `.snapraid/` 디렉터리를 생성합니다(Btrfs,
Bcachefs 및 NTFS). SnapRAID 자체 스캔에서는 이 디렉터리가 자동으로 제외되지만,
외부 백업 도구나 파일 동기화 도구는 이를 발견하게 됩니다. 제외하지 않으면
스냅샷이나 디렉터리 링크를 탐색하여 동결된 전체 데이터 트리를 복사함으로써
데이터를 중복 생성하고 백업 저장 공간을 고갈시킬 수 있습니다. 항상 외부 백업
도구에서 `.snapraid/` 디렉터리를 제외하도록 구성하십시오.
ZFS에서는 스냅샷이 `.snapraid/` 대신 표준 가상 디렉터리인 `.zfs/snapshot/` 을
통해 노출됩니다. 기본값(`snapdir=hidden`)에서는 ZFS가 디렉터리 목록에서 이
디렉터리를 숨기므로 외부 백업 도구가 이를 탐색하지 않습니다. `snapdir=visible` 로
설정한 경우 백업 도구에서 `.zfs/` 디렉터리를 제외하도록 하십시오.
10 패턴 (PATTERN) 10 패턴 (PATTERN)
=============== ===============

View file

@ -1954,6 +1954,36 @@ usuwania, zastępowania lub przenoszenia plików do momentu pomyślnego ukończe
kolejnej operacji \`sync\`. Parzystość może nadal zawierać bloki obliczone na podstawie kolejnej operacji \`sync\`. Parzystość może nadal zawierać bloki obliczone na podstawie
migawki użytej przez przerwaną synchronizację. Późniejsza synchronizacja może zastąpić migawki użytej przez przerwaną synchronizację. Późniejsza synchronizacja może zastąpić
tę migawkę, uniemożliwiając odzyskanie pośrednich wersji plików. tę migawkę, uniemożliwiając odzyskanie pośrednich wersji plików.
.SS Kopie zapasowe z migawkami systemu plików (External backups with filesystem snapshots)
Gdy migawki systemu plików są włączone, SnapRAID uzyskuje dostęp do migawek
lub tworzy je w katalogu głównym każdego podwoluminu danych, woluminu lub
zestawu danych (dataset).
.PP
Prostym sposobem na uniknięcie jakichkolwiek konfliktów z zewnętrznymi
narzędziami jest wskazanie w konfiguracji \`data\` zwykłego podkatalogu
wewnątrz podwoluminu lub woluminu (na przykład \`/mnt/subvol/data\` zamiast
\`/mnt/subvol\`). SnapRAID zawsze tworzy katalog migawek w katalogu głównym
podwoluminu (na przykład \`/mnt/subvol/.snapraid/\`), pozostawiając podkatalog
danych czysty, dzięki czemu migawki pozostają na zewnątrz i są niewidoczne
dla narzędzi do tworzenia kopii zapasowych działających w tym katalogu.
.PP
W przeciwnym razie, jeśli skonfigurowany katalog \`data\` jest sam w sobie
katalogiem głównym podwoluminu lub woluminu, SnapRAID utworzy katalog
\`.snapraid/\` bezpośrednio w nim (w systemach Btrfs, Bcachefs i NTFS).
Chociaż SnapRAID automatycznie wyklucza ten katalog z własnego skanowania,
zewnętrzne narzędzia do tworzenia kopii zapasowych lub synchronizacji
plików napotkają go. Jeśli nie zostanie wykluczony, mogą wejść do migawek
lub dowiązań katalogów i skopiować całe zamrożone drzewo danych, duplikując
dane i wyczerpując przestrzeń dyskową kopii zapasowej. Zawsze konfiguruj
zewnętrzne narzędzia do tworzenia kopii zapasowych tak, aby wykluczały
katalog \`.snapraid/\`.
.PP
W systemie ZFS migawki są udostępniane za pośrednictwem standardowego
katalogu wirtualnego \`.zfs/snapshot/\` zamiast \`.snapraid/\`. Domyślnie
(\`snapdir=hidden\`) system ZFS ukrywa ten katalog na listach katalogów, więc
zewnętrzne narzędzia do tworzenia kopii zapasowych go nie przeskanują. Jeśli
włączono opcję \`snapdir=visible\`, upewnij się, że narzędzia do tworzenia kopii
zapasowych wykluczają katalog \`.zfs/\`.
.SH WZORCE (PATTERN) .SH WZORCE (PATTERN)
Wzorce zapewniają elastyczny sposób filtrowania plików do uwzględnienia lub Wzorce zapewniają elastyczny sposób filtrowania plików do uwzględnienia lub
wykluczenia. Używając znaków globbingowych, można zdefiniować reguły, które wykluczenia. Używając znaków globbingowych, można zdefiniować reguły, które

View file

@ -1559,6 +1559,37 @@ Cykl życia migawek (Snapshots Lifecycle)
migawki użytej przez przerwaną synchronizację. Późniejsza synchronizacja może zastąpić migawki użytej przez przerwaną synchronizację. Późniejsza synchronizacja może zastąpić
tę migawkę, uniemożliwiając odzyskanie pośrednich wersji plików. tę migawkę, uniemożliwiając odzyskanie pośrednich wersji plików.
Kopie zapasowe z migawkami systemu plików (External backups with filesystem snapshots)
Gdy migawki systemu plików są włączone, SnapRAID uzyskuje dostęp do migawek
lub tworzy je w katalogu głównym każdego podwoluminu danych, woluminu lub
zestawu danych (dataset).
Prostym sposobem na uniknięcie jakichkolwiek konfliktów z zewnętrznymi
narzędziami jest wskazanie w konfiguracji `data` zwykłego podkatalogu
wewnątrz podwoluminu lub woluminu (na przykład `/mnt/subvol/data` zamiast
`/mnt/subvol`). SnapRAID zawsze tworzy katalog migawek w katalogu głównym
podwoluminu (na przykład `/mnt/subvol/.snapraid/`), pozostawiając podkatalog
danych czysty, dzięki czemu migawki pozostają na zewnątrz i są niewidoczne
dla narzędzi do tworzenia kopii zapasowych działających w tym katalogu.
W przeciwnym razie, jeśli skonfigurowany katalog `data` jest sam w sobie
katalogiem głównym podwoluminu lub woluminu, SnapRAID utworzy katalog
`.snapraid/` bezpośrednio w nim (w systemach Btrfs, Bcachefs i NTFS).
Chociaż SnapRAID automatycznie wyklucza ten katalog z własnego skanowania,
zewnętrzne narzędzia do tworzenia kopii zapasowych lub synchronizacji
plików napotkają go. Jeśli nie zostanie wykluczony, mogą wejść do migawek
lub dowiązań katalogów i skopiować całe zamrożone drzewo danych, duplikując
dane i wyczerpując przestrzeń dyskową kopii zapasowej. Zawsze konfiguruj
zewnętrzne narzędzia do tworzenia kopii zapasowych tak, aby wykluczały
katalog `.snapraid/`.
W systemie ZFS migawki są udostępniane za pośrednictwem standardowego
katalogu wirtualnego `.zfs/snapshot/` zamiast `.snapraid/`. Domyślnie
(`snapdir=hidden`) system ZFS ukrywa ten katalog na listach katalogów, więc
zewnętrzne narzędzia do tworzenia kopii zapasowych go nie przeskanują. Jeśli
włączono opcję `snapdir=visible`, upewnij się, że narzędzia do tworzenia kopii
zapasowych wykluczają katalog `.zfs/`.
Wzorce (Pattern) Wzorce (Pattern)
Wzorce zapewniają elastyczny sposób filtrowania plików do uwzględnienia lub Wzorce zapewniają elastyczny sposób filtrowania plików do uwzględnienia lub
wykluczenia. Używając znaków globbingowych, można zdefiniować reguły, które wykluczenia. Używając znaków globbingowych, można zdefiniować reguły, które

View file

@ -1669,6 +1669,39 @@ kolejnej operacji `sync`. Parzystość może nadal zawierać bloki obliczone na
migawki użytej przez przerwaną synchronizację. Późniejsza synchronizacja może zastąpić migawki użytej przez przerwaną synchronizację. Późniejsza synchronizacja może zastąpić
tę migawkę, uniemożliwiając odzyskanie pośrednich wersji plików. tę migawkę, uniemożliwiając odzyskanie pośrednich wersji plików.
9.1 Kopie zapasowe z migawkami systemu plików (External backups with filesystem snapshots)
------------------------------------------------------------------------------------------
Gdy migawki systemu plików są włączone, SnapRAID uzyskuje dostęp do migawek
lub tworzy je w katalogu głównym każdego podwoluminu danych, woluminu lub
zestawu danych (dataset).
Prostym sposobem na uniknięcie jakichkolwiek konfliktów z zewnętrznymi
narzędziami jest wskazanie w konfiguracji `data` zwykłego podkatalogu
wewnątrz podwoluminu lub woluminu (na przykład `/mnt/subvol/data` zamiast
`/mnt/subvol`). SnapRAID zawsze tworzy katalog migawek w katalogu głównym
podwoluminu (na przykład `/mnt/subvol/.snapraid/`), pozostawiając podkatalog
danych czysty, dzięki czemu migawki pozostają na zewnątrz i są niewidoczne
dla narzędzi do tworzenia kopii zapasowych działających w tym katalogu.
W przeciwnym razie, jeśli skonfigurowany katalog `data` jest sam w sobie
katalogiem głównym podwoluminu lub woluminu, SnapRAID utworzy katalog
`.snapraid/` bezpośrednio w nim (w systemach Btrfs, Bcachefs i NTFS).
Chociaż SnapRAID automatycznie wyklucza ten katalog z własnego skanowania,
zewnętrzne narzędzia do tworzenia kopii zapasowych lub synchronizacji
plików napotkają go. Jeśli nie zostanie wykluczony, mogą wejść do migawek
lub dowiązań katalogów i skopiować całe zamrożone drzewo danych, duplikując
dane i wyczerpując przestrzeń dyskową kopii zapasowej. Zawsze konfiguruj
zewnętrzne narzędzia do tworzenia kopii zapasowych tak, aby wykluczały
katalog `.snapraid/`.
W systemie ZFS migawki są udostępniane za pośrednictwem standardowego
katalogu wirtualnego `.zfs/snapshot/` zamiast `.snapraid/`. Domyślnie
(`snapdir=hidden`) system ZFS ukrywa ten katalog na listach katalogów, więc
zewnętrzne narzędzia do tworzenia kopii zapasowych go nie przeskanują. Jeśli
włączono opcję `snapdir=visible`, upewnij się, że narzędzia do tworzenia kopii
zapasowych wykluczają katalog `.zfs/`.
10 WZORCE (PATTERN) 10 WZORCE (PATTERN)
=================== ===================

View file

@ -1992,6 +1992,36 @@ com sucesso. A paridade ainda pode conter blocos calculados a partir do
instantâneo usado pelo sync interrompido. Um sync posterior pode substituir instantâneo usado pelo sync interrompido. Um sync posterior pode substituir
esse instantâneo, tornando as versões intermediárias dos arquivos indisponíveis esse instantâneo, tornando as versões intermediárias dos arquivos indisponíveis
para recuperação. para recuperação.
.SS Cópias de segurança externas com instantâneos do sistema de ficheiros (External backups with filesystem snapshots)
Quando os instantâneos do sistema de ficheiros estão ativados, o SnapRAID
acede ou cria instantâneos na raiz de cada subvolume, volume ou conjunto
de dados (dataset).
.PP
Uma forma simples de evitar qualquer interferência com ferramentas externas
é apontar a configuração \`data\` para um subdiretório normal dentro do
subvolume ou volume (por exemplo, \`/mnt/subvol/data\` em vez de \`/mnt/subvol\`).
O SnapRAID cria sempre o diretório de instantâneos na raiz do subvolume
(por exemplo, \`/mnt/subvol/.snapraid/\`), deixando o subdiretório de dados
limpo, de modo que os instantâneos permaneçam fora e invisíveis para as
ferramentas de cópia de segurança que operam dentro dele.
.PP
Caso contrário, se o diretório \`data\` configurado for ele próprio a raiz
do subvolume ou do volume, o SnapRAID cria um diretório \`.snapraid/\`
diretamente dentro dele (em Btrfs, Bcachefs e NTFS). Embora o SnapRAID
exclua automaticamente esse diretório das suas próprias verificações,
ferramentas externas de cópia de segurança ou de sincronização irão
encontrá\-lo. Se não for excluído, podem atravessar os instantâneos ou
ligações de diretório e copiar toda a árvore de dados congelada, duplicando
dados e esgotando o armazenamento de backup. Configure sempre as
ferramentas de cópia de segurança externas para excluir o diretório
\`.snapraid/\`.
.PP
No ZFS, os instantâneos são expostos através do diretório virtual padrão
\`.zfs/snapshot/\` em vez de \`.snapraid/\`. Por predefinição (\`snapdir=hidden\`),
o ZFS oculta esse diretório das listagens, de modo que ferramentas externas
de cópia de segurança não o percorrem. Se tiver ativado \`snapdir=visible\`,
certifique\-se de que as suas ferramentas de cópia de segurança excluem o
diretório \`.zfs/\`.
.SH PADRãO (PATTERN) .SH PADRãO (PATTERN)
Os padrões fornecem uma maneira flexível de filtrar arquivos para inclusão ou Os padrões fornecem uma maneira flexível de filtrar arquivos para inclusão ou
exclusão. Ao usar caracteres de globbing, você pode definir regras que exclusão. Ao usar caracteres de globbing, você pode definir regras que

View file

@ -1597,6 +1597,37 @@ Ciclo de Vida dos Instantâneos (Snapshots Lifecycle)
esse instantâneo, tornando as versões intermediárias dos arquivos indisponíveis esse instantâneo, tornando as versões intermediárias dos arquivos indisponíveis
para recuperação. para recuperação.
Cópias de segurança externas com instantâneos do sistema de ficheiros (External backups with filesystem snapshots)
Quando os instantâneos do sistema de ficheiros estão ativados, o SnapRAID
acede ou cria instantâneos na raiz de cada subvolume, volume ou conjunto
de dados (dataset).
Uma forma simples de evitar qualquer interferência com ferramentas externas
é apontar a configuração `data` para um subdiretório normal dentro do
subvolume ou volume (por exemplo, `/mnt/subvol/data` em vez de `/mnt/subvol`).
O SnapRAID cria sempre o diretório de instantâneos na raiz do subvolume
(por exemplo, `/mnt/subvol/.snapraid/`), deixando o subdiretório de dados
limpo, de modo que os instantâneos permaneçam fora e invisíveis para as
ferramentas de cópia de segurança que operam dentro dele.
Caso contrário, se o diretório `data` configurado for ele próprio a raiz
do subvolume ou do volume, o SnapRAID cria um diretório `.snapraid/`
diretamente dentro dele (em Btrfs, Bcachefs e NTFS). Embora o SnapRAID
exclua automaticamente esse diretório das suas próprias verificações,
ferramentas externas de cópia de segurança ou de sincronização irão
encontrá-lo. Se não for excluído, podem atravessar os instantâneos ou
ligações de diretório e copiar toda a árvore de dados congelada, duplicando
dados e esgotando o armazenamento de backup. Configure sempre as
ferramentas de cópia de segurança externas para excluir o diretório
`.snapraid/`.
No ZFS, os instantâneos são expostos através do diretório virtual padrão
`.zfs/snapshot/` em vez de `.snapraid/`. Por predefinição (`snapdir=hidden`),
o ZFS oculta esse diretório das listagens, de modo que ferramentas externas
de cópia de segurança não o percorrem. Se tiver ativado `snapdir=visible`,
certifique-se de que as suas ferramentas de cópia de segurança excluem o
diretório `.zfs/`.
Padrão (Pattern) Padrão (Pattern)
Os padrões fornecem uma maneira flexível de filtrar arquivos para inclusão ou Os padrões fornecem uma maneira flexível de filtrar arquivos para inclusão ou
exclusão. Ao usar caracteres de globbing, você pode definir regras que exclusão. Ao usar caracteres de globbing, você pode definir regras que

View file

@ -1707,6 +1707,39 @@ instantâneo usado pelo sync interrompido. Um sync posterior pode substituir
esse instantâneo, tornando as versões intermediárias dos arquivos indisponíveis esse instantâneo, tornando as versões intermediárias dos arquivos indisponíveis
para recuperação. para recuperação.
9.1 Cópias de segurança externas com instantâneos do sistema de ficheiros (External backups with filesystem snapshots)
----------------------------------------------------------------------------------------------------------------------
Quando os instantâneos do sistema de ficheiros estão ativados, o SnapRAID
acede ou cria instantâneos na raiz de cada subvolume, volume ou conjunto
de dados (dataset).
Uma forma simples de evitar qualquer interferência com ferramentas externas
é apontar a configuração `data` para um subdiretório normal dentro do
subvolume ou volume (por exemplo, `/mnt/subvol/data` em vez de `/mnt/subvol`).
O SnapRAID cria sempre o diretório de instantâneos na raiz do subvolume
(por exemplo, `/mnt/subvol/.snapraid/`), deixando o subdiretório de dados
limpo, de modo que os instantâneos permaneçam fora e invisíveis para as
ferramentas de cópia de segurança que operam dentro dele.
Caso contrário, se o diretório `data` configurado for ele próprio a raiz
do subvolume ou do volume, o SnapRAID cria um diretório `.snapraid/`
diretamente dentro dele (em Btrfs, Bcachefs e NTFS). Embora o SnapRAID
exclua automaticamente esse diretório das suas próprias verificações,
ferramentas externas de cópia de segurança ou de sincronização irão
encontrá-lo. Se não for excluído, podem atravessar os instantâneos ou
ligações de diretório e copiar toda a árvore de dados congelada, duplicando
dados e esgotando o armazenamento de backup. Configure sempre as
ferramentas de cópia de segurança externas para excluir o diretório
`.snapraid/`.
No ZFS, os instantâneos são expostos através do diretório virtual padrão
`.zfs/snapshot/` em vez de `.snapraid/`. Por predefinição (`snapdir=hidden`),
o ZFS oculta esse diretório das listagens, de modo que ferramentas externas
de cópia de segurança não o percorrem. Se tiver ativado `snapdir=visible`,
certifique-se de que as suas ferramentas de cópia de segurança excluem o
diretório `.zfs/`.
10 PADRãO (PATTERN) 10 PADRãO (PATTERN)
=================== ===================

View file

@ -1952,6 +1952,36 @@ cu succes. Paritatea poate conține în continuare blocuri calculate din
snapshot\-ul utilizat de sync\-ul întrerupt. Un sync ulterior poate înlocui snapshot\-ul utilizat de sync\-ul întrerupt. Un sync ulterior poate înlocui
acel snapshot, făcând versiunile intermediare ale fișierelor indisponibile acel snapshot, făcând versiunile intermediare ale fișierelor indisponibile
pentru recuperare. pentru recuperare.
.SS Copii de rezervă externe cu snapshot\-uri de sistem de fișiere (External backups with filesystem snapshots)
Când snapshot\-urile sistemului de fișiere sunt activate, SnapRAID accesează
sau creează snapshot\-uri la rădăcina fiecărui subvolum, volum sau set de
date (dataset).
.PP
O modalitate simplă de a evita orice interferență cu instrumentele externe
este de a configura discul \`data\` astfel încât să indice spre un subdirector
obișnuit din cadrul subvolumului sau volumului (de exemplu
\`/mnt/subvol/data\` în loc de \`/mnt/subvol\`). SnapRAID creează întotdeauna
directorul de snapshot\-uri la rădăcina subvolumului (de exemplu
\`/mnt/subvol/.snapraid/\`), lăsând subdirectorul de date curat, astfel încât
snapshot\-urile să rămână în exterior și invizibile pentru instrumentele de
backup care operează în interiorul său.
.PP
În caz contrar, dacă directorul \`data\` configurat este chiar rădăcina
subvolumului sau a volumului, SnapRAID creează un director \`.snapraid/\`
direct în interiorul acestuia (pe Btrfs, Bcachefs și NTFS). Deși SnapRAID
exclude automat acest director din scanarea proprie, instrumentele externe
de backup sau sincronizare îl vor întâlni. Dacă nu este exclus, acestea pot
traversa snapshot\-urile sau legăturile de directoare și pot copia întregul
arbore de date înghețat, duplicând datele și epuizând spațiul de stocare al
backup\-ului. Configurați întotdeauna instrumentele externe de backup să
excludă directorul \`.snapraid/\`.
.PP
Pe ZFS, snapshot\-urile sunt expuse prin directorul virtual standard
\`.zfs/snapshot/\` în loc de \`.snapraid/\`. În mod implicit (\`snapdir=hidden\`),
ZFS ascunde acest director din listările de directoare, astfel încât
instrumentele externe de backup nu îl vor parcurge. Dacă ați activat
\`snapdir=visible\`, asigurați\-vă că instrumentele de backup exclud
directorul \`.zfs/\`.
.SH MODEL (PATTERN) .SH MODEL (PATTERN)
Modelele oferă o modalitate flexibilă de a filtra fișierele pentru includere sau Modelele oferă o modalitate flexibilă de a filtra fișierele pentru includere sau
excludere. Folosind caractere de tip globbing, puteți defini reguli care să excludere. Folosind caractere de tip globbing, puteți defini reguli care să

View file

@ -1557,6 +1557,37 @@ Ciclul de viață al snapshot-urilor (Snapshots Lifecycle)
acel snapshot, făcând versiunile intermediare ale fișierelor indisponibile acel snapshot, făcând versiunile intermediare ale fișierelor indisponibile
pentru recuperare. pentru recuperare.
Copii de rezervă externe cu snapshot-uri de sistem de fișiere (External backups with filesystem snapshots)
Când snapshot-urile sistemului de fișiere sunt activate, SnapRAID accesează
sau creează snapshot-uri la rădăcina fiecărui subvolum, volum sau set de
date (dataset).
O modalitate simplă de a evita orice interferență cu instrumentele externe
este de a configura discul `data` astfel încât să indice spre un subdirector
obișnuit din cadrul subvolumului sau volumului (de exemplu
`/mnt/subvol/data` în loc de `/mnt/subvol`). SnapRAID creează întotdeauna
directorul de snapshot-uri la rădăcina subvolumului (de exemplu
`/mnt/subvol/.snapraid/`), lăsând subdirectorul de date curat, astfel încât
snapshot-urile să rămână în exterior și invizibile pentru instrumentele de
backup care operează în interiorul său.
În caz contrar, dacă directorul `data` configurat este chiar rădăcina
subvolumului sau a volumului, SnapRAID creează un director `.snapraid/`
direct în interiorul acestuia (pe Btrfs, Bcachefs și NTFS). Deși SnapRAID
exclude automat acest director din scanarea proprie, instrumentele externe
de backup sau sincronizare îl vor întâlni. Dacă nu este exclus, acestea pot
traversa snapshot-urile sau legăturile de directoare și pot copia întregul
arbore de date înghețat, duplicând datele și epuizând spațiul de stocare al
backup-ului. Configurați întotdeauna instrumentele externe de backup să
excludă directorul `.snapraid/`.
Pe ZFS, snapshot-urile sunt expuse prin directorul virtual standard
`.zfs/snapshot/` în loc de `.snapraid/`. În mod implicit (`snapdir=hidden`),
ZFS ascunde acest director din listările de directoare, astfel încât
instrumentele externe de backup nu îl vor parcurge. Dacă ați activat
`snapdir=visible`, asigurați-vă că instrumentele de backup exclud
directorul `.zfs/`.
Model (Pattern) Model (Pattern)
Modelele oferă o modalitate flexibilă de a filtra fișierele pentru includere sau Modelele oferă o modalitate flexibilă de a filtra fișierele pentru includere sau
excludere. Folosind caractere de tip globbing, puteți defini reguli care să excludere. Folosind caractere de tip globbing, puteți defini reguli care să

View file

@ -1667,6 +1667,39 @@ snapshot-ul utilizat de sync-ul întrerupt. Un sync ulterior poate înlocui
acel snapshot, făcând versiunile intermediare ale fișierelor indisponibile acel snapshot, făcând versiunile intermediare ale fișierelor indisponibile
pentru recuperare. pentru recuperare.
9.1 Copii de rezervă externe cu snapshot-uri de sistem de fișiere (External backups with filesystem snapshots)
--------------------------------------------------------------------------------------------------------------
Când snapshot-urile sistemului de fișiere sunt activate, SnapRAID accesează
sau creează snapshot-uri la rădăcina fiecărui subvolum, volum sau set de
date (dataset).
O modalitate simplă de a evita orice interferență cu instrumentele externe
este de a configura discul `data` astfel încât să indice spre un subdirector
obișnuit din cadrul subvolumului sau volumului (de exemplu
`/mnt/subvol/data` în loc de `/mnt/subvol`). SnapRAID creează întotdeauna
directorul de snapshot-uri la rădăcina subvolumului (de exemplu
`/mnt/subvol/.snapraid/`), lăsând subdirectorul de date curat, astfel încât
snapshot-urile să rămână în exterior și invizibile pentru instrumentele de
backup care operează în interiorul său.
În caz contrar, dacă directorul `data` configurat este chiar rădăcina
subvolumului sau a volumului, SnapRAID creează un director `.snapraid/`
direct în interiorul acestuia (pe Btrfs, Bcachefs și NTFS). Deși SnapRAID
exclude automat acest director din scanarea proprie, instrumentele externe
de backup sau sincronizare îl vor întâlni. Dacă nu este exclus, acestea pot
traversa snapshot-urile sau legăturile de directoare și pot copia întregul
arbore de date înghețat, duplicând datele și epuizând spațiul de stocare al
backup-ului. Configurați întotdeauna instrumentele externe de backup să
excludă directorul `.snapraid/`.
Pe ZFS, snapshot-urile sunt expuse prin directorul virtual standard
`.zfs/snapshot/` în loc de `.snapraid/`. În mod implicit (`snapdir=hidden`),
ZFS ascunde acest director din listările de directoare, astfel încât
instrumentele externe de backup nu îl vor parcurge. Dacă ați activat
`snapdir=visible`, asigurați-vă că instrumentele de backup exclud
directorul `.zfs/`.
10 MODEL (PATTERN) 10 MODEL (PATTERN)
================== ==================

View file

@ -1957,6 +1957,34 @@ SnapRAID управляет тремя конкретными снимками,
использованного прерванной синхронизацией. Более поздняя синхронизация может использованного прерванной синхронизацией. Более поздняя синхронизация может
заменить этот снимок, сделав промежуточные версии файлов недоступными для заменить этот снимок, сделав промежуточные версии файлов недоступными для
восстановления. восстановления.
.SS Внешнее резервное копирование со снимками файловой системы (External backups with filesystem snapshots)
Когда снимки файловой системы включены, SnapRAID обращается к снимкам или
создает их в корне каждого подтома, тома или набора данных (dataset).
.PP
Простой способ избежать любых конфликтов со сторонними инструментами —
указать в директиве \`data\` обычный подкаталог внутри подтома или тома
(например, \`/mnt/subvol/data\` вместо \`/mnt/subvol\`). SnapRAID всегда
создает каталог снимков в корне подтома (например,
\`/mnt/subvol/.snapraid/\`), оставив подкаталог данных чистым, благодаря
чему снимки останутся снаружи и будут невидимы для программ резервного
копирования, работающих внутри него.
.PP
В противном случае, если настроенный каталог \`data\` сам по себе является
корнем подтома или тома, SnapRAID создает каталог \`.snapraid/\` прямо внутри
него (в Btrfs, Bcachefs и NTFS). Хотя SnapRAID автоматически исключает этот
каталог из собственного сканирования, внешние утилиты резервного
копирования или синхронизации файлов обнаружат его. Если каталог не
исключен, они могут войти в снимки или ссылки на каталоги и скопировать
все замороженное дерево данных, дублируя файлы и исчерпывая место в
хранилище резервных копий. Всегда настраивайте внешние утилиты резервного
копирования на исключение каталога \`.snapraid/\`.
.PP
В ZFS снимки доступны через стандартный виртуальный каталог
\`.zfs/snapshot/\`, а не через \`.snapraid/\`. По умолчанию (\`snapdir=hidden\`)
ZFS скрывает этот каталог из списков директорий, поэтому внешние утилиты
резервного копирования не будут сканировать его. Если вы включили
\`snapdir=visible\`, обязательно настройте утилиты резервного копирования на
исключение каталога \`.zfs/\`.
.SH Шаблон (PATTERN) .SH Шаблон (PATTERN)
Шаблоны обеспечивают гибкий способ фильтрации файлов для включения или Шаблоны обеспечивают гибкий способ фильтрации файлов для включения или
исключения. Используя символы подстановки (globbing), вы можете определить правила, исключения. Используя символы подстановки (globbing), вы можете определить правила,

View file

@ -1564,6 +1564,35 @@ Name{number}
заменить этот снимок, сделав промежуточные версии файлов недоступными для заменить этот снимок, сделав промежуточные версии файлов недоступными для
восстановления. восстановления.
Внешнее резервное копирование со снимками файловой системы (External backups with filesystem snapshots)
Когда снимки файловой системы включены, SnapRAID обращается к снимкам или
создает их в корне каждого подтома, тома или набора данных (dataset).
Простой способ избежать любых конфликтов со сторонними инструментами —
указать в директиве `data` обычный подкаталог внутри подтома или тома
(например, `/mnt/subvol/data` вместо `/mnt/subvol`). SnapRAID всегда
создает каталог снимков в корне подтома (например,
`/mnt/subvol/.snapraid/`), оставив подкаталог данных чистым, благодаря
чему снимки останутся снаружи и будут невидимы для программ резервного
копирования, работающих внутри него.
В противном случае, если настроенный каталог `data` сам по себе является
корнем подтома или тома, SnapRAID создает каталог `.snapraid/` прямо внутри
него (в Btrfs, Bcachefs и NTFS). Хотя SnapRAID автоматически исключает этот
каталог из собственного сканирования, внешние утилиты резервного
копирования или синхронизации файлов обнаружат его. Если каталог не
исключен, они могут войти в снимки или ссылки на каталоги и скопировать
все замороженное дерево данных, дублируя файлы и исчерпывая место в
хранилище резервных копий. Всегда настраивайте внешние утилиты резервного
копирования на исключение каталога `.snapraid/`.
В ZFS снимки доступны через стандартный виртуальный каталог
`.zfs/snapshot/`, а не через `.snapraid/`. По умолчанию (`snapdir=hidden`)
ZFS скрывает этот каталог из списков директорий, поэтому внешние утилиты
резервного копирования не будут сканировать его. Если вы включили
`snapdir=visible`, обязательно настройте утилиты резервного копирования на
исключение каталога `.zfs/`.
Шаблон (Pattern) Шаблон (Pattern)
Шаблоны обеспечивают гибкий способ фильтрации файлов для включения или Шаблоны обеспечивают гибкий способ фильтрации файлов для включения или
исключения. Используя символы подстановки (globbing), вы можете определить правила, исключения. Используя символы подстановки (globbing), вы можете определить правила,

View file

@ -1674,6 +1674,37 @@ SnapRAID управляет тремя конкретными снимками,
заменить этот снимок, сделав промежуточные версии файлов недоступными для заменить этот снимок, сделав промежуточные версии файлов недоступными для
восстановления. восстановления.
9.1 Внешнее резервное копирование со снимками файловой системы (External backups with filesystem snapshots)
-----------------------------------------------------------------------------------------------------------
Когда снимки файловой системы включены, SnapRAID обращается к снимкам или
создает их в корне каждого подтома, тома или набора данных (dataset).
Простой способ избежать любых конфликтов со сторонними инструментами —
указать в директиве `data` обычный подкаталог внутри подтома или тома
(например, `/mnt/subvol/data` вместо `/mnt/subvol`). SnapRAID всегда
создает каталог снимков в корне подтома (например,
`/mnt/subvol/.snapraid/`), оставив подкаталог данных чистым, благодаря
чему снимки останутся снаружи и будут невидимы для программ резервного
копирования, работающих внутри него.
В противном случае, если настроенный каталог `data` сам по себе является
корнем подтома или тома, SnapRAID создает каталог `.snapraid/` прямо внутри
него (в Btrfs, Bcachefs и NTFS). Хотя SnapRAID автоматически исключает этот
каталог из собственного сканирования, внешние утилиты резервного
копирования или синхронизации файлов обнаружат его. Если каталог не
исключен, они могут войти в снимки или ссылки на каталоги и скопировать
все замороженное дерево данных, дублируя файлы и исчерпывая место в
хранилище резервных копий. Всегда настраивайте внешние утилиты резервного
копирования на исключение каталога `.snapraid/`.
В ZFS снимки доступны через стандартный виртуальный каталог
`.zfs/snapshot/`, а не через `.snapraid/`. По умолчанию (`snapdir=hidden`)
ZFS скрывает этот каталог из списков директорий, поэтому внешние утилиты
резервного копирования не будут сканировать его. Если вы включили
`snapdir=visible`, обязательно настройте утилиты резервного копирования на
исключение каталога `.zfs/`.
10 Шаблон (PATTERN) 10 Шаблон (PATTERN)
=================== ===================

View file

@ -1953,6 +1953,34 @@ framgångsrikt. Pariteten kan fortfarande innehålla block som beräknats från
ögonblicksbilden som användes av den avbrutna synkroniseringen. En senare ögonblicksbilden som användes av den avbrutna synkroniseringen. En senare
synkronisering kan ersätta den ögonblicksbilden, vilket gör mellanliggande synkronisering kan ersätta den ögonblicksbilden, vilket gör mellanliggande
filversioner otillgängliga för återställning. filversioner otillgängliga för återställning.
.SS Externa säkerhetskopior med ögonblicksbilder av filsystem (External backups with filesystem snapshots)
När ögonblicksbilder av filsystem är aktiverade ansluter eller skapar
SnapRAID ögonblicksbilder vid roten av varje dataundervolym, volym eller
datauppsättning (dataset).
.PP
Ett enkelt sätt att undvika konflikter med externa verktyg är att peka
din \`data\`\-konfiguration till en vanlig underkatalog i undervolymen eller
volymen (till exempel \`/mnt/subvol/data\` istället för \`/mnt/subvol\`).
SnapRAID skapar alltid katalogen för ögonblicksbilder i undervolymens rot
(till exempel \`/mnt/subvol/.snapraid/\`), vilket håller underkatalogen för
data ren så att ögonblicksbilderna förblir utanför och osynliga för
säkerhetskopieringsverktyg som arbetar i den.
.PP
Annars, om din konfigurerade \`data\`\-katalog i sig är roten på undervolymen
eller volymen, skapar SnapRAID en \`.snapraid/\`\-katalog direkt i den (på
Btrfs, Bcachefs och NTFS). Även om SnapRAID automatiskt utesluter denna
katalog från sin egen skanning, kommer externa säkerhetskopieringsverktyg
eller synkroniseringsprogram att stöta på den. Om den inte utesluts kan de
gå in i ögonblicksbilderna eller kataloglänkarna och kopiera hela det frysta
dataträdet, vilket duplicerar data och kan tömma lagringsutrymmet för
säkerhetskopior. Konfigurera alltid externa säkerhetskopieringsverktyg till
att utesluta katalogen \`.snapraid/\`.
.PP
På ZFS exponeras ögonblicksbilder via den virtuella standardkatalogen
\`.zfs/snapshot/\` istället för \`.snapraid/\`. Som standard (\`snapdir=hidden\`)
döljer ZFS denna katalog från kataloglistor så att externa säkerhetskopieringsverktyg
inte söker igenom den. Om du har aktiverat \`snapdir=visible\`, se till att dina
säkerhetskopieringsverktyg utesluter katalogen \`.zfs/\`.
.SH MöNSTER (PATTERN) .SH MöNSTER (PATTERN)
Mönster ger ett flexibelt sätt att filtrera filer för inkludering eller Mönster ger ett flexibelt sätt att filtrera filer för inkludering eller
exkludering. Genom att använda jokertecken kan du definiera regler som exkludering. Genom att använda jokertecken kan du definiera regler som

View file

@ -1558,6 +1558,35 @@ Livscykel för ögonblicksbilder (Snapshots Lifecycle)
synkronisering kan ersätta den ögonblicksbilden, vilket gör mellanliggande synkronisering kan ersätta den ögonblicksbilden, vilket gör mellanliggande
filversioner otillgängliga för återställning. filversioner otillgängliga för återställning.
Externa säkerhetskopior med ögonblicksbilder av filsystem (External backups with filesystem snapshots)
När ögonblicksbilder av filsystem är aktiverade ansluter eller skapar
SnapRAID ögonblicksbilder vid roten av varje dataundervolym, volym eller
datauppsättning (dataset).
Ett enkelt sätt att undvika konflikter med externa verktyg är att peka
din `data`-konfiguration till en vanlig underkatalog i undervolymen eller
volymen (till exempel `/mnt/subvol/data` istället för `/mnt/subvol`).
SnapRAID skapar alltid katalogen för ögonblicksbilder i undervolymens rot
(till exempel `/mnt/subvol/.snapraid/`), vilket håller underkatalogen för
data ren så att ögonblicksbilderna förblir utanför och osynliga för
säkerhetskopieringsverktyg som arbetar i den.
Annars, om din konfigurerade `data`-katalog i sig är roten på undervolymen
eller volymen, skapar SnapRAID en `.snapraid/`-katalog direkt i den (på
Btrfs, Bcachefs och NTFS). Även om SnapRAID automatiskt utesluter denna
katalog från sin egen skanning, kommer externa säkerhetskopieringsverktyg
eller synkroniseringsprogram att stöta på den. Om den inte utesluts kan de
gå in i ögonblicksbilderna eller kataloglänkarna och kopiera hela det frysta
dataträdet, vilket duplicerar data och kan tömma lagringsutrymmet för
säkerhetskopior. Konfigurera alltid externa säkerhetskopieringsverktyg till
att utesluta katalogen `.snapraid/`.
På ZFS exponeras ögonblicksbilder via den virtuella standardkatalogen
`.zfs/snapshot/` istället för `.snapraid/`. Som standard (`snapdir=hidden`)
döljer ZFS denna katalog från kataloglistor så att externa säkerhetskopieringsverktyg
inte söker igenom den. Om du har aktiverat `snapdir=visible`, se till att dina
säkerhetskopieringsverktyg utesluter katalogen `.zfs/`.
Mönster (Pattern) Mönster (Pattern)
Mönster ger ett flexibelt sätt att filtrera filer för inkludering eller Mönster ger ett flexibelt sätt att filtrera filer för inkludering eller
exkludering. Genom att använda jokertecken kan du definiera regler som exkludering. Genom att använda jokertecken kan du definiera regler som

View file

@ -1668,6 +1668,37 @@ framgångsrikt. Pariteten kan fortfarande innehålla block som beräknats från
synkronisering kan ersätta den ögonblicksbilden, vilket gör mellanliggande synkronisering kan ersätta den ögonblicksbilden, vilket gör mellanliggande
filversioner otillgängliga för återställning. filversioner otillgängliga för återställning.
9.1 Externa säkerhetskopior med ögonblicksbilder av filsystem (External backups with filesystem snapshots)
----------------------------------------------------------------------------------------------------------
När ögonblicksbilder av filsystem är aktiverade ansluter eller skapar
SnapRAID ögonblicksbilder vid roten av varje dataundervolym, volym eller
datauppsättning (dataset).
Ett enkelt sätt att undvika konflikter med externa verktyg är att peka
din `data`-konfiguration till en vanlig underkatalog i undervolymen eller
volymen (till exempel `/mnt/subvol/data` istället för `/mnt/subvol`).
SnapRAID skapar alltid katalogen för ögonblicksbilder i undervolymens rot
(till exempel `/mnt/subvol/.snapraid/`), vilket håller underkatalogen för
data ren så att ögonblicksbilderna förblir utanför och osynliga för
säkerhetskopieringsverktyg som arbetar i den.
Annars, om din konfigurerade `data`-katalog i sig är roten på undervolymen
eller volymen, skapar SnapRAID en `.snapraid/`-katalog direkt i den (på
Btrfs, Bcachefs och NTFS). Även om SnapRAID automatiskt utesluter denna
katalog från sin egen skanning, kommer externa säkerhetskopieringsverktyg
eller synkroniseringsprogram att stöta på den. Om den inte utesluts kan de
gå in i ögonblicksbilderna eller kataloglänkarna och kopiera hela det frysta
dataträdet, vilket duplicerar data och kan tömma lagringsutrymmet för
säkerhetskopior. Konfigurera alltid externa säkerhetskopieringsverktyg till
att utesluta katalogen `.snapraid/`.
På ZFS exponeras ögonblicksbilder via den virtuella standardkatalogen
`.zfs/snapshot/` istället för `.snapraid/`. Som standard (`snapdir=hidden`)
döljer ZFS denna katalog från kataloglistor så att externa säkerhetskopieringsverktyg
inte söker igenom den. Om du har aktiverat `snapdir=visible`, se till att dina
säkerhetskopieringsverktyg utesluter katalogen `.zfs/`.
10 MöNSTER (PATTERN) 10 MöNSTER (PATTERN)
==================== ====================

View file

@ -2126,6 +2126,34 @@ SnapRAID керує трьома конкретними знімками, \`stab
використаного перерваною синхронізацією. Пізніша синхронізація може використаного перерваною синхронізацією. Пізніша синхронізація може
замінити цей знімок, зробивши проміжні версії файлів недоступними для замінити цей знімок, зробивши проміжні версії файлів недоступними для
відновлення. відновлення.
.SS Зовнішнє резервне копіювання зі знімками файлової системи (External backups with filesystem snapshots)
Коли знімки файлової системи ввімкнено, SnapRAID звертається до знімків або
створює їх у корені кожного підтому даних, тому або набору даних (dataset).
.PP
Простий спосіб уникнути будь\-яких конфліктів зі сторонніми інструментами —
вказати в налаштуванні \`data\` звичайний підкаталог усередині підтому або
тому (наприклад, \`/mnt/subvol/data\` замість \`/mnt/subvol\`). SnapRAID завжди
створює каталог знімків у корені підтому (наприклад,
\`/mnt/subvol/.snapraid/\`), залишивши підкаталог даних чистим, завдяки чому
знімки залишаться ззовні та будуть невидимими для засобів резервного
копіювання, що працюють у ньому.
.PP
В іншому випадку, якщо налаштований каталог \`data\` сам по собі є коренем
підтому або тому, SnapRAID створює каталог \`.snapraid/\` безпосередньо
всередині нього (у Btrfs, Bcachefs та NTFS). Хоча SnapRAID автоматично
виключає цей каталог із власного сканування, зовнішні інструменти
резервного копіювання або синхронізації файлів виявлять його. Якщо каталог
не виключено, вони можуть увійти у знімки або посилання на каталоги та
скопіювати все заморожене дерево даних, дублюючи файли й вичерпуючи
дисковий простір резервного сховища. Завжди налаштовуйте зовнішні засоби
резервного копіювання на виключення каталогу \`.snapraid/\`.
.PP
У ZFS знімки надаються через стандартний віртуальний каталог
\`.zfs/snapshot/\` замість \`.snapraid/\`. За замовчуванням (\`snapdir=hidden\`)
ZFS приховує цей каталог зі списків каталогів, тому зовнішні інструменти
резервного копіювання не скануватимуть його. Якщо ви ввімкнули
\`snapdir=visible\`, обов\'язково переконайтеся, що ваші інструменти
резервного копіювання виключають каталог \`.zfs/\`.
.SH Шаблон (PATTERN) .SH Шаблон (PATTERN)
Шаблони забезпечують гнучкий спосіб фільтрації файлів для включення або Шаблони забезпечують гнучкий спосіб фільтрації файлів для включення або
виключення. Використовуючи символи підстановки (globbing), ви можете визначити правила, які виключення. Використовуючи символи підстановки (globbing), ви можете визначити правила, які

View file

@ -1722,6 +1722,35 @@ Name{number}
замінити цей знімок, зробивши проміжні версії файлів недоступними для замінити цей знімок, зробивши проміжні версії файлів недоступними для
відновлення. відновлення.
Зовнішнє резервне копіювання зі знімками файлової системи (External backups with filesystem snapshots)
Коли знімки файлової системи ввімкнено, SnapRAID звертається до знімків або
створює їх у корені кожного підтому даних, тому або набору даних (dataset).
Простий спосіб уникнути будь-яких конфліктів зі сторонніми інструментами —
вказати в налаштуванні `data` звичайний підкаталог усередині підтому або
тому (наприклад, `/mnt/subvol/data` замість `/mnt/subvol`). SnapRAID завжди
створює каталог знімків у корені підтому (наприклад,
`/mnt/subvol/.snapraid/`), залишивши підкаталог даних чистим, завдяки чому
знімки залишаться ззовні та будуть невидимими для засобів резервного
копіювання, що працюють у ньому.
В іншому випадку, якщо налаштований каталог `data` сам по собі є коренем
підтому або тому, SnapRAID створює каталог `.snapraid/` безпосередньо
всередині нього (у Btrfs, Bcachefs та NTFS). Хоча SnapRAID автоматично
виключає цей каталог із власного сканування, зовнішні інструменти
резервного копіювання або синхронізації файлів виявлять його. Якщо каталог
не виключено, вони можуть увійти у знімки або посилання на каталоги та
скопіювати все заморожене дерево даних, дублюючи файли й вичерпуючи
дисковий простір резервного сховища. Завжди налаштовуйте зовнішні засоби
резервного копіювання на виключення каталогу `.snapraid/`.
У ZFS знімки надаються через стандартний віртуальний каталог
`.zfs/snapshot/` замість `.snapraid/`. За замовчуванням (`snapdir=hidden`)
ZFS приховує цей каталог зі списків каталогів, тому зовнішні інструменти
резервного копіювання не скануватимуть його. Якщо ви ввімкнули
`snapdir=visible`, обов'язково переконайтеся, що ваші інструменти
резервного копіювання виключають каталог `.zfs/`.
Шаблон (Pattern) Шаблон (Pattern)
Шаблони забезпечують гнучкий спосіб фільтрації файлів для включення або Шаблони забезпечують гнучкий спосіб фільтрації файлів для включення або
виключення. Використовуючи символи підстановки (globbing), ви можете визначити правила, які виключення. Використовуючи символи підстановки (globbing), ви можете визначити правила, які

View file

@ -1832,6 +1832,37 @@ SnapRAID керує трьома конкретними знімками, `stabl
замінити цей знімок, зробивши проміжні версії файлів недоступними для замінити цей знімок, зробивши проміжні версії файлів недоступними для
відновлення. відновлення.
9.1 Зовнішнє резервне копіювання зі знімками файлової системи (External backups with filesystem snapshots)
----------------------------------------------------------------------------------------------------------
Коли знімки файлової системи ввімкнено, SnapRAID звертається до знімків або
створює їх у корені кожного підтому даних, тому або набору даних (dataset).
Простий спосіб уникнути будь-яких конфліктів зі сторонніми інструментами —
вказати в налаштуванні `data` звичайний підкаталог усередині підтому або
тому (наприклад, `/mnt/subvol/data` замість `/mnt/subvol`). SnapRAID завжди
створює каталог знімків у корені підтому (наприклад,
`/mnt/subvol/.snapraid/`), залишивши підкаталог даних чистим, завдяки чому
знімки залишаться ззовні та будуть невидимими для засобів резервного
копіювання, що працюють у ньому.
В іншому випадку, якщо налаштований каталог `data` сам по собі є коренем
підтому або тому, SnapRAID створює каталог `.snapraid/` безпосередньо
всередині нього (у Btrfs, Bcachefs та NTFS). Хоча SnapRAID автоматично
виключає цей каталог із власного сканування, зовнішні інструменти
резервного копіювання або синхронізації файлів виявлять його. Якщо каталог
не виключено, вони можуть увійти у знімки або посилання на каталоги та
скопіювати все заморожене дерево даних, дублюючи файли й вичерпуючи
дисковий простір резервного сховища. Завжди налаштовуйте зовнішні засоби
резервного копіювання на виключення каталогу `.snapraid/`.
У ZFS знімки надаються через стандартний віртуальний каталог
`.zfs/snapshot/` замість `.snapraid/`. За замовчуванням (`snapdir=hidden`)
ZFS приховує цей каталог зі списків каталогів, тому зовнішні інструменти
резервного копіювання не скануватимуть його. Якщо ви ввімкнули
`snapdir=visible`, обов'язково переконайтеся, що ваші інструменти
резервного копіювання виключають каталог `.zfs/`.
10 Шаблон (PATTERN) 10 Шаблон (PATTERN)
=================== ===================

View file

@ -1755,6 +1755,25 @@ SnapRAID 在每个数据子卷根目录下的隐藏目录中管理三个特定
但是,如果 \`sync\` 中断,请避免在后续 \`sync\` 成功完成之前修改、删除、 但是,如果 \`sync\` 中断,请避免在后续 \`sync\` 成功完成之前修改、删除、
替换或移动文件。校验可能仍包含根据中断的同步所使用的快照计算的块。 替换或移动文件。校验可能仍包含根据中断的同步所使用的快照计算的块。
以后的同步可能会替换该快照,从而导致中间文件版本无法用于恢复。 以后的同步可能会替换该快照,从而导致中间文件版本无法用于恢复。
.SS 使用文件系统快照进行外部备份 (External backups with filesystem snapshots)
当启用文件系统快照时,SnapRAID 会在每个数据子卷、卷或数据集(dataset)
的根目录下访问或创建快照。
.PP
避免与外部工具发生冲突的一种简单方法,是将 \`data\` 配置指向子卷或卷内的
常规子目录(例如 \`/mnt/subvol/data\` 而不是 \`/mnt/subvol\`)。SnapRAID
始终会在子卷根目录下创建快照目录(例如 \`/mnt/subvol/.snapraid/\`),从而保持
数据子目录整洁,使快照保留在外部且对在该目录内运行的备份工具不可见。
.PP
否则,如果配置的 \`data\` 目录本身就是子卷或卷的根目录,SnapRAID 会直接在其中
创建 \`.snapraid/\` 目录(在 Btrfs、Bcachefs 和 NTFS 上)。虽然 SnapRAID
会在其自身的扫描中自动排除此目录,但外部备份工具或文件同步工具会发现它。如果未
将其排除,它们可能会遍历快照或目录链接并复制整个冻结的数据树,从而导致数据
重复并耗尽备份存储空间。请务必将外部备份工具配置为排除 \`.snapraid/\` 目录。
.PP
在 ZFS 上,快照是通过标准虚拟目录 \`.zfs/snapshot/\` 而不是 \`.snapraid/\`
公开的。默认情况下(\`snapdir=hidden\`),ZFS 会在目录列表中隐藏此目录,因此
外部备份工具不会遍历它。如果您启用了 \`snapdir=visible\`,请确保您的备份工具
排除 \`.zfs/\` 目录。
.SH 模式 (PATTERN) .SH 模式 (PATTERN)
模式提供了一种灵活的方法来过滤要包含或排除的文件。通过使用通配符(globbing), 模式提供了一种灵活的方法来过滤要包含或排除的文件。通过使用通配符(globbing),
您可以定义匹配特定文件名或整个目录结构的规则,而无需手动列出每个路径。 您可以定义匹配特定文件名或整个目录结构的规则,而无需手动列出每个路径。

View file

@ -1360,6 +1360,26 @@ Name{number}
替换或移动文件。校验可能仍包含根据中断的同步所使用的快照计算的块。 替换或移动文件。校验可能仍包含根据中断的同步所使用的快照计算的块。
以后的同步可能会替换该快照,从而导致中间文件版本无法用于恢复。 以后的同步可能会替换该快照,从而导致中间文件版本无法用于恢复。
使用文件系统快照进行外部备份 (External backups with filesystem snapshots)
当启用文件系统快照时,SnapRAID 会在每个数据子卷、卷或数据集(dataset)
的根目录下访问或创建快照。
避免与外部工具发生冲突的一种简单方法,是将 `data` 配置指向子卷或卷内的
常规子目录(例如 `/mnt/subvol/data` 而不是 `/mnt/subvol`)。SnapRAID
始终会在子卷根目录下创建快照目录(例如 `/mnt/subvol/.snapraid/`),从而保持
数据子目录整洁,使快照保留在外部且对在该目录内运行的备份工具不可见。
否则,如果配置的 `data` 目录本身就是子卷或卷的根目录,SnapRAID 会直接在其中
创建 `.snapraid/` 目录(在 Btrfs、Bcachefs 和 NTFS 上)。虽然 SnapRAID
会在其自身的扫描中自动排除此目录,但外部备份工具或文件同步工具会发现它。如果未
将其排除,它们可能会遍历快照或目录链接并复制整个冻结的数据树,从而导致数据
重复并耗尽备份存储空间。请务必将外部备份工具配置为排除 `.snapraid/` 目录。
在 ZFS 上,快照是通过标准虚拟目录 `.zfs/snapshot/` 而不是 `.snapraid/`
公开的。默认情况下(`snapdir=hidden`),ZFS 会在目录列表中隐藏此目录,因此
外部备份工具不会遍历它。如果您启用了 `snapdir=visible`,请确保您的备份工具
排除 `.zfs/` 目录。
模式 (Pattern) 模式 (Pattern)
模式提供了一种灵活的方法来过滤要包含或排除的文件。通过使用通配符(globbing), 模式提供了一种灵活的方法来过滤要包含或排除的文件。通过使用通配符(globbing),
您可以定义匹配特定文件名或整个目录结构的规则,而无需手动列出每个路径。 您可以定义匹配特定文件名或整个目录结构的规则,而无需手动列出每个路径。

View file

@ -1470,6 +1470,28 @@ SnapRAID 在每个数据子卷根目录下的隐藏目录中管理三个特定
替换或移动文件。校验可能仍包含根据中断的同步所使用的快照计算的块。 替换或移动文件。校验可能仍包含根据中断的同步所使用的快照计算的块。
以后的同步可能会替换该快照,从而导致中间文件版本无法用于恢复。 以后的同步可能会替换该快照,从而导致中间文件版本无法用于恢复。
9.1 使用文件系统快照进行外部备份 (External backups with filesystem snapshots)
---------------------------------------------------------------
当启用文件系统快照时,SnapRAID 会在每个数据子卷、卷或数据集(dataset)
的根目录下访问或创建快照。
避免与外部工具发生冲突的一种简单方法,是将 `data` 配置指向子卷或卷内的
常规子目录(例如 `/mnt/subvol/data` 而不是 `/mnt/subvol`)。SnapRAID
始终会在子卷根目录下创建快照目录(例如 `/mnt/subvol/.snapraid/`),从而保持
数据子目录整洁,使快照保留在外部且对在该目录内运行的备份工具不可见。
否则,如果配置的 `data` 目录本身就是子卷或卷的根目录,SnapRAID 会直接在其中
创建 `.snapraid/` 目录(在 Btrfs、Bcachefs 和 NTFS 上)。虽然 SnapRAID
会在其自身的扫描中自动排除此目录,但外部备份工具或文件同步工具会发现它。如果未
将其排除,它们可能会遍历快照或目录链接并复制整个冻结的数据树,从而导致数据
重复并耗尽备份存储空间。请务必将外部备份工具配置为排除 `.snapraid/` 目录。
在 ZFS 上,快照是通过标准虚拟目录 `.zfs/snapshot/` 而不是 `.snapraid/`
公开的。默认情况下(`snapdir=hidden`),ZFS 会在目录列表中隐藏此目录,因此
外部备份工具不会遍历它。如果您启用了 `snapdir=visible`,请确保您的备份工具
排除 `.zfs/` 目录。
10 模式 (PATTERN) 10 模式 (PATTERN)
=============== ===============

View file

@ -1962,6 +1962,33 @@ successfully. Parity may still contain blocks computed from the
snapshot used by the interrupted sync. A later sync may replace snapshot used by the interrupted sync. A later sync may replace
that snapshot, making intermediate file versions unavailable for that snapshot, making intermediate file versions unavailable for
recovery. recovery.
.SS External backups with filesystem snapshots
When filesystem snapshots are enabled, SnapRAID accesses or creates
snapshots at the root of each data subvolume, volume, or dataset.
.PP
A simple way to avoid any interference with external tools is to point
your \`data\` configuration to a regular subdirectory within the subvolume
or volume (for example, \`/mnt/subvol/data\` instead of \`/mnt/subvol\`).
SnapRAID always creates the snapshot directory at the subvolume root
(for example, \`/mnt/subvol/.snapraid/\`), leaving the data subdirectory
clean so that snapshots remain outside and invisible to backup tools
operating inside it.
.PP
Otherwise, if your configured \`data\` directory is itself the subvolume
or volume root, SnapRAID creates the \`.snapraid/\` directory directly
inside it (on Btrfs, Bcachefs, and NTFS). While SnapRAID automatically
excludes this directory from its own scanning, external backup tools
or file synchronizers will encounter it. If not excluded, they may
traverse into the snapshots or directory links and copy the entire
frozen data tree, duplicating data and potentially exhausting backup
storage. Always configure external backup tools to exclude the
\`.snapraid/\` directory.
.PP
On ZFS, snapshots are exposed through the standard \`.zfs/snapshot/\`
virtual directory rather than \`.snapraid/\`. By default (\`snapdir=hidden\`),
ZFS hides this directory from directory listings, so external backup
tools will not traverse it. If you have enabled \`snapdir=visible\`,
ensure your backup tools exclude the \`.zfs/\` directory.
.SH PATTERN .SH PATTERN
Patterns are used to select a subset of files to exclude or include in Patterns are used to select a subset of files to exclude or include in
the process. Globbing characters can be used to match files and paths the process. Globbing characters can be used to match files and paths

View file

@ -1567,6 +1567,34 @@ Snapshots Lifecycle
that snapshot, making intermediate file versions unavailable for that snapshot, making intermediate file versions unavailable for
recovery. recovery.
External backups with filesystem snapshots
When filesystem snapshots are enabled, SnapRAID accesses or creates
snapshots at the root of each data subvolume, volume, or dataset.
A simple way to avoid any interference with external tools is to point
your `data` configuration to a regular subdirectory within the subvolume
or volume (for example, `/mnt/subvol/data` instead of `/mnt/subvol`).
SnapRAID always creates the snapshot directory at the subvolume root
(for example, `/mnt/subvol/.snapraid/`), leaving the data subdirectory
clean so that snapshots remain outside and invisible to backup tools
operating inside it.
Otherwise, if your configured `data` directory is itself the subvolume
or volume root, SnapRAID creates the `.snapraid/` directory directly
inside it (on Btrfs, Bcachefs, and NTFS). While SnapRAID automatically
excludes this directory from its own scanning, external backup tools
or file synchronizers will encounter it. If not excluded, they may
traverse into the snapshots or directory links and copy the entire
frozen data tree, duplicating data and potentially exhausting backup
storage. Always configure external backup tools to exclude the
`.snapraid/` directory.
On ZFS, snapshots are exposed through the standard `.zfs/snapshot/`
virtual directory rather than `.snapraid/`. By default (`snapdir=hidden`),
ZFS hides this directory from directory listings, so external backup
tools will not traverse it. If you have enabled `snapdir=visible`,
ensure your backup tools exclude the `.zfs/` directory.
Pattern Pattern
Patterns are used to select a subset of files to exclude or include in Patterns are used to select a subset of files to exclude or include in
the process. Globbing characters can be used to match files and paths the process. Globbing characters can be used to match files and paths

View file

@ -1677,6 +1677,36 @@ snapshot used by the interrupted sync. A later sync may replace
that snapshot, making intermediate file versions unavailable for that snapshot, making intermediate file versions unavailable for
recovery. recovery.
9.1 External backups with filesystem snapshots
----------------------------------------------
When filesystem snapshots are enabled, SnapRAID accesses or creates
snapshots at the root of each data subvolume, volume, or dataset.
A simple way to avoid any interference with external tools is to point
your `data` configuration to a regular subdirectory within the subvolume
or volume (for example, `/mnt/subvol/data` instead of `/mnt/subvol`).
SnapRAID always creates the snapshot directory at the subvolume root
(for example, `/mnt/subvol/.snapraid/`), leaving the data subdirectory
clean so that snapshots remain outside and invisible to backup tools
operating inside it.
Otherwise, if your configured `data` directory is itself the subvolume
or volume root, SnapRAID creates the `.snapraid/` directory directly
inside it (on Btrfs, Bcachefs, and NTFS). While SnapRAID automatically
excludes this directory from its own scanning, external backup tools
or file synchronizers will encounter it. If not excluded, they may
traverse into the snapshots or directory links and copy the entire
frozen data tree, duplicating data and potentially exhausting backup
storage. Always configure external backup tools to exclude the
`.snapraid/` directory.
On ZFS, snapshots are exposed through the standard `.zfs/snapshot/`
virtual directory rather than `.snapraid/`. By default (`snapdir=hidden`),
ZFS hides this directory from directory listings, so external backup
tools will not traverse it. If you have enabled `snapdir=visible`,
ensure your backup tools exclude the `.zfs/` directory.
10 PATTERN 10 PATTERN
========== ==========

View file

@ -3,7 +3,7 @@
#include "os/portable.h" #include "os/portable.h"
#ifdef __MINGW32__ /* Only for MingW */ #ifdef __MINGW32__ /* only for MingW */
#include "os.h" #include "os.h"
@ -14,9 +14,9 @@
/****************************************************************************/ /****************************************************************************/
/* global */ /* global */
/* Add missing Windows declaration */ /* add missing Windows declaration */
/* For SetThreadExecutionState */ /* for SetThreadExecutionState */
#ifndef WIN32_ES_SYSTEM_REQUIRED #ifndef WIN32_ES_SYSTEM_REQUIRED
#define WIN32_ES_SYSTEM_REQUIRED 0x00000001L #define WIN32_ES_SYSTEM_REQUIRED 0x00000001L
#endif #endif
@ -33,7 +33,7 @@
#define WIN32_ES_CONTINUOUS 0x80000000L #define WIN32_ES_CONTINUOUS 0x80000000L
#endif #endif
/* For SetSearchPathMode */ /* for SetSearchPathMode */
#ifndef BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE #ifndef BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE
#define BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE 0x00000001 #define BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE 0x00000001
#endif #endif
@ -41,7 +41,7 @@
#define BASE_SEARCH_PATH_PERMANENT 0x00008000 #define BASE_SEARCH_PATH_PERMANENT 0x00008000
#endif #endif
/* File Index */ /* file Index */
#undef FILE_INVALID_FILE_ID #undef FILE_INVALID_FILE_ID
#define FILE_INVALID_FILE_ID ((ULONGLONG)-1LL) #define FILE_INVALID_FILE_ID ((ULONGLONG)-1LL)
#undef FILE_UNSUPPORTED_FILE_ID #undef FILE_UNSUPPORTED_FILE_ID
@ -64,6 +64,7 @@ static windows_key_t last_error;
*/ */
static windows_mutex_t tick_lock; static windows_mutex_t tick_lock;
static uint64_t tick_last; static uint64_t tick_last;
static uint64_t tick_frequency;
/** /**
* Mutex for process reference publication, termination, and unpublication. * Mutex for process reference publication, termination, and unpublication.
@ -570,17 +571,17 @@ static BOOL GetReparseTagInfoByHandle(HANDLE hFile, FILE_ATTRIBUTE_TAG_INFO* lpF
*/ */
static void windows_attr2stat(DWORD FileAttributes, DWORD ReparseTag, struct windows_stat* st) static void windows_attr2stat(DWORD FileAttributes, DWORD ReparseTag, struct windows_stat* st)
{ {
/* Convert special attributes */ /* convert special attributes */
if ((FileAttributes & FILE_ATTRIBUTE_DEVICE) != 0) { if ((FileAttributes & FILE_ATTRIBUTE_DEVICE) != 0) {
st->st_mode = S_IFBLK; st->st_mode = S_IFBLK;
st->st_desc = "device"; st->st_desc = "device";
} else if ((FileAttributes & FILE_ATTRIBUTE_OFFLINE) != 0) { /* Offline */ } else if ((FileAttributes & FILE_ATTRIBUTE_OFFLINE) != 0) { /* offline */
st->st_mode = S_IFCHR; st->st_mode = S_IFCHR;
st->st_desc = "offline"; st->st_desc = "offline";
} else if ((FileAttributes & FILE_ATTRIBUTE_TEMPORARY) != 0) { /* Temporary */ } else if ((FileAttributes & FILE_ATTRIBUTE_TEMPORARY) != 0) { /* temporary */
st->st_mode = S_IFCHR; st->st_mode = S_IFCHR;
st->st_desc = "temporary"; st->st_desc = "temporary";
} else if ((FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { /* Reparse point */ } else if ((FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0) { /* reparse point */
switch (ReparseTag) { switch (ReparseTag) {
/* if we don't have the ReparseTag information */ /* if we don't have the ReparseTag information */
case 0 : case 0 :
@ -621,7 +622,7 @@ static void windows_attr2stat(DWORD FileAttributes, DWORD ReparseTag, struct win
st->st_desc = "reparse-point"; st->st_desc = "reparse-point";
break; break;
} }
} else if ((FileAttributes & FILE_ATTRIBUTE_SYSTEM) != 0) { /* System */ } else if ((FileAttributes & FILE_ATTRIBUTE_SYSTEM) != 0) { /* system */
if ((FileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { if ((FileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) {
st->st_mode = S_IFCHR; st->st_mode = S_IFCHR;
st->st_desc = "system-directory"; st->st_desc = "system-directory";
@ -695,7 +696,7 @@ static int windows_info2stat(const BY_HANDLE_FILE_INFORMATION* info, const FILE_
/* GetFileInformationByHandle() ensures to return synced information */ /* GetFileInformationByHandle() ensures to return synced information */
st->st_sync = 1; st->st_sync = 1;
/** /*
* In ReFS the IDs are 128 bit, and the 64 bit interface may fail. * In ReFS the IDs are 128 bit, and the 64 bit interface may fail.
* *
* From Microsoft "Application Compatibility with ReFS" * From Microsoft "Application Compatibility with ReFS"
@ -798,13 +799,13 @@ static void windows_finddata2stat(const WIN32_FIND_DATAW* info, struct windows_s
windows_time2stat(mtime, st); windows_time2stat(mtime, st);
/* No inode information available */ /* no inode information available */
st->st_ino = INODE_INVALID; st->st_ino = INODE_INVALID;
/* No link information available */ /* no link information available */
st->st_nlink = 0; st->st_nlink = 0;
/* No device information available */ /* no device information available */
st->st_dev = 0; st->st_dev = 0;
/* directory listing doesn't ensure to return synced information */ /* directory listing doesn't ensure to return synced information */
@ -877,6 +878,9 @@ void windows_errno(DWORD error)
case ERROR_PATH_NOT_FOUND : /* in GetFileAttributeW() if internal path not found */ case ERROR_PATH_NOT_FOUND : /* in GetFileAttributeW() if internal path not found */
errno = ENOENT; errno = ENOENT;
break; break;
case ERROR_DIRECTORY :
errno = ENOTDIR;
break;
case ERROR_ACCESS_DENIED : /* in CreateDirectoryW() if dir is scheduled for deletion */ case ERROR_ACCESS_DENIED : /* in CreateDirectoryW() if dir is scheduled for deletion */
case ERROR_CURRENT_DIRECTORY : /* in RemoveDirectoryW() if removing the current directory */ case ERROR_CURRENT_DIRECTORY : /* in RemoveDirectoryW() if removing the current directory */
case ERROR_SHARING_VIOLATION : /* in RemoveDirectoryW() if in use */ case ERROR_SHARING_VIOLATION : /* in RemoveDirectoryW() if in use */
@ -1188,8 +1192,8 @@ int windows_fsync(int fd)
* So, we use now an extended error reporting. * So, we use now an extended error reporting.
*/ */
windows_errno(error); windows_errno(error);
os_syslog(OS_LVL_INFO, "unexpected Windows INVALID_HANDLE error in FlushFileBuffers()"); os_syslog(OS_LVL_ERROR, "unexpected Windows INVALID_HANDLE error in FlushFileBuffers()");
os_syslog(OS_LVL_INFO, "are you using ATA-over-Ethernet? Please report it."); os_syslog(OS_LVL_ERROR, "are you using ATA-over-Ethernet? Please report it.");
return -1; return -1;
case ERROR_ACCESS_DENIED : case ERROR_ACCESS_DENIED :
@ -1245,8 +1249,8 @@ static int windows_vsync(const wchar_t* volume)
* So, we use now an extended error reporting. * So, we use now an extended error reporting.
*/ */
windows_errno(error); windows_errno(error);
os_syslog(OS_LVL_INFO, "unexpected Windows INVALID_HANDLE error in FlushFileBuffers()"); os_syslog(OS_LVL_ERROR, "unexpected Windows INVALID_HANDLE error in FlushFileBuffers()");
os_syslog(OS_LVL_INFO, "are you using ATA-over-Ethernet? Please report it."); os_syslog(OS_LVL_ERROR, "are you using ATA-over-Ethernet? Please report it.");
return -1; return -1;
case ERROR_ACCESS_DENIED : case ERROR_ACCESS_DENIED :
@ -2075,7 +2079,7 @@ int windows_symlink_directory(const char* existing, const char* file)
return windows_symlink_flags(existing, file, SYMBOLIC_LINK_FLAG_DIRECTORY); return windows_symlink_flags(existing, file, SYMBOLIC_LINK_FLAG_DIRECTORY);
} }
/* Adds missing definitions in MingW winnt.h */ /* adds missing definitions in MingW winnt.h */
#ifndef FSCTL_GET_REPARSE_POINT #ifndef FSCTL_GET_REPARSE_POINT
#define FSCTL_GET_REPARSE_POINT 0x000900a8 #define FSCTL_GET_REPARSE_POINT 0x000900a8
#endif #endif
@ -2254,7 +2258,7 @@ ssize_t windows_read(int fd, void* buffer, size_t size)
if (!ReadFile(h, buffer, size, &count, 0)) { if (!ReadFile(h, buffer, size, &count, 0)) {
DWORD error = GetLastError(); DWORD error = GetLastError();
/* A closed Windows pipe has the same read semantics as a POSIX pipe at EOF. */ /* a closed Windows pipe has the same read semantics as a POSIX pipe at EOF. */
if (error == ERROR_BROKEN_PIPE) if (error == ERROR_BROKEN_PIPE)
return 0; return 0;
@ -2978,7 +2982,7 @@ static int fixcat(WCHAR* cmd, int size, int pos, const WCHAR* arg)
return pos; return pos;
} }
/* /**
* Append one argument using the Microsoft C runtime command-line * Append one argument using the Microsoft C runtime command-line
* quoting rules. Use this when building a normal CreateProcessW() * quoting rules. Use this when building a normal CreateProcessW()
* command line that the target process will parse back into argv[]. * command line that the target process will parse back into argv[].
@ -3039,7 +3043,7 @@ static int argcat(WCHAR* cmd, int size, int pos, const WCHAR* arg)
return pos; return pos;
} }
/* /**
* Append one argument for a batch script invoked through cmd.exe /c. * Append one argument for a batch script invoked through cmd.exe /c.
* Unlike argcat(), this must preserve the argument boundary while * Unlike argcat(), this must preserve the argument boundary while
* preventing cmd.exe command metacharacters from changing the command * preventing cmd.exe command metacharacters from changing the command
@ -3202,14 +3206,14 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
/* create a pipe for the child process's STDOUT */ /* create a pipe for the child process's STDOUT */
if (!CreatePipe(&stdout_read_handle, &stdout_write_handle, &sa, 0)) { if (!CreatePipe(&stdout_read_handle, &stdout_write_handle, &sa, 0)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to create pipe for spawn, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to create pipe for spawn, errno=%s(%d)", strerror(errno), errno);
return -1; return -1;
} }
/* ensure the reading handle to the pipe is not inherited */ /* ensure the reading handle to the pipe is not inherited */
if (!SetHandleInformation(stdout_read_handle, HANDLE_FLAG_INHERIT, 0)) { if (!SetHandleInformation(stdout_read_handle, HANDLE_FLAG_INHERIT, 0)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to handle information for spawn, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to set handle information for spawn, errno=%s(%d)", strerror(errno), errno);
CloseHandle(stdout_write_handle); CloseHandle(stdout_write_handle);
CloseHandle(stdout_read_handle); CloseHandle(stdout_read_handle);
return -1; return -1;
@ -3218,7 +3222,7 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
out_f = _open_osfhandle((intptr_t)stdout_read_handle, O_RDONLY | O_BINARY); out_f = _open_osfhandle((intptr_t)stdout_read_handle, O_RDONLY | O_BINARY);
if (out_f == -1) { if (out_f == -1) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to open osfhandle for spawn, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to open osfhandle for spawn, errno=%s(%d)", strerror(errno), errno);
CloseHandle(stdout_write_handle); CloseHandle(stdout_write_handle);
CloseHandle(stdout_read_handle); CloseHandle(stdout_read_handle);
return -1; return -1;
@ -3229,7 +3233,7 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
/* create a pipe for the child process's STDERR */ /* create a pipe for the child process's STDERR */
if (!CreatePipe(&stderr_read_handle, &stderr_write_handle, &sa, 0)) { if (!CreatePipe(&stderr_read_handle, &stderr_write_handle, &sa, 0)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to create pipe for spawn, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to create pipe for spawn, errno=%s(%d)", strerror(errno), errno);
if (has_out) { if (has_out) {
CloseHandle(stdout_write_handle); CloseHandle(stdout_write_handle);
close(out_f); close(out_f);
@ -3240,7 +3244,7 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
/* ensure the reading handle to the pipe is not inherited */ /* ensure the reading handle to the pipe is not inherited */
if (!SetHandleInformation(stderr_read_handle, HANDLE_FLAG_INHERIT, 0)) { if (!SetHandleInformation(stderr_read_handle, HANDLE_FLAG_INHERIT, 0)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to handle information for spawn, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to set handle information for spawn, errno=%s(%d)", strerror(errno), errno);
CloseHandle(stderr_write_handle); CloseHandle(stderr_write_handle);
CloseHandle(stderr_read_handle); CloseHandle(stderr_read_handle);
if (has_out) { if (has_out) {
@ -3253,7 +3257,7 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
err_f = _open_osfhandle((intptr_t)stderr_read_handle, O_RDONLY | O_BINARY); err_f = _open_osfhandle((intptr_t)stderr_read_handle, O_RDONLY | O_BINARY);
if (err_f == -1) { if (err_f == -1) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to open osfhandle for spawn, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to open osfhandle for spawn, errno=%s(%d)", strerror(errno), errno);
CloseHandle(stderr_write_handle); CloseHandle(stderr_write_handle);
CloseHandle(stderr_read_handle); CloseHandle(stderr_read_handle);
if (has_out) { if (has_out) {
@ -3268,7 +3272,7 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
HANDLE nul_handle = CreateFileW(L"NUL", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, OPEN_EXISTING, 0, NULL); HANDLE nul_handle = CreateFileW(L"NUL", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, OPEN_EXISTING, 0, NULL);
if (nul_handle == INVALID_HANDLE_VALUE) { if (nul_handle == INVALID_HANDLE_VALUE) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to open NUL for spawn, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to open NUL for spawn, errno=%s(%d)", strerror(errno), errno);
if (has_out) { if (has_out) {
CloseHandle(stdout_write_handle); CloseHandle(stdout_write_handle);
close(out_f); close(out_f);
@ -3298,7 +3302,7 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
} }
pos = argcat(cmd_buffer, COMMAND_LINE_MAX, pos, conv); pos = argcat(cmd_buffer, COMMAND_LINE_MAX, pos, conv);
if (pos < 0) { if (pos < 0) {
os_syslog(OS_LVL_INFO, "command to long for spawn"); os_syslog(OS_LVL_ERROR, "command too long for spawn");
CloseHandle(nul_handle); CloseHandle(nul_handle);
if (has_out) { if (has_out) {
CloseHandle(stdout_write_handle); CloseHandle(stdout_write_handle);
@ -3318,7 +3322,7 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
if (process_startup_init(&startup, nul_handle, if (process_startup_init(&startup, nul_handle,
has_out ? stdout_write_handle : nul_handle, has_out ? stdout_write_handle : nul_handle,
has_err ? stderr_write_handle : nul_handle) != 0) { has_err ? stderr_write_handle : nul_handle) != 0) {
os_syslog(OS_LVL_INFO, "failed to create handle list for spawn, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to create handle list for spawn, errno=%s(%d)", strerror(errno), errno);
CloseHandle(nul_handle); CloseHandle(nul_handle);
if (has_out) { if (has_out) {
CloseHandle(stdout_write_handle); CloseHandle(stdout_write_handle);
@ -3365,12 +3369,12 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
if (!ret) if (!ret)
create_error = GetLastError(); create_error = GetLastError();
} else { } else {
/* Drop to restricted service account */ /* drop to restricted service account */
HANDLE h_token = NULL; HANDLE h_token = NULL;
/* Validate that the requested user is actually a supported Service Account before attempting logon */ /* validate that the requested user is actually a supported Service Account before attempting logon */
if (_stricmp(run_as_user, "LocalService") != 0 && _stricmp(run_as_user, "NetworkService") != 0) { if (_stricmp(run_as_user, "LocalService") != 0 && _stricmp(run_as_user, "NetworkService") != 0) {
os_syslog(OS_LVL_INFO, "only supported users are LocalService and NetworkService"); os_syslog(OS_LVL_ERROR, "only supported users are LocalService and NetworkService");
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
process_startup_done(&startup); process_startup_done(&startup);
CloseHandle(nul_handle); CloseHandle(nul_handle);
@ -3388,7 +3392,7 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
const wchar_t* wuser = _stricmp(run_as_user, "LocalService") == 0 ? L"LocalService" : L"NetworkService"; const wchar_t* wuser = _stricmp(run_as_user, "LocalService") == 0 ? L"LocalService" : L"NetworkService";
if (!LogonUserW(wuser, L"NT AUTHORITY", NULL, LOGON32_LOGON_SERVICE, LOGON32_PROVIDER_DEFAULT, &h_token)) { if (!LogonUserW(wuser, L"NT AUTHORITY", NULL, LOGON32_LOGON_SERVICE, LOGON32_PROVIDER_DEFAULT, &h_token)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to logon user %s, errno=%s(%d)", run_as_user, strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to logon user %s, errno=%s(%d)", run_as_user, strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
process_startup_done(&startup); process_startup_done(&startup);
CloseHandle(nul_handle); CloseHandle(nul_handle);
@ -3403,11 +3407,11 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
return -1; return -1;
} }
/* Create an environment block to ensure PATH is loaded */ /* create an environment block to ensure PATH is loaded */
LPVOID env = NULL; LPVOID env = NULL;
if (!CreateEnvironmentBlock(&env, h_token, FALSE)) { if (!CreateEnvironmentBlock(&env, h_token, FALSE)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to get user %s environment, errno=%s(%d)", run_as_user, strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to get user %s environment, errno=%s(%d)", run_as_user, strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
CloseHandle(h_token); CloseHandle(h_token);
process_startup_done(&startup); process_startup_done(&startup);
@ -3443,7 +3447,7 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
process_startup_done(&startup); process_startup_done(&startup);
if (!ret) { if (!ret) {
windows_errno(create_error); windows_errno(create_error);
os_syslog(OS_LVL_INFO, "failed to create process '%s' for spawn, errno=%s(%d)", argv[0], strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to create process '%s' for spawn, errno=%s(%d)", argv[0], strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
CloseHandle(nul_handle); CloseHandle(nul_handle);
if (has_out) { if (has_out) {
@ -3467,7 +3471,7 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
if (os_job_handle != 0) { if (os_job_handle != 0) {
if (!AssignProcessToJobObject(os_job_handle, pi.hProcess)) { if (!AssignProcessToJobObject(os_job_handle, pi.hProcess)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to assign process to job object, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to assign process to job object, errno=%s(%d)", strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
TerminateProcess(pi.hProcess, 1); TerminateProcess(pi.hProcess, 1);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
@ -3487,7 +3491,7 @@ pid_t os_spawn(char** argv, int* stdout_read_int, int* stderr_read_int, const ch
/* resume the primary thread now that the process is assigned to the job object */ /* resume the primary thread now that the process is assigned to the job object */
if (ResumeThread(pi.hThread) == (DWORD)-1) { if (ResumeThread(pi.hThread) == (DWORD)-1) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to resume thread for spawn, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to resume thread for spawn, errno=%s(%d)", strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
TerminateProcess(pi.hProcess, 1); TerminateProcess(pi.hProcess, 1);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
@ -3692,14 +3696,14 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
/* create pipe for child's STDIN */ /* create pipe for child's STDIN */
if (!CreatePipe(&stdin_read_handle, &stdin_write_handle, &sa, 0)) { if (!CreatePipe(&stdin_read_handle, &stdin_write_handle, &sa, 0)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to create pipe for command, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to create pipe for command, errno=%s(%d)", strerror(errno), errno);
return -1; return -1;
} }
/* ensure the parent's write end is NOT inherited */ /* ensure the parent's write end is NOT inherited */
if (!SetHandleInformation(stdin_write_handle, HANDLE_FLAG_INHERIT, 0)) { if (!SetHandleInformation(stdin_write_handle, HANDLE_FLAG_INHERIT, 0)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to handle information for spawn, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to set handle information for command, errno=%s(%d)", strerror(errno), errno);
CloseHandle(stdin_read_handle); CloseHandle(stdin_read_handle);
CloseHandle(stdin_write_handle); CloseHandle(stdin_write_handle);
return -1; return -1;
@ -3716,7 +3720,7 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
NULL); NULL);
if (nul == INVALID_HANDLE_VALUE) { if (nul == INVALID_HANDLE_VALUE) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to create nul device, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to create nul device, errno=%s(%d)", strerror(errno), errno);
CloseHandle(stdin_read_handle); CloseHandle(stdin_read_handle);
CloseHandle(stdin_write_handle); CloseHandle(stdin_write_handle);
return -1; return -1;
@ -3724,7 +3728,7 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
ZeroMemory(&pi, sizeof(pi)); ZeroMemory(&pi, sizeof(pi));
if (process_startup_init(&startup, stdin_read_handle, nul, nul) != 0) { if (process_startup_init(&startup, stdin_read_handle, nul, nul) != 0) {
os_syslog(OS_LVL_INFO, "failed to create handle list for command, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to create handle list for command, errno=%s(%d)", strerror(errno), errno);
CloseHandle(stdin_read_handle); CloseHandle(stdin_read_handle);
CloseHandle(stdin_write_handle); CloseHandle(stdin_write_handle);
CloseHandle(nul); CloseHandle(nul);
@ -3773,7 +3777,7 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
* Service Account before attempting logon. * Service Account before attempting logon.
*/ */
if (_stricmp(run_as_user, "LocalService") != 0 && _stricmp(run_as_user, "NetworkService") != 0) { if (_stricmp(run_as_user, "LocalService") != 0 && _stricmp(run_as_user, "NetworkService") != 0) {
os_syslog(OS_LVL_INFO, "only supported users are LocalService and NetworkService"); os_syslog(OS_LVL_ERROR, "only supported users are LocalService and NetworkService");
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
process_startup_done(&startup); process_startup_done(&startup);
CloseHandle(stdin_read_handle); CloseHandle(stdin_read_handle);
@ -3785,7 +3789,7 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
const wchar_t* wuser = _stricmp(run_as_user, "LocalService") == 0 ? L"LocalService" : L"NetworkService"; const wchar_t* wuser = _stricmp(run_as_user, "LocalService") == 0 ? L"LocalService" : L"NetworkService";
if (!LogonUserW(wuser, L"NT AUTHORITY", NULL, LOGON32_LOGON_SERVICE, LOGON32_PROVIDER_DEFAULT, &h_token)) { if (!LogonUserW(wuser, L"NT AUTHORITY", NULL, LOGON32_LOGON_SERVICE, LOGON32_PROVIDER_DEFAULT, &h_token)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to logon user %s, errno=%s(%d)", run_as_user, strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to logon user %s, errno=%s(%d)", run_as_user, strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
process_startup_done(&startup); process_startup_done(&startup);
CloseHandle(stdin_read_handle); CloseHandle(stdin_read_handle);
@ -3800,7 +3804,7 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
LPVOID env = NULL; LPVOID env = NULL;
if (!CreateEnvironmentBlock(&env, h_token, FALSE)) { if (!CreateEnvironmentBlock(&env, h_token, FALSE)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to get user %s environment, errno=%s(%d)", run_as_user, strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to get user %s environment, errno=%s(%d)", run_as_user, strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
process_startup_done(&startup); process_startup_done(&startup);
CloseHandle(stdin_read_handle); CloseHandle(stdin_read_handle);
@ -3830,7 +3834,7 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
process_startup_done(&startup); process_startup_done(&startup);
if (!ret) { if (!ret) {
windows_errno(create_error); windows_errno(create_error);
os_syslog(OS_LVL_INFO, "failed to create process '%s' for command, errno=%s(%d)", command, strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to create process '%s' for command, errno=%s(%d)", command, strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
CloseHandle(stdin_read_handle); CloseHandle(stdin_read_handle);
CloseHandle(stdin_write_handle); CloseHandle(stdin_write_handle);
@ -3848,7 +3852,7 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
if (os_job_handle != 0) { if (os_job_handle != 0) {
if (!AssignProcessToJobObject(os_job_handle, pi.hProcess)) { if (!AssignProcessToJobObject(os_job_handle, pi.hProcess)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to assign command process to job object, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to assign command process to job object, errno=%s(%d)", strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
TerminateProcess(pi.hProcess, 1); TerminateProcess(pi.hProcess, 1);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
@ -3861,7 +3865,7 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
/* resume the primary thread now that the process is assigned to the job object */ /* resume the primary thread now that the process is assigned to the job object */
if (ResumeThread(pi.hThread) == (DWORD)-1) { if (ResumeThread(pi.hThread) == (DWORD)-1) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to resume thread for command, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to resume thread for command, errno=%s(%d)", strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
TerminateProcess(pi.hProcess, 1); TerminateProcess(pi.hProcess, 1);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
@ -3884,7 +3888,7 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
if (error == ERROR_BROKEN_PIPE || error == ERROR_NO_DATA) if (error == ERROR_BROKEN_PIPE || error == ERROR_NO_DATA)
break; /* child closed stdin early */ break; /* child closed stdin early */
windows_errno(error); windows_errno(error);
os_syslog(OS_LVL_INFO, "failed to write stdin to command %s, errno=%s(%d)", command, strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to write stdin to command %s, errno=%s(%d)", command, strerror(errno), errno);
break; break;
} }
written += count; written += count;
@ -3910,7 +3914,7 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
int64_t execution_time = stop - start; int64_t execution_time = stop - start;
if (timed_out) { if (timed_out) {
os_syslog(OS_LVL_INFO, "command %s timeout after %" PRId64 " seconds", command, execution_time); os_syslog(OS_LVL_ERROR, "command %s timeout after %" PRId64 " seconds", command, execution_time);
return -1; return -1;
} }
@ -3922,16 +3926,16 @@ int os_command(const char* command, const char* run_as_user, const char* stdin_t
if (exit_code == 0) if (exit_code == 0)
os_syslog(OS_LVL_INFO, "command %s terminated in %" PRId64 " seconds with success", command, execution_time); os_syslog(OS_LVL_INFO, "command %s terminated in %" PRId64 " seconds with success", command, execution_time);
else else
os_syslog(OS_LVL_INFO, "command %s terminated in %" PRId64 " seconds with exit code %d", command, execution_time, exit_code); os_syslog(OS_LVL_ERROR, "command %s terminated in %" PRId64 " seconds with exit code %d", command, execution_time, exit_code);
return exit_code; return exit_code;
} else if (WIFSIGNALED(status)) { } else if (WIFSIGNALED(status)) {
/* child died from a signal */ /* child died from a signal */
int sig = WTERMSIG(status); int sig = WTERMSIG(status);
os_syslog(OS_LVL_INFO, "command %s terminated in %" PRId64 " seconds with signal %s(%d)", command, execution_time, os_signal_name(sig), sig); os_syslog(OS_LVL_ERROR, "command %s terminated in %" PRId64 " seconds with signal %s(%d)", command, execution_time, os_signal_name(sig), sig);
return 128 + sig; return 128 + sig;
} else { } else {
/* in Windows it can happen */ /* in Windows it can happen */
os_syslog(OS_LVL_INFO, "command %s terminated in %" PRId64 " seconds for unknown reason, status=0x%08x", command, execution_time, (unsigned)status); os_syslog(OS_LVL_ERROR, "command %s terminated in %" PRId64 " seconds for unknown reason, status=0x%08x", command, execution_time, (unsigned)status);
return -1; return -1;
} }
} }
@ -4090,7 +4094,7 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
/* resolve the script path to prevent symlink attacks */ /* resolve the script path to prevent symlink attacks */
if (!realpath(script_path, resolved_path)) { if (!realpath(script_path, resolved_path)) {
os_syslog(OS_LVL_INFO, "failed to resolve script, path=%s, errno=%s(%d)", script_path, strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to resolve script, path=%s, errno=%s(%d)", script_path, strerror(errno), errno);
return -1; return -1;
} }
@ -4116,9 +4120,9 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
pos = scriptcat(cmd_buffer, COMMAND_LINE_MAX, pos, conv); pos = scriptcat(cmd_buffer, COMMAND_LINE_MAX, pos, conv);
if (pos < 0) { if (pos < 0) {
if (errno == EINVAL) if (errno == EINVAL)
os_syslog(OS_LVL_INFO, "unsupported embedded double quote in script path"); os_syslog(OS_LVL_ERROR, "unsupported embedded double quote in script path");
else else
os_syslog(OS_LVL_INFO, "command to long for script"); os_syslog(OS_LVL_ERROR, "command too long for script");
return -1; return -1;
} }
for (int i = 1; argv[i]; ++i) { for (int i = 1; argv[i]; ++i) {
@ -4127,15 +4131,15 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
pos = scriptcat(cmd_buffer, COMMAND_LINE_MAX, pos, conv); pos = scriptcat(cmd_buffer, COMMAND_LINE_MAX, pos, conv);
if (pos < 0) { if (pos < 0) {
if (errno == EINVAL) if (errno == EINVAL)
os_syslog(OS_LVL_INFO, "unsupported embedded double quote in script argument"); os_syslog(OS_LVL_ERROR, "unsupported embedded double quote in script argument");
else else
os_syslog(OS_LVL_INFO, "command to long for script"); os_syslog(OS_LVL_ERROR, "command too long for script");
return -1; return -1;
} }
} }
pos = fixcat(cmd_buffer, COMMAND_LINE_MAX, pos, L" \""); pos = fixcat(cmd_buffer, COMMAND_LINE_MAX, pos, L" \"");
if (pos < 0) { if (pos < 0) {
os_syslog(OS_LVL_INFO, "command to long for script"); os_syslog(OS_LVL_ERROR, "command too long for script");
return -1; return -1;
} }
cmd_buffer[pos] = 0; cmd_buffer[pos] = 0;
@ -4163,14 +4167,14 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
base_env = GetEnvironmentStringsW(); base_env = GetEnvironmentStringsW();
if (!base_env) { if (!base_env) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to get environment strings, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to get environment strings, errno=%s(%d)", strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
return -1; return -1;
} }
combined_env = env_combine(base_env, envp); combined_env = env_combine(base_env, envp);
FreeEnvironmentStringsW(base_env); FreeEnvironmentStringsW(base_env);
if (!combined_env) { if (!combined_env) {
os_syslog(OS_LVL_INFO, "failed to combine environment strings, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to combine environment strings, errno=%s(%d)", strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
return -1; return -1;
} }
@ -4201,7 +4205,7 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
* Service Account before attempting logon. * Service Account before attempting logon.
*/ */
if (_stricmp(run_as_user, "LocalService") != 0 && _stricmp(run_as_user, "NetworkService") != 0) { if (_stricmp(run_as_user, "LocalService") != 0 && _stricmp(run_as_user, "NetworkService") != 0) {
os_syslog(OS_LVL_INFO, "only supported users are LocalService and NetworkService"); os_syslog(OS_LVL_ERROR, "only supported users are LocalService and NetworkService");
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
return -1; return -1;
} }
@ -4209,7 +4213,7 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
const wchar_t* wuser = _stricmp(run_as_user, "LocalService") == 0 ? L"LocalService" : L"NetworkService"; const wchar_t* wuser = _stricmp(run_as_user, "LocalService") == 0 ? L"LocalService" : L"NetworkService";
if (!LogonUserW(wuser, L"NT AUTHORITY", NULL, LOGON32_LOGON_SERVICE, LOGON32_PROVIDER_DEFAULT, &h_token)) { if (!LogonUserW(wuser, L"NT AUTHORITY", NULL, LOGON32_LOGON_SERVICE, LOGON32_PROVIDER_DEFAULT, &h_token)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to logon user %s, errno=%s(%d)", run_as_user, strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to logon user %s, errno=%s(%d)", run_as_user, strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
return -1; return -1;
} }
@ -4220,7 +4224,7 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
LPVOID env = NULL; LPVOID env = NULL;
if (!CreateEnvironmentBlock(&env, h_token, FALSE)) { if (!CreateEnvironmentBlock(&env, h_token, FALSE)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to get user %s environment, errno=%s(%d)", run_as_user, strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to get user %s environment, errno=%s(%d)", run_as_user, strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
CloseHandle(h_token); CloseHandle(h_token);
return -1; return -1;
@ -4230,7 +4234,7 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
if (envp != NULL) { if (envp != NULL) {
combined_env = env_combine((const WCHAR*)env, envp); combined_env = env_combine((const WCHAR*)env, envp);
if (!combined_env) { if (!combined_env) {
os_syslog(OS_LVL_INFO, "failed to combine environment strings, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to combine environment strings, errno=%s(%d)", strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
DestroyEnvironmentBlock(env); DestroyEnvironmentBlock(env);
CloseHandle(h_token); CloseHandle(h_token);
@ -4257,7 +4261,7 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
} }
if (!ret) { if (!ret) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to create process '%s' for script, errno=%s(%d)", resolved_path, strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to create process '%s' for script, errno=%s(%d)", resolved_path, strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
return -1; return -1;
} }
@ -4266,7 +4270,7 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
if (os_job_handle != 0) { if (os_job_handle != 0) {
if (!AssignProcessToJobObject(os_job_handle, pi.hProcess)) { if (!AssignProcessToJobObject(os_job_handle, pi.hProcess)) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to assign script process to job object, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to assign script process to job object, errno=%s(%d)", strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
TerminateProcess(pi.hProcess, 1); TerminateProcess(pi.hProcess, 1);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
@ -4278,7 +4282,7 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
/* resume the primary thread now that the process is assigned to the job object */ /* resume the primary thread now that the process is assigned to the job object */
if (ResumeThread(pi.hThread) == (DWORD)-1) { if (ResumeThread(pi.hThread) == (DWORD)-1) {
windows_errno(GetLastError()); windows_errno(GetLastError());
os_syslog(OS_LVL_INFO, "failed to resume thread for script, errno=%s(%d)", strerror(errno), errno); os_syslog(OS_LVL_ERROR, "failed to resume thread for script, errno=%s(%d)", strerror(errno), errno);
pid_unpublish(pid_slot, 0); pid_unpublish(pid_slot, 0);
TerminateProcess(pi.hProcess, 1); TerminateProcess(pi.hProcess, 1);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
@ -4305,7 +4309,7 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
int64_t execution_time = stop - start; int64_t execution_time = stop - start;
if (timed_out) { if (timed_out) {
os_syslog(OS_LVL_INFO, "script %s timeout after %" PRId64 " seconds", resolved_path, execution_time); os_syslog(OS_LVL_ERROR, "script %s timeout after %" PRId64 " seconds", resolved_path, execution_time);
return -1; return -1;
} }
@ -4317,16 +4321,16 @@ int os_script(char** argv, char** envp, const char* run_as_user, uint64_t timeou
if (exit_code == 0) if (exit_code == 0)
os_syslog(OS_LVL_INFO, "script %s terminated in %" PRId64 " seconds with success", resolved_path, execution_time); os_syslog(OS_LVL_INFO, "script %s terminated in %" PRId64 " seconds with success", resolved_path, execution_time);
else else
os_syslog(OS_LVL_INFO, "script %s terminated in %" PRId64 " seconds with exit code %d", resolved_path, execution_time, exit_code); os_syslog(OS_LVL_ERROR, "script %s terminated in %" PRId64 " seconds with exit code %d", resolved_path, execution_time, exit_code);
return exit_code; return exit_code;
} else if (WIFSIGNALED(status)) { } else if (WIFSIGNALED(status)) {
/* child died from a signal */ /* child died from a signal */
int sig = WTERMSIG(status); int sig = WTERMSIG(status);
os_syslog(OS_LVL_INFO, "script %s terminated in %" PRId64 " seconds with signal %s(%d)", resolved_path, execution_time, os_signal_name(sig), sig); os_syslog(OS_LVL_ERROR, "script %s terminated in %" PRId64 " seconds with signal %s(%d)", resolved_path, execution_time, os_signal_name(sig), sig);
return 128 + sig; return 128 + sig;
} else { } else {
/* in Windows it can happen */ /* in Windows it can happen */
os_syslog(OS_LVL_INFO, "script %s terminated in %" PRId64 " seconds for unknown reason, status=0x%08x", resolved_path, execution_time, (unsigned)status); os_syslog(OS_LVL_ERROR, "script %s terminated in %" PRId64 " seconds for unknown reason, status=0x%08x", resolved_path, execution_time, (unsigned)status);
return -1; return -1;
} }
} }
@ -4381,7 +4385,7 @@ OS_FILE* os_popen(const char** argv)
fail_child: fail_child:
saved_errno = errno; saved_errno = errno;
close(stdout_fd); close(stdout_fd);
/* Terminate and reap the child immediately so no process or handle is leaked on stream creation failure. */ /* terminate and reap the child immediately so no process or handle is leaked on stream creation failure. */
pid_kill(pid); pid_kill(pid);
status = 0; status = 0;
os_wait(pid, &status, 0); os_wait(pid, &status, 0);
@ -4405,15 +4409,15 @@ int os_pclose(OS_FILE* stream)
int close_ret; int close_ret;
pid_t wait_ret; pid_t wait_ret;
/* Keep the owned resources locally so the OS_FILE container can be released immediately. */ /* keep the owned resources locally so the OS_FILE container can be released immediately. */
free(stream); free(stream);
/* Closing the stream also closes the CRT descriptor and the underlying stdout pipe handle. */ /* closing the stream also closes the CRT descriptor and the underlying stdout pipe handle. */
close_ret = fclose(fp); close_ret = fclose(fp);
if (close_ret != 0) if (close_ret != 0)
saved_errno = errno; saved_errno = errno;
/* Always reap the child even if closing the stream failed. */ /* always reap the child even if closing the stream failed. */
wait_ret = os_wait(pid, &status, 0); wait_ret = os_wait(pid, &status, 0);
if (wait_ret < 0 && saved_errno == 0) if (wait_ret < 0 && saved_errno == 0)
saved_errno = errno; saved_errno = errno;
@ -4495,6 +4499,24 @@ uint64_t os_tick_ms(void)
return GetTickCount64(); return GetTickCount64();
} }
uint64_t os_tick_us(void)
{
uint64_t ticks = os_tick();
uint64_t sec = ticks / tick_frequency;
uint64_t rem = ticks % tick_frequency;
return sec * 1000000ULL + (rem * 1000000ULL) / tick_frequency;
}
uint64_t os_tick_ns(void)
{
uint64_t ticks = os_tick();
uint64_t sec = ticks / tick_frequency;
uint64_t rem = ticks % tick_frequency;
return sec * 1000000000ULL + (rem * 1000000000ULL) / tick_frequency;
}
int os_usleep(uint64_t usec) int os_usleep(uint64_t usec)
{ {
while (usec > 0) { while (usec > 0) {
@ -4534,26 +4556,27 @@ void os_abort(void)
size_t size; size_t size;
unsigned i; unsigned i;
printf("Stacktrace of " PACKAGE " v" VERSION); fprintf(stderr, "Stacktrace of " PACKAGE " v" VERSION);
printf(", mingw"); fprintf(stderr, ", mingw");
#ifdef __GNUC__ #ifdef __GNUC__
printf(", gcc " __VERSION__); fprintf(stderr, ", gcc " __VERSION__);
#endif #endif
printf(", %d-bit", (int)sizeof(void*) * 8); fprintf(stderr, ", %d-bit", (int)sizeof(void*) * 8);
printf(", PATH_MAX=%d", PATH_MAX); fprintf(stderr, ", PATH_MAX=%d", PATH_MAX);
printf("\n"); fprintf(stderr, "\n");
/* get stackstrace, but without symbols */ /* get stackstrace, but without symbols */
size = CaptureStackBackTrace(0, 32, stack, NULL); size = CaptureStackBackTrace(0, 32, stack, 0);
for (i = 0; i < size; ++i) for (i = 0; i < size; ++i)
printf("[bt] %02u: %p\n", i, stack[i]); fprintf(stderr, "[bt] %02u: %p\n", i, stack[i]);
printf("Please report this error to the SnapRAID Issues:\n"); fprintf(stderr, "Please report this error to the SnapRAID Issues:\n");
printf("https://github.com/amadvance/snapraid/issues\n"); fprintf(stderr, "https://github.com/amadvance/snapraid/issues\n");
fflush(stderr);
/* use exit() and not abort to avoid the Windows abort dialog */ /* use exit(134) (128 + SIGABRT) and not abort to avoid the Windows abort dialog while distinguishing abort from normal failure */
os_exit(); exit(134);
} }
void os_exit(void) void os_exit(void)
@ -4605,6 +4628,13 @@ void os_init(unsigned opt)
os_exit(); os_exit();
} }
LARGE_INTEGER freq;
if (!QueryPerformanceFrequency(&freq) || freq.QuadPart <= 0) {
os_syslog(OS_LVL_CRITICAL, "error calling QueryPerformanceFrequency()");
os_exit();
}
tick_frequency = freq.QuadPart;
if (windows_mutex_init(&exec_mutex, 0) != 0) { if (windows_mutex_init(&exec_mutex, 0) != 0) {
os_syslog(OS_LVL_CRITICAL, "error calling windows_mutex_init()"); os_syslog(OS_LVL_CRITICAL, "error calling windows_mutex_init()");
os_exit(); os_exit();
@ -4631,21 +4661,33 @@ void os_init(unsigned opt)
os_exit(); os_exit();
} }
/* initialize job object to terminate child processes if daemon dies */ /*
os_job_handle = CreateJobObjectW(0, 0); * Skip creating a separate job object if already running inside one
if (os_job_handle != 0) { * (e.g. spawned by snapraid-daemon, a service, or Task Scheduler).
JOBOBJECT_EXTENDED_LIMIT_INFORMATION info; * Child processes automatically inherit the parent's job object, and
ZeroMemory(&info, sizeof(info)); * attempting to assign them to a second independent job object would
info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; * fail with ERROR_ACCESS_DENIED.
if (!SetInformationJobObject(os_job_handle, JobObjectExtendedLimitInformation, &info, sizeof(info))) { */
windows_errno(GetLastError()); BOOL in_job = 0;
os_syslog(OS_LVL_WARNING, "failed to configure job object, errno=%s(%d)", strerror(errno), errno); if (IsProcessInJob(GetCurrentProcess(), 0, &in_job) && in_job) {
CloseHandle(os_job_handle); os_job_handle = 0;
os_job_handle = 0;
}
} else { } else {
windows_errno(GetLastError()); /* initialize job object to terminate child processes if daemon dies */
os_syslog(OS_LVL_WARNING, "failed to create job object, errno=%s(%d)", strerror(errno), errno); os_job_handle = CreateJobObjectW(0, 0);
if (os_job_handle != 0) {
JOBOBJECT_EXTENDED_LIMIT_INFORMATION info;
ZeroMemory(&info, sizeof(info));
info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
if (!SetInformationJobObject(os_job_handle, JobObjectExtendedLimitInformation, &info, sizeof(info))) {
windows_errno(GetLastError());
os_syslog(OS_LVL_WARNING, "failed to configure job object, errno=%s(%d)", strerror(errno), errno);
CloseHandle(os_job_handle);
os_job_handle = 0;
}
} else {
windows_errno(GetLastError());
os_syslog(OS_LVL_WARNING, "failed to create job object, errno=%s(%d)", strerror(errno), errno);
}
} }
/* check for Wine presence */ /* check for Wine presence */
@ -4680,6 +4722,7 @@ void os_done(void)
windows_mutex_destroy(&exec_mutex); windows_mutex_destroy(&exec_mutex);
windows_mutex_destroy(&tick_lock); windows_mutex_destroy(&tick_lock);
tick_frequency = 0;
/* restore the normal execution level */ /* restore the normal execution level */
SetThreadExecutionState(WIN32_ES_CONTINUOUS); SetThreadExecutionState(WIN32_ES_CONTINUOUS);
@ -4688,3 +4731,4 @@ void os_done(void)
} }
#endif #endif

View file

@ -4,7 +4,7 @@
#ifndef __PORTABLE_MINGW_H #ifndef __PORTABLE_MINGW_H
#define __PORTABLE_MINGW_H #define __PORTABLE_MINGW_H
#ifdef __MINGW32__ /* Only for MingW */ #ifdef __MINGW32__ /* only for MingW */
#include <wchar.h> #include <wchar.h>
@ -98,7 +98,7 @@ wchar_t* u8tou16_mayfail(wchar_t* conv_buf, size_t number_of_wchar, const char*
#undef PATH_MAX #undef PATH_MAX
#define PATH_MAX 1024 #define PATH_MAX 1024
/* Remap functions and types */ /* remap functions and types */
#undef fopen #undef fopen
#define fopen windows_fopen #define fopen windows_fopen
#define FOPEN_TEXT "t" #define FOPEN_TEXT "t"
@ -167,11 +167,11 @@ wchar_t* u8tou16_mayfail(wchar_t* conv_buf, size_t number_of_wchar, const char*
#undef sleep #undef sleep
#define sleep windows_sleep #define sleep windows_sleep
/* 4==DIR, 5,6,7=free, 8==REG */ /* 4==DIR, 5,6,7=free, 8==REG */
#define S_IFLNK 0x5000 /* Symbolic link to file */ #define S_IFLNK 0x5000 /* symbolic link to file */
#define S_ISLNK(m) (((m) & _S_IFMT) == S_IFLNK) #define S_ISLNK(m) (((m) & _S_IFMT) == S_IFLNK)
#define S_IFLNKDIR 0x6000 /* Symbolic link to directory */ #define S_IFLNKDIR 0x6000 /* symbolic link to directory */
#define S_ISLNKDIR(m) (((m) & _S_IFMT) == S_IFLNKDIR) #define S_ISLNKDIR(m) (((m) & _S_IFMT) == S_IFLNKDIR)
#define S_IFJUN 0x7000 /* Junction */ #define S_IFJUN 0x7000 /* junction */
#define S_ISJUN(m) (((m) & _S_IFMT) == S_IFJUN) #define S_ISJUN(m) (((m) & _S_IFMT) == S_IFJUN)
#undef readlink #undef readlink
#define readlink windows_readlink #define readlink windows_readlink
@ -210,7 +210,7 @@ wchar_t* u8tou16_mayfail(wchar_t* conv_buf, size_t number_of_wchar, const char*
*/ */
#define STAT_NSEC_INVALID -1 #define STAT_NSEC_INVALID -1
/* We have nano second support */ /* we have nano second support */
#define STAT_NSEC(st) ((int)(st)->st_mtimensec) #define STAT_NSEC(st) ((int)(st)->st_mtimensec)
static inline int WEXITSTATUS(DWORD status) static inline int WEXITSTATUS(DWORD status)

12
os/os.h
View file

@ -397,6 +397,18 @@ uint64_t os_tick(void);
*/ */
uint64_t os_tick_ms(void); uint64_t os_tick_ms(void);
/**
* Get the os_tick counter value in microsecond.
* \return Monotonic clock value in microseconds.
*/
uint64_t os_tick_us(void);
/**
* Get the os_tick counter value in nanosecond.
* \return Monotonic clock value in nanoseconds.
*/
uint64_t os_tick_ns(void);
/** /**
* Get the os_tick counter value in seconds. * Get the os_tick counter value in seconds.
* \return Monotonic clock value in seconds. * \return Monotonic clock value in seconds.

View file

@ -5,11 +5,11 @@
#define __PORTABLE_H #define __PORTABLE_H
#if HAVE_CONFIG_H #if HAVE_CONFIG_H
#include "config.h" /* Use " to include first in the same directory of this file */ #include "config.h" /* use " to include first in the same directory of this file */
#endif #endif
/***************************************************************************/ /***************************************************************************/
/* Config */ /* config */
#ifdef __MINGW32__ #ifdef __MINGW32__
/** /**
@ -70,6 +70,22 @@
#define __noreturn __attribute__((noreturn)) #define __noreturn __attribute__((noreturn))
#endif #endif
#ifndef __aligned
#if defined(__GNUC__) || defined(__clang__)
#define __aligned(n) __attribute__((aligned(n)))
#else
#define __aligned(n)
#endif
#endif
#ifndef __aligned_loops
#if defined(__GNUC__) && !defined(__clang__)
#define __aligned_loops(n) __attribute__((optimize("align-loops=" #n)))
#else
#define __aligned_loops(n)
#endif
#endif
/** /**
* Architecture for inline assembly. * Architecture for inline assembly.
*/ */
@ -84,11 +100,22 @@
#define CONFIG_X86_64 1 #define CONFIG_X86_64 1
#endif #endif
#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) #if defined(__aarch64__)
#if defined(__ARM_NEON) || defined(__ARM_NEON__)
#define CONFIG_NEON 1
#endif
#if defined(__ARM_FEATURE_CRC32)
#define CONFIG_ARM_CRC 1 #define CONFIG_ARM_CRC 1
#endif #endif
#endif #endif
#if defined(__arm__)
#if defined(__ARM_NEON) || defined(__ARM_NEON__)
#define CONFIG_NEON32 1
#endif
#endif
#endif
/** /**
* Includes some platform specific headers. * Includes some platform specific headers.
*/ */
@ -132,12 +159,11 @@
#include <linux/fiemap.h> #include <linux/fiemap.h>
#endif #endif
/** /**
* Includes some standard headers. * Includes some standard headers.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> /* On many systems (e.g., Darwin), `stdio.h' is a prerequisite. */ #include <stdlib.h> /* on many systems (e.g., Darwin), `stdio.h' is a prerequisite. */
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
@ -174,10 +200,6 @@
#endif #endif
#endif #endif
#if HAVE_MACH_MACH_TIME_H
#include <mach/mach_time.h>
#endif
#if HAVE_DIRENT_H #if HAVE_DIRENT_H
#include <dirent.h> #include <dirent.h>
#endif #endif
@ -277,7 +299,7 @@
#include <linux/close_range.h> #include <linux/close_range.h>
#endif #endif
/* /**
* Flags for open() * Flags for open()
*/ */
#ifndef O_PATH #ifndef O_PATH

Some files were not shown because too many files have changed in this diff Show more