Skip to content

Commit

Permalink
#298: move ceph objects the standard way.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrse committed Mar 10, 2022
1 parent 836e07e commit c5866b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
11 changes: 6 additions & 5 deletions src/storage-rbox/rbox-copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static int copy_mail(struct mail_save_context *ctx, librmb::RadosStorage *rados_
#endif
return 0;
}

//unused!
static int move_mail(struct mail_save_context *ctx, librmb::RadosStorage *rados_storage, struct mail *mail,
const std::string *ns_src, const std::string *ns_dest) {
struct rbox_save_context *r_ctx = (struct rbox_save_context *)ctx;
Expand Down Expand Up @@ -324,13 +324,14 @@ static int rbox_mail_storage_try_copy(struct mail_save_context **_ctx, struct ma
}

librmb::RadosStorage *rados_storage = !from_alt_storage ? r_storage->s : r_storage->alt;
if (ctx->moving != TRUE) {
// if (ctx->moving != TRUE) {
if (copy_mail(ctx, rados_storage, rmail, &ns_src, &ns_dest) < 0) {
FUNC_END_RET("ret == -1, copy mail failed");
return -1;
}
}
if (ctx->moving) {
//}
// Avoid using move directly : use copy and expunge instead
/*if (ctx->moving) {
int ret = 0;
T_BEGIN {
if (move_mail(ctx, rados_storage, mail, &ns_src, &ns_dest) < 0) {
Expand All @@ -342,7 +343,7 @@ static int rbox_mail_storage_try_copy(struct mail_save_context **_ctx, struct ma
if (ret < 0) {
return ret;
}
}
}*/

index_copy_cache_fields(ctx, mail, r_ctx->seq);
if (ctx->dest_mail != NULL) {
Expand Down
17 changes: 7 additions & 10 deletions src/storage-rbox/rbox-mail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ using librmb::rbox_metadata_key;

void rbox_mail_set_expunged(struct rbox_mail *mail) {
FUNC_START();


//we need to do this here to make sure that everything is in sync.
//#222 describes error with this approach, but to be honest, slow
// recovery by resyncing the index is maybe the only thing
Expand All @@ -58,6 +60,7 @@ void rbox_mail_set_expunged(struct rbox_mail *mail) {
if (mail_index_is_expunged(_mail->transaction->view, _mail->seq)) {
mail_set_expunged(_mail);
} else {
i_info("rbox_mail_set_expunged call, mail is not expunged!");
mail_storage_set_critical(_mail->box->storage, "rbox %s: Unexpectedly lost uid=%u", mailbox_get_path(_mail->box),
_mail->uid);
/* the message was probably just purged */
Expand Down Expand Up @@ -145,22 +148,16 @@ static int rbox_mail_metadata_get(struct rbox_mail *rmail, enum rbox_metadata_ke
return -1;
}
}

if(rmail->rados_mail->get_oid()->length() == 0){
// try to reinitialize the oid again from the index header!
if (rbox_get_index_record(mail) < 0) {
i_error("Error rbox_get_index_record uid(%d) for rados_mail: %s", mail->uid,
rmail->rados_mail->to_string(" ").c_str());
FUNC_END();
return -1;
}
i_info("mail uid: %d , oid '%s', guid: %s, index-oid: %s ",mail->uid,rmail->rados_mail->get_oid()->c_str(), guid_128_to_string(rmail->index_guid), guid_128_to_string(rmail->index_oid) );
rmail->rados_mail->set_oid(rmail->index_oid);
}
int ret_load_metadata = r_storage->ms->get_storage()->load_metadata(rmail->rados_mail);
if (ret_load_metadata < 0) {
std::string metadata_key = librmb::rbox_metadata_key_to_char(key);
if (ret_load_metadata == -ENOENT) {
i_warning("Errorcode: process %d returned with %d cannot get x_attr(%s,%c) from rados_object: %s",getpid(), ret_load_metadata,
metadata_key.c_str(), key, rmail->rados_mail != NULL ? rmail->rados_mail->to_string(" ").c_str() : " no rados_mail");
//i_debug("Errorcode: process %d returned with %d cannot get x_attr(%s,%c) from rados_object: %s",getpid(), ret_load_metadata,
// metadata_key.c_str(), key, rmail->rados_mail != NULL ? rmail->rados_mail->to_string(" ").c_str() : " no rados_mail");
rbox_mail_set_expunged(rmail);
} else {
i_error("Errorcode: process %d returned with %d cannot get x_attr(%s,%c) from rados_object: %s",getpid(), ret_load_metadata,
Expand Down

0 comments on commit c5866b2

Please sign in to comment.