From b6297a704b62e5477c3539197a5af7da637f0cb7 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Wed, 13 Apr 2016 10:07:05 -0400 Subject: [PATCH] rgw_file: fix silly abuse of flags in fh_lookup Initially lookup_fh used its cflags argument just to proxy create flags to new objects. It's used for call path state now too, so disambiguate it, and of course, fh->flags can't be consulted for a call path state. Signed-off-by: Matt Benjamin --- src/rgw/rgw_file.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 0cf1d679f5b..d1c627c1fd6 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -216,6 +216,9 @@ namespace rgw { static constexpr uint32_t FLAG_LOCK = 0x0040; static constexpr uint32_t FLAG_DELETED = 0x0080; +#define CREATE_FLAGS(x) \ + ((x) & ~(RGWFileHandle::FLAG_CREATE|RGWFileHandle::FLAG_LOCK)) + friend class RGWLibFS; private: @@ -784,7 +787,7 @@ namespace rgw { /* find or create an RGWFileHandle */ LookupFHResult lookup_fh(RGWFileHandle* parent, const char *name, - const uint32_t cflags = RGWFileHandle::FLAG_NONE) { + const uint32_t flags = RGWFileHandle::FLAG_NONE) { using std::get; LookupFHResult fhr { nullptr, RGWFileHandle::FLAG_NONE }; @@ -822,19 +825,19 @@ namespace rgw { goto retry; /* !LATCHED */ } /* LATCHED, LOCKED */ - if (! (fh->flags & RGWFileHandle::FLAG_LOCK)) + if (! (flags & RGWFileHandle::FLAG_LOCK)) fh->mtx.unlock(); /* ! LOCKED */ } else { /* make or re-use handle */ RGWFileHandle::Factory prototype(this, get_inst(), parent, fhk, - obj_name, cflags); + obj_name, CREATE_FLAGS(flags)); fh = static_cast( fh_lru.insert(&prototype, cohort::lru::Edge::MRU, cohort::lru::FLAG_INITIAL)); if (fh) { /* lock fh (LATCHED) */ - if (fh->flags & RGWFileHandle::FLAG_LOCK) + if (flags & RGWFileHandle::FLAG_LOCK) fh->mtx.lock(); /* inserts, releasing latch */ fh_cache.insert_latched(fh, lat, RGWFileHandle::FHCache::FLAG_UNLOCK);