1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Add --addnodeonresume, --addnodeoncreate

Add new function dm_task_set_add_node() to select between 2 types
of node creation in device directory.

DM_ADD_NODE_ON_RESUME is now default and ensures node is created on
resume. Old original behavior is accessible with DM_ADD_NODE_ON_CREATE.
In this case node would be created during dmsetup create --notable.

For the user 2 new options for dmsetup create are added:
[{--addnodeonresume | --addnodeoncreate }]

Properly working node creation on resume is needed for proper operation
stacking and ability to correctly check in which state the device should
after whole udev transation.
This commit is contained in:
Zdenek Kabelac 2011-02-04 19:33:53 +00:00
parent 577c542adc
commit 84f191ce5a
6 changed files with 56 additions and 2 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.83 -
===================================
Add --addnodeonresume, --addnodeoncreate options for dmsetup create.
Use cluster-wide message to request device name sync.
Fix operation node stacking for consecutive dm ops.
Increase hash table size to 1024 lv names and 64 pv uuids.

View File

@ -1181,6 +1181,19 @@ int dm_task_suppress_identical_reload(struct dm_task *dmt)
return 1;
}
int dm_task_set_add_node(struct dm_task *dmt, dm_add_node_t add_node)
{
switch (add_node) {
case DM_ADD_NODE_ON_RESUME:
case DM_ADD_NODE_ON_CREATE:
dmt->add_node = add_node;
return 1;
default:
log_error("Unknown add node parameter");
return 0;
}
}
int dm_task_set_newuuid(struct dm_task *dmt, const char *newuuid)
{
if (strlen(newuuid) >= DM_UUID_LEN) {
@ -2075,7 +2088,8 @@ repeat_ioctl:
switch (dmt->type) {
case DM_DEVICE_CREATE:
if (dmt->dev_name && *dmt->dev_name && !udev_only)
if ((dmt->add_node == DM_ADD_NODE_ON_CREATE) &&
dmt->dev_name && *dmt->dev_name && !udev_only)
add_dev_node(dmt->dev_name, MAJOR(dmi->dev),
MINOR(dmi->dev), dmt->uid, dmt->gid,
dmt->mode, check_udev);
@ -2094,6 +2108,11 @@ repeat_ioctl:
break;
case DM_DEVICE_RESUME:
if ((dmt->add_node == DM_ADD_NODE_ON_RESUME) &&
dmt->dev_name && *dmt->dev_name && !udev_only)
add_dev_node(dmt->dev_name, MAJOR(dmi->dev),
MINOR(dmi->dev), dmt->uid, dmt->gid,
dmt->mode, check_udev);
/* FIXME Kernel needs to fill in dmi->name */
set_dev_node_read_ahead(dmt->dev_name, dmt->read_ahead,
dmt->read_ahead_flags);

View File

@ -60,6 +60,7 @@ struct dm_task {
int skip_lockfs;
int query_inactive_table;
int suppress_identical_reload;
dm_add_node_t add_node;
uint64_t existing_table_size;
int cookie_set;
int new_uuid;

View File

@ -185,6 +185,11 @@ int dm_task_skip_lockfs(struct dm_task *dmt);
int dm_task_query_inactive_table(struct dm_task *dmt);
int dm_task_suppress_identical_reload(struct dm_task *dmt);
int dm_task_secure_data(struct dm_task *dmt);
typedef enum {
DM_ADD_NODE_ON_RESUME, /* add /dev/mapper node with dmsetup resume */
DM_ADD_NODE_ON_CREATE /* add /dev/mapper node with dmsetup create */
} dm_add_node_t;
int dm_task_set_add_node(struct dm_task *dmt, dm_add_node_t add_node);
/*
* Control read_ahead.

View File

@ -8,6 +8,7 @@ dmsetup \- low level logical volume management
.br
.B dmsetup create
.I device_name [-u uuid] [--notable | --table <table> | table_file]
.I [{ --addnodeonresume | --addnodeoncreate }]
.br
.B dmsetup remove
.I [-f|--force] device_name
@ -139,6 +140,12 @@ Tell the kernel not to supply the open reference count for the device.
.IP \fB--notable
.br
When creating a device, don't load any table.
.IP \fB--addnodeonresume
.br
Ensure /dev/mapper node exists after dmsetup resume (default with udev).
.IP \fB--addnodeoncreate
.br
Ensure /dev/mapper node exists after dmsetup create.
.IP \fB--udevcookie\ \fIcookie
.br
Use cookie for udev synchronisation.

View File

@ -153,6 +153,8 @@ enum {
VERBOSE_ARG,
VERSION_ARG,
YES_ARG,
ADD_NODE_ON_RESUME_ARG,
ADD_NODE_ON_CREATE_ARG,
NUM_SWITCHES
};
@ -624,6 +626,14 @@ static int _create(int argc, char **argv, void *data __attribute__((unused)))
udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG |
DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG;
if (_switches[ADD_NODE_ON_RESUME_ARG] &&
!dm_task_set_add_node(dmt, DM_ADD_NODE_ON_RESUME))
goto out;
if (_switches[ADD_NODE_ON_CREATE_ARG] &&
!dm_task_set_add_node(dmt, DM_ADD_NODE_ON_CREATE))
goto out;
if (_udev_cookie) {
cookie = _udev_cookie;
if (_udev_only)
@ -2693,7 +2703,7 @@ static struct command _commands[] = {
{"help", "[-c|-C|--columns]", 0, 0, _help},
{"create", "<dev_name> [-j|--major <major> -m|--minor <minor>]\n"
"\t [-U|--uid <uid>] [-G|--gid <gid>] [-M|--mode <octal_mode>]\n"
"\t [-u|uuid <uuid>]\n"
"\t [-u|uuid <uuid>] [{--addnodeonresume|--addnodeoncreate}]\n"
"\t [--notable | --table <table> | <table_file>]",
1, 2, _create},
{"remove", "[-f|--force] <device>", 0, 1, _remove},
@ -3124,6 +3134,8 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
{"verbose", 1, &ind, VERBOSE_ARG},
{"version", 0, &ind, VERSION_ARG},
{"yes", 0, &ind, YES_ARG},
{"addnodeonresume", 0, &ind, ADD_NODE_ON_RESUME_ARG},
{"addnodeoncreate", 0, &ind, ADD_NODE_ON_CREATE_ARG},
{0, 0, 0, 0}
};
#else
@ -3221,6 +3233,10 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
}
if (c == 'y' || ind == YES_ARG)
_switches[YES_ARG]++;
if (ind == ADD_NODE_ON_RESUME_ARG)
_switches[ADD_NODE_ON_RESUME_ARG]++;
if (ind == ADD_NODE_ON_CREATE_ARG)
_switches[ADD_NODE_ON_CREATE_ARG]++;
if (ind == UDEVCOOKIE_ARG) {
_switches[UDEVCOOKIE_ARG]++;
_udev_cookie = _get_cookie_value(optarg);
@ -3318,6 +3334,11 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
return 0;
}
if (_switches[ADD_NODE_ON_RESUME_ARG] && _switches[ADD_NODE_ON_CREATE_ARG]) {
fprintf(stderr, "--addnodeonresume and --addnodeoncreate are incompatible.\n");
return 0;
}
*argv += optind;
*argc -= optind;
return 1;