From: Andriy Tkachuk Date: Sat, 28 Jan 2023 22:10:48 +0000 (+0000) Subject: Merge branch 'master' into update-ceph-mgw X-Git-Tag: v18.1.0~422^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4cd24a9c9b80ad0689ab946565283f4d6e52c02c;p=ceph.git Merge branch 'master' into update-ceph-mgw --- 4cd24a9c9b80ad0689ab946565283f4d6e52c02c diff --cc src/rgw/rgw_sal.cc index 1102d8d461f3,8a793f753146..58a21f707f58 --- a/src/rgw/rgw_sal.cc +++ b/src/rgw/rgw_sal.cc @@@ -152,15 -182,42 +182,15 @@@ rgw::sal::Driver* DriverManager::init_s #endif #ifdef WITH_RADOSGW_MOTR - if (svc.compare("motr") == 0) { - rgw::sal::Store* store = newMotrStore(cct); - if (store == nullptr) { + else if (cfg.store_name.compare("motr") == 0) { + driver = newMotrStore(cct); + if (driver == nullptr) { ldpp_dout(dpp, 0) << "newMotrStore() failed!" << dendl; - return store; + return driver; } - ((rgw::sal::MotrStore *)store)->init_metadata_cache(dpp, cct); + ((rgw::sal::MotrStore *)driver)->init_metadata_cache(dpp, cct); - /* XXX: temporary - create testid user */ - rgw_user testid_user("tenant", "tester", "ns"); - std::unique_ptr user = driver->get_user(testid_user); - user->get_info().user_id = testid_user; - user->get_info().display_name = "Motr Explorer"; - user->get_info().user_email = "tester@seagate.com"; - RGWAccessKey k1("0555b35654ad1656d804", "h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=="); - user->get_info().access_keys["0555b35654ad1656d804"] = k1; - - ldpp_dout(dpp, 20) << "Store testid and user for Motr. User = " << user->get_info().user_id.id << dendl; - int rc = user->store_user(dpp, null_yield, true); - if (rc < 0) { - ldpp_dout(dpp, 0) << "ERROR: failed to store testid user ar Motr: rc=" << rc << dendl; - } - - // Read user info and compare. - rgw_user ruser("", "tester", ""); - std::unique_ptr suser = driver->get_user(ruser); - suser->get_info().user_id = ruser; - rc = suser->load_user(dpp, null_yield); - if (rc != 0) { - ldpp_dout(dpp, 0) << "ERROR: failed to load testid user from Motr: rc=" << rc << dendl; - } else { - ldpp_dout(dpp, 20) << "Read and compare user info: " << dendl; - ldpp_dout(dpp, 20) << "User id = " << suser->get_info().user_id.id << dendl; - ldpp_dout(dpp, 20) << "User display name = " << suser->get_info().display_name << dendl; - ldpp_dout(dpp, 20) << "User email = " << suser->get_info().user_email << dendl; - } + return store; } #endif diff --cc src/rgw/rgw_sal_motr.cc index ebeda17aa7c6,81d801782aae..728c6d2b07fb --- a/src/rgw/rgw_sal_motr.cc +++ b/src/rgw/rgw_sal_motr.cc @@@ -1514,24 -1231,16 +1502,24 @@@ MotrObject::MotrDeleteOp::MotrDeleteOp( // 2. Delete an object when its versioning is turned on. int MotrObject::MotrDeleteOp::delete_obj(const DoutPrefixProvider* dpp, optional_yield y) { - ldpp_dout(dpp, 20) << "delete " << source->get_key().to_str() << " from " << source->get_bucket()->get_name() << dendl; + ldpp_dout(dpp, 20) << "delete " << source->get_key().get_oid() << " from " << source->get_bucket()->get_name() << dendl; + rgw_bucket_dir_entry ent; + int rc = source->get_bucket_dir_ent(dpp, ent); + if (rc < 0) { + return rc; + } + + //TODO: When integrating with background GC for object deletion, + // we should consider adding object entry to GC before deleting the metadata. // Delete from the cache first. - source->store->get_obj_meta_cache()->remove(dpp, source->get_key().to_str()); + source->store->get_obj_meta_cache()->remove(dpp, source->get_key().get_oid()); // Delete the object's entry from the bucket index. bufferlist bl; string bucket_index_iname = "motr.rgw.bucket.index." + source->get_bucket()->get_name(); - int rc = source->store->do_idx_op_by_name(bucket_index_iname, - M0_IC_DEL, source->get_key().get_oid(), bl); + rc = source->store->do_idx_op_by_name(bucket_index_iname, - M0_IC_DEL, source->get_key().to_str(), bl); ++ M0_IC_DEL, source->get_key().get_oid(), bl); if (rc < 0) { ldpp_dout(dpp, 0) << "Failed to del object's entry from bucket index. " << dendl; return rc; @@@ -2005,12 -1687,12 +1993,12 @@@ int MotrObject::get_bucket_dir_ent(cons } } } else { - if (this->store->get_obj_meta_cache()->get(dpp, this->get_key().to_str(), bl)) { + if (this->store->get_obj_meta_cache()->get(dpp, this->get_key().get_oid(), bl)) { ldpp_dout(dpp, 20) <<__func__<< ": non-versioned bucket!" << dendl; rc = this->store->do_idx_op_by_name(bucket_index_iname, - M0_IC_GET, this->get_key().to_str(), bl); + M0_IC_GET, this->get_key().get_oid(), bl); if (rc < 0) { - ldpp_dout(dpp, 0) << "ERROR: failed to get object's entry from bucket index: rc=" + ldpp_dout(dpp, 0) << __func__ << "ERROR: failed to get object's entry from bucket index: rc=" << rc << dendl; return rc; } @@@ -2464,17 -2142,10 +2452,17 @@@ int MotrAtomicWriter::complete(size_t a // Insert an entry into bucket index. string bucket_index_iname = "motr.rgw.bucket.index." + obj.get_bucket()->get_name(); rc = store->do_idx_op_by_name(bucket_index_iname, - M0_IC_PUT, obj.get_key().to_str(), bl); + M0_IC_PUT, obj.get_key().get_oid(), bl); if (rc == 0) - store->get_obj_meta_cache()->put(dpp, obj.get_key().to_str(), bl); + store->get_obj_meta_cache()->put(dpp, obj.get_key().get_oid(), bl); + if (old_obj.get_bucket()->get_info().versioning_status() != BUCKET_VERSIONED) { + // Delete old object data if exists. + old_obj.delete_mobj(dpp); + } + + // TODO: We need to handle the object leak caused by parallel object upload by + // making use of background gc, which is currently not enabled for motr. return rc; } @@@ -2548,11 -2205,15 +2536,11 @@@ int MotrMultipartUpload::abort(const Do if (rc < 0) return rc; + bl.clear(); // Remove the upload from bucket multipart index. - bufferlist bl; - std::unique_ptr meta_obj; - meta_obj = get_meta_obj(); - string bucket_multipart_iname = - "motr.rgw.bucket." + meta_obj->get_bucket()->get_name() + ".multiparts"; - return store->do_idx_op_by_name(bucket_multipart_iname, - M0_IC_DEL, meta_obj->get_key().get_oid(), bl); - return 0; + rc = store->do_idx_op_by_name(bucket_multipart_iname, - M0_IC_DEL, meta_obj->get_key().to_str(), bl); ++ M0_IC_DEL, meta_obj->get_key().get_oid(), bl); + return rc; } std::unique_ptr MotrMultipartUpload::get_meta_obj() @@@ -2958,10 -2614,10 +2946,10 @@@ int MotrMultipartUpload::get_info(cons string bucket_multipart_iname = "motr.rgw.bucket." + meta_obj->get_bucket()->get_name() + ".multiparts"; int rc = this->store->do_idx_op_by_name(bucket_multipart_iname, - M0_IC_GET, meta_obj->get_key().to_str(), bl); + M0_IC_GET, meta_obj->get_key().get_oid(), bl); if (rc < 0) { - ldpp_dout(dpp, 0) << "Failed to get object's entry from bucket index. " << dendl; - return rc; + ldpp_dout(dpp, 0) << __func__ << ": Failed to get multipart info. rc=" << rc << dendl; + return rc == -ENOENT ? -ERR_NO_SUCH_UPLOAD : rc; } rgw_bucket_dir_entry ent; diff --cc src/rgw/rgw_sal_motr.h index 17f726117e13,aab3873ce2e1..bc276b892c32 --- a/src/rgw/rgw_sal_motr.h +++ b/src/rgw/rgw_sal_motr.h @@@ -251,10 -196,9 +251,11 @@@ class MotrUser : public StoreUser virtual int load_user(const DoutPrefixProvider* dpp, optional_yield y) override; virtual int store_user(const DoutPrefixProvider* dpp, optional_yield y, bool exclusive, RGWUserInfo* old_info = nullptr) override; virtual int remove_user(const DoutPrefixProvider* dpp, optional_yield y) override; + virtual int verify_mfa(const std::string& mfa_str, bool* verified, const DoutPrefixProvider* dpp, optional_yield y) override; int create_user_info_idx(); + int load_user_from_idx(const DoutPrefixProvider *dpp, MotrStore *store, RGWUserInfo& info, std::map *attrs, RGWObjVersionTracker *objv_tr); friend class MotrBucket; };