Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit95ef43c

Browse files
committed
Widen amount-to-flush arguments of FileWriteback and callers.
It's silly to define these counts as narrower than they might somedayneed to be. Also, I believe that the BLCKSZ * nflush calculation inmdwriteback was capable of overflowing an int.
1 parentfa11a09 commit95ef43c

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

‎src/backend/storage/file/fd.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,28 +1538,28 @@ FilePrefetch(File file, off_t offset, int amount)
15381538
}
15391539

15401540
void
1541-
FileWriteback(Filefile,off_toffset,intamount)
1541+
FileWriteback(Filefile,off_toffset,off_tnbytes)
15421542
{
15431543
intreturnCode;
15441544

15451545
Assert(FileIsValid(file));
15461546

1547-
DO_DB(elog(LOG,"FileWriteback: %d (%s) "INT64_FORMAT"%d",
1547+
DO_DB(elog(LOG,"FileWriteback: %d (%s) "INT64_FORMAT""INT64_FORMAT,
15481548
file,VfdCache[file].fileName,
1549-
(int64)offset,amount));
1549+
(int64)offset,(int64)nbytes));
15501550

15511551
/*
1552-
* Caution: do not call pg_flush_data withamount = 0, it could trash the
1553-
* file's seek position.
1552+
* Caution: do not call pg_flush_data withnbytes = 0, it could trash the
1553+
* file's seek position. We prefer to define that as a no-op here.
15541554
*/
1555-
if (amount <=0)
1555+
if (nbytes <=0)
15561556
return;
15571557

15581558
returnCode=FileAccess(file);
15591559
if (returnCode<0)
15601560
return;
15611561

1562-
pg_flush_data(VfdCache[file].fd,offset,amount);
1562+
pg_flush_data(VfdCache[file].fd,offset,nbytes);
15631563
}
15641564

15651565
int

‎src/backend/storage/smgr/md.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -669,15 +669,16 @@ mdprefetch(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum)
669669
* considerably more efficient than doing so individually.
670670
*/
671671
void
672-
mdwriteback(SMgrRelationreln,ForkNumberforknum,BlockNumberblocknum,intnblocks)
672+
mdwriteback(SMgrRelationreln,ForkNumberforknum,
673+
BlockNumberblocknum,BlockNumbernblocks)
673674
{
674675
/*
675676
* Issue flush requests in as few requests as possible; have to split at
676677
* segment boundaries though, since those are actually separate files.
677678
*/
678-
while (nblocks!=0)
679+
while (nblocks>0)
679680
{
680-
intnflush=nblocks;
681+
BlockNumbernflush=nblocks;
681682
off_tseekpos;
682683
MdfdVec*v;
683684
intsegnum_start,
@@ -706,7 +707,7 @@ mdwriteback(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum, int nbl
706707

707708
seekpos= (off_t)BLCKSZ*(blocknum % ((BlockNumber)RELSEG_SIZE));
708709

709-
FileWriteback(v->mdfd_vfd,seekpos,BLCKSZ*nflush);
710+
FileWriteback(v->mdfd_vfd,seekpos,(off_t)BLCKSZ*nflush);
710711

711712
nblocks-=nflush;
712713
blocknum+=nflush;

‎src/backend/storage/smgr/smgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ typedef struct f_smgr
5454
void(*smgr_write) (SMgrRelationreln,ForkNumberforknum,
5555
BlockNumberblocknum,char*buffer,boolskipFsync);
5656
void(*smgr_writeback) (SMgrRelationreln,ForkNumberforknum,
57-
BlockNumberblocknum,intnblocks);
57+
BlockNumberblocknum,BlockNumbernblocks);
5858
BlockNumber (*smgr_nblocks) (SMgrRelationreln,ForkNumberforknum);
5959
void(*smgr_truncate) (SMgrRelationreln,ForkNumberforknum,
6060
BlockNumbernblocks);
@@ -658,7 +658,7 @@ smgrwrite(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
658658
*/
659659
void
660660
smgrwriteback(SMgrRelationreln,ForkNumberforknum,BlockNumberblocknum,
661-
intnblocks)
661+
BlockNumbernblocks)
662662
{
663663
(*(smgrsw[reln->smgr_which].smgr_writeback)) (reln,forknum,blocknum,
664664
nblocks);

‎src/include/storage/fd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ extern intFileWrite(File file, char *buffer, int amount);
7474
externintFileSync(Filefile);
7575
externoff_tFileSeek(Filefile,off_toffset,intwhence);
7676
externintFileTruncate(Filefile,off_toffset);
77-
externvoidFileWriteback(Filefile,off_toffset,intamount);
77+
externvoidFileWriteback(Filefile,off_toffset,off_tnbytes);
7878
externchar*FilePathName(Filefile);
7979
externintFileGetRawDesc(Filefile);
8080
externintFileGetRawFlags(Filefile);

‎src/include/storage/smgr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ extern void smgrread(SMgrRelation reln, ForkNumber forknum,
9797
externvoidsmgrwrite(SMgrRelationreln,ForkNumberforknum,
9898
BlockNumberblocknum,char*buffer,boolskipFsync);
9999
externvoidsmgrwriteback(SMgrRelationreln,ForkNumberforknum,
100-
BlockNumberblocknum,intnblocks);
100+
BlockNumberblocknum,BlockNumbernblocks);
101101
externBlockNumbersmgrnblocks(SMgrRelationreln,ForkNumberforknum);
102102
externvoidsmgrtruncate(SMgrRelationreln,ForkNumberforknum,
103103
BlockNumbernblocks);
@@ -125,7 +125,7 @@ extern void mdread(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknum,
125125
externvoidmdwrite(SMgrRelationreln,ForkNumberforknum,
126126
BlockNumberblocknum,char*buffer,boolskipFsync);
127127
externvoidmdwriteback(SMgrRelationreln,ForkNumberforknum,
128-
BlockNumberblocknum,intnblocks);
128+
BlockNumberblocknum,BlockNumbernblocks);
129129
externBlockNumbermdnblocks(SMgrRelationreln,ForkNumberforknum);
130130
externvoidmdtruncate(SMgrRelationreln,ForkNumberforknum,
131131
BlockNumbernblocks);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp