From: Matt Benjamin Date: Tue, 10 Nov 2015 00:19:52 +0000 (-0500) Subject: librgw: don't abuse fs_private X-Git-Tag: v10.1.0~382^2~154 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=66823a06b6f411a26f7f24e121d9cd0226064e4b;p=ceph.git librgw: don't abuse fs_private Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 828760bf938e..29c50f803df5 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -47,7 +47,8 @@ extern "C" { int rc = 0; /* stash access data for "mount" */ - RGWLibFS* new_fs = new RGWLibFS(uid, acc_key, sec_key); + RGWLibFS* new_fs = new RGWLibFS(static_cast(rgw), uid, acc_key, + sec_key); assert(new_fs); rc = new_fs->authorize(librgw.get_store()); @@ -244,10 +245,15 @@ int rgw_lookup(struct rgw_fs *rgw_fs, RGWFileHandle* rgw_fh; if (parent->is_root()) { - /* XXX if lookup is in the root, then (for now) just get a handle */ - rgw_fh = fs->lookup_fh(parent, path); - if (! rgw_fh) - return ENOENT; + /* special: lookup on root itself */ + if (strcmp(path, "/") == 0) { + rgw_fh = parent->ref(); + } else { + /* name lookup in root--for now) just get a handle */ + rgw_fh = fs->lookup_fh(parent, path); + if (! rgw_fh) + return ENOENT; + } } else { std::string object_name{path}; RGWStatObjRequest req(cct, fs->get_user(), @@ -263,7 +269,7 @@ int rgw_lookup(struct rgw_fs *rgw_fs, rgw_fh = fs->lookup_fh(parent, path); if (! rgw_fh) return ENOENT; - } + } /* !root */ struct rgw_file_handle *rfh = rgw_fh->get_fh(); *fh = rfh; diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index b1801901c495..2eb3da14775e 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -191,6 +191,11 @@ namespace rgw { } } + RGWFileHandle* ref() { + intrusive_ptr_add_ref(this); + return this; + } + inline void rele() { intrusive_ptr_release(this); } @@ -248,6 +253,7 @@ namespace rgw { class RGWLibFS { + CephContext* cct; struct rgw_fs fs; RGWFileHandle root_fh; @@ -262,8 +268,9 @@ namespace rgw { std::string fsid; public: - RGWLibFS(const char *_uid, const char *_user_id, const char* _key) - : root_fh(this), uid(_uid), key(_user_id, _key) { + RGWLibFS(CephContext* _cct, const char *_uid, const char *_user_id, + const char* _key) + : cct(_cct), root_fh(this), uid(_uid), key(_user_id, _key) { /* no bucket may be named rgw_fs_inst-(.*) */ fsid = RGWFileHandle::root_name + "rgw_fs_inst-" + @@ -339,7 +346,7 @@ namespace rgw { } CephContext* get_context() { - return static_cast(get_fs()->fs_private); + return cct; } struct rgw_fs* get_fs() { return &fs; }