Evidently ceph will report a 4M blocksize, which trips clonerange_f's
clumsy attempt to avoid reflinking an extent on top of itself. The
original code assumed that "pick a random destination up to 1MB past the
end of the file" would suffice, but that clearly won't with a 4M
blocksize. Instead, we'll change it to 1024*blksize.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Tested-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
off64_t lr;
off64_t off1;
off64_t off2;
+ off64_t max_off2;
size_t len;
int v1;
int v2;
* If srcfile == destfile, randomly generate destination ranges
* until we find one that doesn't overlap the source range.
*/
+ max_off2 = MIN(stat2.st_size + (1024ULL * stat2.st_blksize), MAXFSIZE);
do {
lr = ((int64_t)random() << 32) + random();
- off2 = (off64_t)(lr % MIN(stat2.st_size + (1024 * 1024), MAXFSIZE));
+ off2 = (off64_t)(lr % max_off2);
off2 %= maxfsize;
off2 &= ~(stat2.st_blksize - 1);
} while (stat1.st_ino == stat2.st_ino && llabs(off2 - off1) < len);