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. With Kevin's proposal, there is no reason to add a flag to bdi. (Sorry it took a few iterations to get it right). Paolo