]> sourceware.org Git - lvm2.git/commitdiff
libdm: dm_tree_node_size_changed recognizes reduction
authorZdenek Kabelac <zkabelac@redhat.com>
Sun, 25 Oct 2015 18:27:09 +0000 (19:27 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Sun, 25 Oct 2015 20:05:15 +0000 (21:05 +0100)
Add more functionality to size_changed function.
While 'existing' API only detected  0 for
unchanged,  and !0 for changed,
new improved API will also detected if the
size has only went bigger - or there was
size reduction.

Function work for the whole dm-tree - so
no change is size is always 0.
only size extension  1.
and if some size reduction is there - returns -1.

This result can be used for better evaluation
whether we need to flush before suspend.

WHATS_NEW_DM
libdm/.exported_symbols.Base
libdm/.exported_symbols.DM_1_02_110
libdm/libdevmapper.h
libdm/libdm-deptree.c

index 910f6d66829a73f8e9678cbac3af3b28c121e568..e09ab63943d7cf79e6724ca7c5e149ad1f76254e 100644 (file)
@@ -1,5 +1,6 @@
 Version 1.02.110 - 
 ======================================
+  Enhance dm_tree_node_size_changed() to recognize size reduction.
   Support exit on idle for dmenventd (1 hour).
   Add support to allow unmonitor device from plugin itself.
   New design for thread co-operation in dmeventd.
index f9c3cb1a040d3d1500f12595a19a36cf33fd88a0..27fef5394924acaf29418365b907abb21d9683c9 100644 (file)
@@ -262,7 +262,6 @@ dm_tree_node_set_thin_external_origin
 dm_tree_node_set_thin_pool_discard
 dm_tree_node_set_thin_pool_error_if_no_space
 dm_tree_node_set_udev_flags
-dm_tree_node_size_changed
 dm_tree_preload_children
 dm_tree_retry_remove
 dm_tree_set_cookie
index da742eef7d2e8b3bc6781e18937f42dd4d59d5a9..eba56259ab64b7de78031b15ad0ddfeb4a8d5962 100644 (file)
@@ -1,2 +1,3 @@
 dm_report_compact_given_fields
 dm_hold_control_dev
+dm_tree_node_size_changed
index 08b24feeab8172d1956d5fbc4d21af50cadc56b8..f7ab2577e8ab5a085890106ef4c792a0f4c1ab15 100644 (file)
@@ -1256,6 +1256,11 @@ const char *dm_tree_node_get_name(const struct dm_tree_node *node);
 const char *dm_tree_node_get_uuid(const struct dm_tree_node *node);
 const struct dm_info *dm_tree_node_get_info(const struct dm_tree_node *node);
 void *dm_tree_node_get_context(const struct dm_tree_node *node);
+/*
+ * Returns  0 when node size and its children is unchanged.
+ * Returns  1 when node or any of its children has increased size.
+ * Rerurns -1 when node or any of its children has reduced size.
+ */
 int dm_tree_node_size_changed(const struct dm_tree_node *dnode);
 
 /*
index afdce8d726d4c30177392842508fb0b59577167c..d7e2143ae04093206434a0b42794666347f0fcf4 100644 (file)
@@ -220,7 +220,7 @@ struct load_properties {
        uint32_t read_ahead_flags;
 
        unsigned segment_count;
-       unsigned size_changed;
+       int size_changed;
        struct dm_list segs;
 
        const char *new_name;
@@ -2729,7 +2729,8 @@ static int _load_node(struct dm_tree_node *dnode)
 
                existing_table_size = dm_task_get_existing_table_size(dmt);
                if ((dnode->props.size_changed =
-                    (existing_table_size == seg_start) ? 0 : 1)) {
+                    (existing_table_size == seg_start) ? 0 :
+                    (existing_table_size > seg_start) ? -1 : 1)) {
                        /*
                         * Kernel usually skips size validation on zero-length devices
                         * now so no need to preload them.
@@ -2825,8 +2826,10 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
                }
 
                /* Propagate device size change change */
-               if (child->props.size_changed)
+               if (child->props.size_changed > 0 && !dnode->props.size_changed)
                        dnode->props.size_changed = 1;
+               else if (child->props.size_changed < 0)
+                       dnode->props.size_changed = -1;
 
                /* Resume device immediately if it has parents and its size changed */
                if (!dm_tree_node_num_children(child, 1) || !child->props.size_changed)
@@ -3853,3 +3856,19 @@ void dm_tree_node_set_callback(struct dm_tree_node *dnode,
        dnode->callback = cb;
        dnode->callback_data = data;
 }
+
+/*
+ * Backward compatible dm_tree_node_size_changed() implementations.
+ *
+ * Keep these at the end of the file to avoid adding clutter around the
+ * current dm_tree_node_size_changed() version.
+ */
+#if defined(__GNUC__)
+int dm_tree_node_size_changed_base(const struct dm_tree_node *dnode);
+DM_EXPORT_SYMBOL_BASE(dm_tree_node_size_changed);
+int dm_tree_node_size_changed_base(const struct dm_tree_node *dnode)
+{
+       /* Base does not make difference between smaller and bigger */
+       return dm_tree_node_size_changed(dnode) ? 1 : 0;
+}
+#endif
This page took 0.053373 seconds and 5 git commands to generate.