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

Re: [Nbd] write_zeroes/trim on the whole disk



> On 24 Sep 2016, at 17:20, Vladimir Sementsov-Ogievskiy <vsementsov@...2723...9...> wrote:
> 
> Also, accordingly to documentation, NBD_CMD_TRIM is not appropriate for disk clearing:
> 
>  * `NBD_CMD_TRIM` (4)
> 
>      A hint to the server that the data defined by len and offset is no
>      longer needed. A server MAY discard len bytes starting at offset, but
>      is not required to.
> 
>      After issuing this command, a client MUST NOT make any assumptions
>      about the contents of the export affected by this command, until
>      overwriting it again with `NBD_CMD_WRITE`.
> 
> - it may do nothing.. So, what to do with this? add flag FORCE_TRIM for this command? Or add FORCE_HOLES flag to WRITE_ZEROES?

You cannot force a hole, because NBD the is not guaranteed to support holes.

Use NBD_CMD_WRITE_ZEROES without NBD_CMD_FLAG_NO_HOLE and you can pretty much assume that a server that supports holes will write holes. A server that does not support holes will write zeroes. If you don't care whether the resultant data is zero, just use NBD_CMD_TRIM. But as you do care (see above) you must be prepared for a 'thick' write of zeroes on servers that don't support it.

-- 
Alex Bligh







Reply to: