]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: default_file_layout now uses modern encoding
authorGreg Farnum <greg@inktank.com>
Thu, 17 Jan 2013 18:23:16 +0000 (10:23 -0800)
committerGreg Farnum <greg@inktank.com>
Tue, 5 Feb 2013 21:29:05 +0000 (13:29 -0800)
And move implementations into mdstypes.cc from CInode and common/types.
mdstypes.cc sadly lives in libcommon; as several of the types we're going
to put there are needed for Messages and similar things.

Signed-off-by: Sage Weil <sage@inktank.com>
Signed-off-by: Greg Farnum <greg@inktank.com>
src/Makefile.am
src/common/types.cc
src/mds/CInode.h
src/mds/mdstypes.cc [new file with mode: 0644]
src/mds/mdstypes.h
src/test/encoding/types.h

index 402386d1868ea509634a887adda2a825ac558953..c95ab5af0533bd3c633e16a23a28193c949d2b9b 100644 (file)
@@ -1279,6 +1279,7 @@ libcommon_files = \
        osd/osd_types.cc \
        mds/MDSMap.cc \
        mds/inode_backtrace.cc \
+       mds/mdstypes.cc \
        common/blkdev.cc \
        common/common_init.cc \
        common/pipe.c \
index c5482e108225f363f7bac000dbb886308a2382fc..d50e7da4a5287a8a18f06c1ef3a10583a9cb97b6 100644 (file)
@@ -4,19 +4,6 @@
 #include "include/types.h"
 #include "common/Formatter.h"
 
-void dump(const ceph_file_layout& l, Formatter *f)
-{
-  f->dump_unsigned("stripe_unit", l.fl_stripe_unit);
-  f->dump_unsigned("stripe_count", l.fl_stripe_count);
-  f->dump_unsigned("object_size", l.fl_object_size);
-  if (l.fl_cas_hash)
-    f->dump_unsigned("cas_hash", l.fl_cas_hash);
-  if (l.fl_object_stripe_unit)
-    f->dump_unsigned("object_stripe_unit", l.fl_object_stripe_unit);
-  if (l.fl_pg_pool)
-    f->dump_unsigned("pg_pool", l.fl_pg_pool);
-}
-
 void dump(const ceph_dir_layout& dl, Formatter *f)
 {
   f->dump_unsigned("dir_hash", dl.dl_dir_hash);
index 51e1eea5d5829085112aafb13d0d88863914884d..7001c933935051bec20f01a6ab2b1d3f9e286710 100644 (file)
@@ -63,37 +63,6 @@ struct cinode_lock_info_t {
 extern cinode_lock_info_t cinode_lock_info[];
 extern int num_cinode_locks;
 
-/**
- * Default file layout stuff. This lets us set a default file layout on
- * a directory inode that all files in its tree will use on creation.
- */
-struct default_file_layout {
-
-  ceph_file_layout layout;
-
-  default_file_layout() {
-    memset(&layout, 0, sizeof(layout));
-  }
-
-  void encode(bufferlist &bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
-    ::encode(layout, bl);
-  }
-
-  void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
-    if (struct_v != 1) { //uh-oh
-      derr << "got default layout I don't understand!" << dendl;
-      assert(0);
-    }
-    ::decode(layout, bl);
-  }
-};
-WRITE_CLASS_ENCODER(default_file_layout);
-
-
 // cached inode wrapper
 class CInode : public MDSCacheObject {
   /*
diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc
new file mode 100644 (file)
index 0000000..3a113af
--- /dev/null
@@ -0,0 +1,49 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+
+#include "mdstypes.h"
+#include "common/Formatter.h"
+
+void default_file_layout::encode(bufferlist &bl) const
+{
+  ENCODE_START(2, 2, bl);
+  ::encode(layout, bl);
+  ENCODE_FINISH(bl);
+}
+
+void default_file_layout::decode(bufferlist::iterator& bl)
+{
+  DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
+  ::decode(layout, bl);
+  DECODE_FINISH(bl);
+}
+
+void dump(const ceph_file_layout& l, Formatter *f)
+{
+  f->dump_unsigned("stripe_unit", l.fl_stripe_unit);
+  f->dump_unsigned("stripe_count", l.fl_stripe_count);
+  f->dump_unsigned("object_size", l.fl_object_size);
+  if (l.fl_cas_hash)
+    f->dump_unsigned("cas_hash", l.fl_cas_hash);
+  if (l.fl_object_stripe_unit)
+    f->dump_unsigned("object_stripe_unit", l.fl_object_stripe_unit);
+  if (l.fl_pg_pool)
+    f->dump_unsigned("pg_pool", l.fl_pg_pool);
+}
+
+void default_file_layout::dump(Formatter *f) const
+{
+  ::dump(layout, f);
+}
+
+void default_file_layout::generate_test_instances(list<default_file_layout*>& ls)
+{
+  ls.push_back(new default_file_layout);
+  ls.push_back(new default_file_layout);
+  ls.back()->layout.fl_stripe_unit = 1024;
+  ls.back()->layout.fl_stripe_count = 2;
+  ls.back()->layout.fl_object_size = 2048;
+  ls.back()->layout.fl_cas_hash = 3;
+  ls.back()->layout.fl_object_stripe_unit = 8;
+  ls.back()->layout.fl_pg_pool = 9;
+}
index 74b8571e0f33f2bb6f27d73f51dface068a289d9..58f647569193b7fe67a2089320ed5dc969e0a8cd 100644 (file)
@@ -107,6 +107,25 @@ inline string ccap_string(int cap)
 }
 
 
+/**
+ * Default file layout stuff. This lets us set a default file layout on
+ * a directory inode that all files in its tree will use on creation.
+ */
+struct default_file_layout {
+  ceph_file_layout layout;
+
+  default_file_layout() {
+    memset(&layout, 0, sizeof(layout));
+  }
+
+  void encode(bufferlist &bl) const;
+  void decode(bufferlist::iterator& bl);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<default_file_layout*>& ls);
+};
+WRITE_CLASS_ENCODER(default_file_layout);
+
+
 struct scatter_info_t {
   version_t version;
 
index 3902337654a184d5114a8c22d04c7be132253f93..321250c17b532d2839ea4396faf4dcf1b8018970 100644 (file)
@@ -96,6 +96,9 @@ TYPE(Anchor)
 TYPE(snaplink_t)
 TYPE(sr_t)*/
 
+#include "mds/mdstypes.h"
+TYPE(default_file_layout)
+
 #ifdef WITH_RADOSGW
 
 #include "rgw/rgw_rados.h"