Radosgw process_request
介绍rgw_main.cc:512,方法 process_request 用于处理请求。
分析1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 static int process_request (RGWRados store, RGWREST rest, RGWRequest req, RGWClientIO client_io, OpsLogSocket olog) { dout(1 ) << “====== starting new request req=” << hex << req << dec << “ =====” << dendl; req->log (s, “initializing” ); RGWHandler handler = rest->get_handler(store, s, client_io, &mgr, &init_error); req->log (s, “getting op” ); op = handler->get_op(store); req->op = op; req->log (s, “authorizing” ); ret = handler->authorize(); req->log (s, “reading permissions” ); req->log (s, “init op” ); req->log (s, “verifying op mask” ); req->log (s, “verifying op permissions” ); req->log (s, “verifying op params” ); req->log (s, “executing” ); op->pre_exec(); op->execute(); op->complete(); done: }
RGWHandler *handler = rest->get_handler(store, s, client_io, &mgr, &init_error);
对应的是
1 2 3 4 5 6 7 8 9 10 11 12 13 14 RGWHandler RGWRESTMgr_S3::get_handler(struct req_state s) { int ret = RGWHandler_ObjStore_S3::init_from_header(s, RGW_FORMAT_XML, false ); if (ret < 0 ) return NULL ; if (s->bucket_name_str.empty()) return new RGWHandler_ObjStore_Service_S3; if (!s->object) return new RGWHandler_ObjStore_Bucket_S3; return new RGWHandler_ObjStore_Obj_S3; }
op = handler->get_op(store);
对应的是 rgw_op.cc:3134
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 RGWOp RGWHandler::get_op(RGWRados store) { RGWOp *op; switch (s->op) { case OP_GET: op = op_get(); break ; case OP_PUT: op = op_put(); break ; case OP_DELETE: op = op_delete(); break ; case OP_HEAD: op = op_head(); break ; case OP_POST: op = op_post(); break ; case OP_COPY: op = op_copy(); break ; case OP_OPTIONS: op = op_options(); break ; default : return NULL ; }
这里的op_xxx()
在rgw_rest_s3.cc
里对应的 handler 的 op_xxx()
, 如当使用 s3 的借口请求s3cmd ls
时,op 对应 RGWListBuckets_ObjStore_S3
…,这些类定义在 rgw_rest_s3.h
在真正进行处理的的一些方法
1 2 3 op->pre_exec(); op->execute(); op->complete();
均是在rgw_op.cc
中实现。