Skip to content

Commit da031ca

Browse files
committed
fix with Freund's suggestion
1 parent 63125b1 commit da031ca

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
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, false);
195+
pg_flush_data(dstfd, offset, nbytes);
196196
}
197197

198198
if (CloseTransientFile(dstfd))

src/backend/storage/file/fd.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,8 @@ pg_fdatasync(int fd)
395395
* flushed.
396396
*/
397397
void
398-
pg_flush_data(int fd, off_t offset, off_t nbytes, bool isdir)
398+
pg_flush_data(int fd, off_t offset, off_t nbytes)
399399
{
400-
(void) isdir; /* this can be unused on some archs */
401-
402400
/*
403401
* Right now file flushing is primarily used to avoid making later
404402
* fsync()/fdatasync() calls have a less impact. Thus don't trigger
@@ -454,10 +452,6 @@ pg_flush_data(int fd, off_t offset, off_t nbytes, bool isdir)
454452
* (msync()), and then remove the mapping again (munmap()).
455453
*/
456454

457-
/* mmap() will not work with dirs */
458-
if (isdir)
459-
return;
460-
461455
/* mmap() need exact length when we want to map whole file */
462456
if ((offset == 0) && (nbytes == 0))
463457
{
@@ -472,7 +466,7 @@ pg_flush_data(int fd, off_t offset, off_t nbytes, bool isdir)
472466
/* aling to pagesize with underestimation */
473467
nbytes = (nbytes/pagesize)*pagesize;
474468

475-
if(nbytes == 0)
469+
if (nbytes == 0)
476470
return;
477471
}
478472

@@ -1539,7 +1533,7 @@ FileWriteback(File file, off_t offset, int amount)
15391533
if (returnCode < 0)
15401534
return;
15411535

1542-
pg_flush_data(VfdCache[file].fd, offset, amount, false);
1536+
pg_flush_data(VfdCache[file].fd, offset, amount);
15431537
}
15441538

15451539
int
@@ -2945,7 +2939,8 @@ pre_sync_fname(const char *fname, bool isdir, int elevel)
29452939
* pg_flush_data() ignores errors, which is ok because this is only a
29462940
* hint.
29472941
*/
2948-
pg_flush_data(fd, 0, 0, isdir);
2942+
if (!isdir)
2943+
pg_flush_data(fd, 0, 0);
29492944

29502945
(void) CloseTransientFile(fd);
29512946
}

src/include/storage/fd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extern int pg_fsync(int fd);
116116
extern int pg_fsync_no_writethrough(int fd);
117117
extern int pg_fsync_writethrough(int fd);
118118
extern int pg_fdatasync(int fd);
119-
extern void pg_flush_data(int fd, off_t offset, off_t amount, bool isdir);
119+
extern void pg_flush_data(int fd, off_t offset, off_t amount);
120120
extern void fsync_fname(const char *fname, bool isdir);
121121
extern int durable_rename(const char *oldfile, const char *newfile, int loglevel);
122122
extern int durable_link_or_rename(const char *oldfile, const char *newfile, int loglevel);

0 commit comments

Comments
 (0)