Skip to content

Commit

Permalink
Merge pull request #13084 from linuxbox2/wip-librgw-parentref
Browse files Browse the repository at this point in the history
rgw_file:  interned RGWFileHandle objects need parent refs
  • Loading branch information
mattbenjamin committed Jan 24, 2017
2 parents 3140a52 + 0e5299f commit 3534595
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/rgw/rgw_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,19 @@ namespace rgw {
} while (! (stop || shutdown));
} /* RGWLibFS::gc */

RGWFileHandle::~RGWFileHandle() {
if (parent && (! parent->is_root())) {
/* safe because if parent->unref causes its deletion,
* there are a) by refcnt, no other objects/paths pointing
* to it and b) by the semantics of valid iteration of
* fh_lru (observed, e.g., by cohort_lru<T,...>::drain())
* no unsafe iterators reaching it either--n.b., this constraint
* is binding oncode which may in future attempt to e.g.,
* cause the eviction of objects in LRU order */
(void) get_fs()->fh_lru.unref(parent, cohort::lru::FLAG_NONE);
}
}

void RGWFileHandle::encode_attrs(ceph::buffer::list& ux_key1,
ceph::buffer::list& ux_attrs1)
{
Expand Down
6 changes: 5 additions & 1 deletion src/rgw/rgw_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ namespace rgw {
typedef cohort::lru::TreeX<RGWFileHandle, FhTree, FhLT, FhEQ, fh_key,
std::mutex> FHCache;

virtual ~RGWFileHandle() {}
virtual ~RGWFileHandle();

class Factory : public cohort::lru::ObjectFactory
{
Expand Down Expand Up @@ -958,6 +958,10 @@ namespace rgw {
/* inserts, releasing latch */
fh_cache.insert_latched(fh, lat, RGWFileHandle::FHCache::FLAG_UNLOCK);
get<1>(fhr) |= RGWFileHandle::FLAG_CREATE;
/* ref parent (non-initial ref cannot fail on valid object) */
if (! parent->is_root()) {
(void) fh_lru.ref(parent, cohort::lru::FLAG_NONE);
}
goto out; /* !LATCHED */
} else {
lat.lock->unlock();
Expand Down

0 comments on commit 3534595

Please sign in to comment.