From a08e0bfacdab6930237806e003365444a459e045 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 22 Mar 2020 20:36:29 +0300 Subject: [PATCH] Treat misplaced and degraded as separate state parts --- osd_peering_pg.cpp | 38 ++++++++++---------------------------- osd_peering_pg.h | 7 +++---- 2 files changed, 13 insertions(+), 32 deletions(-) diff --git a/osd_peering_pg.cpp b/osd_peering_pg.cpp index f3f64fda..ca925620 100644 --- a/osd_peering_pg.cpp +++ b/osd_peering_pg.cpp @@ -4,28 +4,10 @@ void pg_t::remember_object(pg_obj_state_check_t &st, std::vector & { auto & pg = *this; // Remember the decision - uint64_t state = 0; - if (st.target_ver == 0) + uint64_t state = OBJ_CLEAN; + if (st.target_ver > 0) { - st.has_roles = st.n_copies = st.n_roles = st.n_stable = st.n_matched = 0; - st.ver_start = st.ver_end = st.obj_end; - state = OBJ_CLEAN; - } - else - { - if (st.n_roles == pg.pg_cursize) - { - if (st.n_matched == pg.pg_cursize) - { - state = OBJ_CLEAN; - } - else - { - state = OBJ_MISPLACED; - pg.state = pg.state | PG_HAS_MISPLACED; - } - } - else if (st.n_roles < pg.pg_minsize) + if (st.n_roles < pg.pg_minsize) { printf("Object is incomplete: inode=%lu stripe=%lu version=%lu/%lu\n", st.oid.inode, st.oid.stripe, st.target_ver, st.max_ver); for (int i = st.ver_start; i < st.ver_end; i++) @@ -35,7 +17,7 @@ void pg_t::remember_object(pg_obj_state_check_t &st, std::vector & state = OBJ_INCOMPLETE; pg.state = pg.state | PG_HAS_INCOMPLETE; } - else + else if (st.n_roles < pg.pg_cursize) { printf("Object is degraded: inode=%lu stripe=%lu version=%lu/%lu\n", st.oid.inode, st.oid.stripe, st.target_ver, st.max_ver); for (int i = st.ver_start; i < st.ver_end; i++) @@ -45,9 +27,9 @@ void pg_t::remember_object(pg_obj_state_check_t &st, std::vector & state = OBJ_DEGRADED; pg.state = pg.state | PG_HAS_DEGRADED; } - if (st.n_copies > pg.pg_size) + if (st.n_mismatched > 0) { - state |= OBJ_OVERCOPIED; + state |= OBJ_MISPLACED; pg.state = pg.state | PG_HAS_MISPLACED; } if (st.n_stable < st.n_copies) @@ -214,7 +196,7 @@ void pg_t::calc_object_states() st.last_ver = st.max_ver = all[i].version; st.target_ver = 0; st.ver_start = i; - st.has_roles = st.n_copies = st.n_roles = st.n_stable = st.n_matched = 0; + st.has_roles = st.n_copies = st.n_roles = st.n_stable = st.n_mismatched = 0; } if (!st.target_ver && st.last_ver != all[i].version && (st.n_stable > 0 || st.n_roles >= pg.pg_minsize)) { @@ -227,7 +209,7 @@ void pg_t::calc_object_states() if (st.last_ver != all[i].version) { st.ver_start = i; - st.has_roles = st.n_copies = st.n_roles = st.n_stable = st.n_matched = 0; + st.has_roles = st.n_copies = st.n_roles = st.n_stable = st.n_mismatched = 0; st.last_ver = all[i].version; } replica = (all[i].oid.stripe & STRIPE_MASK); @@ -243,9 +225,9 @@ void pg_t::calc_object_states() { st.n_stable++; } - if (pg.cur_set[replica] == all[i].osd_num) + if (pg.cur_set[replica] != all[i].osd_num) { - st.n_matched++; + st.n_mismatched++; } if (!(st.has_roles & (1 << replica))) { diff --git a/osd_peering_pg.h b/osd_peering_pg.h index e820d0a7..c37de105 100644 --- a/osd_peering_pg.h +++ b/osd_peering_pg.h @@ -26,12 +26,11 @@ // OSD object states #define OBJ_CLEAN 0x01 -#define OBJ_MISPLACED 0x02 -#define OBJ_DEGRADED 0x03 +#define OBJ_DEGRADED 0x02 #define OBJ_INCOMPLETE 0x04 +#define OBJ_MISPLACED 0x08 #define OBJ_NEEDS_STABLE 0x10000 #define OBJ_NEEDS_ROLLBACK 0x20000 -#define OBJ_OVERCOPIED 0x40000 #define OBJ_BUGGY 0x80000 struct pg_obj_loc_t @@ -77,7 +76,7 @@ struct pg_obj_state_check_t uint64_t max_ver = 0; uint64_t last_ver = 0; uint64_t target_ver = 0; - uint64_t n_copies = 0, has_roles = 0, n_roles = 0, n_stable = 0, n_matched = 0; + uint64_t n_copies = 0, has_roles = 0, n_roles = 0, n_stable = 0, n_mismatched = 0; bool is_buggy = false, has_old_unstable = false; pg_osd_set_t osd_set; };