Skip to content

Commit

Permalink
buffer: Fix bufferlist::zero bug with special case
Browse files Browse the repository at this point in the history
Fixes: #12252
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
(cherry picked from commit 43f583d)
  • Loading branch information
yuyuyu101 authored and smithfarm committed Jul 28, 2015
1 parent abe6c03 commit 4443acd
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/common/buffer.cc
Expand Up @@ -1060,12 +1060,23 @@ static uint32_t simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZE
it != _buffers.end();
++it) {
if (p + it->length() > o) {
if (p >= o && p+it->length() <= o+l)
it->zero(); // all
else if (p >= o)
it->zero(0, o+l-p); // head
else
it->zero(o-p, it->length()-(o-p)); // tail
if (p >= o && p+it->length() <= o+l) {
// 'o'------------- l -----------|
// 'p'-- it->length() --|
it->zero();
} else if (p >= o) {
// 'o'------------- l -----------|
// 'p'------- it->length() -------|
it->zero(0, o+l-p);
} else if (p + it->length() <= o+l) {
// 'o'------------- l -----------|
// 'p'------- it->length() -------|
it->zero(o-p, it->length()-(o-p));
} else {
// 'o'----------- l -----------|
// 'p'---------- it->length() ----------|
it->zero(o-p, l);
}
}
p += it->length();
if (o+l <= p)
Expand Down

0 comments on commit 4443acd

Please sign in to comment.