From 73829a5cbd5b5c53cd49f0b29a5df11c6f345942 Mon Sep 17 00:00:00 2001 From: sageweil Date: Sat, 29 Sep 2007 00:28:23 +0000 Subject: [PATCH] ref_set can be ifdefed out with MDS_REF_SET git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1869 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/mds/CInode.h | 4 ++++ trunk/ceph/mds/mdstypes.h | 35 +++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/trunk/ceph/mds/CInode.h b/trunk/ceph/mds/CInode.h index 569db3a0a9fe9..1af9cc8cdf662 100644 --- a/trunk/ceph/mds/CInode.h +++ b/trunk/ceph/mds/CInode.h @@ -433,12 +433,16 @@ public: // -- reference counting -- void bad_put(int by) { generic_dout(7) << " bad put " << *this << " by " << by << " " << pin_name(by) << " was " << ref << " (" << ref_set << ")" << dendl; +#ifdef MDS_REF_SET assert(ref_set.count(by) == 1); +#endif assert(ref > 0); } void bad_get(int by) { generic_dout(7) << " bad get " << *this << " by " << by << " " << pin_name(by) << " was " << ref << " (" << ref_set << ")" << dendl; +#ifdef MDS_REF_SET assert(ref_set.count(by) == 0); +#endif } void first_get(); void last_put(); diff --git a/trunk/ceph/mds/mdstypes.h b/trunk/ceph/mds/mdstypes.h index 41588b30196ce..f48c4e2d34ca4 100644 --- a/trunk/ceph/mds/mdstypes.h +++ b/trunk/ceph/mds/mdstypes.h @@ -18,6 +18,7 @@ using namespace std; #include "include/frag.h" +#define MDS_REF_SET // define me for improved debug output, sanity checking #define MDS_PORT_MAIN 0 #define MDS_PORT_SERVER 1 @@ -35,12 +36,12 @@ using namespace std; #define MDS_INO_ROOT 1 #define MDS_INO_PGTABLE 2 #define MDS_INO_ANCHORTABLE 3 -#define MDS_INO_PG 4 // this should match osd/osd_types.h PG_INO -#define MDS_INO_LOG_OFFSET 0x100 -#define MDS_INO_IDS_OFFSET 0x200 -#define MDS_INO_CLIENTMAP_OFFSET 0x300 -#define MDS_INO_STRAY_OFFSET 0x400 -#define MDS_INO_BASE 0x1000 +#define MDS_INO_PG 4 // *** WARNING: this should match osd/osd_types.h PG_INO *** +#define MDS_INO_LOG_OFFSET (1*MAX_MDS) +#define MDS_INO_IDS_OFFSET (2*MAX_MDS) +#define MDS_INO_CLIENTMAP_OFFSET (3*MAX_MDS) +#define MDS_INO_STRAY_OFFSET (4*MAX_MDS) +#define MDS_INO_BASE (5*MAX_MDS) #define MDS_INO_STRAY(x) (MDS_INO_STRAY_OFFSET+((unsigned)x)) #define MDS_INO_IS_STRAY(i) ((i) >= MDS_INO_STRAY_OFFSET && (i) < MDS_INO_STRAY_OFFSET+MAX_MDS) @@ -437,26 +438,36 @@ class MDSCacheObject { // pins protected: int ref; // reference count +#ifdef MDS_REF_SET multiset ref_set; +#endif public: int get_num_ref() { return ref; } - bool is_pinned_by(int by) { return ref_set.count(by); } - multiset& get_ref_set() { return ref_set; } virtual const char *pin_name(int by) = 0; + //bool is_pinned_by(int by) { return ref_set.count(by); } + //multiset& get_ref_set() { return ref_set; } virtual void last_put() {} virtual void bad_put(int by) { +#ifdef MDS_REF_SET assert(ref_set.count(by) > 0); +#endif assert(ref > 0); } void put(int by) { +#ifdef MDS_REF_SET if (ref == 0 || ref_set.count(by) == 0) { +#else + if (ref == 0) { +#endif bad_put(by); } else { ref--; +#ifdef MDS_REF_SET ref_set.erase(ref_set.find(by)); assert(ref == (int)ref_set.size()); +#endif if (ref == 0) last_put(); } @@ -464,22 +475,29 @@ protected: virtual void first_get() {} virtual void bad_get(int by) { +#ifdef MDS_REF_SET assert(by < 0 || ref_set.count(by) == 0); +#endif assert(0); } void get(int by) { +#ifdef MDS_REF_SET if (by >= 0 && ref_set.count(by)) { bad_get(by); } else { +#endif if (ref == 0) first_get(); ref++; +#ifdef MDS_REF_SET ref_set.insert(by); assert(ref == (int)ref_set.size()); } +#endif } void print_pin_set(ostream& out) { +#ifdef MDS_REF_SET multiset::iterator it = ref_set.begin(); while (it != ref_set.end()) { out << " " << pin_name(*it); @@ -492,6 +510,7 @@ protected: if (c > 1) out << "*" << c; } +#endif } -- 2.39.5