]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rgw/rgw_lib.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rgw / rgw_lib.h
index 3117f3c3468397b9fac248841b6523b59a366aba..63f34cf3d7942e5d94a0b593d05664345efcd3bf 100644 (file)
@@ -117,31 +117,31 @@ namespace rgw {
     friend class RGWRESTMgr_Lib;
   public:
 
-    int authorize(const DoutPrefixProvider *dpp) override;
+    int authorize(const DoutPrefixProvider *dpp, optional_yield y) override;
 
     RGWHandler_Lib() {}
     ~RGWHandler_Lib() override {}
-    static int init_from_header(struct req_state *s);
+    static int init_from_header(rgw::sal::RGWRadosStore *store,
+                               struct req_state *s);
   }; /* RGWHandler_Lib */
 
   class RGWLibRequest : public RGWRequest,
                        public RGWHandler_Lib {
+  private:
+    std::unique_ptr<rgw::sal::RGWUser> tuser; // Don't use this.  It's empty except during init.
   public:
     CephContext* cct;
-    rgw::sal::RGWUser* user;
     boost::optional<RGWSysObjectCtx> sysobj_ctx;
 
     /* unambiguiously return req_state */
     inline struct req_state* get_state() { return this->RGWRequest::s; }
 
-    RGWLibRequest(CephContext* _cct, rgw::sal::RGWUser* _user)
-      :  RGWRequest(rgwlib.get_store()->getRados()->get_new_req_id()), cct(_cct),
-        user(_user)
+    RGWLibRequest(CephContext* _cct, std::unique_ptr<rgw::sal::RGWUser> _user)
+      :  RGWRequest(rgwlib.get_store()->getRados()->get_new_req_id()),
+        tuser(std::move(_user)), cct(_cct)
       {}
 
-    rgw::sal::RGWUser* get_user() { return user; }
-
-  int postauth_init() override { return 0; }
+  int postauth_init(optional_yield) override { return 0; }
 
     /* descendant equivalent of *REST*::init_from_header(...):
      * prepare request for execute()--should mean, fixup URI-alikes
@@ -167,20 +167,22 @@ namespace rgw {
       get_state()->sysobj_ctx = &(sysobj_ctx.get());
       get_state()->req_id = store->svc()->zone_utils->unique_id(id);
       get_state()->trans_id = store->svc()->zone_utils->unique_trans_id(id);
+      get_state()->bucket_tenant = tuser->get_tenant();
+      get_state()->set_user(tuser);
 
       ldpp_dout(_s, 2) << "initializing for trans_id = "
          << get_state()->trans_id.c_str() << dendl;
 
       int ret = header_init();
       if (ret == 0) {
-       ret = init_from_header(_s);
+       ret = init_from_header(rados_ctx->get_store(), _s);
       }
       return ret;
     }
 
     virtual bool only_bucket() = 0;
 
-    int read_permissions(RGWOp *op) override;
+    int read_permissions(RGWOp *op, optional_yield y) override;
 
   }; /* RGWLibRequest */
 
@@ -190,9 +192,10 @@ namespace rgw {
     RGWObjectCtx rados_ctx;
   public:
 
-    RGWLibContinuedReq(CephContext* _cct, rgw::sal::RGWUser* _user)
-      :  RGWLibRequest(_cct, _user), io_ctx(),
-        rstate(_cct, &io_ctx.get_env(), _user, id),
+    RGWLibContinuedReq(CephContext* _cct,
+                      std::unique_ptr<rgw::sal::RGWUser> _user)
+      :  RGWLibRequest(_cct, std::move(_user)), io_ctx(),
+        rstate(_cct, &io_ctx.get_env(), id),
         rados_ctx(rgwlib.get_store(), &rstate)
       {
        io_ctx.init(_cct);
@@ -202,6 +205,7 @@ namespace rgw {
 
        sysobj_ctx.emplace(store->svc()->sysobj);
 
+       get_state()->cio = &io_ctx;
        get_state()->obj_ctx = &rados_ctx;
        get_state()->sysobj_ctx = &(sysobj_ctx.get());
        get_state()->req_id = store->svc()->zone_utils->unique_id(id);
@@ -212,6 +216,8 @@ namespace rgw {
       }
 
     inline rgw::sal::RGWRadosStore* get_store() { return store; }
+    inline RGWLibIO& get_io() { return io_ctx; }
+    inline RGWObjectCtx& get_octx() { return rados_ctx; }
 
     virtual int execute() final { ceph_abort(); }
     virtual int exec_start() = 0;