Commit fef0c834 authored by Neil Conway's avatar Neil Conway

I posted some bufmgr cleanup a few weeks ago, but it conflicted with

some concurrent changes Jan was making to the bufmgr. Here's an
updated version of the patch -- it should apply cleanly to CVS
HEAD and passes the regression tests.

This patch makes the following changes:

     - remove the UnlockAndReleaseBuffer() and UnlockAndWriteBuffer()
       macros, and replace uses of them with calls to the appropriate
       functions.

     - remove a bunch of #ifdef BMTRACE code: it is ugly & broken
       (i.e. it doesn't compile)

     - make BufferReplace() return a bool, not an int

     - cleanup some logic in bufmgr.c; should be functionality
       equivalent to the previous code, just cleaner now

     - remove the BM_PRIVATE flag as it is unused

     - improve a few comments, etc.
parent 81e94551
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.158 2003/11/29 19:51:40 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.159 2003/12/14 00:34:47 neilc Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -2110,7 +2110,8 @@ heap_xlog_clean(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -2110,7 +2110,8 @@ heap_xlog_clean(bool redo, XLogRecPtr lsn, XLogRecord *record)
if (XLByteLE(lsn, PageGetLSN(page))) if (XLByteLE(lsn, PageGetLSN(page)))
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return; return;
} }
...@@ -2135,7 +2136,8 @@ heap_xlog_clean(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -2135,7 +2136,8 @@ heap_xlog_clean(bool redo, XLogRecPtr lsn, XLogRecord *record)
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); /* prev sui */ PageSetSUI(page, ThisStartUpID); /* prev sui */
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
static void static void
...@@ -2170,7 +2172,8 @@ heap_xlog_delete(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -2170,7 +2172,8 @@ heap_xlog_delete(bool redo, XLogRecPtr lsn, XLogRecord *record)
{ {
if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return; return;
} }
} }
...@@ -2199,7 +2202,8 @@ heap_xlog_delete(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -2199,7 +2202,8 @@ heap_xlog_delete(bool redo, XLogRecPtr lsn, XLogRecord *record)
htup->t_ctid = xlrec->target.tid; htup->t_ctid = xlrec->target.tid;
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
return; return;
} }
...@@ -2249,7 +2253,8 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -2249,7 +2253,8 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record)
if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return; return;
} }
...@@ -2282,7 +2287,8 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -2282,7 +2287,8 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record)
elog(PANIC, "heap_insert_redo: failed to add tuple"); elog(PANIC, "heap_insert_redo: failed to add tuple");
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); /* prev sui */ PageSetSUI(page, ThisStartUpID); /* prev sui */
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
return; return;
} }
...@@ -2332,7 +2338,8 @@ heap_xlog_update(bool redo, XLogRecPtr lsn, XLogRecord *record, bool move) ...@@ -2332,7 +2338,8 @@ heap_xlog_update(bool redo, XLogRecPtr lsn, XLogRecord *record, bool move)
{ {
if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
if (samepage) if (samepage)
return; return;
goto newt; goto newt;
...@@ -2378,7 +2385,8 @@ heap_xlog_update(bool redo, XLogRecPtr lsn, XLogRecord *record, bool move) ...@@ -2378,7 +2385,8 @@ heap_xlog_update(bool redo, XLogRecPtr lsn, XLogRecord *record, bool move)
goto newsame; goto newsame;
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
goto newt; goto newt;
} }
...@@ -2421,7 +2429,8 @@ newsame:; ...@@ -2421,7 +2429,8 @@ newsame:;
if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */ if (XLByteLE(lsn, PageGetLSN(page))) /* changes are applied */
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return; return;
} }
...@@ -2474,7 +2483,8 @@ newsame:; ...@@ -2474,7 +2483,8 @@ newsame:;
elog(PANIC, "heap_update_redo: failed to add tuple"); elog(PANIC, "heap_update_redo: failed to add tuple");
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); /* prev sui */ PageSetSUI(page, ThisStartUpID); /* prev sui */
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
return; return;
} }
...@@ -2523,7 +2533,8 @@ _heap_unlock_tuple(void *data) ...@@ -2523,7 +2533,8 @@ _heap_unlock_tuple(void *data)
elog(PANIC, "_heap_unlock_tuple: invalid xmax in rollback"); elog(PANIC, "_heap_unlock_tuple: invalid xmax in rollback");
htup->t_infomask &= ~HEAP_XMAX_UNLOGGED; htup->t_infomask &= ~HEAP_XMAX_UNLOGGED;
htup->t_infomask |= HEAP_XMAX_INVALID; htup->t_infomask |= HEAP_XMAX_INVALID;
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
return; return;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.8 2003/11/29 19:51:40 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtxlog.c,v 1.9 2003/12/14 00:34:47 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -69,7 +69,8 @@ forget_matching_split(Relation reln, RelFileNode node, ...@@ -69,7 +69,8 @@ forget_matching_split(Relation reln, RelFileNode node,
btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offnum)); btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offnum));
rightblk = ItemPointerGetBlockNumber(&(btitem->bti_itup.t_tid)); rightblk = ItemPointerGetBlockNumber(&(btitem->bti_itup.t_tid));
Assert(ItemPointerGetOffsetNumber(&(btitem->bti_itup.t_tid)) == P_HIKEY); Assert(ItemPointerGetOffsetNumber(&(btitem->bti_itup.t_tid)) == P_HIKEY);
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
foreach(l, incomplete_splits) foreach(l, incomplete_splits)
{ {
...@@ -137,7 +138,8 @@ _bt_restore_meta(Relation reln, XLogRecPtr lsn, ...@@ -137,7 +138,8 @@ _bt_restore_meta(Relation reln, XLogRecPtr lsn,
PageSetLSN(metapg, lsn); PageSetLSN(metapg, lsn);
PageSetSUI(metapg, ThisStartUpID); PageSetSUI(metapg, ThisStartUpID);
UnlockAndWriteBuffer(metabuf); LockBuffer(metabuf, BUFFER_LOCK_UNLOCK);
WriteBuffer(metabuf);
} }
static void static void
...@@ -184,7 +186,10 @@ btree_xlog_insert(bool redo, bool isleaf, bool ismeta, ...@@ -184,7 +186,10 @@ btree_xlog_insert(bool redo, bool isleaf, bool ismeta,
if (redo) if (redo)
{ {
if (XLByteLE(lsn, PageGetLSN(page))) if (XLByteLE(lsn, PageGetLSN(page)))
UnlockAndReleaseBuffer(buffer); {
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
}
else else
{ {
if (PageAddItem(page, (Item) datapos, datalen, if (PageAddItem(page, (Item) datapos, datalen,
...@@ -194,7 +199,8 @@ btree_xlog_insert(bool redo, bool isleaf, bool ismeta, ...@@ -194,7 +199,8 @@ btree_xlog_insert(bool redo, bool isleaf, bool ismeta,
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
} }
else else
...@@ -203,7 +209,10 @@ btree_xlog_insert(bool redo, bool isleaf, bool ismeta, ...@@ -203,7 +209,10 @@ btree_xlog_insert(bool redo, bool isleaf, bool ismeta,
elog(PANIC, "btree_insert_undo: bad page LSN"); elog(PANIC, "btree_insert_undo: bad page LSN");
if (!P_ISLEAF(pageop)) if (!P_ISLEAF(pageop))
UnlockAndReleaseBuffer(buffer); {
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
}
else else
elog(PANIC, "btree_insert_undo: unimplemented"); elog(PANIC, "btree_insert_undo: unimplemented");
} }
...@@ -275,7 +284,8 @@ btree_xlog_split(bool redo, bool onleft, bool isroot, ...@@ -275,7 +284,8 @@ btree_xlog_split(bool redo, bool onleft, bool isroot,
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
else else
{ {
...@@ -310,7 +320,8 @@ btree_xlog_split(bool redo, bool onleft, bool isroot, ...@@ -310,7 +320,8 @@ btree_xlog_split(bool redo, bool onleft, bool isroot,
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
else else
{ {
...@@ -334,7 +345,10 @@ btree_xlog_split(bool redo, bool onleft, bool isroot, ...@@ -334,7 +345,10 @@ btree_xlog_split(bool redo, bool onleft, bool isroot,
elog(PANIC, "btree_split_redo: uninitialized next right page"); elog(PANIC, "btree_split_redo: uninitialized next right page");
if (XLByteLE(lsn, PageGetLSN(page))) if (XLByteLE(lsn, PageGetLSN(page)))
UnlockAndReleaseBuffer(buffer); {
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
}
else else
{ {
pageop = (BTPageOpaque) PageGetSpecialPointer(page); pageop = (BTPageOpaque) PageGetSpecialPointer(page);
...@@ -342,7 +356,8 @@ btree_xlog_split(bool redo, bool onleft, bool isroot, ...@@ -342,7 +356,8 @@ btree_xlog_split(bool redo, bool onleft, bool isroot,
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
} }
} }
...@@ -385,7 +400,8 @@ btree_xlog_delete(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -385,7 +400,8 @@ btree_xlog_delete(bool redo, XLogRecPtr lsn, XLogRecord *record)
if (XLByteLE(lsn, PageGetLSN(page))) if (XLByteLE(lsn, PageGetLSN(page)))
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return; return;
} }
...@@ -407,7 +423,8 @@ btree_xlog_delete(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -407,7 +423,8 @@ btree_xlog_delete(bool redo, XLogRecPtr lsn, XLogRecord *record)
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
static void static void
...@@ -445,7 +462,10 @@ btree_xlog_delete_page(bool redo, bool ismeta, ...@@ -445,7 +462,10 @@ btree_xlog_delete_page(bool redo, bool ismeta,
if (PageIsNew((PageHeader) page)) if (PageIsNew((PageHeader) page))
elog(PANIC, "btree_delete_page_redo: uninitialized parent page"); elog(PANIC, "btree_delete_page_redo: uninitialized parent page");
if (XLByteLE(lsn, PageGetLSN(page))) if (XLByteLE(lsn, PageGetLSN(page)))
UnlockAndReleaseBuffer(buffer); {
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
}
else else
{ {
OffsetNumber poffset; OffsetNumber poffset;
...@@ -472,7 +492,8 @@ btree_xlog_delete_page(bool redo, bool ismeta, ...@@ -472,7 +492,8 @@ btree_xlog_delete_page(bool redo, bool ismeta,
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
} }
...@@ -486,7 +507,10 @@ btree_xlog_delete_page(bool redo, bool ismeta, ...@@ -486,7 +507,10 @@ btree_xlog_delete_page(bool redo, bool ismeta,
if (PageIsNew((PageHeader) page)) if (PageIsNew((PageHeader) page))
elog(PANIC, "btree_delete_page_redo: uninitialized right sibling"); elog(PANIC, "btree_delete_page_redo: uninitialized right sibling");
if (XLByteLE(lsn, PageGetLSN(page))) if (XLByteLE(lsn, PageGetLSN(page)))
UnlockAndReleaseBuffer(buffer); {
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
}
else else
{ {
pageop = (BTPageOpaque) PageGetSpecialPointer(page); pageop = (BTPageOpaque) PageGetSpecialPointer(page);
...@@ -494,7 +518,8 @@ btree_xlog_delete_page(bool redo, bool ismeta, ...@@ -494,7 +518,8 @@ btree_xlog_delete_page(bool redo, bool ismeta,
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
} }
...@@ -510,7 +535,10 @@ btree_xlog_delete_page(bool redo, bool ismeta, ...@@ -510,7 +535,10 @@ btree_xlog_delete_page(bool redo, bool ismeta,
if (PageIsNew((PageHeader) page)) if (PageIsNew((PageHeader) page))
elog(PANIC, "btree_delete_page_redo: uninitialized left sibling"); elog(PANIC, "btree_delete_page_redo: uninitialized left sibling");
if (XLByteLE(lsn, PageGetLSN(page))) if (XLByteLE(lsn, PageGetLSN(page)))
UnlockAndReleaseBuffer(buffer); {
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
}
else else
{ {
pageop = (BTPageOpaque) PageGetSpecialPointer(page); pageop = (BTPageOpaque) PageGetSpecialPointer(page);
...@@ -518,7 +546,8 @@ btree_xlog_delete_page(bool redo, bool ismeta, ...@@ -518,7 +546,8 @@ btree_xlog_delete_page(bool redo, bool ismeta,
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
} }
} }
...@@ -543,7 +572,8 @@ btree_xlog_delete_page(bool redo, bool ismeta, ...@@ -543,7 +572,8 @@ btree_xlog_delete_page(bool redo, bool ismeta,
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
else else
{ {
...@@ -606,7 +636,8 @@ btree_xlog_newroot(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -606,7 +636,8 @@ btree_xlog_newroot(bool redo, XLogRecPtr lsn, XLogRecord *record)
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
_bt_restore_meta(reln, lsn, _bt_restore_meta(reln, lsn,
xlrec->rootblk, xlrec->level, xlrec->rootblk, xlrec->level,
...@@ -668,7 +699,8 @@ btree_xlog_newpage(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -668,7 +699,8 @@ btree_xlog_newpage(bool redo, XLogRecPtr lsn, XLogRecord *record)
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.127 2003/12/12 18:45:08 petere Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.128 2003/12/14 00:34:47 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1712,7 +1712,8 @@ RestoreBkpBlocks(XLogRecord *record, XLogRecPtr lsn) ...@@ -1712,7 +1712,8 @@ RestoreBkpBlocks(XLogRecord *record, XLogRecPtr lsn)
memcpy((char *) page, blk, BLCKSZ); memcpy((char *) page, blk, BLCKSZ);
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.27 2003/11/29 19:51:40 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.28 2003/12/14 00:34:47 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -60,13 +60,15 @@ XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr, ...@@ -60,13 +60,15 @@ XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr,
if (PageIsNew((PageHeader) page) || if (PageIsNew((PageHeader) page) ||
ItemPointerGetOffsetNumber(iptr) > PageGetMaxOffsetNumber(page)) ItemPointerGetOffsetNumber(iptr) > PageGetMaxOffsetNumber(page))
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return (0); return (0);
} }
lp = PageGetItemId(page, ItemPointerGetOffsetNumber(iptr)); lp = PageGetItemId(page, ItemPointerGetOffsetNumber(iptr));
if (!ItemIdIsUsed(lp) || ItemIdDeleted(lp)) if (!ItemIdIsUsed(lp) || ItemIdDeleted(lp))
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return (0); return (0);
} }
...@@ -76,11 +78,13 @@ XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr, ...@@ -76,11 +78,13 @@ XLogIsOwnerOfTuple(RelFileNode hnode, ItemPointer iptr,
if (!TransactionIdEquals(HeapTupleHeaderGetXmin(htup), xid) || if (!TransactionIdEquals(HeapTupleHeaderGetXmin(htup), xid) ||
HeapTupleHeaderGetCmin(htup) != cid) HeapTupleHeaderGetCmin(htup) != cid)
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return (-1); return (-1);
} }
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return (1); return (1);
} }
...@@ -112,21 +116,24 @@ XLogIsValidTuple(RelFileNode hnode, ItemPointer iptr) ...@@ -112,21 +116,24 @@ XLogIsValidTuple(RelFileNode hnode, ItemPointer iptr)
if (PageIsNew((PageHeader) page) || if (PageIsNew((PageHeader) page) ||
ItemPointerGetOffsetNumber(iptr) > PageGetMaxOffsetNumber(page)) ItemPointerGetOffsetNumber(iptr) > PageGetMaxOffsetNumber(page))
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return (false); return (false);
} }
if (PageGetSUI(page) != ThisStartUpID) if (PageGetSUI(page) != ThisStartUpID)
{ {
Assert(PageGetSUI(page) < ThisStartUpID); Assert(PageGetSUI(page) < ThisStartUpID);
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return (true); return (true);
} }
lp = PageGetItemId(page, ItemPointerGetOffsetNumber(iptr)); lp = PageGetItemId(page, ItemPointerGetOffsetNumber(iptr));
if (!ItemIdIsUsed(lp) || ItemIdDeleted(lp)) if (!ItemIdIsUsed(lp) || ItemIdDeleted(lp))
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return (false); return (false);
} }
...@@ -141,12 +148,14 @@ XLogIsValidTuple(RelFileNode hnode, ItemPointer iptr) ...@@ -141,12 +148,14 @@ XLogIsValidTuple(RelFileNode hnode, ItemPointer iptr)
TransactionIdDidAbort(HeapTupleHeaderGetXvac(htup))) || TransactionIdDidAbort(HeapTupleHeaderGetXvac(htup))) ||
TransactionIdDidAbort(HeapTupleHeaderGetXmin(htup))) TransactionIdDidAbort(HeapTupleHeaderGetXmin(htup)))
{ {
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return (false); return (false);
} }
} }
UnlockAndReleaseBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
return (true); return (true);
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.105 2003/11/29 19:51:47 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.106 2003/12/14 00:34:47 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1104,7 +1104,8 @@ seq_redo(XLogRecPtr lsn, XLogRecord *record) ...@@ -1104,7 +1104,8 @@ seq_redo(XLogRecPtr lsn, XLogRecord *record)
PageSetLSN(page, lsn); PageSetLSN(page, lsn);
PageSetSUI(page, ThisStartUpID); PageSetSUI(page, ThisStartUpID);
UnlockAndWriteBuffer(buffer); LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
WriteBuffer(buffer);
} }
void void
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.58 2003/11/29 19:51:56 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/storage/buffer/buf_init.c,v 1.59 2003/12/14 00:34:47 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -34,17 +34,6 @@ ...@@ -34,17 +34,6 @@
#include "utils/hsearch.h" #include "utils/hsearch.h"
#include "utils/memutils.h" #include "utils/memutils.h"
/*
* if BMTRACE is defined, we trace the last 200 buffer allocations and
* deallocations in a circular buffer in shared memory.
*/
#ifdef BMTRACE
bmtrace *TraceBuf;
long *CurTraceBuf;
#define BMT_LIMIT 200
#endif /* BMTRACE */
int ShowPinTrace = 0; int ShowPinTrace = 0;
int Data_Descriptors; int Data_Descriptors;
...@@ -138,16 +127,6 @@ InitBufferPool(void) ...@@ -138,16 +127,6 @@ InitBufferPool(void)
*/ */
LWLockAcquire(BufMgrLock, LW_EXCLUSIVE); LWLockAcquire(BufMgrLock, LW_EXCLUSIVE);
#ifdef BMTRACE
CurTraceBuf = (long *) ShmemInitStruct("Buffer trace",
(BMT_LIMIT * sizeof(bmtrace)) + sizeof(long),
&foundDescs);
if (!foundDescs)
MemSet(CurTraceBuf, 0, (BMT_LIMIT * sizeof(bmtrace)) + sizeof(long));
TraceBuf = (bmtrace *) & (CurTraceBuf[1]);
#endif
BufferDescriptors = (BufferDesc *) BufferDescriptors = (BufferDesc *)
ShmemInitStruct("Buffer Descriptors", ShmemInitStruct("Buffer Descriptors",
Data_Descriptors * sizeof(BufferDesc), &foundDescs); Data_Descriptors * sizeof(BufferDesc), &foundDescs);
...@@ -256,9 +235,5 @@ BufferShmemSize(void) ...@@ -256,9 +235,5 @@ BufferShmemSize(void)
/* size of buffer hash table */ /* size of buffer hash table */
size += hash_estimate_size(NBuffers, sizeof(BufferLookupEnt)); size += hash_estimate_size(NBuffers, sizeof(BufferLookupEnt));
#ifdef BMTRACE
size += (BMT_LIMIT * sizeof(bmtrace)) + sizeof(long);
#endif
return size; return size;
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/buffer/buf_table.c,v 1.33 2003/11/29 19:51:56 pgsql Exp $ * $PostgreSQL: pgsql/src/backend/storage/buffer/buf_table.c,v 1.34 2003/12/14 00:34:47 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -117,15 +117,3 @@ BufTableDelete(BufferTag *tagPtr) ...@@ -117,15 +117,3 @@ BufTableDelete(BufferTag *tagPtr)
return TRUE; return TRUE;
} }
/* prints out collision stats for the buf table */
#ifdef NOT_USED
void
DBG_LookupListCheck(int nlookup)
{
nlookup = 10;
hash_stats("Shared", SharedBufHash);
}
#endif
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.148 2003/12/01 16:53:19 tgl Exp $ * $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.149 2003/12/14 00:34:47 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -84,7 +84,7 @@ static Buffer ReadBufferInternal(Relation reln, BlockNumber blockNum, ...@@ -84,7 +84,7 @@ static Buffer ReadBufferInternal(Relation reln, BlockNumber blockNum,
bool bufferLockHeld); bool bufferLockHeld);
static BufferDesc *BufferAlloc(Relation reln, BlockNumber blockNum, static BufferDesc *BufferAlloc(Relation reln, BlockNumber blockNum,
bool *foundPtr); bool *foundPtr);
static int BufferReplace(BufferDesc *bufHdr); static bool BufferReplace(BufferDesc *bufHdr);
#ifdef NOT_USED #ifdef NOT_USED
void PrintBufferDescs(void); void PrintBufferDescs(void);
...@@ -109,13 +109,6 @@ static void write_buffer(Buffer buffer, bool unpin); ...@@ -109,13 +109,6 @@ static void write_buffer(Buffer buffer, bool unpin);
* *
* Note: a side effect of a P_NEW call is to update reln->rd_nblocks. * Note: a side effect of a P_NEW call is to update reln->rd_nblocks.
*/ */
#undef ReadBuffer /* conflicts with macro when BUFMGR_DEBUG
* defined */
/*
* ReadBuffer
*/
Buffer Buffer
ReadBuffer(Relation reln, BlockNumber blockNum) ReadBuffer(Relation reln, BlockNumber blockNum)
{ {
...@@ -363,15 +356,10 @@ BufferAlloc(Relation reln, ...@@ -363,15 +356,10 @@ BufferAlloc(Relation reln,
* This is never going to happen, don't worry about it. * This is never going to happen, don't worry about it.
*/ */
*foundPtr = FALSE; *foundPtr = FALSE;
StartBufferIO(buf, true);
} }
#ifdef BMTRACE
_bm_trace((reln->rd_rel->relisshared ? 0 : MyDatabaseId), RelationGetRelid(reln), blockNum, BufferDescriptorGetBuffer(buf), BMT_ALLOCFND);
#endif /* BMTRACE */
if (!(*foundPtr))
StartBufferIO(buf, true);
LWLockRelease(BufMgrLock); LWLockRelease(BufMgrLock);
return buf; return buf;
} }
...@@ -402,7 +390,7 @@ BufferAlloc(Relation reln, ...@@ -402,7 +390,7 @@ BufferAlloc(Relation reln,
if (buf->flags & BM_DIRTY || buf->cntxDirty) if (buf->flags & BM_DIRTY || buf->cntxDirty)
{ {
bool smok; bool replace_ok;
/* /*
* skip write error buffers * skip write error buffers
...@@ -436,9 +424,9 @@ BufferAlloc(Relation reln, ...@@ -436,9 +424,9 @@ BufferAlloc(Relation reln,
* Write the buffer out, being careful to release BufMgrLock * Write the buffer out, being careful to release BufMgrLock
* before starting the I/O. * before starting the I/O.
*/ */
smok = BufferReplace(buf); replace_ok = BufferReplace(buf);
if (smok == FALSE) if (replace_ok == false)
{ {
ereport(WARNING, ereport(WARNING,
(errcode(ERRCODE_IO_ERROR), (errcode(ERRCODE_IO_ERROR),
...@@ -465,7 +453,7 @@ BufferAlloc(Relation reln, ...@@ -465,7 +453,7 @@ BufferAlloc(Relation reln,
buf->tag.blockNum, buf->tag.blockNum,
buf->tag.rnode.tblNode, buf->tag.rnode.relNode); buf->tag.rnode.tblNode, buf->tag.rnode.relNode);
} }
else
buf->flags &= ~BM_DIRTY; buf->flags &= ~BM_DIRTY;
buf->cntxDirty = false; buf->cntxDirty = false;
} }
...@@ -523,13 +511,14 @@ BufferAlloc(Relation reln, ...@@ -523,13 +511,14 @@ BufferAlloc(Relation reln,
WaitIO(buf2); WaitIO(buf2);
inProgress = (buf2->flags & BM_IO_IN_PROGRESS); inProgress = (buf2->flags & BM_IO_IN_PROGRESS);
} }
if (BUFFER_IS_BROKEN(buf2)) if (BUFFER_IS_BROKEN(buf2))
{
*foundPtr = FALSE; *foundPtr = FALSE;
if (!(*foundPtr))
StartBufferIO(buf2, true); StartBufferIO(buf2, true);
LWLockRelease(BufMgrLock); }
LWLockRelease(BufMgrLock);
return buf2; return buf2;
} }
} }
...@@ -558,10 +547,6 @@ BufferAlloc(Relation reln, ...@@ -558,10 +547,6 @@ BufferAlloc(Relation reln,
else else
ContinueBufferIO(buf, true); ContinueBufferIO(buf, true);
#ifdef BMTRACE
_bm_trace((reln->rd_rel->relisshared ? 0 : MyDatabaseId), RelationGetRelid(reln), blockNum, BufferDescriptorGetBuffer(buf), BMT_ALLOCNOTFND);
#endif /* BMTRACE */
LWLockRelease(BufMgrLock); LWLockRelease(BufMgrLock);
return buf; return buf;
...@@ -602,15 +587,11 @@ write_buffer(Buffer buffer, bool release) ...@@ -602,15 +587,11 @@ write_buffer(Buffer buffer, bool release)
* *
* Marks buffer contents as dirty (actual write happens later). * Marks buffer contents as dirty (actual write happens later).
* *
* Assume that buffer is pinned. Assume that reln is * Assume that buffer is pinned. Assume that reln is valid.
* valid.
* *
* Side Effects: * Side Effects:
* Pin count is decremented. * Pin count is decremented.
*/ */
#undef WriteBuffer
void void
WriteBuffer(Buffer buffer) WriteBuffer(Buffer buffer)
{ {
...@@ -627,8 +608,6 @@ WriteNoReleaseBuffer(Buffer buffer) ...@@ -627,8 +608,6 @@ WriteNoReleaseBuffer(Buffer buffer)
write_buffer(buffer, false); write_buffer(buffer, false);
} }
#undef ReleaseAndReadBuffer
/* /*
* ReleaseAndReadBuffer -- combine ReleaseBuffer() and ReadBuffer() * ReleaseAndReadBuffer -- combine ReleaseBuffer() and ReadBuffer()
* to save a lock release/acquire. * to save a lock release/acquire.
...@@ -638,7 +617,7 @@ WriteNoReleaseBuffer(Buffer buffer) ...@@ -638,7 +617,7 @@ WriteNoReleaseBuffer(Buffer buffer)
* Since the passed buffer must be pinned, it's OK to examine its block * Since the passed buffer must be pinned, it's OK to examine its block
* number without getting the lock first. * number without getting the lock first.
* *
* Note: it is OK to pass buffer = InvalidBuffer, indicating that no old * Note: it is OK to pass buffer == InvalidBuffer, indicating that no old
* buffer actually needs to be released. This case is the same as ReadBuffer, * buffer actually needs to be released. This case is the same as ReadBuffer,
* but can save some tests in the caller. * but can save some tests in the caller.
* *
...@@ -1092,11 +1071,12 @@ BufferGetBlockNumber(Buffer buffer) ...@@ -1092,11 +1071,12 @@ BufferGetBlockNumber(Buffer buffer)
/* /*
* BufferReplace * BufferReplace
* *
* Write out the buffer corresponding to 'bufHdr' * Write out the buffer corresponding to 'bufHdr'. Returns 'true' if
* the buffer was successfully written out, 'false' otherwise.
* *
* BufMgrLock must be held at entry, and the buffer must be pinned. * BufMgrLock must be held at entry, and the buffer must be pinned.
*/ */
static int static bool
BufferReplace(BufferDesc *bufHdr) BufferReplace(BufferDesc *bufHdr)
{ {
Relation reln; Relation reln;
...@@ -1147,11 +1127,11 @@ BufferReplace(BufferDesc *bufHdr) ...@@ -1147,11 +1127,11 @@ BufferReplace(BufferDesc *bufHdr)
LWLockAcquire(BufMgrLock, LW_EXCLUSIVE); LWLockAcquire(BufMgrLock, LW_EXCLUSIVE);
if (status == SM_FAIL) if (status == SM_FAIL)
return FALSE; return false;
BufferFlushCount++; BufferFlushCount++;
return TRUE; return true;
} }
/* /*
...@@ -1167,7 +1147,7 @@ RelationGetNumberOfBlocks(Relation relation) ...@@ -1167,7 +1147,7 @@ RelationGetNumberOfBlocks(Relation relation)
* new or temp, because no one else should be modifying it. Otherwise * new or temp, because no one else should be modifying it. Otherwise
* we need to ask the smgr for the current physical file length. * we need to ask the smgr for the current physical file length.
* *
* Don't call smgr on a view, either. * Don't call smgr on a view or a composite type, either.
*/ */
if (relation->rd_rel->relkind == RELKIND_VIEW) if (relation->rd_rel->relkind == RELKIND_VIEW)
relation->rd_nblocks = 0; relation->rd_nblocks = 0;
...@@ -1175,6 +1155,7 @@ RelationGetNumberOfBlocks(Relation relation) ...@@ -1175,6 +1155,7 @@ RelationGetNumberOfBlocks(Relation relation)
relation->rd_nblocks = 0; relation->rd_nblocks = 0;
else if (!relation->rd_isnew && !relation->rd_istemp) else if (!relation->rd_isnew && !relation->rd_istemp)
relation->rd_nblocks = smgrnblocks(DEFAULT_SMGR, relation); relation->rd_nblocks = smgrnblocks(DEFAULT_SMGR, relation);
return relation->rd_nblocks; return relation->rd_nblocks;
} }
...@@ -1623,8 +1604,6 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock) ...@@ -1623,8 +1604,6 @@ FlushRelationBuffers(Relation rel, BlockNumber firstDelBlock)
return 0; return 0;
} }
#undef ReleaseBuffer
/* /*
* ReleaseBuffer -- remove the pin on a buffer without * ReleaseBuffer -- remove the pin on a buffer without
* marking it dirty. * marking it dirty.
...@@ -1737,151 +1716,6 @@ refcount = %ld, file: %s, line: %d\n", ...@@ -1737,151 +1716,6 @@ refcount = %ld, file: %s, line: %d\n",
} }
#endif #endif
#ifdef BMTRACE
/*
* trace allocations and deallocations in a circular buffer in
* shared memory. check the buffer before doing the allocation,
* and die if there's anything fishy.
*/
void
_bm_trace(Oid dbId, Oid relId, int blkNo, int bufNo, int allocType)
{
long start,
cur;
bmtrace *tb;
start = *CurTraceBuf;
if (start > 0)
cur = start - 1;
else
cur = BMT_LIMIT - 1;
for (;;)
{
tb = &TraceBuf[cur];
if (tb->bmt_op != BMT_NOTUSED)
{
if (tb->bmt_buf == bufNo)
{
if ((tb->bmt_op == BMT_DEALLOC)
|| (tb->bmt_dbid == dbId && tb->bmt_relid == relId
&& tb->bmt_blkno == blkNo))
goto okay;
/* die holding the buffer lock */
_bm_die(dbId, relId, blkNo, bufNo, allocType, start, cur);
}
}
if (cur == start)
goto okay;
if (cur == 0)
cur = BMT_LIMIT - 1;
else
cur--;
}
okay:
tb = &TraceBuf[start];
tb->bmt_pid = MyProcPid;
tb->bmt_buf = bufNo;
tb->bmt_dbid = dbId;
tb->bmt_relid = relId;
tb->bmt_blkno = blkNo;
tb->bmt_op = allocType;
*CurTraceBuf = (start + 1) % BMT_LIMIT;
}
void
_bm_die(Oid dbId, Oid relId, int blkNo, int bufNo,
int allocType, long start, long cur)
{
FILE *fp;
bmtrace *tb;
int i;
tb = &TraceBuf[cur];
if ((fp = AllocateFile("/tmp/death_notice", "w")) == NULL)
elog(FATAL, "buffer alloc trace error and can't open log file");
fprintf(fp, "buffer alloc trace detected the following error:\n\n");
fprintf(fp, " buffer %d being %s inconsistently with a previous %s\n\n",
bufNo, (allocType == BMT_DEALLOC ? "deallocated" : "allocated"),
(tb->bmt_op == BMT_DEALLOC ? "deallocation" : "allocation"));
fprintf(fp, "the trace buffer contains:\n");
i = start;
for (;;)
{
tb = &TraceBuf[i];
if (tb->bmt_op != BMT_NOTUSED)
{
fprintf(fp, " [%3d]%spid %d buf %2d for <%u,%u,%u> ",
i, (i == cur ? " ---> " : "\t"),
tb->bmt_pid, tb->bmt_buf,
tb->bmt_dbid, tb->bmt_relid, tb->bmt_blkno);
switch (tb->bmt_op)
{
case BMT_ALLOCFND:
fprintf(fp, "allocate (found)\n");
break;
case BMT_ALLOCNOTFND:
fprintf(fp, "allocate (not found)\n");
break;
case BMT_DEALLOC:
fprintf(fp, "deallocate\n");
break;
default:
fprintf(fp, "unknown op type %d\n", tb->bmt_op);
break;
}
}
i = (i + 1) % BMT_LIMIT;
if (i == start)
break;
}
fprintf(fp, "\noperation causing error:\n");
fprintf(fp, "\tpid %d buf %d for <%d,%u,%d> ",
getpid(), bufNo, dbId, relId, blkNo);
switch (allocType)
{
case BMT_ALLOCFND:
fprintf(fp, "allocate (found)\n");
break;
case BMT_ALLOCNOTFND:
fprintf(fp, "allocate (not found)\n");
break;
case BMT_DEALLOC:
fprintf(fp, "deallocate\n");
break;
default:
fprintf(fp, "unknown op type %d\n", allocType);
break;
}
FreeFile(fp);
kill(getpid(), SIGILL);
}
#endif /* BMTRACE */
/* /*
* SetBufferCommitInfoNeedsSave * SetBufferCommitInfoNeedsSave
* *
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.65 2003/11/29 22:41:13 pgsql Exp $ * $PostgreSQL: pgsql/src/include/storage/buf_internals.h,v 1.66 2003/12/14 00:34:47 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -33,14 +33,13 @@ extern int ShowPinTrace; ...@@ -33,14 +33,13 @@ extern int ShowPinTrace;
* Flags for buffer descriptors * Flags for buffer descriptors
*/ */
#define BM_DIRTY (1 << 0) #define BM_DIRTY (1 << 0)
#define BM_PRIVATE (1 << 1) #define BM_VALID (1 << 1)
#define BM_VALID (1 << 2) #define BM_DELETED (1 << 2)
#define BM_DELETED (1 << 3) #define BM_FREE (1 << 3)
#define BM_FREE (1 << 4) #define BM_IO_IN_PROGRESS (1 << 4)
#define BM_IO_IN_PROGRESS (1 << 5) #define BM_IO_ERROR (1 << 5)
#define BM_IO_ERROR (1 << 6) #define BM_JUST_DIRTIED (1 << 6)
#define BM_JUST_DIRTIED (1 << 7) #define BM_PIN_COUNT_WAITER (1 << 7)
#define BM_PIN_COUNT_WAITER (1 << 8)
typedef bits16 BufFlags; typedef bits16 BufFlags;
...@@ -136,32 +135,6 @@ typedef struct ...@@ -136,32 +135,6 @@ typedef struct
Buffer id; Buffer id;
} BufferLookupEnt; } BufferLookupEnt;
/*
* mao tracing buffer allocation
*/
/*#define BMTRACE*/
#ifdef BMTRACE
typedef struct _bmtrace
{
int bmt_pid;
int bmt_buf;
Oid bmt_dbid;
Oid bmt_relid;
BlockNumber bmt_blkno;
int bmt_op;
#define BMT_NOTUSED 0
#define BMT_ALLOCFND 1
#define BMT_ALLOCNOTFND 2
#define BMT_DEALLOC 3
} bmtrace;
#endif /* BMTRACE */
/* counters in buf_init.c */ /* counters in buf_init.c */
extern long int ReadBufferCount; extern long int ReadBufferCount;
extern long int ReadLocalBufferCount; extern long int ReadLocalBufferCount;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.72 2003/11/29 22:41:13 pgsql Exp $ * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.73 2003/12/14 00:34:47 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -57,19 +57,6 @@ extern long *LocalRefCount; ...@@ -57,19 +57,6 @@ extern long *LocalRefCount;
*/ */
#define BAD_BUFFER_ID(bid) ((bid) < 1 || (bid) > NBuffers) #define BAD_BUFFER_ID(bid) ((bid) < 1 || (bid) > NBuffers)
#define INVALID_DESCRIPTOR (-3)
#define UnlockAndReleaseBuffer(buffer) \
( \
LockBuffer(buffer, BUFFER_LOCK_UNLOCK), \
ReleaseBuffer(buffer) \
)
#define UnlockAndWriteBuffer(buffer) \
( \
LockBuffer(buffer, BUFFER_LOCK_UNLOCK), \
WriteBuffer(buffer) \
)
/* /*
* BufferIsValid * BufferIsValid
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment