| 1677 | |
| 1678 | |
| 1679 | void CCH_mark(thread_db* tdbb, WIN* window, bool mark_system, bool must_write) |
| 1680 | { |
| 1681 | /************************************** |
| 1682 | * |
| 1683 | * C C H _ m a r k |
| 1684 | * |
| 1685 | ************************************** |
| 1686 | * |
| 1687 | * Functional description |
| 1688 | * Mark a window as dirty. |
| 1689 | * |
| 1690 | **************************************/ |
| 1691 | BufferDesc* bdb = window->win_bdb; |
| 1692 | BLKCHK(bdb, type_bdb); |
| 1693 | |
| 1694 | SET_TDBB(tdbb); |
| 1695 | Database* dbb = tdbb->getDatabase(); |
| 1696 | tdbb->bumpStats(RuntimeStatistics::PAGE_MARKS); |
| 1697 | |
| 1698 | BufferControl* bcb = dbb->dbb_bcb; |
| 1699 | |
| 1700 | if (!(bdb->bdb_flags & BDB_writer)) |
| 1701 | BUGCHECK(208); // msg 208 page not accessed for write |
| 1702 | |
| 1703 | CCH_TRACE(("MARK %d:%06d", window->win_page.getPageSpaceID(), window->win_page.getPageNum())); |
| 1704 | |
| 1705 | // A LATCH_mark is needed before the BufferDesc can be marked. |
| 1706 | // This prevents a write while the page is being modified. |
| 1707 | |
| 1708 | if (!(bdb->bdb_flags & BDB_marked)) |
| 1709 | bdb->lockIO(tdbb); |
| 1710 | |
| 1711 | fb_assert(bdb->ourIOLock()); |
| 1712 | |
| 1713 | // Allocate difference page (if in stalled mode) before mark page as dirty. |
| 1714 | // It guarantees that disk space is allocated and page could be written later. |
| 1715 | |
| 1716 | if (!set_diff_page(tdbb, bdb)) |
| 1717 | { |
| 1718 | clear_dirty_flag_and_nbak_state(tdbb, bdb); |
| 1719 | |
| 1720 | bdb->unLockIO(tdbb); |
| 1721 | CCH_unwind(tdbb, true); |
| 1722 | } |
| 1723 | |
| 1724 | fb_assert(dbb->dbb_backup_manager->getState() != Ods::hdr_nbak_unknown); |
| 1725 | |
| 1726 | bdb->bdb_incarnation = ++bcb->bcb_page_incarnation; |
| 1727 | |
| 1728 | // mark the dirty bit vector for this specific transaction, |
| 1729 | // if it exists; otherwise mark that the system transaction |
| 1730 | // has updated this page |
| 1731 | |
| 1732 | int newFlags = 0; |
| 1733 | TraNumber number; |
| 1734 | jrd_tra* transaction = tdbb->getTransaction(); |
| 1735 | if (transaction && (number = transaction->tra_number)) |
| 1736 | { |
no test coverage detected