diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2017-06-15 16:30:53 +0200 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2017-07-07 17:25:15 +0200 |
commit | dc98ff7230e5ccf11c621dff0d590e83574a7184 (patch) | |
tree | bc98e0f8cf3c0d5800ac6b6d57519d99ffacfc6f /net/ceph/osdmap.c | |
parent | 8e48cf00c48fdefb01f70db81f31438cd0c29dcc (diff) | |
download | linux-dc98ff7230e5ccf11c621dff0d590e83574a7184.tar.gz linux-dc98ff7230e5ccf11c621dff0d590e83574a7184.tar.bz2 linux-dc98ff7230e5ccf11c621dff0d590e83574a7184.zip |
libceph: introduce ceph_spg, ceph_pg_to_primary_shard()
Store both raw pgid and actual spgid in ceph_osd_request_target.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'net/ceph/osdmap.c')
-rw-r--r-- | net/ceph/osdmap.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 710ee3dc01b9..a4155620eace 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -2265,6 +2265,39 @@ out: WARN_ON(!osds_valid(up) || !osds_valid(acting)); } +bool ceph_pg_to_primary_shard(struct ceph_osdmap *osdmap, + const struct ceph_pg *raw_pgid, + struct ceph_spg *spgid) +{ + struct ceph_pg_pool_info *pi; + struct ceph_pg pgid; + struct ceph_osds up, acting; + int i; + + pi = ceph_pg_pool_by_id(osdmap, raw_pgid->pool); + if (!pi) + return false; + + raw_pg_to_pg(pi, raw_pgid, &pgid); + + if (ceph_can_shift_osds(pi)) { + spgid->pgid = pgid; /* struct */ + spgid->shard = CEPH_SPG_NOSHARD; + return true; + } + + ceph_pg_to_up_acting_osds(osdmap, &pgid, &up, &acting); + for (i = 0; i < acting.size; i++) { + if (acting.osds[i] == acting.primary) { + spgid->pgid = pgid; /* struct */ + spgid->shard = i; + return true; + } + } + + return false; +} + /* * Return acting primary for given PG, or -1 if none. */ |