[PATCH] libstore: add sync function for file, mvol, remap and stripe
bug-hurd
Top
][
All Lists
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
][
Date Index
][
Thread Index
[PATCH] libstore: add sync function for file, mvol, remap and stripe
From
Milos Nikic
Subject
[PATCH] libstore: add sync function for file, mvol, remap and stripe
Date
Mon, 26 Jan 2026 21:22:04 -0800
Along side the store_sync this adds sync to other often used stores.
---
libstore/file.c | 9 ++++++++-
libstore/mvol.c | 20 +++++++++++++++++++-
libstore/remap.c | 9 ++++++++-
libstore/stripe.c | 21 ++++++++++++++++++++-
4 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/libstore/file.c b/libstore/file.c
index 80d6812a..5f6d7a46 100644
--- a/libstore/file.c
+++ b/libstore/file.c
@@ -76,6 +76,12 @@ file_write (struct store *store,
return io_write (store->port, (void *) buf, len, addr * bsize, amount);

+static error_t
+file_store_sync (struct store *store)
+{
+ return file_sync (store->port, 1, 0);
+}
static error_t
file_store_set_size (struct store *store, size_t newsize)
@@ -225,7 +231,8 @@ store_file_class =
STORAGE_HURD_FILE, "file", file_read, file_write, file_store_set_size,
store_std_leaf_allocate_encoding, store_std_leaf_encode, file_decode,
- file_set_flags, file_clear_flags, 0, 0, 0, file_open, 0, file_map
+ file_set_flags, file_clear_flags, 0, 0, 0, file_open, 0, file_map,
+ file_store_sync
};
STORE_STD_CLASS (file);

diff --git a/libstore/mvol.c b/libstore/mvol.c
index ee1526be..06d894b1 100644
--- a/libstore/mvol.c
+++ b/libstore/mvol.c
@@ -70,6 +70,23 @@ mvol_write (struct store *store,
return err;

+static error_t
+mvol_sync (struct store *store)
+{
+ size_t i;
+ error_t err = 0;
+ /* We iterate through all known volumes to ensure
+ even inactive volumes are flushed to disk. */
+ for (i = 0; i < store->num_children; i++)
+ {
+ error_t e = store_sync (store->children[i]);
+ if (e)
+ err = e;
+ }
+ return err;
+}
static error_t
mvol_set_size (struct store *store, size_t newsize)
@@ -89,7 +106,8 @@ store_mvol_class =
-1, "mvol", mvol_read, mvol_write, mvol_set_size,
0, 0, 0,
- store_set_child_flags, store_clear_child_flags, 0, 0, mvol_remap
+ store_set_child_flags, store_clear_child_flags, 0, 0, mvol_remap,
+ 0, 0, 0, mvol_sync
};
STORE_STD_CLASS (mvol);

diff --git a/libstore/remap.c b/libstore/remap.c
index de21812e..54ae31c2 100644
--- a/libstore/remap.c
+++ b/libstore/remap.c
@@ -41,6 +41,12 @@ remap_write (struct store *store,
return store_write (store->children[0], addr, buf, len, amount);

+static error_t
+remap_sync (struct store * store)
+{
+ return store_sync (store->children[0]);
+}
static error_t
remap_set_size (struct store *store, size_t newsize)
@@ -210,7 +216,8 @@ store_remap_class =
remap_allocate_encoding, remap_encode, remap_decode,
store_set_child_flags, store_clear_child_flags,
NULL, NULL, NULL, /* cleanup, clone, remap */
- remap_open, remap_validate_name
+ remap_open, remap_validate_name,
+ NULL, remap_sync
};
STORE_STD_CLASS (remap);

diff --git a/libstore/stripe.c b/libstore/stripe.c
index e9c58466..7e437f86 100644
--- a/libstore/stripe.c
+++ b/libstore/stripe.c
@@ -57,6 +57,24 @@ stripe_write (struct store *store,
store_write (stripe, addr_adj (addr, store, stripe), buf, len, amount);

+static error_t
+stripe_sync (struct store *store)
+{
+ size_t i;
+ error_t err = 0;
+ for (i = 0; i < store->num_children; i++)
+ {
+ error_t e = store_sync (store->children[i]);
+ /* If any child fails, we record the error but continue
+ syncing the others to maximize data safety. */
+ if (e)
+ err = e;
+ }
+ return err;
+}
error_t
stripe_set_size (struct store *store, size_t newsize)
@@ -113,7 +131,8 @@ store_ileave_class =
STORAGE_INTERLEAVE, "interleave", stripe_read, stripe_write, stripe_set_size,
ileave_allocate_encoding, ileave_encode, ileave_decode,
- store_set_child_flags, store_clear_child_flags, 0, 0, stripe_remap
+ store_set_child_flags, store_clear_child_flags, 0, 0, stripe_remap,
+ 0, 0, 0, stripe_sync
};
STORE_STD_CLASS (ileave);

--
2.52.0
[Prev in Thread]
Current Thread
Next in Thread
[PATCH] libstore: add sync function for file, mvol, remap and stripe
Milos Nikic
<=
Re: [PATCH] libstore: add sync function for file, mvol, remap and stripe
Milos Nikic
2026/01/27
Re: [PATCH] libstore: add sync function for file, mvol, remap and stripe
Samuel Thibault
2026/01/27
Re: [PATCH] libstore: add sync function for file, mvol, remap and stripe
Milos Nikic
2026/01/27
Re: [PATCH] libstore: add sync function for file, mvol, remap and stripe
Samuel Thibault
2026/01/27
Prev by Date:
Re: [PATCH] libstore, rumpdisk: Add write barrier support
Next by Date:
Re: [PATCH] ext2: support 64 bit time
Previous by thread:
[PATCH 2/2] httpfs: handle 3xx, 4xx, 5xx HTTP status codes
Next by thread:
Re: [PATCH] libstore: add sync function for file, mvol, remap and stripe
Index(es):
Date
Thread