changeset 11751:668e810e6578 HEAD

mdbox: Storage rebuild changes weren't actually being committed to disk.
author Timo Sirainen <tss@iki.fi>
date Wed, 07 Jul 2010 15:52:16 +0100
parents b0e0d4537496
children 6571b3a9c44f
files src/lib-storage/index/dbox-multi/mdbox-map.c src/lib-storage/index/dbox-multi/mdbox-map.h src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c src/lib-storage/index/dbox-multi/mdbox-sync.c
diffstat 4 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-multi/mdbox-map.c	Wed Jul 07 15:32:44 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-map.c	Wed Jul 07 15:52:16 2010 +0100
@@ -474,6 +474,11 @@
 	atomic->success = FALSE;
 }
 
+void mdbox_map_atomic_set_success(struct mdbox_map_atomic_context *atomic)
+{
+	atomic->success = TRUE;
+}
+
 int mdbox_map_atomic_finish(struct mdbox_map_atomic_context **_atomic)
 {
 	struct mdbox_map_atomic_context *atomic = *_atomic;
--- a/src/lib-storage/index/dbox-multi/mdbox-map.h	Wed Jul 07 15:32:44 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-map.h	Wed Jul 07 15:52:16 2010 +0100
@@ -69,6 +69,10 @@
 /* When finish() is called, rollback the changes. If data was already written
    to map's transaction log, this desyncs the map and causes a rebuild */
 void mdbox_map_atomic_set_failed(struct mdbox_map_atomic_context *atomic);
+/* Mark this atomic as having succeeded. This is internally done if
+   transaction or append is committed within this atomic, but not when the
+   atomic is used standalone. */
+void mdbox_map_atomic_set_success(struct mdbox_map_atomic_context *atomic);
 /* Commit/rollback changes within this atomic context. */
 int mdbox_map_atomic_finish(struct mdbox_map_atomic_context **atomic);
 
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c	Wed Jul 07 15:32:44 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c	Wed Jul 07 15:52:16 2010 +0100
@@ -908,6 +908,7 @@
 
 	atomic = mdbox_map_atomic_begin(storage->map);
 	ret = mdbox_storage_rebuild_in_context(storage, atomic);
+	mdbox_map_atomic_set_success(atomic);
 	if (mdbox_map_atomic_finish(&atomic) < 0)
 		ret = -1;
 	return ret;
--- a/src/lib-storage/index/dbox-multi/mdbox-sync.c	Wed Jul 07 15:32:44 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-sync.c	Wed Jul 07 15:52:16 2010 +0100
@@ -308,6 +308,8 @@
 	ret = mdbox_sync_begin(mbox, flags, atomic, &sync_ctx);
 	if (ret == 0 && sync_ctx != NULL)
 		ret = mdbox_sync_finish(&sync_ctx, TRUE);
+	if (ret == 0)
+		mdbox_map_atomic_set_success(atomic);
 	if (mdbox_map_atomic_finish(&atomic) < 0)
 		ret = -1;
 	return ret;