On Fri, Dec 23, 2016 at 05:28:49PM +0300, Vladimir Sementsov-Ogievskiy wrote: > @@ -374,6 +379,101 @@ static bool coroutine_fn yield_and_check(BackupBlockJob > *job) > return false; > } > > +static void backup_skip_clusters(BackupBlockJob *job, > + int64_t start, int64_t end)
Missing coroutine_fn to document that this function must be called from coroutine context. > +{ > + CowRequest cow_request; > + > + wait_for_overlapping_requests(job, start, end); > + cow_request_begin(&cow_request, job, start, end); > + > + if (end * job->cluster_size > job->common.len) { > + int64_t n; > + end--; > + n = job->common.len - end * job->cluster_size; > + assert(n > 0); > + > + if (hbitmap_get(job->copy_bitmap, end)) { > + hbitmap_reset(job->copy_bitmap, end, 1); > + job->common.offset += n; > + } > + } > + > + for ( ; start < end; start++) { > + if (!hbitmap_get(job->copy_bitmap, start)) { > + continue; > + } > + > + hbitmap_reset(job->copy_bitmap, start, 1); > + job->common.offset += job->cluster_size; > + } > + > + cow_request_end(&cow_request); > +} > + > +static int backup_skip_unallocated_clusters(BackupBlockJob *job, > + BlockDriverState *base, > + int64_t start, int *n) Missing coroutine_fn. > +{ > + int ret; > + int64_t sectors_per_cluster = cluster_size_sectors(job); > + BlockDriverState *bs = blk_bs(job->common.blk); > + int64_t sector_end = job->common.len >> BDRV_SECTOR_BITS; > + int64_t sector = start * sectors_per_cluster; > + int max_sectors = MIN(max_query_sectors(job), sector_end - sector); > + int n_sectors = 0; > + > + ret = bdrv_is_allocated_above(bs, base, sector, max_sectors, &n_sectors); > + if (ret < 0) { > + return ret; > + } > + > + if (sector + n_sectors == sector_end || ret == 1) { > + *n = DIV_ROUND_UP(n_sectors, sectors_per_cluster); > + } else if (n_sectors < sectors_per_cluster) { > + *n = 1; > + ret = 1; > + } else { > + *n = n_sectors / sectors_per_cluster; > + } > + > + if (ret == 0) { > + backup_skip_clusters(job, start, start + *n); > + } > + > + return 0; > +} > + > +static void backup_skip_loop(BackupBlockJob *job, BlockDriverState *base) Missing coroutine_fn.
signature.asc
Description: PGP signature