summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage.weil@dreamhost.com>2011-09-04 20:28:30 -0700
committerSage Weil <sage.weil@dreamhost.com>2011-09-06 21:03:05 -0700
commit051f8431bc44a0e931fa1609839559137576d78c (patch)
treece92548b50b1e19d63829b3e78f7e2b2b4afd593
parent07e366f96d4fa4f94db0fac795386e5e9c0063ee (diff)
downloadceph-051f8431bc44a0e931fa1609839559137576d78c.tar.gz
crush: replace magic with encoding version and feature bits
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
-rw-r--r--src/crush/CrushWrapper.h16
-rw-r--r--src/crush/crush.h3
-rw-r--r--src/crush/mapper.c4
3 files changed, 15 insertions, 8 deletions
diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h
index dd2abc7c569..11357d5ec99 100644
--- a/src/crush/CrushWrapper.h
+++ b/src/crush/CrushWrapper.h
@@ -412,8 +412,10 @@ public:
void encode(bufferlist &bl, bool lean=false) {
if (!crush) create(); // duh.
- __u32 magic = CRUSH_MAGIC;
- ::encode(magic, bl);
+ __u16 struct_v = 1;
+ ::encode(struct_v, bl);
+
+ ::encode(crush->features, bl);
::encode(crush->max_buckets, bl);
::encode(crush->max_rules, bl);
@@ -487,10 +489,12 @@ public:
{
create();
- __u32 magic;
- ::decode(magic, blp);
- if (magic != CRUSH_MAGIC)
- throw buffer::malformed_input("bad magic number");
+ __u16 struct_v;
+ ::decode(struct_v, blp);
+ if (struct_v > 1)
+ throw buffer::malformed_input("unsupported encoding");
+
+ ::decode(crush->features, blp);
::decode(crush->max_buckets, blp);
::decode(crush->max_rules, blp);
diff --git a/src/crush/crush.h b/src/crush/crush.h
index 86cffca093e..8595f88b1a2 100644
--- a/src/crush/crush.h
+++ b/src/crush/crush.h
@@ -17,7 +17,6 @@
*/
-#define CRUSH_MAGIC 0x00010000ul /* for detecting algorithm revisions */
#define CRUSH_MAX_DEPTH 10 /* max crush hierarchy depth */
@@ -151,6 +150,8 @@ struct crush_bucket_straw {
* CRUSH map includes all buckets, rules, etc.
*/
struct crush_map {
+ __u16 features;
+
struct crush_bucket **buckets;
struct crush_rule **rules;
diff --git a/src/crush/mapper.c b/src/crush/mapper.c
index 621422ffd96..22c0b4933d0 100644
--- a/src/crush/mapper.c
+++ b/src/crush/mapper.c
@@ -4,6 +4,7 @@
# include <linux/slab.h>
# include <linux/bug.h>
# include <linux/kernel.h>
+# include <linux/errno.h>
# ifndef dprintk
# define dprintk(args...)
# endif
@@ -12,6 +13,7 @@
# include <stdio.h>
# include <stdlib.h>
# include <assert.h>
+# include <errno.h>
# define BUG_ON(x) assert(!(x))
# define dprintk(args...) /* printf(args) */
# define kmalloc(x, f) malloc(x)
@@ -677,7 +679,7 @@ int crush_do_rule(struct crush_map *map,
break;
default:
- BUG_ON(1);
+ return -EOPNOTSUPP;
}
}
rc = result_len;