0
0
mirror of https://github.com/openwrt/packages.git synced 2025-02-07 08:09:51 +00:00
packages/libs/db/patches/140-mmap_extend-mode-requires-page-aligned-extends.patch
Rosen Penev e7badaa6cb db47: replace with db
There's no need to maintain an old version.

Removed all patches as they are all upstream.

Import new ones from Arch, Debian, and OpenEmbedded.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2024-08-22 20:41:15 -07:00

35 lines
1.1 KiB
Diff

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(+)
--- a/src/env/env_file.c
+++ b/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,