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

os/bluestore/BlueFS: release completed aios #11268

Merged
merged 2 commits into from
Sep 30, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 27 additions & 7 deletions src/os/bluestore/BlueFS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1344,8 +1344,11 @@ int BlueFS::_flush_and_sync_log(std::unique_lock<std::mutex>& l,
}

// drop lock while we wait for io
list<FS::aio_t> completed_ios;
_claim_completed_aios(log_writer, &completed_ios);
l.unlock();
wait_for_aio(log_writer);
completed_ios.clear();
flush_bdev();
l.lock();

Expand Down Expand Up @@ -1541,15 +1544,28 @@ int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length)
for (unsigned i = 0; i < MAX_BDEV; ++i) {
if (bdev[i]) {
assert(h->iocv[i]);
if (h->iocv[i]->has_aios())
if (h->iocv[i]->has_aios()) {
bdev[i]->aio_submit(h->iocv[i]);
}
}
}
dout(20) << __func__ << " h " << h << " pos now 0x"
<< std::hex << h->pos << std::dec << dendl;
return 0;
}

// we need to retire old completed aios so they don't stick around in
// memory indefinitely (along with their bufferlist refs).
void BlueFS::_claim_completed_aios(FileWriter *h, list<FS::aio_t> *ls)
{
for (auto p : h->iocv) {
if (p) {
ls->splice(ls->end(), p->running_aios);
}
}
dout(10) << __func__ << " got " << ls->size() << " aios" << dendl;
}

void BlueFS::wait_for_aio(FileWriter *h)
{
// NOTE: this is safe to call without a lock, as long as our reference is
Expand Down Expand Up @@ -1635,8 +1651,11 @@ int BlueFS::_fsync(FileWriter *h, std::unique_lock<std::mutex>& l)
if (r < 0)
return r;
uint64_t old_dirty_seq = h->file->dirty_seq;
list<FS::aio_t> completed_ios;
_claim_completed_aios(h, &completed_ios);
lock.unlock();
wait_for_aio(h);
completed_ios.clear();
lock.lock();
if (old_dirty_seq) {
uint64_t s = log_seq;
Expand Down Expand Up @@ -1673,12 +1692,13 @@ int BlueFS::_allocate(uint8_t id, uint64_t len, vector<bluefs_extent_t> *ev)
}
if (r < 0) {
if (id != BDEV_SLOW) {
if (bdev[id])
derr << __func__ << " failed to allocate 0x" << std::hex << left
<< " on bdev " << (int)id
<< ", free 0x" << alloc[id]->get_free()
<< "; fallback to bdev " << (int)id + 1
<< std::dec << dendl;
if (bdev[id]) {
dout(1) << __func__ << " failed to allocate 0x" << std::hex << left
<< " on bdev " << (int)id
<< ", free 0x" << alloc[id]->get_free()
<< "; fallback to bdev " << (int)id + 1
<< std::dec << dendl;
}
return _allocate(id + 1, len, ev);
}
if (bdev[id])
Expand Down
4 changes: 3 additions & 1 deletion src/os/bluestore/BlueFS.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,11 @@ class BlueFS {
int _allocate(uint8_t bdev, uint64_t len, vector<bluefs_extent_t> *ev);
int _flush_range(FileWriter *h, uint64_t offset, uint64_t length);
int _flush(FileWriter *h, bool force);
void wait_for_aio(FileWriter *h); // safe to call without a lock
int _fsync(FileWriter *h, std::unique_lock<std::mutex>& l);

void _claim_completed_aios(FileWriter *h, list<FS::aio_t> *ls);
void wait_for_aio(FileWriter *h); // safe to call without a lock

int _flush_and_sync_log(std::unique_lock<std::mutex>& l,
uint64_t want_seq = 0,
uint64_t jump_to = 0);
Expand Down