1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-18 05:45:45 +02:00

context: process PREALLOC extents synchronously in extent's Task worker

Inode-oriented scan workers must do all of their work sequentially,
so it's counterproductive to spawn a Task to do a background dedupe.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2021-11-16 01:00:30 -05:00
parent 84f91af503
commit d725f3c66c

View File

@ -332,14 +332,11 @@ BeesContext::scan_one_extent(const BeesFileRange &bfr, const Extent &e)
if (e.flags() & Extent::PREALLOC) { if (e.flags() & Extent::PREALLOC) {
// Prealloc is all zero and we replace it with a hole. // Prealloc is all zero and we replace it with a hole.
// No special handling is required here. Nuke it and move on. // No special handling is required here. Nuke it and move on.
Task(
"dedup_prealloc",
[m_ctx, bfr, e]() {
BEESLOGINFO("prealloc extent " << e); BEESLOGINFO("prealloc extent " << e);
// Must not extend past EOF // Must not extend past EOF
auto extent_size = min(e.end(), bfr.file_size()) - e.begin(); auto extent_size = min(e.end(), bfr.file_size()) - e.begin();
// Must hold tmpfile until dedupe is done // Must hold tmpfile until dedupe is done
auto tmpfile = m_ctx->tmpfile(); const auto tmpfile = m_ctx->tmpfile();
BeesFileRange prealloc_bfr(tmpfile->make_hole(extent_size)); BeesFileRange prealloc_bfr(tmpfile->make_hole(extent_size));
// Apparently they can both extend past EOF // Apparently they can both extend past EOF
BeesFileRange copy_bfr(bfr.fd(), e.begin(), e.begin() + extent_size); BeesFileRange copy_bfr(bfr.fd(), e.begin(), e.begin() + extent_size);
@ -348,14 +345,11 @@ BeesContext::scan_one_extent(const BeesFileRange &bfr, const Extent &e)
if (m_ctx->dedup(brp)) { if (m_ctx->dedup(brp)) {
BEESCOUNT(dedup_prealloc_hit); BEESCOUNT(dedup_prealloc_hit);
BEESCOUNTADD(dedup_prealloc_bytes, e.size()); BEESCOUNTADD(dedup_prealloc_bytes, e.size());
// return bfr; return bfr;
} else { } else {
BEESCOUNT(dedup_prealloc_miss); BEESCOUNT(dedup_prealloc_miss);
} }
} }
).run();
return bfr; // if dedupe success, which we now blindly assume
}
// OK we need to read extent now // OK we need to read extent now
bees_readahead(bfr.fd(), bfr.begin(), bfr.size()); bees_readahead(bfr.fd(), bfr.begin(), bfr.size());