3 Replies Latest reply: Dec 18, 2017 2:02 AM by Pawel RSS

Blocks discarding and BLKDISCARDZEROES ioctl support

mushanov

Hi to all!

 

Does scini devices supports BLKDISCARDZEROES ioctl call (queue/discard_zeroes_data in sysfs), i.e. guarantees that discarded blocks read back as zeroes?

 

I'm using ScaleIO R2_0.13000.211 on CentOS 7.2.1511 with kernel 3.10.0-327.36.3, and blkdiscard syscall works as expected: discarded blocks shows as 'trimmed capacity' and was immediately read back as zeroes. But BLKDISCARDZEROES ioctl call returns zero, which actually incorrect.

  • 1. Re: Blocks discarding and BLKDISCARDZEROES ioctl support
    Pawel

    Hi,

     

    BLKDISCARDZEROES won't work properly with scini devices - they do not guarantee  the zeroing out of discarded regions (this fact is published in the sysfs queue entries of our scini devices).

     

    The reason for this lack of guarantee lies in the fact that any discard region that is not 1MB aligned in offset and size will be completed with “success” without any operation taking place (for example if you discard a single sector at some offset).

    So, let’s say you have data “A” in sector 0 of your volume and discard that single sector at offset 0 and then read that sector from offset 0, you will read data “A”.

     

    The exception is when your discard is aligned to 1MB: if the discard region is 1M aligned in offset and size then we guarantee it will be zeroed; otherwise not.

     

    Hope it helps!

    Cheers,

    Pawel

  • 2. Re: Blocks discarding and BLKDISCARDZEROES ioctl support
    mushanov

    Hi Pawel,

     

    Thanks for detailed description of the discard behavior, it's very helpful! I think that info should be added to ScaleIO user guide, because it's very important for virtualization tools that uses zero write optimizations.

     

    Also, I don't want to hardcode alignment value in my code. Can I rely on the sysfs 'queue/discard_granularity' or 'queue/discard_max_bytes' value for the discard alignment?

  • 3. Re: Blocks discarding and BLKDISCARDZEROES ioctl support
    Pawel

    Hi,

     

    Yes, the sysfs values can be trusted.

     

    Cheers,

    Pawel