Mercurial > dovecot > core-2.2
changeset 12458:10c2540e91b9
lib-storage: If disable_reflink_copy_to=TRUE, disable hardlink/refcount copying.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 23 Nov 2010 15:59:09 +0000 |
parents | 490138318288 |
children | 94fd6fee57a1 |
files | src/lib-storage/index/dbox-multi/mdbox-save.c src/lib-storage/index/dbox-single/sdbox-copy.c src/lib-storage/index/maildir/maildir-copy.c src/lib-storage/mail-copy.c src/lib-storage/mail-copy.h src/lib-storage/mail-storage-private.h |
diffstat | 6 files changed, 22 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-multi/mdbox-save.c Tue Nov 23 15:30:32 2010 +0000 +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c Tue Nov 23 15:59:09 2010 +0000 @@ -408,7 +408,8 @@ ctx->ctx.finished = TRUE; - if (mail->box->storage != _ctx->transaction->box->storage) + if (mail->box->storage != _ctx->transaction->box->storage || + _ctx->transaction->box->disable_reflink_copy_to) return mail_storage_copy(_ctx, mail); src_mbox = (struct mdbox_mailbox *)mail->box;
--- a/src/lib-storage/index/dbox-single/sdbox-copy.c Tue Nov 23 15:30:32 2010 +0000 +++ b/src/lib-storage/index/dbox-single/sdbox-copy.c Tue Nov 23 15:59:09 2010 +0000 @@ -138,13 +138,6 @@ return 1; } -static bool -sdbox_compatible_file_modes(struct mailbox *box1, struct mailbox *box2) -{ - return box1->file_create_mode == box2->file_create_mode && - box1->file_create_gid == box2->file_create_gid; -} - int sdbox_copy(struct mail_save_context *_ctx, struct mail *mail) { struct dbox_save_context *ctx = (struct dbox_save_context *)_ctx; @@ -155,7 +148,7 @@ i_assert((_t->flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0); ctx->finished = TRUE; - if (sdbox_compatible_file_modes(&mbox->box, mail->box)) { + if (mail_storage_copy_can_use_hardlink(mail->box, &mbox->box)) { T_BEGIN { ret = sdbox_copy_hardlink(_ctx, mail); } T_END;
--- a/src/lib-storage/index/maildir/maildir-copy.c Tue Nov 23 15:30:32 2010 +0000 +++ b/src/lib-storage/index/maildir/maildir-copy.c Tue Nov 23 15:59:09 2010 +0000 @@ -122,13 +122,6 @@ return 1; } -static bool -maildir_compatible_file_modes(struct mailbox *box1, struct mailbox *box2) -{ - return box1->file_create_mode == box2->file_create_mode && - box1->file_create_gid == box2->file_create_gid; -} - int maildir_copy(struct mail_save_context *ctx, struct mail *mail) { struct mailbox_transaction_context *_t = ctx->transaction; @@ -138,7 +131,7 @@ i_assert((_t->flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0); if (mbox->storage->set->maildir_copy_with_hardlinks && - maildir_compatible_file_modes(&mbox->box, mail->box)) { + mail_storage_copy_can_use_hardlink(mail->box, &mbox->box)) { T_BEGIN { ret = maildir_copy_hardlink(ctx, mail); } T_END;
--- a/src/lib-storage/mail-copy.c Tue Nov 23 15:30:32 2010 +0000 +++ b/src/lib-storage/mail-copy.c Tue Nov 23 15:59:09 2010 +0000 @@ -74,3 +74,11 @@ } return mailbox_save_finish(&ctx); } + +bool mail_storage_copy_can_use_hardlink(struct mailbox *src, + struct mailbox *dest) +{ + return src->file_create_mode == src->file_create_mode && + src->file_create_gid == src->file_create_gid && + !dest->disable_reflink_copy_to; +}
--- a/src/lib-storage/mail-copy.h Tue Nov 23 15:30:32 2010 +0000 +++ b/src/lib-storage/mail-copy.h Tue Nov 23 15:59:09 2010 +0000 @@ -3,7 +3,13 @@ struct mail; struct mail_save_context; +struct mailbox; int mail_storage_copy(struct mail_save_context *ctx, struct mail *mail); +/* Returns TRUE if mail can be copied using hard linking from src to dest. + (Assuming the storage itself supports this.) */ +bool mail_storage_copy_can_use_hardlink(struct mailbox *src, + struct mailbox *dest); + #endif
--- a/src/lib-storage/mail-storage-private.h Tue Nov 23 15:30:32 2010 +0000 +++ b/src/lib-storage/mail-storage-private.h Tue Nov 23 15:59:09 2010 +0000 @@ -284,6 +284,10 @@ unsigned int inbox_user:1; /* TRUE if this is an INBOX for this namespace (user or shared) */ unsigned int inbox_any:1; + /* When copying to this mailbox, require that mailbox_copy() uses + mailbox_save_*() to actually save a new physical copy rather than + simply incrementing a reference count (e.g. via hard link) */ + unsigned int disable_reflink_copy_to:1; }; struct mail_vfuncs {