If GenericFileStoreBackend::do_fiemap returns anything other than 0, then
fiemap will not be allocated. However,
GenericFileStoreBackend::detect_features will free fiemap regardless,
triggering an assertion in tcmalloc. The attached patch will fix the bug
by only freeing fiemap when necessary.
In my case, do_fiemap returns -ENOSYS because fiemap is not implemented
on FreeBSD. However, this bug could also happen on Linux when do_fiemap
returns -ENOMEM.
Fixes: #6504
Signed-off-by: Alan Somers <asomers@gmail.com>
Reviewed-by: Sage Weil <sage@inktank.com>
if (r < 0)
goto done;
- if (fiemap->fm_mapped_extents == 0)
+ if (fiemap->fm_mapped_extents == 0) {
+ free(fiemap);
goto done;
+ }
struct fiemap_extent *extent = &fiemap->fm_extents[0];
i++;
extent++;
}
+ free(fiemap);
}
done:
}
dout(10) << "fiemap " << cid << "/" << oid << " " << offset << "~" << len << " = " << r << " num_extents=" << exomap.size() << " " << exomap << dendl;
- free(fiemap);
assert(!m_filestore_fail_eio || r != -EIO);
return r;
}
dout(0) << "detect_features: FIEMAP ioctl is supported and appears to work" << dendl;
ioctl_fiemap = true;
}
+ free(fiemap);
}
if (!m_filestore_fiemap) {
dout(0) << "detect_features: FIEMAP ioctl is disabled via 'filestore fiemap' config option" << dendl;
ioctl_fiemap = false;
}
- free(fiemap);
::unlink(fn);
TEMP_FAILURE_RETRY(::close(fd));