MCPcopy Create free account
hub / github.com/apache/cloudberry / LockBuffer

Function LockBuffer

src/backend/storage/buffer/bufmgr.c:4289–4308  ·  view source on GitHub ↗

* Acquire or release the content_lock for the buffer. */

Source from the content-addressed store, hash-verified

4287 * Acquire or release the content_lock for the buffer.
4288 */
4289void
4290LockBuffer(Buffer buffer, int mode)
4291{
4292 BufferDesc *buf;
4293
4294 Assert(BufferIsPinned(buffer));
4295 if (BufferIsLocal(buffer))
4296 return; /* local buffers need no lock */
4297
4298 buf = GetBufferDescriptor(buffer - 1);
4299
4300 if (mode == BUFFER_LOCK_UNLOCK)
4301 ReleaseContentLock(buf);
4302 else if (mode == BUFFER_LOCK_SHARE)
4303 AcquireContentLock(buf, LW_SHARED);
4304 else if (mode == BUFFER_LOCK_EXCLUSIVE)
4305 AcquireContentLock(buf, LW_EXCLUSIVE);
4306 else
4307 elog(ERROR, "unrecognized buffer lock mode: %d", mode);
4308}
4309
4310/*
4311 * Acquire the content_lock for the buffer, but only if we don't have to wait.

Callers 15

pg_visibilityFunction · 0.85
collect_visibility_dataFunction · 0.85
collect_corrupt_itemsFunction · 0.85
verify_heapamFunction · 0.85
bt_recheck_sibling_linksFunction · 0.85
palloc_btree_pageFunction · 0.85
bt_page_stats_internalFunction · 0.85
bt_page_items_internalFunction · 0.85
bt_metapFunction · 0.85
bm_metapFunction · 0.85
bm_lov_page_itemsFunction · 0.85
bm_bitmap_page_headerFunction · 0.85

Calls 2

ReleaseContentLockFunction · 0.85
AcquireContentLockFunction · 0.85

Tested by

no test coverage detected