Re: discarding an rbd device results in partial zero-filling without any errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My sense is that blkdiscard is intended for something different from what you’re intending.  From the man page:

DESCRIPTION
       blkdiscard is used to discard device sectors.
…
       -s, --secure
           Perform a secure discard. A secure discard is the same as a regular discard except that all copies of the discarded blocks that were possibly created by garbage collection must also be
           erased. This requires support from the device.

       -z, --zeroout
           Zero-fill rather than discard.

It’s about sending TRIM commands to the device telling it that SSD or thin-provisioned blocks may be reallocated. Zero-filling or erasing is a different operation.

If your intent is to free RADOS pool capacity,`blkdiscard` should do that, or if there’s a filesystem on the RBD device, mount it and run `fstrim`.  Was there a mounted filesystem when you ran the below?

If your intent is to erase data, any new clients getting discarded or freed blocks see them thin-provisioned, so any existing old data is not visible to them.


> On Jul 11, 2025, at 10:36 AM, Satoru Takeuchi <satoru.takeuchi@xxxxxxxxx> wrote:
> 
> Hi,
> 
> I tried to discard an RBD device by `blkdiscard -o 1K -l 64K
> <devpath>`. It filled zero from 1K to 4K and didn't
> touch other data. In addition, it didn't return any errors. IIUC, the
> expected behavior
> is "discarding specified region with no error" or "returning an error
> with any side effects".
> 
> I encountered this problem on linux 6.6.95-flatcar. Typically, flatcar
> kernels would be
> the same as the perspective of rbd driver. I'll reproduce this problem
> in the latest vanilla
> kernel if necessary.
> 
> This problem can be reproduced as follows.
> 
> ```
> # dd if=/dev/random of=/dev/rbd4 bs=1M count=1
> # strace blkdiscard -o 1K -l 64K /dev/rbd4
> ...
> munmap(0x7f12a09e9000, 262144)          = 0
> munmap(0x7f12a09a9000, 262144)          = 0
> ioctl(3, BLKDISCARD, [1024, 65536])     = 0
> close(3)                                = 0
> dup(1)                                  = 3
> ...
> # echo $?
> 0
> # od -Ad /dev/rbd4
> ...
> 0000992 113211 010561 012202 161732 151214 112507 137032 030556
> 0001008 000566 120371 003710 133162 125036 000063 100157 032223
> 0001024 000000 000000 000000 000000 000000 000000 000000 000000
> *
> 0004096 123624 045340 045305 146214 137637 031304 136205 041435
> 0004112 121425 157166 013424 107157 121636 056600 054077 145651
> ...
> ```
> 
> Here are the results with tweaking `-o` parameters.
> 
> - `-o 0K`: zero-filling from 0 to 64K
> - `-o 2K`: zero-filling from 2K to 4K
> - `-o 3K`: zero-filling from 3K to 4K
> - `-o 4K`: do noting
> - `-o 5K`: zero-filling from 5K to 8K
> - `-o 6K`: zero-filling from 6K to 8K
> - `-o 7K`: zero-filling from 7K to 8K
> - `-o 8K`: do noting
> 
> Although I checked all commits touching driver/block/rbd.c after v6.9,
> I couldn't find any suspects.
> 
> Thanks,
> Satoru
> 






[Index of Archives]     [CEPH Users]     [Ceph Large]     [Ceph Dev]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux