mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-23 10:50:34 +03:00
Add exec_cmd paramater sync_needed
As sync_local_dev_names() cannot be called within activation context, add new parametr which allows to select if the sync call is needed before executing new command.
This commit is contained in:
parent
c6e087d54a
commit
b1b38215ba
@ -1,5 +1,6 @@
|
||||
Version 2.02.81 -
|
||||
===================================
|
||||
Extend exec_cmd params to specify, when device sync is needed.
|
||||
Replace fs_unlock by sync_local_dev_names to notify local clvmd. (2.02.80)
|
||||
Introduce sync_local_dev_names and CLVMD_CMD_SYNC_NAMES to issue fs_unlock.
|
||||
Accept fusion fio in device type filter.
|
||||
|
@ -424,7 +424,7 @@ int module_present(struct cmd_context *cmd, const char *target_name)
|
||||
argv[1] = module;
|
||||
argv[2] = NULL;
|
||||
|
||||
ret = exec_cmd(cmd, argv, NULL);
|
||||
ret = exec_cmd(cmd, argv, NULL, 0);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
@ -47,7 +47,8 @@ static char *_verbose_args(const char *const argv[], char *buf, size_t sz)
|
||||
/*
|
||||
* Execute and wait for external command
|
||||
*/
|
||||
int exec_cmd(struct cmd_context *cmd, const char *const argv[], int *rstatus)
|
||||
int exec_cmd(struct cmd_context *cmd, const char *const argv[],
|
||||
int *rstatus, int sync_needed)
|
||||
{
|
||||
pid_t pid;
|
||||
int status;
|
||||
@ -55,7 +56,12 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[], int *rstatus)
|
||||
|
||||
log_verbose("Executing: %s", _verbose_args(argv, buf, sizeof(buf)));
|
||||
|
||||
sync_local_dev_names(cmd); /* Flush ops and reset dm cookie */
|
||||
if (rstatus)
|
||||
*rstatus = -1;
|
||||
|
||||
if (sync_needed)
|
||||
if (!sync_local_dev_names(cmd)) /* Flush ops and reset dm cookie */
|
||||
return_0;
|
||||
|
||||
if ((pid = fork()) == -1) {
|
||||
log_error("fork failed: %s", strerror(errno));
|
||||
@ -74,9 +80,6 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[], int *rstatus)
|
||||
_exit(errno);
|
||||
}
|
||||
|
||||
if (rstatus)
|
||||
*rstatus = -1;
|
||||
|
||||
/* Parent */
|
||||
if (wait4(pid, &status, 0, NULL) != pid) {
|
||||
log_error("wait4 child process %u failed: %s", pid,
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
@ -19,6 +19,22 @@
|
||||
#include "lib.h"
|
||||
|
||||
struct cmd_context;
|
||||
int exec_cmd(struct cmd_context *cmd, const char *const argv[], int *rstatus);
|
||||
|
||||
/**
|
||||
* Execute command with paramaters and return status
|
||||
*
|
||||
* \param rstatus
|
||||
* Returns command's exit status code.
|
||||
*
|
||||
* \param sync_needed
|
||||
* Bool specifying whether local devices needs to be synchronized
|
||||
* before executing command.
|
||||
* Note: You cannot synchronize devices within activation context.
|
||||
*
|
||||
* \return
|
||||
* 0 (success) or -1 (failure).
|
||||
*/
|
||||
int exec_cmd(struct cmd_context *cmd, const char *const argv[],
|
||||
int *rstatus, int sync_needed);
|
||||
|
||||
#endif
|
||||
|
@ -179,7 +179,7 @@ static int _fsadm_cmd(struct cmd_context *cmd,
|
||||
|
||||
argv[i] = NULL;
|
||||
|
||||
return exec_cmd(cmd, argv, status);
|
||||
return exec_cmd(cmd, argv, status, 1);
|
||||
}
|
||||
|
||||
static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
|
||||
|
Loading…
x
Reference in New Issue
Block a user