mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
hints: fix hint flock when using lvm shell
also cmd->use_hints needs to be set for each shell command
This commit is contained in:
parent
3cf7668e34
commit
7b5abc3fb1
@ -22,6 +22,7 @@
|
|||||||
#include "lib/activate/activate.h"
|
#include "lib/activate/activate.h"
|
||||||
#include "lib/filters/filter.h"
|
#include "lib/filters/filter.h"
|
||||||
#include "lib/label/label.h"
|
#include "lib/label/label.h"
|
||||||
|
#include "lib/label/hints.h"
|
||||||
#include "lib/misc/lvm-file.h"
|
#include "lib/misc/lvm-file.h"
|
||||||
#include "lib/format_text/format-text.h"
|
#include "lib/format_text/format-text.h"
|
||||||
#include "lib/display/display.h"
|
#include "lib/display/display.h"
|
||||||
@ -1781,6 +1782,7 @@ int refresh_toolcontext(struct cmd_context *cmd)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
activation_release();
|
activation_release();
|
||||||
|
hints_exit();
|
||||||
lvmcache_destroy(cmd, 0, 0);
|
lvmcache_destroy(cmd, 0, 0);
|
||||||
label_scan_destroy(cmd);
|
label_scan_destroy(cmd);
|
||||||
label_exit();
|
label_exit();
|
||||||
@ -1900,6 +1902,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
|
|||||||
|
|
||||||
archive_exit(cmd);
|
archive_exit(cmd);
|
||||||
backup_exit(cmd);
|
backup_exit(cmd);
|
||||||
|
hints_exit();
|
||||||
lvmcache_destroy(cmd, 0, 0);
|
lvmcache_destroy(cmd, 0, 0);
|
||||||
label_scan_destroy(cmd);
|
label_scan_destroy(cmd);
|
||||||
label_exit();
|
label_exit();
|
||||||
|
@ -344,6 +344,13 @@ static void _unlock_hints(void)
|
|||||||
_hints_fd = -1;
|
_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)
|
static struct hint *_find_hint_name(struct dm_list *hints, const char *name)
|
||||||
{
|
{
|
||||||
struct hint *hint;
|
struct hint *hint;
|
||||||
@ -989,6 +996,8 @@ void clear_hint_file(struct cmd_context *cmd)
|
|||||||
if (!cmd->enable_hints)
|
if (!cmd->enable_hints)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
log_debug("clear_hint_file");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function runs even when cmd->use_hints is 0,
|
* This function runs even when cmd->use_hints is 0,
|
||||||
* which means this command does not use hints, but
|
* which means this command does not use hints, but
|
||||||
@ -999,11 +1008,6 @@ void clear_hint_file(struct cmd_context *cmd)
|
|||||||
if (!_touch_nohints())
|
if (!_touch_nohints())
|
||||||
stack;
|
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))
|
if (!_lock_hints(LOCK_EX, 0))
|
||||||
stack;
|
stack;
|
||||||
|
|
||||||
|
@ -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);
|
int validate_hints(struct cmd_context *cmd, struct dm_list *hints);
|
||||||
|
|
||||||
|
void hints_exit(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2331,6 +2331,8 @@ static int _get_current_settings(struct cmd_context *cmd)
|
|||||||
/* Only certain commands need to be optimized by using hints. */
|
/* Only certain commands need to be optimized by using hints. */
|
||||||
if (cmd->cname->flags & ALLOW_HINTS)
|
if (cmd->cname->flags & ALLOW_HINTS)
|
||||||
cmd->use_hints = 1;
|
cmd->use_hints = 1;
|
||||||
|
else
|
||||||
|
cmd->use_hints = 0;
|
||||||
|
|
||||||
if ((hint_mode = find_config_tree_str(cmd, devices_hints_CFG, NULL))) {
|
if ((hint_mode = find_config_tree_str(cmd, devices_hints_CFG, NULL))) {
|
||||||
if (!strcmp(hint_mode, "none"))
|
if (!strcmp(hint_mode, "none"))
|
||||||
@ -2986,6 +2988,7 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
|
hints_exit();
|
||||||
lvmcache_destroy(cmd, 1, 1);
|
lvmcache_destroy(cmd, 1, 1);
|
||||||
label_scan_destroy(cmd);
|
label_scan_destroy(cmd);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user