We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent101fd93 commit612fa02Copy full SHA for 612fa02
src/backend/storage/file/fd.c
@@ -451,8 +451,20 @@ pg_flush_data(int fd, off_t offset, off_t nbytes)
451
* We map the file (mmap()), tell the kernel to sync back the contents
452
* (msync()), and then remove the mapping again (munmap()).
453
*/
454
+
455
+/* mmap() need exact length when we want to map whole file */
456
+if ((offset==0)&& (nbytes==0))
457
+{
458
+intpagesize=getpagesize();
459
+nbytes= (lseek(fd,offset,SEEK_END)/pagesize+1)*pagesize;
460
+if (nbytes<0)
461
+ereport(WARNING,
462
+(errcode_for_file_access(),
463
+errmsg("could not determine dirty data size: %m")));
464
+}
465
466
p=mmap(NULL,nbytes,
-PROT_READ |PROT_WRITE,MAP_SHARED,
467
+PROT_READ,MAP_SHARED,
468
fd,offset);
469
if (p==MAP_FAILED)
470
{