cli/dd: Keep in-order output going after ignored errors #133

Merged
vitalif merged 1 commits from koolkhel/vitastor:dd-noerror-in-order into master 2026-11-20 19:33:14 +03:00
Contributor

Description

With conv=noerror, a failed read dropped its block and a failed write dropped its buffer. Output written in order (a pipe, oflag=append) then waited for that block forever, spinning the copy loop. The hang dates from 986cd117 (pipe output). It became reachable with oflag=append after 9684e1af.

  • A failed read from an image or a seekable input now gives a block of zeros, which is what a seekable output already got as a hole.
  • A stream has no block to skip, so its read error ends the copy with an error, also with conv=noerror.
  • In-order writes advance by the blocks taken, not by the bytes written, so an ignored write error does not stop them.
  • A write takes its block only once it has an io_uring sqe, so a full ring no longer drops the block.

Split out of #130 as asked; the two PRs don't depend on each other. They conflict only on one member declaration and on neighbouring test lines, so I'll rebase whichever goes second.

Tested: two new cases in tests/test_dd.sh:

  • conv=noerror oflag=append from /sys/class/net/lo/speed, whose read fails with EINVAL, gives a block of zeros. Without the fix, dd hangs.
  • conv=noerror from an unattached /dev/net/tun, whose read fails with EBADFD, ends the copy with an error and writes nothing. Without the fix, dd exits with 0.

Each case is skipped where its device is missing, or where it can be read. The whole test passes with the fix.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description With `conv=noerror`, a failed read dropped its block and a failed write dropped its buffer. Output written in order (a pipe, `oflag=append`) then waited for that block forever, spinning the copy loop. The hang dates from 986cd117 (pipe output). It became reachable with `oflag=append` after 9684e1af. - A failed read from an image or a seekable input now gives a block of zeros, which is what a seekable output already got as a hole. - A stream has no block to skip, so its read error ends the copy with an error, also with `conv=noerror`. - In-order writes advance by the blocks taken, not by the bytes written, so an ignored write error does not stop them. - A write takes its block only once it has an io_uring sqe, so a full ring no longer drops the block. Split out of #130 as asked; the two PRs don't depend on each other. They conflict only on one member declaration and on neighbouring test lines, so I'll rebase whichever goes second. Tested: two new cases in `tests/test_dd.sh`: - `conv=noerror oflag=append` from `/sys/class/net/lo/speed`, whose read fails with EINVAL, gives a block of zeros. Without the fix, dd hangs. - `conv=noerror` from an unattached `/dev/net/tun`, whose read fails with EBADFD, ends the copy with an error and writes nothing. Without the fix, dd exits with 0. Each case is skipped where its device is missing, or where it can be read. The whole test passes with the fix. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-19 22:32:35 +03:00
With conv=noerror a failed read dropped its block and a failed write
dropped its buffer. An output written in order (a pipe, oflag=append)
then waited for that block forever, spinning the copy loop.

A failed read from an image or a seekable input now gives a block of
zeros, which is what a seekable output already got as a hole. A stream
has no block to skip, so its read error ends the copy with an error,
also with conv=noerror. In-order writes advance by the blocks taken,
not by the bytes written, so an ignored write error does not stop them.
A write takes its block only once it has an io_uring sqe, so a full
ring no longer drops the block.
vitalif merged commit cf5c466e83 into master 2026-11-20 19:33:14 +03:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#133
No description provided.