From 3ced1bf694359a67162cccc7f0e3d94e50929f6e Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 29 May 2013 21:23:02 +0200 Subject: [PATCH] lvresize: check for max snapshot size As for lvcreate, lvresize also doesn't need to grow bigger then needed. --- WHATS_NEW | 1 + tools/lvresize.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index d757e2baa..7589f12b5 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.99 - =================================== + Detect maximum usable size for snapshot for lvresize. Creation of snapshot takes at most 100% origin coverage. Add cow_max_extents() to calc extents for 100% origin coverage. For creation of snapshot require size for at least 3 chunks. diff --git a/tools/lvresize.c b/tools/lvresize.c index b1008ec14..a32930e52 100644 --- a/tools/lvresize.c +++ b/tools/lvresize.c @@ -527,6 +527,16 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg, return EINVALID_CMD_LINE; } lp->extents += lv->le_count; + if (lv_is_cow(lv)) { + extents_used = cow_max_extents(origin_from_cow(lv), find_cow(lv)->chunk_size); + if (extents_used < lp->extents) { + log_print_unless_silent("Reached maximum COW size %s.", + display_size(vg->cmd, (uint64_t) vg->extent_size * extents_used)); + lp->extents = extents_used; + if (lp->extents == lv->le_count) + return ECMD_PROCESSED; + } + } } if (lp->sign == SIGN_MINUS) {