mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Widen amount-to-flush arguments of FileWriteback and callers.
It's silly to define these counts as narrower than they might someday need to be. Also, I believe that the BLCKSZ * nflush calculation in mdwriteback was capable of overflowing an int.
This commit is contained in:
parent
fa11a09fed
commit
95ef43c430
@ -1538,28 +1538,28 @@ FilePrefetch(File file, off_t offset, int amount)
|
||||
}
|
||||
|
||||
void
|
||||
FileWriteback(File file, off_t offset, int amount)
|
||||
FileWriteback(File file, off_t offset, off_t nbytes)
|
||||
{
|
||||
int returnCode;
|
||||
|
||||
Assert(FileIsValid(file));
|
||||
|
||||
DO_DB(elog(LOG, "FileWriteback: %d (%s) " INT64_FORMAT " %d",
|
||||
DO_DB(elog(LOG, "FileWriteback: %d (%s) " INT64_FORMAT " " INT64_FORMAT,
|
||||
file, VfdCache[file].fileName,
|
||||
(int64) offset, amount));
|
||||
(int64) offset, (int64) nbytes));
|
||||
|
||||
/*
|
||||
* Caution: do not call pg_flush_data with amount = 0, it could trash the
|
||||
* file's seek position.
|
||||
* Caution: do not call pg_flush_data with nbytes = 0, it could trash the
|
||||
* file's seek position. We prefer to define that as a no-op here.
|
||||
*/
|
||||
if (amount <= 0)
|
||||
if (nbytes <= 0)
|
||||
return;
|
||||
|
||||
returnCode = FileAccess(file);
|
||||
if (returnCode < 0)
|
||||
return;
|
||||
|
||||
pg_flush_data(VfdCache[file].fd, offset, amount);
|
||||
pg_flush_data(VfdCache[file].fd, offset, nbytes);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -669,15 +669,16 @@ mdprefetch(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum)
|
||||
* considerably more efficient than doing so individually.
|
||||
*/
|
||||
void
|
||||
mdwriteback(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, int nblocks)
|
||||
mdwriteback(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber blocknum, BlockNumber nblocks)
|
||||
{
|
||||
/*
|
||||
* Issue flush requests in as few requests as possible; have to split at
|
||||
* segment boundaries though, since those are actually separate files.
|
||||
*/
|
||||
while (nblocks != 0)
|
||||
while (nblocks > 0)
|
||||
{
|
||||
int nflush = nblocks;
|
||||
BlockNumber nflush = nblocks;
|
||||
off_t seekpos;
|
||||
MdfdVec *v;
|
||||
int segnum_start,
|
||||
@ -706,7 +707,7 @@ mdwriteback(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, int nbl
|
||||
|
||||
seekpos = (off_t) BLCKSZ *(blocknum % ((BlockNumber) RELSEG_SIZE));
|
||||
|
||||
FileWriteback(v->mdfd_vfd, seekpos, BLCKSZ * nflush);
|
||||
FileWriteback(v->mdfd_vfd, seekpos, (off_t) BLCKSZ * nflush);
|
||||
|
||||
nblocks -= nflush;
|
||||
blocknum += nflush;
|
||||
|
@ -54,7 +54,7 @@ typedef struct f_smgr
|
||||
void (*smgr_write) (SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber blocknum, char *buffer, bool skipFsync);
|
||||
void (*smgr_writeback) (SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber blocknum, int nblocks);
|
||||
BlockNumber blocknum, BlockNumber nblocks);
|
||||
BlockNumber (*smgr_nblocks) (SMgrRelation reln, ForkNumber forknum);
|
||||
void (*smgr_truncate) (SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber nblocks);
|
||||
@ -658,7 +658,7 @@ smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
||||
*/
|
||||
void
|
||||
smgrwriteback(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
||||
int nblocks)
|
||||
BlockNumber nblocks)
|
||||
{
|
||||
(*(smgrsw[reln->smgr_which].smgr_writeback)) (reln, forknum, blocknum,
|
||||
nblocks);
|
||||
|
@ -74,7 +74,7 @@ extern int FileWrite(File file, char *buffer, int amount);
|
||||
extern int FileSync(File file);
|
||||
extern off_t FileSeek(File file, off_t offset, int whence);
|
||||
extern int FileTruncate(File file, off_t offset);
|
||||
extern void FileWriteback(File file, off_t offset, int amount);
|
||||
extern void FileWriteback(File file, off_t offset, off_t nbytes);
|
||||
extern char *FilePathName(File file);
|
||||
extern int FileGetRawDesc(File file);
|
||||
extern int FileGetRawFlags(File file);
|
||||
|
@ -97,7 +97,7 @@ extern void smgrread(SMgrRelation reln, ForkNumber forknum,
|
||||
extern void smgrwrite(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber blocknum, char *buffer, bool skipFsync);
|
||||
extern void smgrwriteback(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber blocknum, int nblocks);
|
||||
BlockNumber blocknum, BlockNumber nblocks);
|
||||
extern BlockNumber smgrnblocks(SMgrRelation reln, ForkNumber forknum);
|
||||
extern void smgrtruncate(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber nblocks);
|
||||
@ -125,7 +125,7 @@ extern void mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
|
||||
extern void mdwrite(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber blocknum, char *buffer, bool skipFsync);
|
||||
extern void mdwriteback(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber blocknum, int nblocks);
|
||||
BlockNumber blocknum, BlockNumber nblocks);
|
||||
extern BlockNumber mdnblocks(SMgrRelation reln, ForkNumber forknum);
|
||||
extern void mdtruncate(SMgrRelation reln, ForkNumber forknum,
|
||||
BlockNumber nblocks);
|
||||
|
Loading…
x
Reference in New Issue
Block a user