From a8424a71d70e2f5c54d9e2aab8338cf9547b15b4 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 20 Jun 2023 18:24:34 +0300 Subject: [PATCH] mdbox: Fix fdatasync() path when saving mails It was supposed to be called on the parent directory of where mails were written, i.e. storage/ directory. The previous code was instead calling it on the mailbox-specific directory (similarly to sdbox) where nothing was written. --- src/lib-storage/index/dbox-multi/mdbox-save.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib-storage/index/dbox-multi/mdbox-save.c b/src/lib-storage/index/dbox-multi/mdbox-save.c index beefc07bb7..fdffbbf22d 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-save.c +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c @@ -374,7 +374,9 @@ void mdbox_transaction_save_commit_post(struct mail_save_context *_ctx, struct mail_index_transaction_commit_result *result) { struct mdbox_save_context *ctx = MDBOX_SAVECTX(_ctx); - struct mail_storage *storage = _ctx->transaction->box->storage; + struct mail_storage *_storage = _ctx->transaction->box->storage; + struct mdbox_storage *storage = + container_of(_storage, struct mdbox_storage, storage.storage); _ctx->transaction = NULL; /* transaction is already freed */ @@ -397,12 +399,11 @@ void mdbox_transaction_save_commit_post(struct mail_save_context *_ctx, was already written at this point. */ (void)mdbox_map_atomic_finish(&ctx->atomic); - if (storage->set->parsed_fsync_mode != FSYNC_MODE_NEVER) { - const char *box_path = mailbox_get_path(&ctx->mbox->box); - - if (fdatasync_path(box_path) < 0) { + if (_storage->set->parsed_fsync_mode != FSYNC_MODE_NEVER) { + if (fdatasync_path(storage->storage_dir) < 0) { mailbox_set_critical(_ctx->transaction->box, - "fdatasync_path(%s) failed: %m", box_path); + "fdatasync_path(%s) failed: %m", + storage->storage_dir); } } mdbox_transaction_save_rollback(_ctx); -- 2.47.3