• E
    qcow2: Discard/zero clusters by byte count · d2cb36af
    Eric Blake 提交于
    Passing a byte offset, but sector count, when we ultimately
    want to operate on cluster granularity, is madness.  Clean up
    the external interfaces to take both offset and count as bytes,
    while still keeping the assertion added previously that the
    caller must align the values to a cluster.  Then rename things
    to make sure backports don't get confused by changed units:
    instead of qcow2_discard_clusters() and qcow2_zero_clusters(),
    we now have qcow2_cluster_discard() and qcow2_cluster_zeroize().
    
    The internal functions still operate on clusters at a time, and
    return an int for number of cleared clusters; but on an image
    with 2M clusters, a single L2 table holds 256k entries that each
    represent a 2M cluster, totalling well over INT_MAX bytes if we
    ever had a request for that many bytes at once.  All our callers
    currently limit themselves to 32-bit bytes (and therefore fewer
    clusters), but by making this function 64-bit clean, we have one
    less place to clean up if we later improve the block layer to
    support 64-bit bytes through all operations (with the block layer
    auto-fragmenting on behalf of more-limited drivers), rather than
    the current state where some interfaces are artificially limited
    to INT_MAX at a time.
    Signed-off-by: NEric Blake <eblake@redhat.com>
    Reviewed-by: NMax Reitz <mreitz@redhat.com>
    Message-id: 20170507000552.20847-13-eblake@redhat.com
    Signed-off-by: NMax Reitz <mreitz@redhat.com>
    d2cb36af
qcow2-snapshot.c 21.4 KB