"name=pgid,type=CephPgid ",
"clear pg primary setting for <pgid>",
"osd", "rw")
+COMMAND("osd rm-pg-upmap-primary-all ",
+ "clear all pg primary entries (developers only)",
+ "osd", "rw")
COMMAND("osd primary-temp "
"name=pgid,type=CephPgid "
"name=id,type=CephOsdName",
prefix == "osd pg-upmap-items" ||
prefix == "osd rm-pg-upmap-items" ||
prefix == "osd pg-upmap-primary" ||
- prefix == "osd rm-pg-upmap-primary") {
+ prefix == "osd rm-pg-upmap-primary" ||
+ prefix == "osd rm-pg-upmap-primary-all") {
enum {
OP_PG_UPMAP,
OP_RM_PG_UPMAP,
OP_RM_PG_UPMAP_ITEMS,
OP_PG_UPMAP_PRIMARY,
OP_RM_PG_UPMAP_PRIMARY,
+ OP_RM_PG_UPMAP_PRIMARY_ALL,
} upmap_option;
if (prefix == "osd pg-upmap") {
upmap_option = OP_PG_UPMAP_PRIMARY;
} else if (prefix == "osd rm-pg-upmap-primary") {
upmap_option = OP_RM_PG_UPMAP_PRIMARY;
+ } else if (prefix == "osd rm-pg-upmap-primary-all") {
+ upmap_option = OP_RM_PG_UPMAP_PRIMARY_ALL;
} else {
ceph_abort_msg("invalid upmap option");
}
case OP_PG_UPMAP_PRIMARY: // fall through
case OP_RM_PG_UPMAP_PRIMARY:
+ case OP_RM_PG_UPMAP_PRIMARY_ALL:
min_release = ceph_release_t::reef;
min_feature = CEPH_FEATUREMASK_SERVER_REEF;
feature_name = "pg-upmap-primary";
goto wait;
if (err < 0)
goto reply_no_propose;
+
pg_t pgid;
- err = parse_pgid(cmdmap, ss, pgid);
- if (err < 0)
- goto reply_no_propose;
- if (pending_inc.old_pools.count(pgid.pool())) {
- ss << "pool of " << pgid << " is pending removal";
- err = -ENOENT;
- getline(ss, rs);
- wait_for_commit(op,
- new Monitor::C_Command(mon, op, err, rs, get_last_committed() + 1));
- return true;
+ switch (upmap_option) {
+ case OP_RM_PG_UPMAP_PRIMARY_ALL: // no pgid to check
+ break;
+
+ case OP_PG_UPMAP:
+ case OP_RM_PG_UPMAP:
+ case OP_PG_UPMAP_ITEMS:
+ case OP_RM_PG_UPMAP_ITEMS:
+ case OP_PG_UPMAP_PRIMARY:
+ case OP_RM_PG_UPMAP_PRIMARY:
+ err = parse_pgid(cmdmap, ss, pgid);
+ if (err < 0)
+ goto reply_no_propose;
+ if (pending_inc.old_pools.count(pgid.pool())) {
+ ss << "pool of " << pgid << " is pending removal";
+ err = -ENOENT;
+ getline(ss, rs);
+ wait_for_commit(op,
+ new Monitor::C_Command(mon, op, err, rs, get_last_committed() + 1));
+ return true;
+ }
+ break;
+
+ default:
+ ceph_abort_msg("invalid upmap option");
}
// check pending upmap changes
goto wait;
}
break;
+ case OP_RM_PG_UPMAP_PRIMARY_ALL: // nothing to check
+ break;
default:
ceph_abort_msg("invalid upmap option");
}
break;
+ case OP_RM_PG_UPMAP_PRIMARY_ALL:
+ {
+ osdmap.rm_all_upmap_prims(cct, &pending_inc);
+ ss << "cleared all pg_upmap_primary mappings";
+ }
+ break;
+
default:
ceph_abort_msg("invalid upmap option");
}
return num_changes;
}
+void OSDMap::rm_all_upmap_prims(
+ CephContext *cct,
+ OSDMap::Incremental *pending_inc)
+{
+ for (const auto& [pg, _] : pg_upmap_primaries) {
+ if (pending_inc->new_pg_upmap_primary.contains(pg)) {
+ ldout(cct, 30) << __func__ << "Removing pending pg_upmap_prim for pg " << pg << dendl;
+ pending_inc->new_pg_upmap_primary.erase(pg);
+ }
+ ldout(cct, 30) << __func__ << "Removing pg_upmap_prim for pg " << pg << dendl;
+ pending_inc->old_pg_upmap_primary.insert(pg);
+ }
+}
+
int OSDMap::calc_desired_primary_distribution(
CephContext *cct,
int64_t pid,