]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fold byte_range_t into client_writeable_range_t
authorGreg Farnum <greg@inktank.com>
Thu, 31 Jan 2013 19:00:36 +0000 (11:00 -0800)
committerGreg Farnum <greg@inktank.com>
Tue, 5 Feb 2013 21:29:05 +0000 (13:29 -0800)
As part of this, fold byte_range_t into it as a sub-struct
and eliminate its free-standing functions (it's too small
to live alone).

Signed-off-by: Greg Farnum <greg@inktank.com>
src/mds/mdstypes.cc
src/mds/mdstypes.h

index f27d769fd73f79a6a0ffef99a2a689b55578c8cd..282d22c8cb1a67ec8bb5eebd95c7f9392cbe3c6d 100644 (file)
@@ -190,7 +190,8 @@ ostream& operator<<(ostream &out, const nest_info_t &n)
 void client_writeable_range_t::encode(bufferlist &bl) const
 {
   ENCODE_START(2, 2, bl);
-  ::encode(range, bl);
+  ::encode(range.first, bl);
+  ::encode(range.last, bl);
   ::encode(follows, bl);
   ENCODE_FINISH(bl);
 }
@@ -198,15 +199,18 @@ void client_writeable_range_t::encode(bufferlist &bl) const
 void client_writeable_range_t::decode(bufferlist::iterator& bl)
 {
   DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
-  ::decode(range, bl);
+  ::decode(range.first, bl);
+  ::decode(range.last, bl);
   ::decode(follows, bl);
   DECODE_FINISH(bl);
 }
 
 void client_writeable_range_t::dump(Formatter *f) const
 {
+  f->open_object_section("byte range");
   f->dump_unsigned("first", range.first);
   f->dump_unsigned("last", range.last);
+  f->close_section();
   f->dump_unsigned("follows", follows);
 }
 
@@ -221,6 +225,5 @@ void client_writeable_range_t::generate_test_instances(list<client_writeable_ran
 
 ostream& operator<<(ostream& out, const client_writeable_range_t& r)
 {
-  return out << r.range << "@" << r.follows;
+  return out << r.range.first << '-' << r.range.last << "@" << r.follows;
 }
-
index 8435a59e4b5babd3eb398b862d1bcfbb8788b82d..68bfbcbab3fb0d413a5595ac01386f0605c87fc1 100644 (file)
@@ -282,35 +282,15 @@ inline ostream& operator<<(ostream &out, const vinodeno_t &vino) {
 }
 
 
-struct byte_range_t {
-  uint64_t first, last;    // interval client can write to
-
-  byte_range_t() : first(0), last(0) {}
-
-  void encode(bufferlist &bl) const {
-    ::encode(first, bl);
-    ::encode(last, bl);
-  }
-  void decode(bufferlist::iterator& bl) {
-    ::decode(first, bl);
-    ::decode(last, bl);
-  }    
-};
-WRITE_CLASS_ENCODER(byte_range_t)
-
-inline ostream& operator<<(ostream& out, const byte_range_t& r)
-{
-  return out << r.first << '-' << r.last;
-}
-inline bool operator==(const byte_range_t& l, const byte_range_t& r) {
-  return l.first == r.first && l.last == r.last;
-}
-
-
 /*
  * client_writeable_range_t
  */
 struct client_writeable_range_t {
+  struct byte_range_t {
+    uint64_t first, last;    // interval client can write to
+    byte_range_t() : first(0), last(0) {}
+  };
+
   byte_range_t range;
   snapid_t follows;     // aka "data+metadata flushed thru"
 
@@ -321,12 +301,20 @@ struct client_writeable_range_t {
   void dump(Formatter *f) const;
   static void generate_test_instances(list<client_writeable_range_t*>& ls);
 };
+
+inline void decode(client_writeable_range_t::byte_range_t& range, bufferlist::iterator& bl) {
+  ::decode(range.first, bl);
+  ::decode(range.last, bl);
+}
+
 WRITE_CLASS_ENCODER(client_writeable_range_t)
 
 ostream& operator<<(ostream& out, const client_writeable_range_t& r);
 
-inline bool operator==(const client_writeable_range_t& l, const client_writeable_range_t& r) {
-  return l.range == r.range && l.follows == r.follows;
+inline bool operator==(const client_writeable_range_t& l,
+                      const client_writeable_range_t& r) {
+  return l.range.first == r.range.first && l.range.last == r.range.last &&
+    l.follows == r.follows;
 }
 
 
@@ -505,9 +493,10 @@ struct inode_t {
     if (v >= 3) {
       ::decode(client_ranges, p);
     } else {
-      map<client_t, byte_range_t> m;
+      map<client_t, client_writeable_range_t::byte_range_t> m;
       ::decode(m, p);
-      for (map<client_t, byte_range_t>::iterator q = m.begin(); q != m.end(); q++)
+      for (map<client_t, client_writeable_range_t::byte_range_t>::iterator
+         q = m.begin(); q != m.end(); q++)
        client_ranges[q->first].range = q->second;
     }