Skip to content

Commit

Permalink
Merge pull request ceph#56583 from pritha-srivastava/wip-rgw-del-buck…
Browse files Browse the repository at this point in the history
…et-tag

rgw: fix to correctly store updated attrs in backend store after erasing an attr/attrs for delete ops on a bucket.

Reviewed-by: Daniel Gryniewicz <[email protected]>
Reviewed-by: Casey Bodley <[email protected]>
  • Loading branch information
cbodley authored Dec 17, 2024
2 parents 8234253 + 5c7d47a commit 7c65649
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/rgw/driver/rados/rgw_sal_rados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ int RadosBucket::merge_and_store_attrs(const DoutPrefixProvider* dpp, Attrs& new
attrs[it.first] = it.second;
}
return store->ctl()->bucket->set_bucket_instance_attrs(get_info(),
new_attrs, &get_info().objv_tracker, y, dpp);
attrs, &get_info().objv_tracker, y, dpp);
}

int RadosBucket::try_refresh_info(const DoutPrefixProvider* dpp, ceph::real_time* pmtime, optional_yield y)
Expand Down
20 changes: 10 additions & 10 deletions src/rgw/rgw_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1350,9 +1350,9 @@ void RGWDeleteBucketTags::execute(optional_yield y)
}

op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this, y] {
rgw::sal::Attrs attrs = s->bucket->get_attrs();
rgw::sal::Attrs& attrs = s->bucket->get_attrs();
attrs.erase(RGW_ATTR_TAGS);
op_ret = s->bucket->merge_and_store_attrs(this, attrs, y);
op_ret = s->bucket->put_info(this, false, real_time(), y);
if (op_ret < 0) {
ldpp_dout(this, 0) << "RGWDeleteBucketTags() failed to remove RGW_ATTR_TAGS on bucket="
<< s->bucket->get_name()
Expand Down Expand Up @@ -6386,9 +6386,9 @@ void RGWDeleteCORS::execute(optional_yield y)
return op_ret;
}

rgw::sal::Attrs attrs(s->bucket_attrs);
rgw::sal::Attrs& attrs = s->bucket->get_attrs();
attrs.erase(RGW_ATTR_CORS);
op_ret = s->bucket->merge_and_store_attrs(this, attrs, s->yield);
op_ret = s->bucket->put_info(this, false, real_time(), s->yield);
if (op_ret < 0) {
ldpp_dout(this, 0) << "RGWLC::RGWDeleteCORS() failed to set attrs on bucket=" << s->bucket->get_name()
<< " returned err=" << op_ret << dendl;
Expand Down Expand Up @@ -8511,9 +8511,9 @@ void RGWDeleteBucketPolicy::execute(optional_yield y)
}

op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this] {
rgw::sal::Attrs attrs(s->bucket_attrs);
rgw::sal::Attrs& attrs = s->bucket->get_attrs();
attrs.erase(RGW_ATTR_IAM_POLICY);
op_ret = s->bucket->merge_and_store_attrs(this, attrs, s->yield);
op_ret = s->bucket->put_info(this, false, real_time(), s->yield);
return op_ret;
}, y);
}
Expand Down Expand Up @@ -9031,9 +9031,9 @@ void RGWDeleteBucketPublicAccessBlock::execute(optional_yield y)
}

op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this] {
rgw::sal::Attrs attrs(s->bucket_attrs);
rgw::sal::Attrs& attrs = s->bucket->get_attrs();
attrs.erase(RGW_ATTR_PUBLIC_ACCESS);
op_ret = s->bucket->merge_and_store_attrs(this, attrs, s->yield);
op_ret = s->bucket->put_info(this, false, real_time(), s->yield);
return op_ret;
}, y);
}
Expand Down Expand Up @@ -9142,10 +9142,10 @@ void RGWDeleteBucketEncryption::execute(optional_yield y)
}

op_ret = retry_raced_bucket_write(this, s->bucket.get(), [this, y] {
rgw::sal::Attrs attrs = s->bucket->get_attrs();
rgw::sal::Attrs& attrs = s->bucket->get_attrs();
attrs.erase(RGW_ATTR_BUCKET_ENCRYPTION_POLICY);
attrs.erase(RGW_ATTR_BUCKET_ENCRYPTION_KEY_ID);
op_ret = s->bucket->merge_and_store_attrs(this, attrs, y);
op_ret = s->bucket->put_info(this, false, real_time(), y);
return op_ret;
}, y);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_sal_dbstore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ namespace rgw::sal {

/* XXX: handle has_instance_obj like in set_bucket_instance_attrs() */

ret = store->getDB()->update_bucket(dpp, "attrs", info, false, nullptr, &new_attrs, nullptr, &get_info().objv_tracker);
ret = store->getDB()->update_bucket(dpp, "attrs", info, false, nullptr, &attrs, nullptr, &get_info().objv_tracker);

return ret;
}
Expand Down

0 comments on commit 7c65649

Please sign in to comment.