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

Commit833d481

Browse files
committed
fix warnings
1 parent612fa02 commit833d481

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ copy_file(char *fromfile, char *tofile)
192192
* cache and hopefully get the kernel to start writing them out before
193193
* the fsync comes.
194194
*/
195-
pg_flush_data(dstfd,offset,nbytes);
195+
pg_flush_data(dstfd,offset,nbytes, false);
196196
}
197197

198198
if (CloseTransientFile(dstfd))

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,10 @@ pg_fdatasync(int fd)
395395
* flushed.
396396
*/
397397
void
398-
pg_flush_data(intfd,off_toffset,off_tnbytes)
398+
pg_flush_data(intfd,off_toffset,off_tnbytes,boolisdir)
399399
{
400+
(void)isdir;/* this can be unused on some archs */
401+
400402
/*
401403
* Right now file flushing is primarily used to avoid making later
402404
* fsync()/fdatasync() calls have a less impact. Thus don't trigger
@@ -452,15 +454,26 @@ pg_flush_data(int fd, off_t offset, off_t nbytes)
452454
* (msync()), and then remove the mapping again (munmap()).
453455
*/
454456

457+
/* mmap will not work with dirs */
458+
if (isdir)
459+
return;
460+
455461
/* mmap() need exact length when we want to map whole file */
456462
if ((offset==0)&& (nbytes==0))
457463
{
458-
intpagesize=getpagesize();
459-
nbytes= (lseek(fd,offset,SEEK_END)/pagesize+1)*pagesize;
464+
intpagesize=sysconf(_SC_PAGESIZE);
465+
466+
nbytes=lseek(fd,0,SEEK_END);
460467
if (nbytes<0)
461468
ereport(WARNING,
462469
(errcode_for_file_access(),
463470
errmsg("could not determine dirty data size: %m")));
471+
472+
/* aling to pagesize with underestimation */
473+
nbytes= (nbytes/pagesize)*pagesize;
474+
475+
if(nbytes==0)
476+
return;
464477
}
465478

466479
p=mmap(NULL,nbytes,
@@ -1526,7 +1539,7 @@ FileWriteback(File file, off_t offset, int amount)
15261539
if (returnCode<0)
15271540
return;
15281541

1529-
pg_flush_data(VfdCache[file].fd,offset,amount);
1542+
pg_flush_data(VfdCache[file].fd,offset,amount, false);
15301543
}
15311544

15321545
int
@@ -2932,7 +2945,7 @@ pre_sync_fname(const char *fname, bool isdir, int elevel)
29322945
* pg_flush_data() ignores errors, which is ok because this is only a
29332946
* hint.
29342947
*/
2935-
pg_flush_data(fd,0,0);
2948+
pg_flush_data(fd,0,0,isdir);
29362949

29372950
(void)CloseTransientFile(fd);
29382951
}

‎src/include/storage/fd.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extern intpg_fsync(int fd);
116116
externintpg_fsync_no_writethrough(intfd);
117117
externintpg_fsync_writethrough(intfd);
118118
externintpg_fdatasync(intfd);
119-
externvoidpg_flush_data(intfd,off_toffset,off_tamount);
119+
externvoidpg_flush_data(intfd,off_toffset,off_tamount,boolisdir);
120120
externvoidfsync_fname(constchar*fname,boolisdir);
121121
externintdurable_rename(constchar*oldfile,constchar*newfile,intloglevel);
122122
externintdurable_link_or_rename(constchar*oldfile,constchar*newfile,intloglevel);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp