Skip to content

Commit

Permalink
Merge pull request #54505 from adamemerson/wip-lazyfifo-no-mutex-over…
Browse files Browse the repository at this point in the history
…-coro

rgw/multisite: Fix deadlock by not holding mutex over coroutine

Reviewed-by: Casey Bodley <cbodley@redhat.com>
  • Loading branch information
cbodley committed Jan 4, 2024
2 parents d451898 + 8fa8443 commit 6787c4d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/rgw/driver/rados/rgw_log_backing.h
Expand Up @@ -262,12 +262,24 @@ class LazyFIFO {

int lazy_init(const DoutPrefixProvider *dpp, optional_yield y) {
std::unique_lock l(m);
if (fifo) return 0;
auto r = rgw::cls::fifo::FIFO::create(dpp, ioctx, oid, &fifo, y);
if (r) {
fifo.reset();
if (fifo) {
return 0;
} else {
l.unlock();
// FIFO supports multiple clients by design, so it's safe to
// race to create them.
std::unique_ptr<rgw::cls::fifo::FIFO> fifo_tmp;
auto r = rgw::cls::fifo::FIFO::create(dpp, ioctx, oid, &fifo, y);
if (r) {
return r;
}
l.lock();
if (!fifo) {
// We won the race
fifo = std::move(fifo_tmp);
}
}
return r;
return 0;
}

public:
Expand Down

0 comments on commit 6787c4d

Please sign in to comment.