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

Function WaitIO

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

* WaitIO -- Block until the IO_IN_PROGRESS flag on 'buf' is cleared. */

Source from the content-addressed store, hash-verified

4630 * WaitIO -- Block until the IO_IN_PROGRESS flag on 'buf' is cleared.
4631 */
4632static void
4633WaitIO(BufferDesc *buf)
4634{
4635 ConditionVariable *cv = BufferDescriptorGetIOCV(buf);
4636
4637 ConditionVariablePrepareToSleep(cv);
4638 for (;;)
4639 {
4640 uint32 buf_state;
4641
4642 /*
4643 * It may not be necessary to acquire the spinlock to check the flag
4644 * here, but since this test is essential for correctness, we'd better
4645 * play it safe.
4646 */
4647 buf_state = LockBufHdr(buf);
4648 UnlockBufHdr(buf, buf_state);
4649
4650 if (!(buf_state & BM_IO_IN_PROGRESS))
4651 break;
4652 ConditionVariableSleep(cv, WAIT_EVENT_BUFFER_IO);
4653 }
4654 ConditionVariableCancelSleep();
4655}
4656
4657/*
4658 * StartBufferIO: begin I/O on this buffer

Callers 2

InvalidateBufferFunction · 0.85
StartBufferIOFunction · 0.85

Calls 4

LockBufHdrFunction · 0.85
ConditionVariableSleepFunction · 0.85

Tested by

no test coverage detected