Fixed build_allocation_map in ioutil.c to correctly traverse fiemaps where
there are more than 1000 extents in a 100MB file chunk.
This commit is contained in:
21
src/ioutil.c
21
src/ioutil.c
@@ -27,7 +27,8 @@ int build_allocation_map(struct bitset_mapping* allocation_map, int fd)
|
|||||||
|
|
||||||
memset(&fiemap_static, 0, sizeof(fiemap_static));
|
memset(&fiemap_static, 0, sizeof(fiemap_static));
|
||||||
|
|
||||||
for (offset = 0; offset < allocation_map->size; offset += fiemap->fm_length) {
|
for (offset = 0; offset < allocation_map->size; ) {
|
||||||
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
fiemap->fm_start = offset;
|
fiemap->fm_start = offset;
|
||||||
@@ -41,7 +42,7 @@ int build_allocation_map(struct bitset_mapping* allocation_map, int fd)
|
|||||||
if (ioctl(fd, FS_IOC_FIEMAP, fiemap) < 0) {
|
if (ioctl(fd, FS_IOC_FIEMAP, fiemap) < 0) {
|
||||||
debug( "Couldn't get fiemap, returning no allocation_map" );
|
debug( "Couldn't get fiemap, returning no allocation_map" );
|
||||||
free(allocation_map);
|
free(allocation_map);
|
||||||
return NULL;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0;i<fiemap->fm_mapped_extents;i++) {
|
for (i=0;i<fiemap->fm_mapped_extents;i++) {
|
||||||
@@ -52,10 +53,24 @@ int build_allocation_map(struct bitset_mapping* allocation_map, int fd)
|
|||||||
);
|
);
|
||||||
//debug("range from %ld + %ld", fiemap->fm_extents[i].fe_logical, fiemap->fm_extents[i].fe_length);
|
//debug("range from %ld + %ld", fiemap->fm_extents[i].fe_logical, fiemap->fm_extents[i].fe_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* must move the offset on, but careful not to jump max_length
|
||||||
|
* if we've actually hit max_offsets.
|
||||||
|
*/
|
||||||
|
if (fiemap->fm_mapped_extents > 0) {
|
||||||
|
struct fiemap_extent *last = &fiemap->fm_extents[
|
||||||
|
fiemap->fm_mapped_extents-1
|
||||||
|
];
|
||||||
|
offset += last->fe_logical + last->fe_length;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
offset += fiemap->fm_length;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("Successfully built allocation map");
|
debug("Successfully built allocation map");
|
||||||
return allocation_map;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user