From: Matt Benjamin Date: Sun, 10 Jan 2016 23:32:54 +0000 (-0500) Subject: librgw: partial getattrs/gc checks X-Git-Tag: v10.1.0~382^2~45 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a50416bcd6538dff2ab3e573fe13715853833a8b;p=ceph.git librgw: partial getattrs/gc checks Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 44cee94088c..64b219bf298 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -272,6 +272,10 @@ namespace rgw { size_t get_size() const { return state.size; } + const char* stype() { + return is_dir() ? "DIR" : "FILE"; + } + uint16_t get_depth() const { return depth; } struct rgw_file_handle* get_fh() { return &fh; } diff --git a/src/test/librgw_file_nfsns.cc b/src/test/librgw_file_nfsns.cc index eadace2a5ad..3e15c0ab015 100644 --- a/src/test/librgw_file_nfsns.cc +++ b/src/test/librgw_file_nfsns.cc @@ -190,10 +190,6 @@ TEST(LibRGW, SETUP_HIER1) } } -// create b2 -// create dirs in b2 -// create files in dirs in b2 -// do getattrs (check type and times) TEST(LibRGW, SETUP_DIRS1) { if (do_dirs1) { int rc; @@ -327,6 +323,36 @@ TEST(LibRGW, BAD_DELETES_DIRS1) { } } +TEST(LibRGW, RELEASE_DIRS1) { + if (do_dirs1) { + /* force release of handles for children of dirs1--force subsequent + * checks to reload them from the cluster. + * + * while doing this, verify handle cleanup and correct LRU state + * (not reachable) + */ + int rc; + for (auto& dirs_rec : dirs_vec) { + for (auto& obj : get<1>(dirs_rec)) { + if (verbose) { + std::cout << "release " << obj.name + << " type: " << obj.rgw_fh->stype() + << " refs: " << obj.rgw_fh->get_refcnt() + << std::endl; + } + ASSERT_EQ(obj.rgw_fh->get_refcnt(), 2); + rc = rgw_fh_rele(fs, obj.fh, 0 /* flags */); + ASSERT_EQ(rc, 0); + ASSERT_EQ(obj.rgw_fh->get_refcnt(), 1); + /* try-discard handle */ + /* clear obj_rec vec */ + } + } + } +} + +// do getattrs (check type and times) + extern "C" { static bool r1_cb(const char* name, void *arg, uint64_t offset) { struct rgw_file_handle* parent_fh