MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / flushAll

Function flushAll

src/jrd/cch.cpp:2714–2765  ·  view source on GitHub ↗

Collect pages modified by garbage collector or all dirty pages or release page locks - depending of flush_flag, and write it to disk. See also comments in flushPages.

Source from the content-addressed store, hash-verified

2712// locks - depending of flush_flag, and write it to disk.
2713// See also comments in flushPages.
2714static void flushAll(thread_db* tdbb, USHORT flush_flag)
2715{
2716 SET_TDBB(tdbb);
2717 Database* dbb = tdbb->getDatabase();
2718 BufferControl* bcb = dbb->dbb_bcb;
2719 Firebird::HalfStaticArray<BufferDesc*, 1024> flush(bcb->bcb_dirty_count);
2720
2721 const bool all_flag = (flush_flag & FLUSH_ALL) != 0;
2722 const bool sweep_flag = (flush_flag & FLUSH_SWEEP) != 0;
2723 const bool release_flag = (flush_flag & FLUSH_RLSE) != 0;
2724 const bool write_thru = release_flag;
2725
2726 {
2727 Sync bcbSync(&bcb->bcb_syncObject, FB_FUNCTION);
2728 if (!bcb->bcb_syncObject.ourExclusiveLock())
2729 bcbSync.lock(SYNC_SHARED);
2730
2731 for (auto blk : bcb->bcb_bdbBlocks)
2732 {
2733 for (ULONG i = 0; i < blk.m_count; i++)
2734 {
2735 BufferDesc* bdb = &blk.m_bdbs[i];
2736
2737 if (bdb->bdb_flags & (BDB_db_dirty | BDB_dirty))
2738 {
2739 if (bdb->bdb_flags & BDB_dirty)
2740 flush.add(bdb);
2741 else if (bdb->bdb_flags & BDB_db_dirty)
2742 {
2743 // pages modified by sweep\garbage collector are not in dirty list
2744 const bool dirty_list = (bdb->bdb_dirty.que_forward != &bdb->bdb_dirty);
2745
2746 if (all_flag || (sweep_flag && !dirty_list))
2747 flush.add(bdb);
2748 }
2749 }
2750 else if (release_flag)
2751 {
2752 bdb->addRef(tdbb, SYNC_EXCLUSIVE);
2753
2754 if (bdb->bdb_use_count > 1)
2755 BUGCHECK(210); // msg 210 page in use during flush
2756
2757 PAGE_LOCK_RELEASE(tdbb, bcb, bdb->bdb_lock);
2758 bdb->release(tdbb, false);
2759 }
2760 }
2761 }
2762 }
2763
2764 flushPages(tdbb, flush_flag, flush.begin(), flush.getCount());
2765}
2766
2767
2768// Used in qsort below

Callers 1

CCH_flushFunction · 0.85

Calls 11

SET_TDBBFunction · 0.85
PAGE_LOCK_RELEASEFunction · 0.85
flushPagesFunction · 0.85
getDatabaseMethod · 0.80
ourExclusiveLockMethod · 0.45
lockMethod · 0.45
addMethod · 0.45
addRefMethod · 0.45
releaseMethod · 0.45
beginMethod · 0.45
getCountMethod · 0.45

Tested by

no test coverage detected