[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] dd: Clarify sparse detection is by *output* block
From: |
Kevin Locke |
Subject: |
[PATCH] dd: Clarify sparse detection is by *output* block |
Date: |
Wed, 22 May 2019 21:07:50 -0600 |
The wording of the dd --help text suggests that output will be skipped
for sparse *input* blocks (i.e. that NUL-checking is done on input
blocks) while the code actually checks/skips all-NUL *output* blocks.[1]
Update the --help text to clarify this.
Also update tests/dd/sparse.sh to ensure this is the case and prevent
regressions (since this would be easy to overlook in future changes).
Motivation: Since NUL-checking is per-block, there is a tradeoff
between granularity of sparseness checking and I/O performance. It is
often desirable to have larger input blocks for better performance and
smaller output blocks for better sparseness checking.
[1]: https://superuser.com/a/1136358
---
src/dd.c | 2 +-
tests/dd/sparse.sh | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/dd.c b/src/dd.c
index 2888b8e33..ef0d07ac3 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -601,7 +601,7 @@ Each CONV symbol may be:\n\
unblock replace trailing spaces in cbs-size records with newline\n\
lcase change upper case to lower case\n\
ucase change lower case to upper case\n\
- sparse try to seek rather than write the output for NUL input blocks\n\
+ sparse try to seek rather than write all-NUL output blocks\n\
swab swap every pair of input bytes\n\
sync pad every input block with NULs to ibs-size; when used\n\
with block or unblock, pad with spaces rather than NULs\n\
diff --git a/tests/dd/sparse.sh b/tests/dd/sparse.sh
index b6ec7d78c..272e8d24a 100755
--- a/tests/dd/sparse.sh
+++ b/tests/dd/sparse.sh
@@ -60,9 +60,9 @@ kb_alloc() { du -k "$1"|cut -f1; }
# after its creation.
if test $(kb_alloc file.in) -gt 3000; then
- # Ensure NUL blocks smaller than the block size are not made sparse.
+ # Ensure NUL blocks smaller than the *output* block size are not made sparse.
# Here, with a 2MiB block size, dd's conv=sparse must *not* introduce a hole.
- dd if=file.in of=file.out bs=2M conv=sparse || fail=1
+ dd if=file.in of=file.out ibs=1M obs=2M conv=sparse || fail=1
# Intermittently BTRFS returns 0 allocation for file.out unless synced
sync file.out || framework_failure_
@@ -75,8 +75,8 @@ if test $(kb_alloc file.in) -gt 3000; then
rm -f file.out
truncate --size=3M file.out
- # Ensure that this 1MiB string of NULs *is* converted to a hole.
- dd if=file.in of=file.out bs=1M conv=sparse,notrunc
+ # Ensure that this 1MiB *output* block of NULs *is* converted to a hole.
+ dd if=file.in of=file.out ibs=2M obs=1M conv=sparse,notrunc
test $(kb_alloc file.out) -lt 2500 || fail=1
fi
--
2.20.1
- [PATCH] dd: Clarify sparse detection is by *output* block,
Kevin Locke <=