Skip to content

loop: Better discard for block devices

Evan Green linux-block lkml 8 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest2 patches 10 repliesIn review
  2. v62 patches 8 repliesSuperseded
  3. v52 patches 4 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v42 patches1 replySuperseded
v32 patches2 repliesSuperseded
v22 patches6 repliesSuperseded
v1 posting 2/22 patches2 repliesSuperseded
v1 posting 1/22 patches19 repliesSuperseded

Changes in v7 from the cover letter

- Use errno_to_blk_status() (Christoph)
- Rebase on top of Darrick's patch
- Tweak opening line of commit description (Darrick)

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2loop: Report EOPNOTSUPP properlydrivers/block/loop.c+5 -22 replies
2/2loop: Better discard support for block devicesdrivers/block/loop.c+29 -118 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchGwendal GrignouChaitanya KulkarniBart Van Assche
1/2R-b R-b
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v7 thread

Cover letter [PATCH v7 0/2] loop: Better discard for block devices

This series addresses some errors seen when using the loop device directly backed by a block device. The first change plumbs out the correct error message, and the second change prevents the error from occurring in many cases.

The errors look like this:

[   90.880875] print_req_error: I/O error, dev loop5, sector 0

The errors occur when trying to do a discard or write zeroes operation on a loop device backed by a block device that does not support write zeroes. Firstly, the error itself is incorrectly reported as I/O error, but is actually EOPNOTSUPP. The first patch plumbs out EOPNOTSUPP to properly report the error.

The second patch prevents these errors from occurring by mirroring the zeroing capabilities of the underlying block device into the loop device. Before this change, discard was always reported as being supported, and the loop device simply turns around and does an fallocate operation on the backing device. After this change, backing block devices that do support zeroing will continue to work as before, and continue to get all the benefits of doing that. Backing devices that do not support zeroing will fail earlier, avoiding hitting the loop device at all and ultimately avoiding this error in the logs.

I can also confirm that this fixes test block/003 in the blktests, when running blktests on a loop device backed by a block device.

Changes in v7:
- Use errno_to_blk_status() (Christoph)
- Rebase on top of Darrick's patch
- Tweak opening line of commit description (Darrick)

Changes in v6:
- Updated tags

Changes in v5:
- Don't mirror discard if lo_encrypt_key_size is non-zero (Gwendal)

Changes in v4:
- Mirror blkdev's write_zeroes into loopdev's discard_sectors.

Changes in v3:
- Updated tags
- Updated commit description

Changes in v2:
- Unnested error if statement (Bart)

Evan Green (2):
loop: Report EOPNOTSUPP properly
loop: Better discard support for block devices

 drivers/block/loop.c | 47 ++++++++++++++++++++++++++++++++------------
 1 file changed, 34 insertions(+), 13 deletions(-)
Signature · 1 line
2.21.0