On 06.12.2016 22:26, Eric Blake wrote: > On 12/06/2016 03:01 PM, Max Reitz wrote: >> On 03.12.2016 19:19, Eric Blake wrote: >>> Passing a byte offset, but sector count, when we ultimately >>> want to operate on cluster granularity, is madness. Clean up >>> the interfaces to take byte offset and count. Rename >>> qcow2_discard_clusters() and qcow2_zero_clusters() to the >>> shorter qcow2_discard() and qcow2_zero() to make sure backports >>> don't get confused by changed units. >>> >>> Signed-off-by: Eric Blake <ebl...@redhat.com> >>> --- >>> >>> 2.9 material, depends on 'Don't strand clusters near 2G intervals >>> during commit' >>> > >>> @@ -1595,20 +1593,24 @@ static int zero_single_l2(BlockDriverState *bs, >>> uint64_t offset, >>> return nb_clusters; >>> } >>> >>> -int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int >>> nb_sectors, >>> - int flags) >>> +int qcow2_zero(BlockDriverState *bs, uint64_t offset, uint64_t count, >>> + int flags) >> >> Hmm, I personally liked qcow2_zero_clusters() better. qcow2_zero() >> doesn't really express that it means the verb "to zero". >> >> Also, while you are making a good point why the function should be >> renamed, qcow2_zero_clusters() was much more accurate because offset and >> count are expected to be cluster-aligned. >> >> The only alternative I can come up with would be "qcow2_write_zeroes"; >> that at least solves the first issue I have with this, but not the >> second one... > > Maybe qcow2_cluster_zeroize() and qcow2_cluster_discard()?
I think qcow2_discard() is fine (it works with any alignment (even though it will only discard whole clusters) and "discard" is mainly used as a verb, so at least I'm not confused there). I like qcow2_cluster_zeroize() if nothing else then for the "zeroize" alone. :-) Max > That gets the > benefit of the rename (to force all callers to use the right semantics), > while still being legible as an object-verb naming: the action > ('discard' or 'zeroize') is performed on 'qcow2 cluster' objects.
signature.asc
Description: OpenPGP digital signature