f3probe: support any reset type (even no reset!)

This patch allows f3probe to report an accurate usable size
with any type of reset.
It works even with --reset-type=2 that is no reset at all.
This commit is contained in:
Michel Machado 2015-11-14 09:26:01 -05:00
parent 8348bcd909
commit 70e07816af
2 changed files with 13 additions and 7 deletions

View File

@ -289,7 +289,11 @@ static int unit_test(const char *filename)
if (real_size_byte == item->real_size_byte &&
announced_size_byte == item->fake_size_byte &&
wrap == item->wrap &&
item_cache_byte == (cache_size_block << block_order) &&
/* We don't compare cache size because
* probe_device() only returns an estimate.
* item_cache_byte ==
* (cache_size_block << block_order) &&
*/
!need_reset &&
block_order == item->block_order) {
success++;
@ -472,14 +476,14 @@ static int test_device(struct args *args)
time_s = (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec)/1000000.;
printf("\nDevice geometry:\n");
report_size("\t *Usable* size:", real_size_byte,
report_size("\t *Usable* size:", real_size_byte,
block_order);
report_size("\t Announced size:", announced_size_byte,
report_size("\t Announced size:", announced_size_byte,
block_order);
report_order("\t Module:", wrap);
report_cache("\tPermanent cache size:", cache_size_block,
report_order("\t Module:", wrap);
report_cache("\tApproximate cache size:", cache_size_block,
need_reset, block_order);
report_order("\t Physical block size:", block_order);
report_order("\t Physical block size:", block_order);
printf("\nProbe time: %.2f seconds\n", time_s);
if (args->time_ops) {

View File

@ -340,8 +340,10 @@ static int assess_reset_effect(struct device *dev,
if (after_reset_count_block < write_target) {
assert(after_reset_count_block <= b4_reset_count_block);
*pcache_size_block = after_reset_count_block;
*pneed_reset = after_reset_count_block < b4_reset_count_block;
*pcache_size_block = *pneed_reset
? after_reset_count_block
: write_target;
*pdone = true;
return false;
}