]> sourceware.org Git - lvm2.git/commitdiff
hints: fix hint flock when using lvm shell
authorDavid Teigland <teigland@redhat.com>
Tue, 15 Jan 2019 18:23:16 +0000 (12:23 -0600)
committerDavid Teigland <teigland@redhat.com>
Tue, 15 Jan 2019 18:23:16 +0000 (12:23 -0600)
also cmd->use_hints needs to be set for each shell command

lib/commands/toolcontext.c
lib/label/hints.c
lib/label/hints.h
tools/lvmcmdline.c

index 39ab3df192c6841a6ec29d4dc67dbecf1e3cb5a3..bd216aa5548171963cbf2169c88f782f69ed75c9 100644 (file)
@@ -22,6 +22,7 @@
 #include "lib/activate/activate.h"
 #include "lib/filters/filter.h"
 #include "lib/label/label.h"
+#include "lib/label/hints.h"
 #include "lib/misc/lvm-file.h"
 #include "lib/format_text/format-text.h"
 #include "lib/display/display.h"
@@ -1781,6 +1782,7 @@ int refresh_toolcontext(struct cmd_context *cmd)
         */
 
        activation_release();
+       hints_exit();
        lvmcache_destroy(cmd, 0, 0);
        label_scan_destroy(cmd);
        label_exit();
@@ -1900,6 +1902,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
 
        archive_exit(cmd);
        backup_exit(cmd);
+       hints_exit();
        lvmcache_destroy(cmd, 0, 0);
        label_scan_destroy(cmd);
        label_exit();
index bdd70a9b1780295cf5c6db742e8a99fb7ea861c2..a9c40c223c04c7ab8992d62b418b820e6c1abff1 100644 (file)
@@ -344,6 +344,13 @@ static void _unlock_hints(void)
        _hints_fd = -1;
 }
 
+void hints_exit(void)
+{
+       if (_hints_fd == -1)
+               return;
+       return _unlock_hints();
+}
+
 static struct hint *_find_hint_name(struct dm_list *hints, const char *name)
 {
        struct hint *hint;
@@ -989,6 +996,8 @@ void clear_hint_file(struct cmd_context *cmd)
        if (!cmd->enable_hints)
                return;
 
+       log_debug("clear_hint_file");
+
        /*
         * This function runs even when cmd->use_hints is 0,
         * which means this command does not use hints, but
@@ -999,11 +1008,6 @@ void clear_hint_file(struct cmd_context *cmd)
        if (!_touch_nohints())
                stack;
 
-       /*
-        * We are relying on the command exit to release this flock,
-        * we should probably add an explicit unlock_hints call.
-        */
-
        if (!_lock_hints(LOCK_EX, 0))
                stack;
 
index d80016e0128867d50cc8f7c386e769d02b3ef89e..a17214cdd6034fc7ea237941f249c5a5454bb57f 100644 (file)
@@ -33,5 +33,7 @@ int get_hints(struct cmd_context *cmd, struct dm_list *hints, int *newhints,
 
 int validate_hints(struct cmd_context *cmd, struct dm_list *hints);
 
+void hints_exit(void);
+
 #endif
 
index 55a068f7ff52287792fd07a3a06a19f5b0f84ab5..49a60386a0da9b8a0a5c626c7536b8c4e8d50c1e 100644 (file)
@@ -2331,6 +2331,8 @@ static int _get_current_settings(struct cmd_context *cmd)
        /* Only certain commands need to be optimized by using hints. */
        if (cmd->cname->flags & ALLOW_HINTS)
                cmd->use_hints = 1;
+       else
+               cmd->use_hints = 0;
 
        if ((hint_mode = find_config_tree_str(cmd, devices_hints_CFG, NULL))) {
                if (!strcmp(hint_mode, "none"))
@@ -2986,6 +2988,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
 
       out:
 
+       hints_exit();
        lvmcache_destroy(cmd, 1, 1);
        label_scan_destroy(cmd);
 
This page took 0.041811 seconds and 5 git commands to generate.