*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.98 2000/11/30 19:03:25 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.99 2000/12/22 20:04:43 vadim Exp $
*
*-------------------------------------------------------------------------
*/
RelFileNode rnode;
XLogRecPtr recptr;
Relation reln = NULL;
+ bool dirty = false;
for (i = 0, bufHdr = BufferDescriptors; i < NBuffers; i++, bufHdr++)
{
buffer = BufferDescriptorGetBuffer(bufHdr);
rnode = bufHdr->tag.rnode;
+ dirty = bufHdr->flags & BM_DIRTY;
SpinRelease(BufMgrLock);
*/
LockBuffer(buffer, BUFFER_LOCK_SHARE);
+ if (!dirty && !(bufHdr->cntxDirty))
+ {
+ LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
+ SpinAcquire(BufMgrLock);
+ UnpinBuffer(bufHdr);
+ SpinRelease(BufMgrLock);
+ if (reln != (Relation) NULL)
+ RelationDecrementReferenceCount(reln);
+ continue;
+ }
+
/*
* Force XLOG flush for buffer' LSN
*/
/*
* Now it's safe to write buffer to disk
- * (if needed at all -:))
+ * (if no one else already)
*/
-
SpinAcquire(BufMgrLock);
if (bufHdr->flags & BM_IO_IN_PROGRESS)
WaitIO(bufHdr, BufMgrLock);
*/
if (!(bufHdr->flags & BM_JUST_DIRTIED))
bufHdr->flags &= ~BM_DIRTY;
+ UnpinBuffer(bufHdr);
+ SpinRelease(BufMgrLock);
}
else
+ {
+ UnpinBuffer(bufHdr);
+ SpinRelease(BufMgrLock);
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
-
- UnpinBuffer(bufHdr);
-
- SpinRelease(BufMgrLock);
+ }
/* drop refcnt obtained by RelationNodeCacheGetRelation */
if (reln != (Relation) NULL)
- {
RelationDecrementReferenceCount(reln);
- reln = NULL;
- }
}
}