From aa56ade7995b1e238265ae3a16f38a79ddbeffe6 Mon Sep 17 00:00:00 2001 From: Ning Yao Date: Thu, 13 Oct 2016 16:53:18 +0800 Subject: [PATCH] FileStore:: fix fiemap issue in xfs when #extents > 1364 Signed-off-by: Ning Yao (cherry picked from commit 1a1c126d80b427d5230347fbc71a4edea5c0b6c8) --- src/os/filestore/FileStore.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index ce1cfe262046c..9c4211cf63af3 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -3046,11 +3046,13 @@ int FileStore::read( int FileStore::_do_fiemap(int fd, uint64_t offset, size_t len, map *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; @@ -3090,9 +3092,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; }