X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=dss.c;h=e2ee7dd66e511199c42821cbc32cf0a8ddf727ad;hb=d4d72473957544283b6d426c3d4fa0b3f583da87;hp=b09fc961f28328eb9c7c6e95726fffa3b706de32;hpb=e3f9c1dcc861be14fc9a3f33057a905047e9a926;p=dss.git diff --git a/dss.c b/dss.c index b09fc96..e2ee7dd 100644 --- a/dss.c +++ b/dss.c @@ -1659,7 +1659,7 @@ static int com_prune(void) struct snapshot_list sl; struct snapshot *victim; struct disk_space ds; - const char *why; + char *why; lock_dss_or_die(); ret = get_disk_space(".", &ds); @@ -1667,47 +1667,40 @@ static int com_prune(void) return ret; log_disk_space(&ds); dss_get_snapshot_list(&sl); - why = "outdated"; - victim = find_outdated_snapshot(&sl); - if (victim) - goto rm; - why = "redundant"; - victim = find_redundant_snapshot(&sl); - if (victim) - goto rm; - dss_msg("nothing to prune\n"); - ret = 0; - goto out; -rm: + victim = find_removable_snapshot(&sl, disk_space_low(&ds), &why); + if (!victim) { + dss_msg("nothing to prune\n"); + ret = 0; + goto free_sl; + } if (OPT_GIVEN(DSS, DRY_RUN)) { - dss_msg("%s snapshot %s (interval = %i)\n", + dss_msg("picking %s snapshot %s (interval = %i)\n", why, victim->name, victim->interval); ret = 0; - goto out; + goto free_why; } pre_remove_hook(victim, why); if (snapshot_removal_status == HS_PRE_RUNNING) { ret = wait_for_remove_process(); if (ret < 0) - goto out; + goto free_why; ret = -E_HOOK_FAILED; if (snapshot_removal_status != HS_PRE_SUCCESS) - goto out; + goto free_why; } ret = exec_rm(); if (ret < 0) - goto out; + goto free_why; ret = wait_for_remove_process(); if (ret < 0) - goto out; + goto free_why; assert(snapshot_removal_status == HS_SUCCESS); post_remove_hook(); assert(snapshot_removal_status == HS_POST_RUNNING); ret = wait_for_remove_process(); - if (ret < 0) - goto out; - ret = 1; -out: +free_why: + free(why); +free_sl: free_snapshot_list(&sl); return ret; }