static int64_t compute_next_snapshot_time(void)
{
int64_t x = 0, now = get_current_time(), unit_interval
- = 24 * 3600 * OPT_UINT32_VAL(DSS, UNIT_INTERVAL), ret;
+ = 24 * 3600 * OPT_UINT32_VAL(DSS, UNIT_INTERVAL), ret,
+ last_completion_time;
unsigned wanted = desired_number_of_snapshots(0,
OPT_UINT32_VAL(DSS, NUM_INTERVALS)),
num_complete = 0;
continue;
num_complete++;
x += s->completion_time - s->creation_time;
+ last_completion_time = s->completion_time;
}
assert(x >= 0);
x /= num_complete; /* avg time to create one snapshot */
if (unit_interval < x * wanted) /* oops, no sleep at all */
goto out;
- ret = s->completion_time + unit_interval / wanted - x;
+ ret = last_completion_time + unit_interval / wanted - x;
out:
free_snapshot_list(&sl);
return ret;