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:
parent
84f91af503
commit
d725f3c66c
@ -332,29 +332,23 @@ 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(
|
BEESLOGINFO("prealloc extent " << e);
|
||||||
"dedup_prealloc",
|
// Must not extend past EOF
|
||||||
[m_ctx, bfr, e]() {
|
auto extent_size = min(e.end(), bfr.file_size()) - e.begin();
|
||||||
BEESLOGINFO("prealloc extent " << e);
|
// Must hold tmpfile until dedupe is done
|
||||||
// Must not extend past EOF
|
const auto tmpfile = m_ctx->tmpfile();
|
||||||
auto extent_size = min(e.end(), bfr.file_size()) - e.begin();
|
BeesFileRange prealloc_bfr(tmpfile->make_hole(extent_size));
|
||||||
// Must hold tmpfile until dedupe is done
|
// Apparently they can both extend past EOF
|
||||||
auto tmpfile = m_ctx->tmpfile();
|
BeesFileRange copy_bfr(bfr.fd(), e.begin(), e.begin() + extent_size);
|
||||||
BeesFileRange prealloc_bfr(tmpfile->make_hole(extent_size));
|
BeesRangePair brp(prealloc_bfr, copy_bfr);
|
||||||
// Apparently they can both extend past EOF
|
// Raw dedupe here - nothing else to do with this extent, nothing to merge with
|
||||||
BeesFileRange copy_bfr(bfr.fd(), e.begin(), e.begin() + extent_size);
|
if (m_ctx->dedup(brp)) {
|
||||||
BeesRangePair brp(prealloc_bfr, copy_bfr);
|
BEESCOUNT(dedup_prealloc_hit);
|
||||||
// Raw dedupe here - nothing else to do with this extent, nothing to merge with
|
BEESCOUNTADD(dedup_prealloc_bytes, e.size());
|
||||||
if (m_ctx->dedup(brp)) {
|
return bfr;
|
||||||
BEESCOUNT(dedup_prealloc_hit);
|
} else {
|
||||||
BEESCOUNTADD(dedup_prealloc_bytes, e.size());
|
BEESCOUNT(dedup_prealloc_miss);
|
||||||
// return bfr;
|
}
|
||||||
} else {
|
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user