Skip to content

Commit

Permalink
FileStore:: fix fiemap issue in xfs when #extents > 1364
Browse files Browse the repository at this point in the history
Signed-off-by: Ning Yao <yaoning@unitedstack.com>
  • Loading branch information
Ning Yao committed Nov 3, 2016
1 parent c701628 commit 1a1c126
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/os/filestore/FileStore.cc
Expand Up @@ -3155,11 +3155,13 @@ int FileStore::read(
int FileStore::_do_fiemap(int fd, uint64_t offset, size_t len,
map<uint64_t, uint64_t> *m)
{
struct fiemap *fiemap = NULL;
uint64_t i;
struct fiemap_extent *extent = NULL;
struct fiemap_extent *last = NULL;
struct fiemap *fiemap = NULL;
int r = 0;

more:
r = backend->do_fiemap(fd, offset, len, &fiemap);
if (r < 0)
return r;
Expand Down Expand Up @@ -3199,9 +3201,15 @@ int FileStore::_do_fiemap(int fd, uint64_t offset, size_t len,
extent->fe_length = offset + len - extent->fe_logical;
(*m)[extent->fe_logical] = extent->fe_length;
i++;
extent++;
last = extent++;
}
free(fiemap);
if (!(last->fe_flags & FIEMAP_EXTENT_LAST)) {
uint64_t xoffset = last->fe_logical + last->fe_length - offset;
offset = last->fe_logical + last->fe_length;
len -= xoffset;
goto more;
}

return r;
}
Expand Down

0 comments on commit 1a1c126

Please sign in to comment.