diff --git a/as/include/storage/drv_common.h b/as/include/storage/drv_common.h index 56869439..f1c2f27c 100644 --- a/as/include/storage/drv_common.h +++ b/as/include/storage/drv_common.h @@ -168,8 +168,7 @@ COMPILER_ASSERT(offsetof(drv_header, generic.prefix) == 0); // Public API - shared code between storage engines. // -void drv_adjust_versions(struct as_namespace_s* ns, drv_pmeta* pmeta); -void drv_auto_revive(struct as_namespace_s* ns, drv_pmeta* pmeta); +void drv_adjust_sc_version_flags(struct as_namespace_s* ns, drv_pmeta* pmeta, bool wiped_drives, bool dirty); bool drv_is_set_evictable(const struct as_namespace_s* ns, const struct as_flat_opt_meta_s* opt_meta); void drv_apply_opt_meta(struct as_index_s* r, struct as_namespace_s* ns, const struct as_flat_opt_meta_s* opt_meta); bool pread_all(int fd, void* buf, size_t size, off_t offset); diff --git a/as/src/storage/drv_mem.c b/as/src/storage/drv_mem.c index e2815089..2b6c489a 100644 --- a/as/src/storage/drv_mem.c +++ b/as/src/storage/drv_mem.c @@ -1211,7 +1211,7 @@ init_synchronous(drv_mems* mems) headers[i]->unique.device_id = (uint32_t)i; } - drv_adjust_versions(ns, mems->generic->pmeta); + drv_adjust_sc_version_flags(ns, mems->generic->pmeta, true, false); flush_header(mems, headers); @@ -1229,7 +1229,7 @@ init_synchronous(drv_mems* mems) // At least one device is not fresh. Check that all non-fresh devices match. - bool fresh_drive = false; + uint32_t n_fresh_drives = 0; bool non_commit_drive = false; drv_prefix* prefix_first = &headers[first_used]->generic.prefix; @@ -1246,7 +1246,7 @@ init_synchronous(drv_mems* mems) if (prefix_i->random == 0) { cf_info(AS_DRV_MEM, "{%s} device %s is empty", ns->name, mem->name); - fresh_drive = true; + n_fresh_drives++; continue; } @@ -1279,23 +1279,15 @@ init_synchronous(drv_mems* mems) mems->generic = cf_valloc(ROUND_UP_GENERIC); memcpy(mems->generic, &headers[first_used]->generic, ROUND_UP_GENERIC); - mems->generic->prefix.n_devices = n_mems; // may have added fresh drives + mems->generic->prefix.n_devices = n_mems; // may have added/removed drives mems->generic->prefix.random = random; mems->generic->prefix.flags &= ~DRV_HEADER_FLAG_TRUSTED; flush_flags(mems); - if (fresh_drive || n_mems < prefix_first->n_devices) { - drv_adjust_versions(ns, mems->generic->pmeta); - } - else if (ns->dirty_restart && non_commit_drive) { - if (ns->auto_revive) { - drv_auto_revive(ns, mems->generic->pmeta); - } - else { - drv_adjust_versions(ns, mems->generic->pmeta); - } - } + drv_adjust_sc_version_flags(ns, mems->generic->pmeta, + n_mems < prefix_first->n_devices + n_fresh_drives, + ns->dirty_restart && non_commit_drive); flush_header(mems, headers); flush_final_cfg(ns); diff --git a/as/src/storage/drv_ssd.c b/as/src/storage/drv_ssd.c index 91488010..b50eae0b 100644 --- a/as/src/storage/drv_ssd.c +++ b/as/src/storage/drv_ssd.c @@ -3289,7 +3289,7 @@ ssd_init_synchronous(drv_ssds *ssds) headers[i]->unique.device_id = (uint32_t)i; } - drv_adjust_versions(ns, ssds->generic->pmeta); + drv_adjust_sc_version_flags(ns, ssds->generic->pmeta, true, false); ssd_flush_header(ssds, headers); @@ -3307,7 +3307,7 @@ ssd_init_synchronous(drv_ssds *ssds) // At least one device is not fresh. Check that all non-fresh devices match. - bool fresh_drive = false; + uint32_t n_fresh_drives = 0; bool non_commit_drive = false; drv_prefix *prefix_first = &headers[first_used]->generic.prefix; @@ -3323,7 +3323,7 @@ ssd_init_synchronous(drv_ssds *ssds) // Skip fresh devices. if (prefix_i->random == 0) { cf_info(AS_DRV_SSD, "{%s} device %s is empty", ns->name, ssd->name); - fresh_drive = true; + n_fresh_drives++; continue; } @@ -3356,21 +3356,13 @@ ssd_init_synchronous(drv_ssds *ssds) ssds->generic = cf_valloc(ROUND_UP_GENERIC); memcpy(ssds->generic, &headers[first_used]->generic, ROUND_UP_GENERIC); - ssds->generic->prefix.n_devices = n_ssds; // may have added fresh drives + ssds->generic->prefix.n_devices = n_ssds; // may have added/removed drives ssds->generic->prefix.random = random; ssds->generic->prefix.flags &= ~DRV_HEADER_FLAG_TRUSTED; - if (fresh_drive || n_ssds < prefix_first->n_devices) { - drv_adjust_versions(ns, ssds->generic->pmeta); - } - else if (ns->dirty_restart && non_commit_drive) { - if (ns->auto_revive) { - drv_auto_revive(ns, ssds->generic->pmeta); - } - else { - drv_adjust_versions(ns, ssds->generic->pmeta); - } - } + drv_adjust_sc_version_flags(ns, ssds->generic->pmeta, + n_ssds < prefix_first->n_devices + n_fresh_drives, + ns->dirty_restart && non_commit_drive); ssd_flush_header(ssds, headers); ssd_flush_final_cfg(ns); diff --git a/as/src/storage/drv_ssd_ce.c b/as/src/storage/drv_ssd_ce.c index ec1d7a36..bd1a3c6c 100644 --- a/as/src/storage/drv_ssd_ce.c +++ b/as/src/storage/drv_ssd_ce.c @@ -96,14 +96,8 @@ ssd_cold_start_drop_cenotaphs(as_namespace* ns) // TODO - move to drv_common_ce.c in 8.0! void -drv_adjust_versions(as_namespace* ns, drv_pmeta* pmeta) -{ - // Nothing to do - relevant for enterprise version only. -} - -// TODO - move to drv_common_ce.c in 8.0! -void -drv_auto_revive(as_namespace* ns, drv_pmeta* pmeta) +drv_adjust_sc_version_flags(as_namespace* ns, drv_pmeta* pmeta, + bool wiped_drives, bool dirty) { // Nothing to do - relevant for enterprise version only. }