Avoid unnecessary lseek() calls by cleanups in md.c. mdfd_lstbcnt was
not being consulted anywhere, so remove it and remove the _mdnblocks() calls that were used to set it. Change smgrextend interface to pass in the target block number (ie, current file length) --- the caller always knows this already, having already done smgrnblocks(), so it's silly to do it over again inside mdextend. Net result: extension of a file now takes one lseek(SEEK_END) and a write(), not three lseeks and a write.
This commit is contained in:
parent
a26ad8a643
commit
642107d5ba
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.54 2001/04/04 15:43:25 vadim Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.55 2001/05/10 20:38:49 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -569,7 +569,7 @@ read_info(char *caller, SeqTable elm, Buffer *buf)
|
|||||||
sequence_magic *sm;
|
sequence_magic *sm;
|
||||||
Form_pg_sequence seq;
|
Form_pg_sequence seq;
|
||||||
|
|
||||||
if (RelationGetNumberOfBlocks(elm->rel) != 1)
|
if (elm->rel->rd_nblocks > 1)
|
||||||
elog(ERROR, "%s.%s: invalid number of blocks in sequence",
|
elog(ERROR, "%s.%s: invalid number of blocks in sequence",
|
||||||
elm->name, caller);
|
elm->name, caller);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.109 2001/03/22 03:59:44 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.110 2001/05/10 20:38:49 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -173,9 +173,9 @@ ReadBufferWithBufferLock(Relation reln,
|
|||||||
bool bufferLockHeld)
|
bool bufferLockHeld)
|
||||||
{
|
{
|
||||||
BufferDesc *bufHdr;
|
BufferDesc *bufHdr;
|
||||||
int extend; /* extending the file by one block */
|
|
||||||
int status;
|
int status;
|
||||||
bool found;
|
bool found;
|
||||||
|
bool extend; /* extending the file by one block */
|
||||||
bool isLocalBuf;
|
bool isLocalBuf;
|
||||||
|
|
||||||
extend = (blockNum == P_NEW);
|
extend = (blockNum == P_NEW);
|
||||||
@ -207,21 +207,13 @@ ReadBufferWithBufferLock(Relation reln,
|
|||||||
/* if it's already in the buffer pool, we're done */
|
/* if it's already in the buffer pool, we're done */
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This happens when a bogus buffer was returned previously and is
|
* Could see found && extend if a buffer was already created for
|
||||||
* floating around in the buffer pool. A routine calling this
|
* the next page position, but then smgrextend failed to write
|
||||||
* would want this extended.
|
* the page. Must fall through and try to extend file again.
|
||||||
*/
|
*/
|
||||||
if (extend)
|
if (!extend)
|
||||||
{
|
|
||||||
/* new buffers are zero-filled */
|
|
||||||
MemSet((char *) MAKE_PTR(bufHdr->data), 0, BLCKSZ);
|
|
||||||
smgrextend(DEFAULT_SMGR, reln,
|
|
||||||
(char *) MAKE_PTR(bufHdr->data));
|
|
||||||
}
|
|
||||||
return BufferDescriptorGetBuffer(bufHdr);
|
return BufferDescriptorGetBuffer(bufHdr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -232,17 +224,25 @@ ReadBufferWithBufferLock(Relation reln,
|
|||||||
{
|
{
|
||||||
/* new buffers are zero-filled */
|
/* new buffers are zero-filled */
|
||||||
MemSet((char *) MAKE_PTR(bufHdr->data), 0, BLCKSZ);
|
MemSet((char *) MAKE_PTR(bufHdr->data), 0, BLCKSZ);
|
||||||
status = smgrextend(DEFAULT_SMGR, reln,
|
status = smgrextend(DEFAULT_SMGR, reln, bufHdr->tag.blockNum,
|
||||||
(char *) MAKE_PTR(bufHdr->data));
|
(char *) MAKE_PTR(bufHdr->data));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status = smgrread(DEFAULT_SMGR, reln, blockNum,
|
status = smgrread(DEFAULT_SMGR, reln, bufHdr->tag.blockNum,
|
||||||
(char *) MAKE_PTR(bufHdr->data));
|
(char *) MAKE_PTR(bufHdr->data));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLocalBuf)
|
if (isLocalBuf)
|
||||||
|
{
|
||||||
|
/* No shared buffer state to update... */
|
||||||
|
if (status == SM_FAIL)
|
||||||
|
{
|
||||||
|
bufHdr->flags |= BM_IO_ERROR;
|
||||||
|
return InvalidBuffer;
|
||||||
|
}
|
||||||
return BufferDescriptorGetBuffer(bufHdr);
|
return BufferDescriptorGetBuffer(bufHdr);
|
||||||
|
}
|
||||||
|
|
||||||
/* lock buffer manager again to update IO IN PROGRESS */
|
/* lock buffer manager again to update IO IN PROGRESS */
|
||||||
SpinAcquire(BufMgrLock);
|
SpinAcquire(BufMgrLock);
|
||||||
@ -302,13 +302,11 @@ BufferAlloc(Relation reln,
|
|||||||
*buf2;
|
*buf2;
|
||||||
BufferTag newTag; /* identity of requested block */
|
BufferTag newTag; /* identity of requested block */
|
||||||
bool inProgress; /* buffer undergoing IO */
|
bool inProgress; /* buffer undergoing IO */
|
||||||
bool newblock = FALSE;
|
|
||||||
|
|
||||||
/* create a new tag so we can lookup the buffer */
|
/* create a new tag so we can lookup the buffer */
|
||||||
/* assume that the relation is already open */
|
/* assume that the relation is already open */
|
||||||
if (blockNum == P_NEW)
|
if (blockNum == P_NEW)
|
||||||
{
|
{
|
||||||
newblock = TRUE;
|
|
||||||
blockNum = smgrnblocks(DEFAULT_SMGR, reln);
|
blockNum = smgrnblocks(DEFAULT_SMGR, reln);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1102,7 +1100,8 @@ BufferReplace(BufferDesc *bufHdr)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* RelationGetNumberOfBlocks
|
* RelationGetNumberOfBlocks
|
||||||
* Returns the buffer descriptor associated with a page in a relation.
|
* Determines the current number of pages in the relation.
|
||||||
|
* Side effect: relation->rd_nblocks is updated.
|
||||||
*
|
*
|
||||||
* Note:
|
* Note:
|
||||||
* XXX may fail for huge relations.
|
* XXX may fail for huge relations.
|
||||||
@ -1112,9 +1111,16 @@ BufferReplace(BufferDesc *bufHdr)
|
|||||||
BlockNumber
|
BlockNumber
|
||||||
RelationGetNumberOfBlocks(Relation relation)
|
RelationGetNumberOfBlocks(Relation relation)
|
||||||
{
|
{
|
||||||
return ((relation->rd_myxactonly) ? relation->rd_nblocks :
|
/*
|
||||||
((relation->rd_rel->relkind == RELKIND_VIEW) ? 0 :
|
* relation->rd_nblocks should be accurate already if the relation
|
||||||
smgrnblocks(DEFAULT_SMGR, relation)));
|
* is myxactonly. (XXX how safe is that really?) Don't call smgr
|
||||||
|
* on a view, either.
|
||||||
|
*/
|
||||||
|
if (relation->rd_rel->relkind == RELKIND_VIEW)
|
||||||
|
relation->rd_nblocks = 0;
|
||||||
|
else if (!relation->rd_myxactonly)
|
||||||
|
relation->rd_nblocks = smgrnblocks(DEFAULT_SMGR, relation);
|
||||||
|
return relation->rd_nblocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.83 2001/04/02 23:20:24 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.84 2001/05/10 20:38:49 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -54,10 +54,9 @@ typedef struct _MdfdVec
|
|||||||
int mdfd_flags; /* fd status flags */
|
int mdfd_flags; /* fd status flags */
|
||||||
|
|
||||||
/* these are the assigned bits in mdfd_flags: */
|
/* these are the assigned bits in mdfd_flags: */
|
||||||
#define MDFD_FREE (1 << 0)/* unused entry */
|
#define MDFD_FREE (1 << 0) /* unused entry */
|
||||||
|
|
||||||
int mdfd_lstbcnt; /* most recent block count */
|
int mdfd_nextFree; /* link to next freelist member, if free */
|
||||||
int mdfd_nextFree; /* next free vector */
|
|
||||||
#ifndef LET_OS_MANAGE_FILESIZE
|
#ifndef LET_OS_MANAGE_FILESIZE
|
||||||
struct _MdfdVec *mdfd_chain;/* for large relations */
|
struct _MdfdVec *mdfd_chain;/* for large relations */
|
||||||
#endif
|
#endif
|
||||||
@ -164,7 +163,6 @@ mdcreate(Relation reln)
|
|||||||
|
|
||||||
Md_fdvec[vfd].mdfd_vfd = fd;
|
Md_fdvec[vfd].mdfd_vfd = fd;
|
||||||
Md_fdvec[vfd].mdfd_flags = (uint16) 0;
|
Md_fdvec[vfd].mdfd_flags = (uint16) 0;
|
||||||
Md_fdvec[vfd].mdfd_lstbcnt = 0;
|
|
||||||
#ifndef LET_OS_MANAGE_FILESIZE
|
#ifndef LET_OS_MANAGE_FILESIZE
|
||||||
Md_fdvec[vfd].mdfd_chain = (MdfdVec *) NULL;
|
Md_fdvec[vfd].mdfd_chain = (MdfdVec *) NULL;
|
||||||
#endif
|
#endif
|
||||||
@ -225,52 +223,69 @@ mdunlink(RelFileNode rnode)
|
|||||||
/*
|
/*
|
||||||
* mdextend() -- Add a block to the specified relation.
|
* mdextend() -- Add a block to the specified relation.
|
||||||
*
|
*
|
||||||
|
* The semantics are basically the same as mdwrite(): write at the
|
||||||
|
* specified position. However, we are expecting to extend the
|
||||||
|
* relation (ie, blocknum is the current EOF), and so in case of
|
||||||
|
* failure we clean up by truncating.
|
||||||
|
*
|
||||||
* This routine returns SM_FAIL or SM_SUCCESS, with errno set as
|
* This routine returns SM_FAIL or SM_SUCCESS, with errno set as
|
||||||
* appropriate.
|
* appropriate.
|
||||||
|
*
|
||||||
|
* Note: this routine used to call mdnblocks() to get the block position
|
||||||
|
* to write at, but that's pretty silly since the caller needs to know where
|
||||||
|
* the block will be written, and accordingly must have done mdnblocks()
|
||||||
|
* already. Might as well pass in the position and save a seek.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mdextend(Relation reln, char *buffer)
|
mdextend(Relation reln, BlockNumber blocknum, char *buffer)
|
||||||
{
|
{
|
||||||
long pos,
|
long seekpos;
|
||||||
nbytes;
|
int nbytes;
|
||||||
int nblocks;
|
|
||||||
MdfdVec *v;
|
MdfdVec *v;
|
||||||
|
|
||||||
nblocks = mdnblocks(reln);
|
v = _mdfd_getseg(reln, blocknum);
|
||||||
v = _mdfd_getseg(reln, nblocks);
|
|
||||||
|
|
||||||
if ((pos = FileSeek(v->mdfd_vfd, 0L, SEEK_END)) < 0)
|
#ifndef LET_OS_MANAGE_FILESIZE
|
||||||
return SM_FAIL;
|
seekpos = (long) (BLCKSZ * (blocknum % RELSEG_SIZE));
|
||||||
|
#ifdef DIAGNOSTIC
|
||||||
|
if (seekpos >= BLCKSZ * RELSEG_SIZE)
|
||||||
|
elog(FATAL, "seekpos too big!");
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
seekpos = (long) (BLCKSZ * (blocknum));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pos % BLCKSZ != 0) /* the last block is incomplete */
|
/*
|
||||||
{
|
* Note: because caller obtained blocknum by calling mdnblocks, which
|
||||||
pos -= pos % BLCKSZ;
|
* did a seek(SEEK_END), this seek is often redundant and will be
|
||||||
if (FileSeek(v->mdfd_vfd, pos, SEEK_SET) < 0)
|
* optimized away by fd.c. It's not redundant, however, if there is a
|
||||||
|
* partial page at the end of the file. In that case we want to try to
|
||||||
|
* overwrite the partial page with a full page. It's also not redundant
|
||||||
|
* if bufmgr.c had to dump another buffer of the same file to make room
|
||||||
|
* for the new page's buffer.
|
||||||
|
*/
|
||||||
|
if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)
|
||||||
return SM_FAIL;
|
return SM_FAIL;
|
||||||
}
|
|
||||||
|
|
||||||
if ((nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
|
if ((nbytes = FileWrite(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
|
||||||
{
|
{
|
||||||
if (nbytes > 0)
|
if (nbytes > 0)
|
||||||
{
|
{
|
||||||
FileTruncate(v->mdfd_vfd, pos);
|
int save_errno = errno;
|
||||||
FileSeek(v->mdfd_vfd, pos, SEEK_SET);
|
|
||||||
|
/* Remove the partially-written page */
|
||||||
|
FileTruncate(v->mdfd_vfd, seekpos);
|
||||||
|
FileSeek(v->mdfd_vfd, seekpos, SEEK_SET);
|
||||||
|
errno = save_errno;
|
||||||
}
|
}
|
||||||
return SM_FAIL;
|
return SM_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try to keep the last block count current, though it's just a hint */
|
|
||||||
#ifndef LET_OS_MANAGE_FILESIZE
|
#ifndef LET_OS_MANAGE_FILESIZE
|
||||||
if ((v->mdfd_lstbcnt = (++nblocks % RELSEG_SIZE)) == 0)
|
|
||||||
v->mdfd_lstbcnt = RELSEG_SIZE;
|
|
||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
if (_mdnblocks(v->mdfd_vfd, BLCKSZ) > RELSEG_SIZE
|
if (_mdnblocks(v->mdfd_vfd, BLCKSZ) > RELSEG_SIZE)
|
||||||
|| v->mdfd_lstbcnt > RELSEG_SIZE)
|
|
||||||
elog(FATAL, "segment too big!");
|
elog(FATAL, "segment too big!");
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
v->mdfd_lstbcnt = ++nblocks;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return SM_SUCCESS;
|
return SM_SUCCESS;
|
||||||
@ -319,12 +334,11 @@ mdopen(Relation reln)
|
|||||||
|
|
||||||
Md_fdvec[vfd].mdfd_vfd = fd;
|
Md_fdvec[vfd].mdfd_vfd = fd;
|
||||||
Md_fdvec[vfd].mdfd_flags = (uint16) 0;
|
Md_fdvec[vfd].mdfd_flags = (uint16) 0;
|
||||||
Md_fdvec[vfd].mdfd_lstbcnt = _mdnblocks(fd, BLCKSZ);
|
|
||||||
#ifndef LET_OS_MANAGE_FILESIZE
|
#ifndef LET_OS_MANAGE_FILESIZE
|
||||||
Md_fdvec[vfd].mdfd_chain = (MdfdVec *) NULL;
|
Md_fdvec[vfd].mdfd_chain = (MdfdVec *) NULL;
|
||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
if (Md_fdvec[vfd].mdfd_lstbcnt > RELSEG_SIZE)
|
if (_mdnblocks(fd, BLCKSZ) > RELSEG_SIZE)
|
||||||
elog(FATAL, "segment too big on relopen!");
|
elog(FATAL, "segment too big on relopen!");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -440,9 +454,12 @@ mdread(Relation reln, BlockNumber blocknum, char *buffer)
|
|||||||
status = SM_SUCCESS;
|
status = SM_SUCCESS;
|
||||||
if ((nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
|
if ((nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
|
||||||
{
|
{
|
||||||
if (nbytes == 0)
|
/*
|
||||||
MemSet(buffer, 0, BLCKSZ);
|
* If we are at EOF, return zeroes without complaining.
|
||||||
else if (blocknum == 0 && nbytes > 0 && mdnblocks(reln) == 0)
|
* (XXX Is this still necessary/a good idea??)
|
||||||
|
*/
|
||||||
|
if (nbytes == 0 ||
|
||||||
|
(nbytes > 0 && mdnblocks(reln) == blocknum))
|
||||||
MemSet(buffer, 0, BLCKSZ);
|
MemSet(buffer, 0, BLCKSZ);
|
||||||
else
|
else
|
||||||
status = SM_FAIL;
|
status = SM_FAIL;
|
||||||
@ -459,7 +476,6 @@ mdread(Relation reln, BlockNumber blocknum, char *buffer)
|
|||||||
int
|
int
|
||||||
mdwrite(Relation reln, BlockNumber blocknum, char *buffer)
|
mdwrite(Relation reln, BlockNumber blocknum, char *buffer)
|
||||||
{
|
{
|
||||||
int status;
|
|
||||||
long seekpos;
|
long seekpos;
|
||||||
MdfdVec *v;
|
MdfdVec *v;
|
||||||
|
|
||||||
@ -478,11 +494,10 @@ mdwrite(Relation reln, BlockNumber blocknum, char *buffer)
|
|||||||
if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)
|
if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)
|
||||||
return SM_FAIL;
|
return SM_FAIL;
|
||||||
|
|
||||||
status = SM_SUCCESS;
|
|
||||||
if (FileWrite(v->mdfd_vfd, buffer, BLCKSZ) != BLCKSZ)
|
if (FileWrite(v->mdfd_vfd, buffer, BLCKSZ) != BLCKSZ)
|
||||||
status = SM_FAIL;
|
return SM_FAIL;
|
||||||
|
|
||||||
return status;
|
return SM_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -662,14 +677,15 @@ mdnblocks(Relation reln)
|
|||||||
nblocks = _mdnblocks(v->mdfd_vfd, BLCKSZ);
|
nblocks = _mdnblocks(v->mdfd_vfd, BLCKSZ);
|
||||||
if (nblocks > RELSEG_SIZE)
|
if (nblocks > RELSEG_SIZE)
|
||||||
elog(FATAL, "segment too big in mdnblocks!");
|
elog(FATAL, "segment too big in mdnblocks!");
|
||||||
v->mdfd_lstbcnt = nblocks;
|
if (nblocks < RELSEG_SIZE)
|
||||||
if (nblocks == RELSEG_SIZE)
|
return (segno * RELSEG_SIZE) + nblocks;
|
||||||
{
|
/*
|
||||||
|
* If segment is exactly RELSEG_SIZE, advance to next one.
|
||||||
|
*/
|
||||||
segno++;
|
segno++;
|
||||||
|
|
||||||
if (v->mdfd_chain == (MdfdVec *) NULL)
|
if (v->mdfd_chain == (MdfdVec *) NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Because we pass O_CREAT, we will create the next
|
* Because we pass O_CREAT, we will create the next
|
||||||
* segment (with zero length) immediately, if the last
|
* segment (with zero length) immediately, if the last
|
||||||
@ -685,9 +701,6 @@ mdnblocks(Relation reln)
|
|||||||
|
|
||||||
v = v->mdfd_chain;
|
v = v->mdfd_chain;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return (segno * RELSEG_SIZE) + nblocks;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
return _mdnblocks(v->mdfd_vfd, BLCKSZ);
|
return _mdnblocks(v->mdfd_vfd, BLCKSZ);
|
||||||
#endif
|
#endif
|
||||||
@ -761,7 +774,6 @@ mdtruncate(Relation reln, int nblocks)
|
|||||||
|
|
||||||
if (FileTruncate(v->mdfd_vfd, lastsegblocks * BLCKSZ) < 0)
|
if (FileTruncate(v->mdfd_vfd, lastsegblocks * BLCKSZ) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
v->mdfd_lstbcnt = lastsegblocks;
|
|
||||||
v = v->mdfd_chain;
|
v = v->mdfd_chain;
|
||||||
ov->mdfd_chain = (MdfdVec *) NULL;
|
ov->mdfd_chain = (MdfdVec *) NULL;
|
||||||
}
|
}
|
||||||
@ -779,7 +791,6 @@ mdtruncate(Relation reln, int nblocks)
|
|||||||
#else
|
#else
|
||||||
if (FileTruncate(v->mdfd_vfd, nblocks * BLCKSZ) < 0)
|
if (FileTruncate(v->mdfd_vfd, nblocks * BLCKSZ) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
v->mdfd_lstbcnt = nblocks;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return nblocks;
|
return nblocks;
|
||||||
@ -958,13 +969,12 @@ _mdfd_openseg(Relation reln, int segno, int oflags)
|
|||||||
/* fill the entry */
|
/* fill the entry */
|
||||||
v->mdfd_vfd = fd;
|
v->mdfd_vfd = fd;
|
||||||
v->mdfd_flags = (uint16) 0;
|
v->mdfd_flags = (uint16) 0;
|
||||||
v->mdfd_lstbcnt = _mdnblocks(fd, BLCKSZ);
|
|
||||||
#ifndef LET_OS_MANAGE_FILESIZE
|
#ifndef LET_OS_MANAGE_FILESIZE
|
||||||
v->mdfd_chain = (MdfdVec *) NULL;
|
v->mdfd_chain = (MdfdVec *) NULL;
|
||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
if (v->mdfd_lstbcnt > RELSEG_SIZE)
|
if (_mdnblocks(fd, BLCKSZ) > RELSEG_SIZE)
|
||||||
elog(FATAL, "segment too big on open!");
|
elog(FATAL, "segment too big on openseg!");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.22 2001/01/24 19:43:08 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.23 2001/05/10 20:38:49 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -267,7 +267,7 @@ mmunlink(RelFileNode rnode)
|
|||||||
* appropriate.
|
* appropriate.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mmextend(Relation reln, char *buffer)
|
mmextend(Relation reln, BlockNumber blocknum, char *buffer)
|
||||||
{
|
{
|
||||||
MMRelHashEntry *rentry;
|
MMRelHashEntry *rentry;
|
||||||
MMHashEntry *entry;
|
MMHashEntry *entry;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.48 2001/03/22 03:59:47 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.49 2001/05/10 20:38:49 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -30,7 +30,8 @@ typedef struct f_smgr
|
|||||||
int (*smgr_shutdown) (void); /* may be NULL */
|
int (*smgr_shutdown) (void); /* may be NULL */
|
||||||
int (*smgr_create) (Relation reln);
|
int (*smgr_create) (Relation reln);
|
||||||
int (*smgr_unlink) (RelFileNode rnode);
|
int (*smgr_unlink) (RelFileNode rnode);
|
||||||
int (*smgr_extend) (Relation reln, char *buffer);
|
int (*smgr_extend) (Relation reln, BlockNumber blocknum,
|
||||||
|
char *buffer);
|
||||||
int (*smgr_open) (Relation reln);
|
int (*smgr_open) (Relation reln);
|
||||||
int (*smgr_close) (Relation reln);
|
int (*smgr_close) (Relation reln);
|
||||||
int (*smgr_read) (Relation reln, BlockNumber blocknum,
|
int (*smgr_read) (Relation reln, BlockNumber blocknum,
|
||||||
@ -227,15 +228,20 @@ smgrunlink(int16 which, Relation reln)
|
|||||||
/*
|
/*
|
||||||
* smgrextend() -- Add a new block to a file.
|
* smgrextend() -- Add a new block to a file.
|
||||||
*
|
*
|
||||||
|
* The semantics are basically the same as smgrwrite(): write at the
|
||||||
|
* specified position. However, we are expecting to extend the
|
||||||
|
* relation (ie, blocknum is the current EOF), and so in case of
|
||||||
|
* failure we clean up by truncating.
|
||||||
|
*
|
||||||
* Returns SM_SUCCESS on success; aborts the current transaction on
|
* Returns SM_SUCCESS on success; aborts the current transaction on
|
||||||
* failure.
|
* failure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
smgrextend(int16 which, Relation reln, char *buffer)
|
smgrextend(int16 which, Relation reln, BlockNumber blocknum, char *buffer)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = (*(smgrsw[which].smgr_extend)) (reln, buffer);
|
status = (*(smgrsw[which].smgr_extend)) (reln, blocknum, buffer);
|
||||||
|
|
||||||
if (status == SM_FAIL)
|
if (status == SM_FAIL)
|
||||||
elog(ERROR, "cannot extend %s: %m.\n\tCheck free disk space.",
|
elog(ERROR, "cannot extend %s: %m.\n\tCheck free disk space.",
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: smgr.h,v 1.28 2001/03/22 04:01:09 momjian Exp $
|
* $Id: smgr.h,v 1.29 2001/05/10 20:38:49 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -28,7 +28,8 @@
|
|||||||
extern int smgrinit(void);
|
extern int smgrinit(void);
|
||||||
extern int smgrcreate(int16 which, Relation reln);
|
extern int smgrcreate(int16 which, Relation reln);
|
||||||
extern int smgrunlink(int16 which, Relation reln);
|
extern int smgrunlink(int16 which, Relation reln);
|
||||||
extern int smgrextend(int16 which, Relation reln, char *buffer);
|
extern int smgrextend(int16 which, Relation reln, BlockNumber blocknum,
|
||||||
|
char *buffer);
|
||||||
extern int smgropen(int16 which, Relation reln, bool failOK);
|
extern int smgropen(int16 which, Relation reln, bool failOK);
|
||||||
extern int smgrclose(int16 which, Relation reln);
|
extern int smgrclose(int16 which, Relation reln);
|
||||||
extern int smgrread(int16 which, Relation reln, BlockNumber blocknum,
|
extern int smgrread(int16 which, Relation reln, BlockNumber blocknum,
|
||||||
@ -60,7 +61,7 @@ extern void smgr_desc(char *buf, uint8 xl_info, char *rec);
|
|||||||
extern int mdinit(void);
|
extern int mdinit(void);
|
||||||
extern int mdcreate(Relation reln);
|
extern int mdcreate(Relation reln);
|
||||||
extern int mdunlink(RelFileNode rnode);
|
extern int mdunlink(RelFileNode rnode);
|
||||||
extern int mdextend(Relation reln, char *buffer);
|
extern int mdextend(Relation reln, BlockNumber blocknum, char *buffer);
|
||||||
extern int mdopen(Relation reln);
|
extern int mdopen(Relation reln);
|
||||||
extern int mdclose(Relation reln);
|
extern int mdclose(Relation reln);
|
||||||
extern int mdread(Relation reln, BlockNumber blocknum, char *buffer);
|
extern int mdread(Relation reln, BlockNumber blocknum, char *buffer);
|
||||||
@ -82,7 +83,7 @@ extern SPINLOCK MMCacheLock;
|
|||||||
extern int mminit(void);
|
extern int mminit(void);
|
||||||
extern int mmcreate(Relation reln);
|
extern int mmcreate(Relation reln);
|
||||||
extern int mmunlink(RelFileNode rnode);
|
extern int mmunlink(RelFileNode rnode);
|
||||||
extern int mmextend(Relation reln, char *buffer);
|
extern int mmextend(Relation reln, BlockNumber blocknum, char *buffer);
|
||||||
extern int mmopen(Relation reln);
|
extern int mmopen(Relation reln);
|
||||||
extern int mmclose(Relation reln);
|
extern int mmclose(Relation reln);
|
||||||
extern int mmread(Relation reln, BlockNumber blocknum, char *buffer);
|
extern int mmread(Relation reln, BlockNumber blocknum, char *buffer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user