@@ -1626,8 +1626,8 @@ static int adopt_user_bucket(const DoutPrefixProvider* dpp,
16261626 optional_yield y,
16271627 rgw::sal::Driver* driver,
16281628 const rgw_bucket& bucketid,
1629- const rgw_owner& new_owner)
1630- {
1629+ const rgw_owner& new_owner,
1630+ const std::string& new_owner_name) {
16311631 // retry in case of racing writes to the bucket instance metadata
16321632 static constexpr auto max_retries = 10 ;
16331633 int tries = 0 ;
@@ -1644,7 +1644,7 @@ static int adopt_user_bucket(const DoutPrefixProvider* dpp,
16441644 return r;
16451645 }
16461646
1647- r = bucket->chown (dpp, new_owner, y);
1647+ r = bucket->chown (dpp, new_owner, new_owner_name, y);
16481648 if (r < 0 ) {
16491649 ldpp_dout (dpp, 1 ) << " failed to chown bucket " << bucketid
16501650 << " : " << cpp_strerror (r) << dendl;
@@ -1657,8 +1657,8 @@ static int adopt_user_bucket(const DoutPrefixProvider* dpp,
16571657
16581658static int adopt_user_buckets (const DoutPrefixProvider* dpp, optional_yield y,
16591659 rgw::sal::Driver* driver, const rgw_user& user,
1660- const rgw_account_id& account_id)
1661- {
1660+ const rgw_account_id& account_id,
1661+ const std::string& account_name) {
16621662 const size_t max_chunk = dpp->get_cct ()->_conf ->rgw_list_buckets_max_chunk ;
16631663 constexpr bool need_stats = false ;
16641664
@@ -1674,7 +1674,8 @@ static int adopt_user_buckets(const DoutPrefixProvider* dpp, optional_yield y,
16741674 }
16751675
16761676 for (const auto & ent : listing.buckets ) {
1677- r = adopt_user_bucket (dpp, y, driver, ent.bucket , account_id);
1677+ r = adopt_user_bucket (dpp, y, driver, ent.bucket , account_id,
1678+ account_name);
16781679 if (r < 0 && r != -ENOENT) {
16791680 return r;
16801681 }
@@ -2107,9 +2108,19 @@ int RGWUser::execute_modify(const DoutPrefixProvider *dpp, RGWUserAdminOpState&
21072108 set_err_msg (err_msg, err);
21082109 return ret;
21092110 }
2111+ RGWAccountInfo account_info;
2112+ rgw::sal::Attrs attrs;
2113+ RGWObjVersionTracker objv;
2114+ int r = driver->load_account_by_id (dpp, y, op_state.account_id ,
2115+ account_info,
2116+ attrs, objv);
2117+ if (r < 0 ) {
2118+ err = " Failed to load account by id" ;
2119+ return r;
2120+ }
21102121 // change account on user's buckets
21112122 ret = adopt_user_buckets (dpp, y, driver, user_info.user_id ,
2112- user_info.account_id );
2123+ user_info.account_id , account_info. name );
21132124 if (ret < 0 ) {
21142125 set_err_msg (err_msg, " failed to change ownership of user's buckets" );
21152126 return ret;
0 commit comments