MCPcopy Create free account
hub / github.com/ceph/ceph / release

Method release

src/common/buffer.cc:459–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457 }
458
459 void buffer::ptr::release()
460 {
461 // BE CAREFUL: this is called also for hypercombined ptr_node. After
462 // freeing underlying raw, `*this` can become inaccessible as well!
463 //
464 // cache the pointer to avoid unncecessary reloads and repeated
465 // checks.
466 if (auto* const cached_raw = std::exchange(_raw, nullptr);
467 cached_raw) {
468 bdout << "ptr " << this << " release " << cached_raw << bendl;
469 // optimize the common case where a particular `buffer::raw` has
470 // only a single reference. Altogether with initializing `nref` of
471 // freshly fabricated one with `1` through the std::atomic's ctor
472 // (which doesn't impose a memory barrier on the strongly-ordered
473 // x86), this allows to avoid all atomical operations in such case.
474 const bool last_one = \
475 (1 == cached_raw->nref.load(std::memory_order_acquire));
476 if (likely(last_one) || --cached_raw->nref == 0) {
477 bdout << "deleting raw " << static_cast<void*>(cached_raw)
478 << " len " << cached_raw->get_len() << bendl;
479 ANNOTATE_HAPPENS_AFTER(&cached_raw->nref);
480 ANNOTATE_HAPPENS_BEFORE_FORGET_ALL(&cached_raw->nref);
481 delete cached_raw; // dealloc old (if any)
482 } else {
483 ANNOTATE_HAPPENS_BEFORE(&cached_raw->nref);
484 }
485 }
486 }
487
488 int buffer::ptr::get_mempool() const {
489 if (_raw) {

Callers 15

start_opMethod · 0.45
add_eventMethod · 0.45
ptrMethod · 0.45
rebuildMethod · 0.45
reserveMethod · 0.45
appendMethod · 0.45
buffer.ccFile · 0.45
append_holeMethod · 0.45
prepend_zeroMethod · 0.45
append_zero2Method · 0.45

Calls 2

loadMethod · 0.45
get_lenMethod · 0.45

Tested by

no test coverage detected