Don't skip parts of a file when calling fiemap
A mis-incremented offset in the fiemap-processing code meant that non-sparse portions of files were missed.
This commit is contained in:
@@ -140,8 +140,11 @@ void write_not_zeroes(struct client* client, uint64_t from, int len)
|
||||
* and memcpy being fast, rather than try to
|
||||
* hand-optimized something specific.
|
||||
*/
|
||||
if (zerobuffer[0] != 0 ||
|
||||
memcmp(zerobuffer, zerobuffer + 1, blockrun - 1)) {
|
||||
|
||||
int all_zeros = (zerobuffer[0] == 0) &&
|
||||
(0 == memcmp( zerobuffer, zerobuffer+1, blockrun-1 ));
|
||||
|
||||
if ( !all_zeros ) {
|
||||
memcpy(client->mapped+from, zerobuffer, blockrun);
|
||||
bitset_set_range(map, from, blockrun);
|
||||
server_dirty(client->serve, from, blockrun);
|
||||
|
||||
@@ -64,7 +64,7 @@ int build_allocation_map(struct bitset_mapping* allocation_map, int fd)
|
||||
struct fiemap_extent *last = &fiemap->fm_extents[
|
||||
fiemap->fm_mapped_extents-1
|
||||
];
|
||||
offset += last->fe_logical + last->fe_length;
|
||||
offset = last->fe_logical + last->fe_length;
|
||||
}
|
||||
else {
|
||||
offset += fiemap->fm_length;
|
||||
|
||||
Reference in New Issue
Block a user