summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund2016-02-19 23:03:02 +0000
committerAndres Freund2016-02-19 23:03:02 +0000
commitbf6ad4832b08ee1e903212208c0511d6cc30a74b (patch)
treeab319917f2f6fceee6bf17f90a1ad06b3bbaf525
parent39208e12c947183f5ed565b94bc006eed0138136 (diff)
fixup! allow to trigger kernel writeback after a configurable number of writes.checkpoint-flush
mmap and fadvise path didn't get the memo about restructuring...
-rw-r--r--src/backend/storage/file/fd.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 5b8a765760..8759400542 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -443,36 +443,33 @@ pg_flush_data(int fd, off_t offset, off_t nbytes)
* We map the file (mmap()), tell the kernel to sync back the contents
* (msync()), and then remove the mapping again (munmap()).
*/
- p = mmap(NULL, context->nbytes,
+ p = mmap(NULL, nbytes,
PROT_READ | PROT_WRITE, MAP_SHARED,
- context->fd, context->offset);
+ fd, offset);
if (p == MAP_FAILED)
{
ereport(WARNING,
(errcode_for_file_access(),
- errmsg("could not mmap while flushing dirty data in file \"%s\": %m",
- context->filename ? context->filename : "")));
- goto out;
+ errmsg("could not mmap while flushing dirty data: %m")));
+ return;
}
- rc = msync(p, context->nbytes, MS_ASYNC);
+ rc = msync(p, nbytes, MS_ASYNC);
if (rc != 0)
{
ereport(WARNING,
(errcode_for_file_access(),
- errmsg("could not flush dirty data in file \"%s\": %m",
- context->filename ? context->filename : "")));
+ errmsg("could not flush dirty data: %m")));
/* NB: need to fall through to munmap()! */
}
- rc = munmap(p, context->nbytes);
+ rc = munmap(p, nbytes);
if (rc != 0)
{
/* FATAL error because mapping would remain */
ereport(FATAL,
(errcode_for_file_access(),
- errmsg("could not munmap while flushing blocks in file \"%s\": %m",
- context->filename ? context->filename : "")));
+ errmsg("could not munmap while flushing blocks: %m")));
}
}
#elif defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
@@ -487,17 +484,15 @@ pg_flush_data(int fd, off_t offset, off_t nbytes)
* preferrable method.
*/
- rc = posix_fadvise(context->fd, context->offset, context->nbytes,
- POSIX_FADV_DONTNEED);
+ rc = posix_fadvise(fd, offset, nbytes, POSIX_FADV_DONTNEED);
/* don't error out, this is just a performance optimization */
if (rc != 0)
{
ereport(WARNING,
(errcode_for_file_access(),
- errmsg("could not flush dirty data in file \"%s\": %m",
- context->filename ? context->filename : "")));
- goto out;
+ errmsg("could not flush dirty data: %m")));
+ return;
}
}
#else