From: Timo Sirainen Date: Tue, 20 Jun 2023 15:24:34 +0000 (+0300) Subject: mdbox: Fix fdatasync() path when saving mails X-Git-Tag: 2.3.21~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a8424a71d70e2f5c54d9e2aab8338cf9547b15b4;p=thirdparty%2Fdovecot%2Fcore.git 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. --- 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);