Pull request
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEE+ber27ys35W+dsvQfe+BBqr8OQ4FAl5yg0AACgkQfe+BBqr8 OQ7uWBAArnxhM0kej5NAQiGsC3sHDOGUszKhsz8qwSOYQ0NkOH9495ksklOuw8T9 v/7CAp4rqvma00nL5D+6Srjc9Pe+9BdIz3aa0xvi+tkXvRvFKcWoZlLyNpK+SCbB FwT5sAzoZ004cijG3xsV8U/1i/jEWiRk0AV8USuGymTkQh0M9XS/MHVlrv0HJU9k 2tLz7FGHBmEGhXFXKjviNsrQfvHl2AzIKIYnOcK6OhF6wevJzRz8ShsYcmhyN7V3 rBm0IDiJxJ54a6oZ8FyukkqL5gj+mZDEoGXnspvWkmixqjmNw0iAWgyWNk8vnBue ROphtzZ7xvATu560vIXnlj9q+new5h1ZEb2Q1Nl6WL0PFHJ0vEmRHnpSj+lUTHFD aEwLL72qk12yZFPwEO9V+tO15mE+9vYbbsfe8SXVIlH52ec+OHGQ3/ytulL2zEDz vVJYy37wOhp8f5TFpdmFXi8ovHV7a8g3Vr6Hh1XmcEW0o/GjEgunjW7V+JHSJlDe XBp5IXsz0+zWn2hCxtjUzX3qBDIswyR89qR/NRJKpuu1D5VSaqVwM3vd5dCgDLHA lnCCi8kcq9rsnRNyeBb0t8d7c6e1HSW8OIHL4OC515VUFdrKSEyxprzDyIMPifDg 9B9ImLXg3CgOQVOXPU/0mbh4beTIeI7uJrmgzvzs3vZc+dLG+H8= =xYlZ -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/jnsnow/tags/bitmaps-pull-request' into staging Pull request # gpg: Signature made Wed 18 Mar 2020 20:23:28 GMT # gpg: using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E # gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" [full] # Primary key fingerprint: FAEB 9711 A12C F475 812F 18F2 88A9 064D 1835 61EB # Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76 CBD0 7DEF 8106 AAFC 390E * remotes/jnsnow/tags/bitmaps-pull-request: block/qcow2-bitmap: use bdrv_dirty_bitmap_next_dirty nbd/server: use bdrv_dirty_bitmap_next_dirty_area nbd/server: introduce NBDExtentArray block/dirty-bitmap: improve _next_dirty_area API block/dirty-bitmap: add _next_dirty API block/dirty-bitmap: switch _next_dirty_area and _next_zero to int64_t hbitmap: drop meta bitmaps as they are unused hbitmap: unpublish hbitmap_iter_skip_words hbitmap: move hbitmap_iter_next_word to hbitmap.c hbitmap: assert that we don't create bitmap larger than INT64_MAX build: Silence clang warning on older glib autoptr usage Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
e6d567db23
8 changed files with 397 additions and 463 deletions
|
|
@ -105,10 +105,13 @@ for (bitmap = bdrv_dirty_bitmap_first(bs); bitmap; \
|
|||
bitmap = bdrv_dirty_bitmap_next(bitmap))
|
||||
|
||||
char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp);
|
||||
int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap *bitmap, uint64_t offset,
|
||||
uint64_t bytes);
|
||||
int64_t bdrv_dirty_bitmap_next_dirty(BdrvDirtyBitmap *bitmap, int64_t offset,
|
||||
int64_t bytes);
|
||||
int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap *bitmap, int64_t offset,
|
||||
int64_t bytes);
|
||||
bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap *bitmap,
|
||||
uint64_t *offset, uint64_t *bytes);
|
||||
int64_t start, int64_t end, int64_t max_dirty_count,
|
||||
int64_t *dirty_start, int64_t *dirty_count);
|
||||
BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap,
|
||||
Error **errp);
|
||||
|
||||
|
|
|
|||
|
|
@ -297,12 +297,18 @@ void hbitmap_free(HBitmap *hb);
|
|||
*/
|
||||
void hbitmap_iter_init(HBitmapIter *hbi, const HBitmap *hb, uint64_t first);
|
||||
|
||||
/* hbitmap_iter_skip_words:
|
||||
* @hbi: HBitmapIter to operate on.
|
||||
/*
|
||||
* hbitmap_next_dirty:
|
||||
*
|
||||
* Internal function used by hbitmap_iter_next and hbitmap_iter_next_word.
|
||||
* Find next dirty bit within selected range. If not found, return -1.
|
||||
*
|
||||
* @hb: The HBitmap to operate on
|
||||
* @start: The bit to start from.
|
||||
* @count: Number of bits to proceed. If @start+@count > bitmap size, the whole
|
||||
* bitmap is looked through. You can use INT64_MAX as @count to search up to
|
||||
* the bitmap end.
|
||||
*/
|
||||
unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi);
|
||||
int64_t hbitmap_next_dirty(const HBitmap *hb, int64_t start, int64_t count);
|
||||
|
||||
/* hbitmap_next_zero:
|
||||
*
|
||||
|
|
@ -311,47 +317,28 @@ unsigned long hbitmap_iter_skip_words(HBitmapIter *hbi);
|
|||
* @hb: The HBitmap to operate on
|
||||
* @start: The bit to start from.
|
||||
* @count: Number of bits to proceed. If @start+@count > bitmap size, the whole
|
||||
* bitmap is looked through. You can use UINT64_MAX as @count to search up to
|
||||
* bitmap is looked through. You can use INT64_MAX as @count to search up to
|
||||
* the bitmap end.
|
||||
*/
|
||||
int64_t hbitmap_next_zero(const HBitmap *hb, uint64_t start, uint64_t count);
|
||||
int64_t hbitmap_next_zero(const HBitmap *hb, int64_t start, int64_t count);
|
||||
|
||||
/* hbitmap_next_dirty_area:
|
||||
* @hb: The HBitmap to operate on
|
||||
* @start: in-out parameter.
|
||||
* in: the offset to start from
|
||||
* out: (if area found) start of found area
|
||||
* @count: in-out parameter.
|
||||
* in: length of requested region
|
||||
* out: length of found area
|
||||
* @start: the offset to start from
|
||||
* @end: end of requested area
|
||||
* @max_dirty_count: limit for out parameter dirty_count
|
||||
* @dirty_start: on success: start of found area
|
||||
* @dirty_count: on success: length of found area
|
||||
*
|
||||
* If dirty area found within [@start, @start + @count), returns true and sets
|
||||
* @offset and @bytes appropriately. Otherwise returns false and leaves @offset
|
||||
* and @bytes unchanged.
|
||||
* If dirty area found within [@start, @end), returns true and sets
|
||||
* @dirty_start and @dirty_count appropriately. @dirty_count will not exceed
|
||||
* @max_dirty_count.
|
||||
* If dirty area was not found, returns false and leaves @dirty_start and
|
||||
* @dirty_count unchanged.
|
||||
*/
|
||||
bool hbitmap_next_dirty_area(const HBitmap *hb, uint64_t *start,
|
||||
uint64_t *count);
|
||||
|
||||
/* hbitmap_create_meta:
|
||||
* Create a "meta" hbitmap to track dirtiness of the bits in this HBitmap.
|
||||
* The caller owns the created bitmap and must call hbitmap_free_meta(hb) to
|
||||
* free it.
|
||||
*
|
||||
* Currently, we only guarantee that if a bit in the hbitmap is changed it
|
||||
* will be reflected in the meta bitmap, but we do not yet guarantee the
|
||||
* opposite.
|
||||
*
|
||||
* @hb: The HBitmap to operate on.
|
||||
* @chunk_size: How many bits in @hb does one bit in the meta track.
|
||||
*/
|
||||
HBitmap *hbitmap_create_meta(HBitmap *hb, int chunk_size);
|
||||
|
||||
/* hbitmap_free_meta:
|
||||
* Free the meta bitmap of @hb.
|
||||
*
|
||||
* @hb: The HBitmap whose meta bitmap should be freed.
|
||||
*/
|
||||
void hbitmap_free_meta(HBitmap *hb);
|
||||
bool hbitmap_next_dirty_area(const HBitmap *hb, int64_t start, int64_t end,
|
||||
int64_t max_dirty_count,
|
||||
int64_t *dirty_start, int64_t *dirty_count);
|
||||
|
||||
/**
|
||||
* hbitmap_iter_next:
|
||||
|
|
@ -362,34 +349,4 @@ void hbitmap_free_meta(HBitmap *hb);
|
|||
*/
|
||||
int64_t hbitmap_iter_next(HBitmapIter *hbi);
|
||||
|
||||
/**
|
||||
* hbitmap_iter_next_word:
|
||||
* @hbi: HBitmapIter to operate on.
|
||||
* @p_cur: Location where to store the next non-zero word.
|
||||
*
|
||||
* Return the index of the next nonzero word that is set in @hbi's
|
||||
* associated HBitmap, and set *p_cur to the content of that word
|
||||
* (bits before the index that was passed to hbitmap_iter_init are
|
||||
* trimmed on the first call). Return -1, and set *p_cur to zero,
|
||||
* if all remaining words are zero.
|
||||
*/
|
||||
static inline size_t hbitmap_iter_next_word(HBitmapIter *hbi, unsigned long *p_cur)
|
||||
{
|
||||
unsigned long cur = hbi->cur[HBITMAP_LEVELS - 1];
|
||||
|
||||
if (cur == 0) {
|
||||
cur = hbitmap_iter_skip_words(hbi);
|
||||
if (cur == 0) {
|
||||
*p_cur = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* The next call will resume work from the next word. */
|
||||
hbi->cur[HBITMAP_LEVELS - 1] = 0;
|
||||
*p_cur = cur;
|
||||
return hbi->pos;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue