]> sourceware.org Git - lvm2.git/commitdiff
Add global/si_unit_consistency to enable cleaned-up use of units in output.
authorAlasdair Kergon <agk@redhat.com>
Mon, 28 Sep 2009 16:23:44 +0000 (16:23 +0000)
committerAlasdair Kergon <agk@redhat.com>
Mon, 28 Sep 2009 16:23:44 +0000 (16:23 +0000)
Add configure --enable-units-compat to set si_unit_consistency off by default.

Use standard output units for 'PE Size' and 'Stripe size' in pv/lvdisplay.

WHATS_NEW
configure
configure.in
doc/example.conf
lib/commands/toolcontext.c
lib/commands/toolcontext.h
lib/config/defaults.h
lib/display/display.c
lib/misc/configure.h.in
lib/striped/striped.c

index 7d27545b3bb39a28af96cac564bdbc95299f6d18..f91c06d0c247de36bd196248c3283e92ba9f989d 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,8 @@
 Version 2.02.54 -
 =====================================
+  Use standard output units for 'PE Size' and 'Stripe size' in pv/lvdisplay.
+  Add configure --enable-units-compat to set si_unit_consistency off by default.
+  Add global/si_unit_consistency to enable cleaned-up use of units in output.
 
 Version 2.02.53 - 25th September 2009
 =====================================
index 970a1035636ccbb70bdfa8cd1a163da23bbd2642..db06bd64ebe19652340332450cfa0f7beaa7c79b 100755 (executable)
--- a/configure
+++ b/configure
@@ -825,6 +825,7 @@ enable_devmapper
 enable_udev_sync
 enable_udev_rules
 enable_compat
+enable_units_compat
 enable_ioctl
 enable_o_direct
 enable_applib
@@ -1514,6 +1515,8 @@ Optional Features:
   --enable-udev_sync      Enable synchronisation with udev processing
   --enable-udev_rules     Install rule files needed for udev synchronisation
   --enable-compat         Enable support for old device-mapper versions
+  --enable-units-compat   Enable output compatibility with old versions that
+                          that don't use KiB-style unit suffixes
   --disable-driver        Disable calls to device-mapper in the kernel
   --disable-o_direct      Disable O_DIRECT
   --enable-applib         Build application library
@@ -12215,6 +12218,23 @@ else
 fi
 
 
+################################################################################
+# Check whether --enable-units-compat was given.
+if test "${enable_units_compat+set}" = set; then
+  enableval=$enable_units_compat; UNITS_COMPAT=$enableval
+else
+  UNITS_COMPAT=no
+fi
+
+
+if test x$UNITS_COMPAT = xyes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define DEFAULT_SI_UNIT_CONSISTENCY 0
+_ACEOF
+
+fi
+
 ################################################################################
 # Check whether --enable-ioctl was given.
 if test "${enable_ioctl+set}" = set; then
index 8a63e73651552b131093f049bfd319097db63127..6a3f53a1df7f5d6f094c790a338ae0827c35eafa 100644 (file)
@@ -678,6 +678,17 @@ dnl -- Compatibility mode
 AC_ARG_ENABLE(compat,   [  --enable-compat         Enable support for old device-mapper versions],
   DM_COMPAT=$enableval, DM_COMPAT=no)
 
+################################################################################
+dnl -- Compatible units suffix mode
+AC_ARG_ENABLE(units-compat,
+  [  --enable-units-compat   Enable output compatibility with old versions that
+                          that don't use KiB-style unit suffixes],
+  UNITS_COMPAT=$enableval, UNITS_COMPAT=no)
+
+if test x$UNITS_COMPAT = xyes; then
+       AC_DEFINE([DEFAULT_SI_UNIT_CONSISTENCY], 0, [Define to 0 to reinstate the pre-2.02.54 handling of unit suffixes.])
+fi
+
 ################################################################################
 dnl -- Disable ioctl
 AC_ARG_ENABLE(ioctl,   [  --disable-driver        Disable calls to device-mapper in the kernel],
index 4f57b59e9f394d6991322bb26691f88ad00360a8..f254325f064b39a5a5f3c31865ffe74a0e46cf82 100644 (file)
@@ -236,6 +236,13 @@ global {
     # Default value for --units argument
     units = "h"
 
+    # Since version 2.02.54, the tools distinguish between powers of
+    # 1024 bytes (e.g. KiB, MiB, GiB) and powers of 1000 bytes (e.g.
+    # KB, MB, GB).
+    # If you have scripts that depend on the old behaviour, set this to 0
+    # temporarily until you update them.
+    si_unit_consistency = 1
+
     # Whether or not to communicate with the kernel device-mapper.
     # Set to 0 if you want to use the tools to manipulate LVM metadata 
     # without activating any logical volumes.
index 4c2592609a0004ee954fcb90457411ff21c6f6cd..2a561004d99e27a80d64228d7ddf4eace6cd7013 100644 (file)
@@ -293,6 +293,10 @@ static int _process_config(struct cmd_context *cmd)
                }
        }
 
+       cmd->si_unit_consistency = find_config_tree_int(cmd,
+                                                 "global/si_unit_consistency",
+                                                 DEFAULT_SI_UNIT_CONSISTENCY);
+
        return 1;
 }
 
index 24f924a159d66cfc91a774fec12e4c8705af1275..e4341a70323f4ca2ef6093791c230dfd511c73a1 100644 (file)
@@ -70,6 +70,7 @@ struct cmd_context {
        unsigned is_long_lived:1;       /* Optimises persistent_filter handling */
        unsigned handles_missing_pvs:1;
        unsigned partial_activation:1;
+       unsigned si_unit_consistency:1;
 
        struct dev_filter *filter;
        int dump_filter;        /* Dump filter when exiting? */
index d483492b98780b009e87d5a6a85f17ccda0efe9a..7ce96abc49c1684594ab7780b61231e4f30a6185 100644 (file)
 #define DEFAULT_SUFFIX 1
 #define DEFAULT_HOSTTAGS 0
 
+#ifndef DEFAULT_SI_UNIT_CONSISTENCY
+#  define DEFAULT_SI_UNIT_CONSISTENCY 1
+#endif
+
 #ifdef DEVMAPPER_SUPPORT
 #  define DEFAULT_ACTIVATION 1
 #  define DEFAULT_RESERVED_MEMORY 8192
index 62f30f64837c5719e06c4ee927faca097cb2708b..6e8534a7be2aff820adb28f45b7461c68bf27cc5 100644 (file)
@@ -344,7 +344,12 @@ void pvdisplay_full(const struct cmd_context *cmd,
        /* LV count is no longer available when displaying PV
           log_print("Cur LV                %u", vg->lv_count);
         */
-       log_print("PE Size (KByte)       %" PRIu32, pv->pe_size / 2);
+
+       if (cmd->si_unit_consistency)
+               log_print("PE Size               %s", display_size(cmd, (uint64_t) pv->pe_size));
+       else
+               log_print("PE Size (KByte)       %" PRIu32, pv->pe_size / 2);
+
        log_print("Total PE              %u", pv->pe_count);
        log_print("Free PE               %" PRIu32, pe_free);
        log_print("Allocated PE          %u", pv->pe_alloc_count);
@@ -489,7 +494,7 @@ int lvdisplay_full(struct cmd_context *cmd,
        log_print("Segments               %u", dm_list_size(&lv->segments));
 
 /********* FIXME Stripes & stripesize for each segment
-       log_print("Stripe size (KByte)    %u", lv->stripesize / 2);
+       log_print("Stripe size            %s", display_size(cmd, (uint64_t) lv->stripesize));
 ***********/
 
        log_print("Allocation             %s", get_alloc_string(lv->alloc));
index 6e4043cae88b3cb5662fba4f29310eff6ae2bb13..e5c2e6754c582c797119b77b0d8b45d03ae2abb7 100644 (file)
@@ -17,6 +17,9 @@
 /* Define to 1 if using `alloca.c'. */
 #undef C_ALLOCA
 
+/* Define to 0 to reinstate the pre-2.02.54 handling of unit suffixes. */
+#undef DEFAULT_SI_UNIT_CONSISTENCY
+
 /* Define to 1 to enable LVM2 device-mapper interaction. */
 #undef DEVMAPPER_SUPPORT
 
index 0e1ca2d351b70285b66f6b09b8ec9065a0ee681f..f187da542bdb8c46e332fa3170a12cae26a2795a 100644 (file)
@@ -40,7 +40,14 @@ static void _striped_display(const struct lv_segment *seg)
                display_stripe(seg, 0, "  ");
        else {
                log_print("  Stripes\t\t%u", seg->area_count);
-               log_print("  Stripe size\t\t%u KB", seg->stripe_size / 2);
+
+               if (seg->lv->vg->cmd->si_unit_consistency)
+                       log_print("  Stripe size\t\t%s",
+                                 display_size(seg->lv->vg->cmd,
+                                              (uint64_t) seg->stripe_size));
+               else
+                       log_print("  Stripe size\t\t%u KB",
+                                 seg->stripe_size / 2);
 
                for (s = 0; s < seg->area_count; s++) {
                        log_print("  Stripe %d:", s);
This page took 0.064926 seconds and 5 git commands to generate.