summaryrefslogtreecommitdiff
path: root/libpager/pager-bulk.c
diff options
context:
space:
mode:
authorMilos Nikic <nikic.milos@gmail.com>2025-08-25 21:38:08 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2025-09-01 21:21:08 +0200
commit5eda2dbdb1a3eaae70178df55b7e3d7508b15c9b (patch)
tree508ed0bd02868f4a31de63a60b5ea848ffcabd7b /libpager/pager-bulk.c
parent2ccdc970f7d83a4a5fc3c2c6e89f94a10e36d2ac (diff)
libpager, ext2fs: add bulk page write supportHEADmaster
Introduce a new pager_write_pages() entry point, allowing filesystems to implement multi-page writes in one call. libpager will attempt to coalesce contiguous dirty pages and call this bulk interface; if it is unsupported or only partially completes, the remaining pages are handled by the existing per-page path. ext2fs now provides file_pager_write_pages(), implemented using a small chunked write loop (currently 2 blocks per chunk) under alloc_lock. This reduces lock/unlock cycles, improves batching of store_write() calls, and avoids starvation by yielding between chunks. Other filesystems may continue using pager_write_page() unchanged. Test write 128 MiB dirty file: Before this change: store_write calls: 32,874; avg: 4,096 B After this change (coalesced runs, cap=128): store_write calls: 1,300; avg 103 KiB (~25 times fewer calls, ~25 times larger writes)
Diffstat (limited to 'libpager/pager-bulk.c')
-rw-r--r--libpager/pager-bulk.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/libpager/pager-bulk.c b/libpager/pager-bulk.c
new file mode 100644
index 00000000..8dba01b5
--- /dev/null
+++ b/libpager/pager-bulk.c
@@ -0,0 +1,37 @@
+/* pager-bulk.c Default (dummy) implementation of bulk page write.
+
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ Written by Milos Nikic.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd; if not, see <https://www.gnu.org/licenses/>. */
+
+#include <libpager/pager.h>
+#include "priv.h"
+
+/* Default dummy implementation of pager_write_pages. */
+__attribute__((weak)) error_t
+pager_write_pages (struct user_pager_info *upi,
+ vm_offset_t offset,
+ vm_address_t data, vm_size_t length, vm_size_t *written)
+{
+ (void) upi;
+ (void) offset;
+ (void) data;
+ (void) length;
+ if (written)
+ *written = 0;
+ return EOPNOTSUPP;
+}