Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librbd: create fewer empty objects during copyup #12326

Merged
merged 4 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 33 additions & 23 deletions src/librbd/AioObjectRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ bool AioObjectRequest<I>::compute_parent_extents() {
lderr(m_ictx->cct) << this << " compute_parent_extents: failed to "
<< "retrieve parent overlap: " << cpp_strerror(r)
<< dendl;
m_has_parent = false;
m_parent_extents.clear();
return false;
}
Expand All @@ -122,6 +123,7 @@ bool AioObjectRequest<I>::compute_parent_extents() {
ldout(m_ictx->cct, 20) << this << " compute_parent_extents: "
<< "overlap " << parent_overlap << " "
<< "extents " << m_parent_extents << dendl;
m_has_parent = !m_parent_extents.empty();
return true;
}
return false;
Expand Down Expand Up @@ -357,7 +359,7 @@ void AbstractAioObjectWrite::guard_write()

bool AbstractAioObjectWrite::should_complete(int r)
{
ldout(m_ictx->cct, 20) << get_write_type() << " " << this << " " << m_oid
ldout(m_ictx->cct, 20) << get_op_type() << " " << this << " " << m_oid
<< " " << m_object_off << "~" << m_object_len
<< " should_complete: r = " << r << dendl;

Expand All @@ -369,7 +371,7 @@ bool AbstractAioObjectWrite::should_complete(int r)
return true;
}

send_write();
send_write_op();
finished = false;
break;

Expand All @@ -393,7 +395,7 @@ bool AbstractAioObjectWrite::should_complete(int r)
break;
}

finished = send_post();
finished = send_post_object_map_update();
break;

case LIBRBD_AIO_WRITE_COPYUP:
Expand All @@ -403,14 +405,14 @@ bool AbstractAioObjectWrite::should_complete(int r)
complete(r);
finished = false;
} else {
finished = send_post();
finished = send_post_object_map_update();
}
break;

case LIBRBD_AIO_WRITE_FLAT:
ldout(m_ictx->cct, 20) << "WRITE_FLAT" << dendl;

finished = send_post();
finished = send_post_object_map_update();
break;

case LIBRBD_AIO_WRITE_ERROR:
Expand All @@ -427,13 +429,9 @@ bool AbstractAioObjectWrite::should_complete(int r)
}

void AbstractAioObjectWrite::send() {
ldout(m_ictx->cct, 20) << "send " << get_write_type() << " " << this <<" "
ldout(m_ictx->cct, 20) << "send " << get_op_type() << " " << this <<" "
<< m_oid << " " << m_object_off << "~"
<< m_object_len << dendl;
send_pre();
}

void AbstractAioObjectWrite::send_pre() {
{
RWLock::RLocker snap_lock(m_ictx->snap_lock);
if (m_ictx->object_map == nullptr) {
Expand All @@ -442,12 +440,22 @@ void AbstractAioObjectWrite::send_pre() {
// should have been flushed prior to releasing lock
assert(m_ictx->exclusive_lock->is_lock_owner());
m_object_exist = m_ictx->object_map->object_may_exist(m_object_no);
}
}

send_write();
}

void AbstractAioObjectWrite::send_pre_object_map_update() {
ldout(m_ictx->cct, 20) << __func__ << dendl;

{
RWLock::RLocker snap_lock(m_ictx->snap_lock);
if (m_ictx->object_map != nullptr) {
uint8_t new_state;
pre_object_map_update(&new_state);

RWLock::WLocker object_map_locker(m_ictx->object_map_lock);
ldout(m_ictx->cct, 20) << "send_pre " << this << " " << m_oid << " "
ldout(m_ictx->cct, 20) << __func__ << this << " " << m_oid << " "
<< m_object_off << "~" << m_object_len
<< dendl;
m_state = LIBRBD_AIO_WRITE_PRE;
Expand All @@ -459,11 +467,10 @@ void AbstractAioObjectWrite::send_pre() {
}
}

// no object map update required
send_write();
send_write_op();
}

bool AbstractAioObjectWrite::send_post() {
bool AbstractAioObjectWrite::send_post_object_map_update() {
RWLock::RLocker snap_locker(m_ictx->snap_lock);
if (m_ictx->object_map == nullptr || !post_object_map_update()) {
return true;
Expand All @@ -473,7 +480,7 @@ bool AbstractAioObjectWrite::send_post() {
assert(m_ictx->exclusive_lock->is_lock_owner());

RWLock::WLocker object_map_locker(m_ictx->object_map_lock);
ldout(m_ictx->cct, 20) << "send_post " << this << " " << m_oid << " "
ldout(m_ictx->cct, 20) << __func__ << this << " " << m_oid << " "
<< m_object_off << "~" << m_object_len << dendl;
m_state = LIBRBD_AIO_WRITE_POST;

Expand All @@ -494,7 +501,7 @@ void AbstractAioObjectWrite::send_write() {
m_state = LIBRBD_AIO_WRITE_GUARD;
handle_write_guard();
} else {
send_write_op(true);
send_pre_object_map_update();
}
}

Expand Down Expand Up @@ -524,11 +531,13 @@ void AbstractAioObjectWrite::send_copyup()
m_ictx->copyup_list_lock.Unlock();
}
}
void AbstractAioObjectWrite::send_write_op(bool write_guard)
void AbstractAioObjectWrite::send_write_op()
{
m_state = LIBRBD_AIO_WRITE_FLAT;
if (write_guard)
if (m_guard) {
guard_write();
}

add_write_ops(&m_write);
assert(m_write.size() != 0);

Expand Down Expand Up @@ -580,10 +589,10 @@ void AioObjectWrite::send_write() {
<< " object exist " << m_object_exist
<< " write_full " << write_full << dendl;
if (write_full && !has_parent()) {
send_write_op(false);
} else {
AbstractAioObjectWrite::send_write();
m_guard = false;
}

AbstractAioObjectWrite::send_write();
}

void AioObjectRemove::guard_write() {
Expand All @@ -596,8 +605,9 @@ void AioObjectRemove::guard_write() {
void AioObjectRemove::send_write() {
ldout(m_ictx->cct, 20) << "send_write " << this << " " << m_oid << " "
<< m_object_off << "~" << m_object_len << dendl;
send_write_op(true);
send_pre_object_map_update();
}

void AioObjectTruncate::send_write() {
ldout(m_ictx->cct, 20) << "send_write " << this << " " << m_oid
<< " truncate " << m_object_off << dendl;
Expand Down
Loading