blob: f6f855bf8f74a50886a94e450163cfe0a3468da9 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From: Andy Whitcroft <apw@canonical.com>
2Subject: [PATCH] MMAP_EXTEND mode requires we extend in full system page increments
3Date: Wed, 12 Mar 2014 11:58:31 +0100
4
5When extending a mmap file we must ensure we extend by full system pages,
6otherwise there is a risk (when the filesystem page size is smaller than
7the system page size) that we will not allocate disk extents to store
8the memory and it will be lost resulting in data loss.
9
10Signed-off-by: Andy Whitcroft <apw@canonical.com>
11Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
12
13---
14 env_file.c | 9 +++++++++
15 1 file changed, 9 insertions(+)
16
17--- a/src/env/env_file.c
18+++ b/src/env/env_file.c
19@@ -28,6 +28,15 @@ __db_file_extend(env, fhp, size)
20 int ret;
21 char buf;
22
23+#ifdef HAVE_MMAP_EXTEND
24+ /*
25+ * We have to ensure we extend a mmap'd segment a full memory page at
26+ * a time or risk the end of the page not having any filesystem blocks
27+ * associated resulting in the data loss.
28+ */
29+ size = DB_ALIGN(size, getpagesize()) - 1;
30+#endif
31+
32 buf = '\0';
33 /*
34 * Extend the file by writing the last page. If the region is >4Gb,