]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_process.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "common/errno.h"
5 #include "common/Throttle.h"
6 #include "common/WorkQueue.h"
10 #include "rgw_frontend.h"
11 #include "rgw_request.h"
12 #include "rgw_process.h"
13 #include "rgw_loadgen.h"
14 #include "rgw_client_io.h"
16 #define dout_subsys ceph_subsys_rgw
18 void RGWProcess::RGWWQ::_dump_queue()
20 if (!g_conf
->subsys
.should_gather(ceph_subsys_rgw
, 20)) {
23 deque
<RGWRequest
*>::iterator iter
;
24 if (process
->m_req_queue
.empty()) {
25 dout(20) << "RGWWQ: empty" << dendl
;
28 dout(20) << "RGWWQ:" << dendl
;
29 for (iter
= process
->m_req_queue
.begin();
30 iter
!= process
->m_req_queue
.end(); ++iter
) {
31 dout(20) << "req: " << hex
<< *iter
<< dec
<< dendl
;
33 } /* RGWProcess::RGWWQ::_dump_queue */
36 int rgw_process_authenticated(RGWHandler_REST
* const handler
,
38 RGWRequest
* const req
,
40 const bool skip_retarget
)
42 req
->log(s
, "init permissions");
43 int ret
= handler
->init_permissions(op
);
49 * Only some accesses support website mode, and website mode does NOT apply
50 * if you are using the REST endpoint either (ergo, no authenticated access)
52 if (! skip_retarget
) {
53 req
->log(s
, "recalculating target");
54 ret
= handler
->retarget(op
, &op
);
60 req
->log(s
, "retargeting skipped because of SubOp mode");
63 /* If necessary extract object ACL and put them into req_state. */
64 req
->log(s
, "reading permissions");
65 ret
= handler
->read_permissions(op
);
70 req
->log(s
, "init op");
71 ret
= op
->init_processing();
76 req
->log(s
, "verifying op mask");
77 ret
= op
->verify_op_mask();
82 req
->log(s
, "verifying op permissions");
83 ret
= op
->verify_permission();
85 if (s
->system_request
) {
86 dout(2) << "overriding permissions due to system operation" << dendl
;
87 } else if (s
->auth
.identity
->is_admin_of(s
->user
->user_id
)) {
88 dout(2) << "overriding permissions due to admin operation" << dendl
;
94 req
->log(s
, "verifying op params");
95 ret
= op
->verify_params();
100 req
->log(s
, "pre-executing");
103 req
->log(s
, "executing");
106 req
->log(s
, "completing");
112 int process_request(RGWRados
* const store
,
114 RGWRequest
* const req
,
115 const std::string
& frontend_prefix
,
116 const rgw_auth_registry_t
& auth_registry
,
117 RGWRestfulIO
* const client_io
,
118 OpsLogSocket
* const olog
)
122 client_io
->init(g_ceph_context
);
126 dout(1) << "====== starting new request req=" << hex
<< req
<< dec
127 << " =====" << dendl
;
128 perfcounter
->inc(l_rgw_req
);
130 RGWEnv
& rgw_env
= client_io
->get_env();
132 RGWUserInfo userinfo
;
134 struct req_state
rstate(g_ceph_context
, &rgw_env
, &userinfo
);
135 struct req_state
*s
= &rstate
;
137 RGWObjectCtx
rados_ctx(store
, s
);
138 s
->obj_ctx
= &rados_ctx
;
140 s
->req_id
= store
->unique_id(req
->id
);
141 s
->trans_id
= store
->unique_trans_id(req
->id
);
142 s
->host_id
= store
->host_id
;
144 req
->log_format(s
, "initializing for trans_id = %s", s
->trans_id
.c_str());
148 bool should_log
= false;
150 RGWHandler_REST
*handler
= rest
->get_handler(store
, s
,
153 client_io
, &mgr
, &init_error
);
154 if (init_error
!= 0) {
155 abort_early(s
, NULL
, init_error
, NULL
);
158 dout(10) << "handler=" << typeid(*handler
).name() << dendl
;
160 should_log
= mgr
->get_logging();
162 req
->log_format(s
, "getting op %d", s
->op
);
163 op
= handler
->get_op(store
);
165 abort_early(s
, NULL
, -ERR_METHOD_NOT_ALLOWED
, handler
);
170 dout(10) << "op=" << typeid(*op
).name() << dendl
;
172 s
->op_type
= op
->get_type();
174 req
->log(s
, "verifying requester");
175 ret
= op
->verify_requester(auth_registry
);
177 dout(10) << "failed to authorize request" << dendl
;
178 abort_early(s
, NULL
, ret
, handler
);
182 /* FIXME: remove this after switching all handlers to the new authentication
184 if (nullptr == s
->auth
.identity
) {
185 s
->auth
.identity
= rgw::auth::transform_old_authinfo(s
);
188 req
->log(s
, "normalizing buckets and tenants");
189 ret
= handler
->postauth_init();
191 dout(10) << "failed to run post-auth init" << dendl
;
192 abort_early(s
, op
, ret
, handler
);
196 if (s
->user
->suspended
) {
197 dout(10) << "user is suspended, uid=" << s
->user
->user_id
<< dendl
;
198 abort_early(s
, op
, -ERR_USER_SUSPENDED
, handler
);
202 ret
= rgw_process_authenticated(handler
, op
, req
, s
);
204 abort_early(s
, op
, ret
, handler
);
209 client_io
->complete_request();
210 } catch (rgw::io::Exception
& e
) {
211 dout(0) << "ERROR: client_io->complete_request() returned "
212 << e
.what() << dendl
;
216 rgw_log_op(store
, rest
, s
, (op
? op
->name() : "unknown"), olog
);
219 int http_ret
= s
->err
.http_ret
;
222 op_ret
= op
->get_ret();
225 req
->log_format(s
, "op status=%d", op_ret
);
226 req
->log_format(s
, "http status=%d", http_ret
);
230 rest
->put_handler(handler
);
232 dout(1) << "====== req done req=" << hex
<< req
<< dec
233 << " op status=" << op_ret
234 << " http_status=" << http_ret
238 return (ret
< 0 ? ret
: s
->err
.ret
);
239 } /* process_request */