master - snapshot: zero cow header for read-only snapshot
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2b044452e30accf9ee026fc62ccea219bb4c7be4 Commit: 2b044452e30accf9ee026fc62ccea219bb4c7be4 Parent: 3bb9eda97c6ef2fb6848322e36b2b44a688ed37c Author: Zdenek Kabelac <[email protected]> AuthorDate: Wed Feb 26 00:17:11 2014 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Wed Feb 26 00:22:46 2014 +0100
snapshot: zero cow header for read-only snapshot
When read-only snapshot was created, tool was skipping header initialization of cow device. If it happened device has been already containing header from some previous snapshot, it's been 'reused' for a newly created snapshot instead of being cleared.
--- WHATS_NEW | 1 + test/shell/snapshot-usage.sh | 11 +++++++++++ tools/lvcreate.c | 8 ++++++-- 3 files changed, 18 insertions(+), 2 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.106 - ==================================== + Zero snapshot COW header when creating read-only snapshot. Comment out config lines in dumpconfig output without default values defined. Improve detection of clustered mirror support. Enhance raid code with feature flags, for now checks for raid10.
test/shell/snapshot-usage.sh +11 -0
@@ -131,4 +131,15 @@ vgremove -ff $vg1 fi +lvremove -f $vg + +# Check snapshot really deletes COW header for read-only snapshot +aux lvmconf "allocation/wipe_signatures_when_zeroing_new_lvs = 1" +lvcreate -L10 -n $lv1 $vg +lvcreate -s -L10 -n snap $vg/$lv1 +# Populate snapshot with some filesystem signatures +mkfs.ext4 "$DM_DEV_DIR/$vg/snap" +lvremove -f $vg/snap +lvcreate -s -pr -l12 -n snap $vg/$lv1 + vgremove -ff $vg
tools/lvcreate.c +6 -2
@@ -769,8 +769,12 @@ static int _read_activation_params(struct lvcreate_params *lp, lp->permission =arg_uint_value (cmd, permission_ARG,LVM_READ |LVM_WRITE ); -/* Must not zero/wipe read only volume */ -if (!(lp->permission &LVM_WRITE )) { +if (lp->snapshot) { +/* Snapshot has to zero COW header */ + lp->zero =1 ; + lp->wipe_signatures =0 ; + }else if (!(lp->permission &LVM_WRITE )) { +/* Must not zero/wipe read only volume */ lp->zero =0 ; lp->wipe_signatures =0 ; }