]> sourceware.org Git - lvm2.git/commitdiff
Add -t or --test arg to all tools that update metadata to avoid
authorAlasdair Kergon <agk@redhat.com>
Wed, 28 Nov 2001 18:03:11 +0000 (18:03 +0000)
committerAlasdair Kergon <agk@redhat.com>
Wed, 28 Nov 2001 18:03:11 +0000 (18:03 +0000)
committing metadata changes or (de)activating.

lib/activate/activate.c
lib/device/dev-io.c
tools/commands.h
tools/lvm.c
tools/lvremove.c

index 3faf82b5f2f507c291fb0ac3a6c4b9708dfe9c26..e23f658aff7d85fa198742f35f1f1b0f0978e758 100644 (file)
@@ -165,6 +165,9 @@ int _load(struct logical_volume *lv, int task)
 /* FIXME: Always display error msg */
 int lv_activate(struct logical_volume *lv)
 {
+       if (test_mode())
+               return 0;
+
        return _load(lv, DM_DEVICE_CREATE) && fs_add_lv(lv);
 }
 
@@ -190,6 +193,10 @@ int _suspend(struct logical_volume *lv, int sus)
 int lv_reactivate(struct logical_volume *lv)
 {
        int r;
+
+       if (test_mode())
+               return 0;
+
        if (!_suspend(lv, 1)) {
                stack;
                return 0;
@@ -210,6 +217,9 @@ int lv_deactivate(struct logical_volume *lv)
        int r;
        struct dm_task *dmt;
 
+       if (test_mode())
+               return 0;
+
        if (!(dmt = _setup_task(lv, DM_DEVICE_REMOVE))) {
                stack;
                return 0;
index 64632762ff66d0f945b6432ecb14a2eb18246796..cd0b1f9e40faeffb8fbd5b45bb859fab4119e7ea 100644 (file)
@@ -121,6 +121,10 @@ int _write(int fd, const void *buf, size_t count)
        size_t n = 0;
        int tot = 0;
 
+       /* Skip all writes */
+       if (test_mode())
+               return count;
+
        while (tot < count) {
                do
                        n = write(fd, buf, count - tot);
index 46a44e2ba16b4dc7ebd2121a885744a9c975be44..b2d55be6fff426730018c6ef2b1b612227c075c0 100644 (file)
@@ -57,11 +57,12 @@ xx(lvchange,
    "\t[-h/-?/--help]\n"
    "\t[-p/--permission r/rw]\n"
    "\t[-r/--readahead ReadAheadSectors]\n"
+   "\t[-t/--test]\n"
    "\t[-v/--verbose]\n"
    "\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
 
    autobackup_ARG, available_ARG, contiguous_ARG,
-   permission_ARG, readahead_ARG)
+   permission_ARG, readahead_ARG, test_ARG)
 
 xx(lvcreate,
    "Create a logical volume",
@@ -76,6 +77,7 @@ xx(lvcreate,
    "[-n|--name LogicalVolumeName]\n\t"
    "[-p|--permission {r|rw}] "
    "[-r|--readahead ReadAheadSectors]\n\t"
+   "[-t|--test] "
    "[-v|--verbose] "
    "[-Z|--zero {y|n}] "
    "[--version]\n\t"
@@ -86,11 +88,12 @@ xx(lvcreate,
    "{-l|--extents LogicalExtentsNumber |\n\t"
    " -L|--size LogicalVolumeSize[kKmMgGtT]}\n\t"
    "-n|--name SnapshotLogicalVolumeName\n\t"
+   "[-t|--test]\n\t"
    "LogicalVolume[Path] [PhysicalVolumePath...]\n",
 
    autobackup_ARG, chunksize_ARG, contiguous_ARG,
    stripes_ARG, stripesize_ARG, extents_ARG, size_ARG, name_ARG,
-   permission_ARG, readahead_ARG, snapshot_ARG, zero_ARG)
+   permission_ARG, readahead_ARG, snapshot_ARG, test_ARG, zero_ARG)
 
 xx(lvdisplay,
    "Display information about a logical volume",
@@ -113,10 +116,12 @@ xx(lvextend,
    "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
    "\t{-l/--extents [+]LogicalExtentsNumber |\n"
    "\t -L/--size [+]LogicalVolumeSize[kKmMgGtT]}\n"
+   "\t[-t/--test]\n"
    "\t[-v/--verbose]\n"
    "\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
 
-   autobackup_ARG, extents_ARG, size_ARG, stripes_ARG, stripesize_ARG)
+   autobackup_ARG, extents_ARG, size_ARG, stripes_ARG, stripesize_ARG,
+   test_ARG)
 
 xx(lvmchange,
    "With the device mapper, lvmchange is obsolete and does nothing.",
@@ -169,11 +174,12 @@ xx(lvreduce,
    "\t[-h/-?/--help]\n"
    "\t{-l/--extents [-]LogicalExtentsNumber |\n"
    "\t -L/--size [-]LogicalVolumeSize[kKmMgGtT]}\n"
+   "\t[-t/--test]\n"
    "\t[-v/--verbose]\n"
    "\tLogicalVolume[Path]\n",
 
    autobackup_ARG, force_ARG,  extents_ARG,
-   size_ARG, yes_ARG)
+   size_ARG, test_ARG, yes_ARG)
 
 xx(lvremove,
    "Remove logical volume(s) from the system",
@@ -182,10 +188,11 @@ xx(lvremove,
    "\t[-d/--debug]\n"
    "\t[-f/--force]\n"
    "\t[-h/-?/--help]\n"
+   "\t[-t/--test]\n"
    "\t[-v/--verbose]\n"
    "\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
 
-   autobackup_ARG, force_ARG)
+   autobackup_ARG, force_ARG, test_ARG)
 
 xx(lvrename,
    "Rename a logical volume",
@@ -193,12 +200,13 @@ xx(lvrename,
    "[-A|--autobackup {y|n}] "
    "[-d|--debug] "
    "[-h|--help] "
+   "[-t|--test] "
    "[-v|--verbose]\n\t"
    "[--version] "
    "{ OldLogicalVolumePath NewLogicalVolumePath |\n\t"
    "  VolumeGroupName OldLogicalVolumeName NewLogicalVolumeName }\n",
 
-   autobackup_ARG)
+   autobackup_ARG, test_ARG)
 
 xx(lvresize,
    "Resize a logical volume",
@@ -209,10 +217,12 @@ xx(lvresize,
    "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
    "\t{-l/--extents [+/-]LogicalExtentsNumber |\n"
    "\t -L/--size [+/-]LogicalVolumeSize[kKmMgGtT]}\n"
+   "\t[-t|--test]\n"
    "\t[-v/--verbose]\n"
    "\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
 
-   autobackup_ARG, extents_ARG, size_ARG, stripes_ARG, stripesize_ARG)
+   autobackup_ARG, extents_ARG, size_ARG, stripes_ARG, stripesize_ARG,
+   test_ARG)
 
 xx(lvscan,
    "List all logical volumes in all volume groups",
@@ -234,10 +244,11 @@ xx(pvchange,
    "\t[-h/-?/--help]\n"
    "\t[-v/--verbose]\n"
    "\t[-a/--all]\n"
+   "\t[-t|--test]\n"
    "\t[-x/--allocation y/n]\n"
    "\t[PhysicalVolumePath...]\n",
 
-   all_ARG, autobackup_ARG, allocation_ARG)
+   all_ARG, autobackup_ARG, allocation_ARG, test_ARG)
 
 xx(pvcreate,
    "Initialize physical volume(s) for use by LVM",
@@ -246,11 +257,12 @@ xx(pvcreate,
    "[-f[f]|--force [--force]] "
    "[-h|--help] "
    "[-y|--yes]\n\t"
+   "[-t|--test] "
    "[-v|--verbose] "
    "[--version] "
    "PhysicalVolume [PhysicalVolume...]\n",
 
-   force_ARG, yes_ARG)
+   force_ARG, test_ARG, yes_ARG)
 
 xx(pvdata,
    "Display the on-disk metadata for physical volume(s)",
@@ -343,7 +355,8 @@ xx(vgchange,
    "vgchange\n\t"
    "[-A|--autobackup {y|n}] "
    "[-d|--debug] "
-   "[-h|--help]\n\t"
+   "[-h|--help] "
+   "[-t|--test]\n\t"
    "[-v|--verbose] "
    "[--version]\n\t"
    "{-a|--available {y|n} |\n\t"
@@ -351,7 +364,8 @@ xx(vgchange,
    " -l|--logicalvolume MaxLogicalVolumes}\n\t"
    "[VolumeGroupName...]\n",
 
-   autobackup_ARG, available_ARG, logicalvolume_ARG, allocation_ARG )
+   autobackup_ARG, available_ARG, logicalvolume_ARG, allocation_ARG,
+   test_ARG)
 
 xx(vgck,
    "Check the consistency of volume group(s)",
@@ -370,13 +384,14 @@ xx(vgcreate,
    "[-p|--maxphysicalvolumes MaxPhysicalVolumes] "
    "[-h|--help]\n\t"
    "[-s|--physicalextentsize PhysicalExtentSize[kKmMgGtT]] "
+   "[-t|--test] "
    "[-v|--verbose]\n\t"
    "[--version] "
    "VolumeGroupName "
    "PhysicalVolume [PhysicalVolume...]\n",
 
    autobackup_ARG, maxlogicalvolumes_ARG, maxphysicalvolumes_ARG,
-   physicalextentsize_ARG)
+   physicalextentsize_ARG, test_ARG)
 
 xx(vgdisplay,
    "Display volume group information",
@@ -399,7 +414,7 @@ xx(vgexport,
    "[--version] "
    "VolumeGroupName [VolumeGroupName...]\n",
 
-   all_ARG)
+   all_ARG, test_ARG)
 
 xx(vgextend,
    "Add physical volumes to a volume group",
@@ -407,11 +422,12 @@ xx(vgextend,
    "\t[-A/--autobackup y/n]\n"
    "\t[-d/--debug]\n"
    "\t[-h/-?/--help]\n"
+   "\t[-t/--test]\n"
    "\t[-v/--verbose]\n"
    "\tVolumeGroupName\n"
    "\tPhysicalDevicePath [PhysicalDevicePath...]\n",
 
-   autobackup_ARG)
+   autobackup_ARG, test_ARG)
 
 xx(vgimport,
    "Register exported volume group with system",
@@ -419,11 +435,12 @@ xx(vgimport,
    "[-d|--debug] "
    "[-f|--force] "
    "[-h|--help] "
+   "[-t|--test] "
    "[-v|--verbose]\n\t"
    "VolumeGroupName PhysicalVolumePath "
    "[PhysicalVolumePath...]\n",
 
-   force_ARG)
+   force_ARG, test_ARG)
 
 xx(vgmerge,
    "Merge volume groups",
@@ -453,19 +470,23 @@ xx(vgreduce,
    "\t[-A/--autobackup y/n]\n"
    "\t[-d/--debug]\n"
    "\t[-h/-?/--help]\n"
+   "\t[-t/--test]\n"
    "\t[-v/--verbose]\n"
    "\tVolumeGroupName\n"
    "\t[PhysicalVolumePath...]\n",
 
-   all_ARG, autobackup_ARG)
+   all_ARG, autobackup_ARG, test_ARG)
 
 xx(vgremove,
    "Remove volume group(s)",
    "vgremove\n"
    "\t[-d/--debug]\n"
    "\t[-h/-?/--help]\n"
+   "\t[-t/--test]\n"
    "\t[-v/--verbose]\n"
-   "\tVolumeGroupName [VolumeGroupName...]\n" )
+   "\tVolumeGroupName [VolumeGroupName...]\n",
+
+   test_ARG)
 
 xx(vgrename,
    "Rename a volume group",
@@ -474,11 +495,12 @@ xx(vgrename,
    "\t[-d/--debug]\n"
    "\t[-f/--force]\n"
    "\t[-h/-?/--help]\n"
+   "\t[-t/--test]\n"
    "\t[-v/--verbose]\n"
    "\tOldVolumeGroupPath NewVolumeGroupPath /\n"
    "\tOldVolumeGroupName NewVolumeGroupName\n",
 
-   autobackup_ARG, force_ARG)
+   autobackup_ARG, force_ARG, test_ARG)
 
 xx(vgscan,
    "Search for all volume groups",
index 7f654d784cef3abeef9e02f473a723ff47ceed0f..f14244636c29ba7ace0c6005a47ead17275ee6f2 100644 (file)
@@ -479,7 +479,10 @@ static int process_common_commands(struct command *com)
 
        init_verbose(arg_count(verbose_ARG));
 
-       init_test(arg_count(test_ARG));
+       if ((l = arg_count(test_ARG))) {
+               log_error("Test mode. Metadata will NOT be updated.");
+               init_test(l);
+       }
 
        if (arg_count(help_ARG)) {
                usage(com->name);
index 697ce2a99eec88a182dbf3fdf3b27b5e371e0763..5c474547ba1221da5c55cbc2e02c248216781a4f 100644 (file)
@@ -53,7 +53,7 @@ static int lvremove_single(struct logical_volume *lv)
        }
 
        /* FIXME Force option? */
-       if (lv_open_count(lv)) {
+       if (lv_open_count(lv) > 0) {
                log_error("Can't remove open logical volume %s", lv->name);
                return ECMD_FAILED;
        }
@@ -84,7 +84,7 @@ static int lvremove_single(struct logical_volume *lv)
 **********/
 
        /* store it on disks */
-       if (fid->ops->vg_write(fid, vg))
+       if (!fid->ops->vg_write(fid, vg))
                return ECMD_FAILED;
 
 /******** FIXME
This page took 0.053621 seconds and 5 git commands to generate.