From: Matt Benjamin Date: Wed, 6 Jan 2016 02:34:34 +0000 (-0500) Subject: librgw: consolidate dup'd librgw, rgwlib X-Git-Tag: v10.1.0~382^2~65 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e6b3be3cbf15ce1676c1c4d1306cbf1dac935487;p=ceph.git librgw: consolidate dup'd librgw, rgwlib There can be only one. Fixes crash on shutdown. Signed-off-by: Matt Benjamin --- diff --git a/src/include/rados/librgw.h b/src/include/rados/librgw.h index eeeea463cf88..9ba8f3ac67a6 100644 --- a/src/include/rados/librgw.h +++ b/src/include/rados/librgw.h @@ -22,9 +22,6 @@ typedef void* librgw_t; int librgw_create(librgw_t *rgw, int argc, char **argv); void librgw_shutdown(librgw_t rgw); -int librgw_init(); -int librgw_stop(); - #ifdef __cplusplus } #endif diff --git a/src/rgw/librgw.cc b/src/rgw/librgw.cc index 2c0b22bdcd71..84db604d83fb 100644 --- a/src/rgw/librgw.cc +++ b/src/rgw/librgw.cc @@ -62,7 +62,7 @@ namespace rgw { static std::mutex librgw_mtx; - RGWLib librgw; /* XXX initialize? */ + RGWLib rgwlib; class C_InitTimeout : public Context { public: @@ -476,7 +476,7 @@ namespace rgw { int port = 80; RGWProcessEnv env = { store, &rest, olog, port }; - fec = new RGWFrontendConfig("librgw"); + fec = new RGWFrontendConfig("rgwlib"); fe = new RGWLibFrontend(env, fec); fe->init(); @@ -531,7 +531,7 @@ namespace rgw { int RGWLibRequest::read_permissions(RGWOp* op) { int ret = - rgw_build_bucket_policies(librgw.get_store(), get_state()); + rgw_build_bucket_policies(rgwlib.get_store(), get_state()); if (ret < 0) { ldout(get_state()->cct, 10) << "read_permissions on " << get_state()->bucket << ":" @@ -564,20 +564,10 @@ namespace rgw { return 0; } /* RGWHandler_Lib::authorize */ -/* global RGW library object */ - static RGWLib rgwlib; - } /* namespace rgw */ extern "C" { -int librgw_init() -{ - using namespace rgw; - - return rgwlib.init(); -} - int librgw_create(librgw_t* rgw, int argc, char **argv) { using namespace rgw; @@ -587,7 +577,7 @@ int librgw_create(librgw_t* rgw, int argc, char **argv) if (! g_ceph_context) { vector args; argv_to_vec(argc, const_cast(argv), args); - librgw.init(args); + rgwlib.init(args); } } @@ -687,9 +677,7 @@ void librgw_shutdown(librgw_t rgw) using namespace rgw; CephContext* cct = static_cast(rgw); -#if 0 rgwlib.stop(); -#endif cct->put(); } diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 9a29675dddfe..49cb70fc1821 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -32,7 +32,7 @@ using namespace rgw; namespace rgw { - extern RGWLib librgw; + extern RGWLib rgwlib; const string RGWFileHandle::root_name = "/"; @@ -45,7 +45,7 @@ namespace rgw { std::string bucket_name{path}; RGWStatBucketRequest req(cct, get_user(), bucket_name); - int rc = librgw.get_fe()->execute_req(&req); + int rc = rgwlib.get_fe()->execute_req(&req); if ((rc == 0) && (req.get_ret() == 0) && (req.matched())) { @@ -87,7 +87,7 @@ namespace rgw { RGWStatObjRequest req(cct, get_user(), parent->bucket_name(), object_name, RGWStatObjRequest::FLAG_NONE); - int rc = librgw.get_fe()->execute_req(&req); + int rc = rgwlib.get_fe()->execute_req(&req); if ((rc == 0) && (req.get_ret() == 0)) { fhr = lookup_fh(parent, path, RGWFileHandle::FLAG_NONE); @@ -98,7 +98,7 @@ namespace rgw { case 1: { RGWStatLeafRequest req(cct, get_user(), parent, object_name); - int rc = librgw.get_fe()->execute_req(&req); + int rc = rgwlib.get_fe()->execute_req(&req); if ((rc == 0) && (req.get_ret() == 0)) { if (req.matched) { @@ -142,7 +142,7 @@ namespace rgw { /* force cache drain, forces objects to evict */ fh_cache.drain(ObjUnref(this), RGWFileHandle::FHCache::FLAG_LOCK); - librgw.get_fe()->get_process()->unregister_fs(this); + rgwlib.get_fe()->get_process()->unregister_fs(this); rele(); } /* RGWLibFS::close */ @@ -224,7 +224,7 @@ namespace rgw { if (is_root()) { RGWListBucketsRequest req(cct, fs->get_user(), this, rcb, cb_arg, offset); - rc = librgw.get_fe()->execute_req(&req); + rc = rgwlib.get_fe()->execute_req(&req); if (! rc) { parent->set_nlink(3 + d->name_cache.size()); state.atime = now; @@ -235,7 +235,7 @@ namespace rgw { } else { rgw_obj_key marker{"", ""}; RGWReaddirRequest req(cct, fs->get_user(), this, rcb, cb_arg, offset); - rc = librgw.get_fe()->execute_req(&req); + rc = rgwlib.get_fe()->execute_req(&req); if (! rc) { state.atime = now; parent->set_nlink(3 + d->name_cache.size()); @@ -268,7 +268,7 @@ namespace rgw { f->write_req = new RGWWriteRequest(fs->get_context(), fs->get_user(), this, bucket_name(), object_name); - rc = librgw.get_fe()->start_req(f->write_req); + rc = rgwlib.get_fe()->start_req(f->write_req); } f->write_req->put_data(off, bl); @@ -289,7 +289,7 @@ namespace rgw { int rc = 0; file* f = get(&variant_type); if (f && (f->write_req)) { - rc = librgw.get_fe()->finish_req(f->write_req); + rc = rgwlib.get_fe()->finish_req(f->write_req); if (! rc) { rc = f->write_req->get_ret(); } @@ -523,14 +523,14 @@ extern "C" { sec_key); assert(new_fs); - rc = new_fs->authorize(librgw.get_store()); + rc = new_fs->authorize(rgwlib.get_store()); if (rc != 0) { delete new_fs; return -EINVAL; } /* register fs for shared gc */ - librgw.get_fe()->get_process()->register_fs(new_fs); + rgwlib.get_fe()->get_process()->register_fs(new_fs); struct rgw_fs *fs = new_fs->get_fs(); fs->rgw = rgw; @@ -655,7 +655,7 @@ int rgw_mkdir(struct rgw_fs *rgw_fs, uri += "/"; /* XXX */ uri += name; RGWCreateBucketRequest req(cct, fs->get_user(), uri); - rc = librgw.get_fe()->execute_req(&req); + rc = rgwlib.get_fe()->execute_req(&req); rc2 = req.get_ret(); } else { /* create an object representing the directory (naive version) */ @@ -665,7 +665,7 @@ int rgw_mkdir(struct rgw_fs *rgw_fs, string dir_name = rgw_fh->relative_object_name() + "/"; RGWPutObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(), dir_name, bl); - rc = librgw.get_fe()->execute_req(&req); + rc = rgwlib.get_fe()->execute_req(&req); rc2 = req.get_ret(); } @@ -712,7 +712,7 @@ int rgw_unlink(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh, string uri = "/"; uri += name; RGWDeleteBucketRequest req(cct, fs->get_user(), uri); - rc = librgw.get_fe()->execute_req(&req); + rc = rgwlib.get_fe()->execute_req(&req); } else { /* * leaf object @@ -728,7 +728,7 @@ int rgw_unlink(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh, std::string oname = rgw_fh->relative_object_name(); RGWDeleteObjRequest req(cct, fs->get_user(), parent->bucket_name(), oname); - rc = librgw.get_fe()->execute_req(&req); + rc = rgwlib.get_fe()->execute_req(&req); /* release */ (void) rgw_fh_rele(rgw_fs, fh, 0 /* flags */); } @@ -746,7 +746,7 @@ void dump_buckets(void) { RGWUserBuckets buckets; uint64_t max_buckets = g_ceph_context->_conf->rgw_list_buckets_max_chunk; - RGWRados* store = librgw.get_store(); + RGWRados* store = rgwlib.get_store(); /* XXX check offsets */ uint64_t ix = 3; @@ -875,7 +875,7 @@ int rgw_getattr(struct rgw_fs *rgw_fs, RGWStatObjRequest req(cct, fs->get_user(), bname, oname, RGWStatObjRequest::FLAG_NONE); - int rc = librgw.get_fe()->execute_req(&req); + int rc = rgwlib.get_fe()->execute_req(&req); if ((rc != 0) || (req.get_ret() != 0)) { /* XXX EINVAL is likely illegal protocol return--if the object @@ -986,7 +986,7 @@ int rgw_read(struct rgw_fs *rgw_fs, rgw_fh->object_name(), offset, length, buffer); - int rc = librgw.get_fe()->execute_req(&req); + int rc = rgwlib.get_fe()->execute_req(&req); if ((rc == 0) && (req.get_ret() == 0)) { *bytes_read = req.nread; @@ -1060,7 +1060,7 @@ int rgw_readv(struct rgw_fs *rgw_fs, bl); req.do_hexdump = false; - rc = librgw.get_fe()->execute_req(&req); + rc = rgwlib.get_fe()->execute_req(&req); if (! rc) { RGWReadV* rdv = static_cast( @@ -1119,7 +1119,7 @@ int rgw_readv(struct rgw_fs *rgw_fs, RGWPutObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(), oname, bl); - int rc = librgw.get_fe()->execute_req(&req); + int rc = rgwlib.get_fe()->execute_req(&req); /* XXX update size (in request) */ diff --git a/src/rgw/rgw_lib.h b/src/rgw/rgw_lib.h index fc4aa771b5e4..1a75e379e716 100644 --- a/src/rgw/rgw_lib.h +++ b/src/rgw/rgw_lib.h @@ -41,7 +41,7 @@ namespace rgw { int stop(); }; - extern RGWLib librgw; + extern RGWLib rgwlib; /* request interface */ @@ -161,7 +161,7 @@ namespace rgw { RGWLibContinuedReq(CephContext* _cct, RGWUserInfo* _user) : RGWLibRequest(_cct, _user), io_ctx(), - rstate(_cct, &io_ctx.get_env(), _user), rados_ctx(librgw.get_store(), + rstate(_cct, &io_ctx.get_env(), _user), rados_ctx(rgwlib.get_store(), &rstate) { io_ctx.init(_cct);