Package: db5.3 / 5.3.28-12+deb9u1

mmap_extend-mode-requires-page-aligned-extends.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From: Andy Whitcroft <apw@canonical.com>
Subject: [PATCH] MMAP_EXTEND mode requires we extend in full system page increments
Date: Wed, 12 Mar 2014 11:58:31 +0100

When extending a mmap file we must ensure we extend by full system pages,
otherwise there is a risk (when the filesystem page size is smaller than
the system page size) that we will not allocate disk extents to store
the memory and it will be lost resulting in data loss.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: C├ędric Le Goater <clg@fr.ibm.com>

---
 env_file.c |    9 +++++++++
 1 file changed, 9 insertions(+)

--- db5.3.orig/src/env/env_file.c
+++ db5.3/src/env/env_file.c
@@ -28,6 +28,15 @@ __db_file_extend(env, fhp, size)
 	int ret;
 	char buf;
 
+#ifdef HAVE_MMAP_EXTEND
+	/*
+	 * We have to ensure we extend a mmap'd segment a full memory page at
+	 * a time or risk the end of the page not having any filesystem blocks
+	 * associated resulting in the data loss.
+	 */
+	size = DB_ALIGN(size, getpagesize()) - 1;
+#endif
+
 	buf = '\0';
 	/*
 	 * Extend the file by writing the last page.  If the region is >4Gb,