On Wed, Feb 06, 2013 at 01:31:40PM +0100, Benoît Canet wrote: > +/* Deduplicate all the cluster that can be deduplicated. > + * > + * Next it compute the number of non deduplicable sectors to come while > storing
s/compute/computes/ > + * the hashes of these sectors in a linked list for later usage. > + * Then it compute the first duplicated cluster hash that come after non s/compute/computes/ s/come/comes/ > + * deduplicable cluster, this hash will be used at next call of the function > + * > + * @ds: a structure containing the state of the deduplication > + * for this write request > + * @sector_num: The logical sector > + * @data: the buffer containing the data to deduplicate > + * @data_nr: the size of the buffer in sectors > + * > + */ > +int qcow2_dedup(BlockDriverState *bs, > + QCowDedupState *ds, > + uint64_t sector_num, > + uint8_t *data, > + int data_nr) > +{ > + BDRVQcowState *s = bs->opaque; > + int ret = 0; > + int deduped_clusters_nr = 0; > + int left_to_process; > + int begining_index; > + > + begining_index = sector_num & (s->cluster_sectors - 1); s/begining/beginning/ but start_index would be shorter. > + > + left_to_process = (data_nr / s->cluster_sectors) - > + ds->nb_clusters_processed; data_nr must be a multiple of cluster_sectors?