diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2017-07-27 15:16:39 +0200 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2017-08-01 16:46:45 +0200 |
commit | f53b7665c8cec40c8a638b55ee098b721e6be20c (patch) | |
tree | ab5cbcfbfee3cc1670e738b7c89ea55cbe279d63 /net | |
parent | c7ed1a4bf4b446317eefa0f4916d94b1f6d3ada5 (diff) | |
download | linux-stable-f53b7665c8cec40c8a638b55ee098b721e6be20c.tar.gz linux-stable-f53b7665c8cec40c8a638b55ee098b721e6be20c.tar.bz2 linux-stable-f53b7665c8cec40c8a638b55ee098b721e6be20c.zip |
libceph: upmap semantic changes
- apply both pg_upmap and pg_upmap_items
- allow bidirectional swap of pg-upmap-items
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Sage Weil <sage@redhat.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/osdmap.c | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 2586e5546143..0bec71fa712e 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -2437,40 +2437,23 @@ static void apply_upmap(struct ceph_osdmap *osdmap, for (i = 0; i < pg->pg_upmap.len; i++) raw->osds[i] = pg->pg_upmap.osds[i]; raw->size = pg->pg_upmap.len; - return; + /* check and apply pg_upmap_items, if any */ } pg = lookup_pg_mapping(&osdmap->pg_upmap_items, pgid); if (pg) { - /* - * Note: this approach does not allow a bidirectional swap, - * e.g., [[1,2],[2,1]] applied to [0,1,2] -> [0,2,1]. - */ - for (i = 0; i < pg->pg_upmap_items.len; i++) { - int from = pg->pg_upmap_items.from_to[i][0]; - int to = pg->pg_upmap_items.from_to[i][1]; - int pos = -1; - bool exists = false; - - /* make sure replacement doesn't already appear */ - for (j = 0; j < raw->size; j++) { - int osd = raw->osds[j]; - - if (osd == to) { - exists = true; + for (i = 0; i < raw->size; i++) { + for (j = 0; j < pg->pg_upmap_items.len; j++) { + int from = pg->pg_upmap_items.from_to[j][0]; + int to = pg->pg_upmap_items.from_to[j][1]; + + if (from == raw->osds[i]) { + if (!(to != CRUSH_ITEM_NONE && + to < osdmap->max_osd && + osdmap->osd_weight[to] == 0)) + raw->osds[i] = to; break; } - /* ignore mapping if target is marked out */ - if (osd == from && pos < 0 && - !(to != CRUSH_ITEM_NONE && - to < osdmap->max_osd && - osdmap->osd_weight[to] == 0)) { - pos = j; - } - } - if (!exists && pos >= 0) { - raw->osds[pos] = to; - return; } } } |