diff options
author | Sage Weil <sage.weil@dreamhost.com> | 2011-09-04 20:51:05 -0700 |
---|---|---|
committer | Sage Weil <sage.weil@dreamhost.com> | 2011-09-06 21:03:05 -0700 |
commit | 9c0793d4cc2ab1f1c14e9512293cff070a50b2d2 (patch) | |
tree | b80659444a56c5907e442988cbbe4d98c4725add | |
parent | 051f8431bc44a0e931fa1609839559137576d78c (diff) | |
download | ceph-9c0793d4cc2ab1f1c14e9512293cff070a50b2d2.tar.gz |
crush: add PUSHOP feature bit
Set the PUSHPOP feature bit while encoding if we use any of the new
PUSH/POP/SHIFT/UNSHIF rule ops.
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
-rw-r--r-- | src/crush/CrushWrapper.h | 17 | ||||
-rw-r--r-- | src/crush/crush.h | 6 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 11357d5ec99..c94536f3af1 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -409,12 +409,29 @@ public: return bl.write_file(fn); } + void calc_features() { + // see if we have any rules that use push|pop|shift|unshift + for (unsigned i=0; i<crush->max_rules; ++i) { + crush_rule *r = crush->rules[i]; + if (r == NULL) + continue; + for (unsigned j=0; j<r->len; ++j) { + if (r->steps[j].op == CRUSH_RULE_PUSH || + r->steps[j].op == CRUSH_RULE_POP || + r->steps[j].op == CRUSH_RULE_SHIFT || + r->steps[j].op == CRUSH_RULE_UNSHIFT) + crush->features |= CRUSH_FEATURE_PUSHPOP; + } + } + } + void encode(bufferlist &bl, bool lean=false) { if (!crush) create(); // duh. __u16 struct_v = 1; ::encode(struct_v, bl); + calc_features(); ::encode(crush->features, bl); ::encode(crush->max_buckets, bl); diff --git a/src/crush/crush.h b/src/crush/crush.h index 8595f88b1a2..0c60920a0f8 100644 --- a/src/crush/crush.h +++ b/src/crush/crush.h @@ -17,7 +17,9 @@ */ +#define CRUSH_FEATURE_PUSHPOP (1<<0) +#define CRUSH_FEATURE_ALL (CRUSH_FEATURE_PUSHPOP) #define CRUSH_MAX_DEPTH 10 /* max crush hierarchy depth */ #define CRUSH_MAX_SET 10 /* max size of a mapping result */ @@ -150,6 +152,10 @@ struct crush_bucket_straw { * CRUSH map includes all buckets, rules, etc. */ struct crush_map { + /* + * Bit mask indicating which CRUSH_FEATURE_* features are used + * by this map. + */ __u16 features; struct crush_bucket **buckets; |