From 23c2fa7fc230702e04a9a1b32830181d7b08a7c6 Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Thu, 28 Mar 2013 19:24:51 +0000 Subject: [PATCH] osd: osd_types: add pool quota related fields --- src/osd/osd_types.cc | 18 +++++++++++++++++- src/osd/osd_types.h | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 3fd134e31edce..8410d83a7b1b5 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -551,6 +551,8 @@ void pg_pool_t::dump(Formatter *f) const } f->close_section(); f->dump_stream("removed_snaps") << removed_snaps; + f->dump_int("quota_max_bytes", quota_max_bytes); + f->dump_int("quota_max_objects", quota_max_objects); } @@ -755,7 +757,7 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const return; } - ENCODE_START(7, 5, bl); + ENCODE_START(8, 5, bl); ::encode(type, bl); ::encode(size, bl); ::encode(crush_ruleset, bl); @@ -774,6 +776,8 @@ void pg_pool_t::encode(bufferlist& bl, uint64_t features) const ::encode(flags, bl); ::encode(crash_replay_interval, bl); ::encode(min_size, bl); + ::encode(quota_max_bytes, bl); + ::encode(quota_max_objects, bl); ENCODE_FINISH(bl); } @@ -828,6 +832,10 @@ void pg_pool_t::decode(bufferlist::iterator& bl) } else { min_size = size - size/2; } + if (struct_v >= 8) { + ::decode(quota_max_bytes, bl); + ::decode(quota_max_objects, bl); + } DECODE_FINISH(bl); calc_pg_masks(); } @@ -848,6 +856,8 @@ void pg_pool_t::generate_test_instances(list& o) a.snap_epoch = 11; a.auid = 12; a.crash_replay_interval = 13; + a.quota_max_bytes = 473; + a.quota_max_objects = 474; o.push_back(new pg_pool_t(a)); a.snaps[3].name = "asdf"; @@ -859,6 +869,8 @@ void pg_pool_t::generate_test_instances(list& o) o.push_back(new pg_pool_t(a)); a.removed_snaps.insert(2); // not quite valid to combine with snaps! + a.quota_max_bytes = 2473; + a.quota_max_objects = 4374; o.push_back(new pg_pool_t(a)); } @@ -877,6 +889,10 @@ ostream& operator<<(ostream& out, const pg_pool_t& p) out << " flags " << p.flags; if (p.crash_replay_interval) out << " crash_replay_interval " << p.crash_replay_interval; + if (p.quota_max_bytes) + out << " max_bytes " << p.quota_max_bytes; + if (p.quota_max_objects) + out << " max_objects " << p.quota_max_objects; return out; } diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index d20e842859cd5..dbed64ec5d179 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -623,6 +623,7 @@ struct pg_pool_t { }; enum { FLAG_HASHPSPOOL = 1, // hash pg seed and pool together (instead of adding) + FLAG_FULL = 2, // pool is full }; static const char *get_type_name(int t) { @@ -650,6 +651,9 @@ public: uint64_t auid; /// who owns the pg __u32 crash_replay_interval; /// seconds to allow clients to replay ACKed but unCOMMITted requests + uint64_t quota_max_bytes; /// maximum number of bytes for this pool + uint64_t quota_max_objects; /// maximum number of objects for this pool + /* * Pool snaps (global to this pool). These define a SnapContext for * the pool, unless the client manually specifies an alternate @@ -674,6 +678,7 @@ public: snap_seq(0), snap_epoch(0), auid(0), crash_replay_interval(0), + quota_max_bytes(0), quota_max_objects(0), pg_num_mask(0), pgp_num_mask(0) { } void dump(Formatter *f) const; @@ -714,6 +719,20 @@ public: calc_pg_masks(); } + void set_quota_max_bytes(uint64_t m) { + quota_max_bytes = m; + } + uint64_t get_quota_max_bytes() { + return quota_max_bytes; + } + + void set_quota_max_objects(uint64_t m) { + quota_max_objects = m; + } + uint64_t get_quota_max_objects() { + return quota_max_objects; + } + static int calc_bits_of(int t); void calc_pg_masks(); -- 2.39.5