qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 4/4] qemu-img: conditionally discard target on c


From: ronnie sahlberg
Subject: Re: [Qemu-devel] [PATCH 4/4] qemu-img: conditionally discard target on convert
Date: Thu, 18 Jul 2013 06:55:43 -0700

On Thu, Jul 18, 2013 at 6:29 AM, Peter Lieven <address@hidden> wrote:
> On 18.07.2013 14:31, Paolo Bonzini wrote:
>>
>> Il 18/07/2013 13:04, Peter Lieven ha scritto:
>>>>
>>>> But if you set BDRV_DISCARD_WRITE_ZEROES, then you always need a
>>>> fallback to bdrv_write_zeroes.  Why not just call bdrv_write_zeroes to
>>>> begin with?  That's why extending bdrv_write_zeroes is preferable.
>>>
>>> In this case wo do not need a flag to the function at all. If the
>>> driver sets bdi->write_zeroes_w_discard = 1 then bdrv_write_zeroes
>>> can use bdrv_discard to write zeroes and the driver has to
>>> ensure that all is zero afterwards.
>>
>> Peter, you removed exactly the part of the email where I explained the
>> wrong part of your reasoning:
>>
>>     you cannot do that [discard in bdrv_write_zeroes] unconditionally.
>>     Some operations can use it, some cannot.  Think of SCSI disk
>>     emulation: it must not discard is WRITE SAME is sent without the
>>     UNMAP bit!
>>
>>> If the driver would have a better method of writing zeroes than
>>> discard it simply should not set bdi->write_zeroes_w_discard = 1.
>>
>> If the driver had a better method of writing zeroes than discard, it
>> simply should ignore the BDRV_MAY_UNMAP (or BDRV_MAY_DISCARD) flag in
>> its bdrv_write_zeros implementation.
>
> ok, but this would require an individual patch in every driver, wouldn't it.
> i am ok with that.
>
> the BDRV_MAY_DISCARD flag is at the end a hint if the driver can optimize
> writing zeroes by a discard or if real zeroes should be written e.g. to
> sanitize the device?
>
> talking for iscsi:
> bdrv->discard can remain to use UNMAP and silently fail if lbpu == 0.
> bdrv->write_zeroes will use writesame16 and set the unmap flag only if
> BDRV_MAY_DISCARD == 1 and BDRV_O_UNMAP == 1 and lbprz == 1.

When you use WRITESAME16 you can ignore the lbprz flag.
Just send a WRITESAME16 command with one block of data that is all set to zero.
If the unmap flag is set and if unmapped blocks read back the same as
the block you provided (all zero)
then it will unmap those blocks, where possible.
All other blocks that can not be unmapped, or where unmapped blocks
will not read back the same, will instead be overwritten by the
provided all-zero block.


> in case lbpws == 0 it will return -ENOSUP.
>
> Correct?
>
> Peter
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]