]> sourceware.org Git - lvm2.git/commitdiff
Add --addnodeonresume, --addnodeoncreate
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 4 Feb 2011 19:33:53 +0000 (19:33 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 4 Feb 2011 19:33:53 +0000 (19:33 +0000)
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.

WHATS_NEW
libdm/ioctl/libdm-iface.c
libdm/ioctl/libdm-targets.h
libdm/libdevmapper.h
man/dmsetup.8.in
tools/dmsetup.c

index 7e06bfa9c21df162c31ee0a95bc3114ada93b697..54f05f06854f643ee8f2e9a90101988d69c1a822 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -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.
index 956ccd53a25df3a99a2775552893424a5de05989..9ff8b36eb44f6fa268c63a7d22a07c7c5c954eff 100644 (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);
index 24c01a77d61a4b1ae9a8cdb53b1d889935f72427..d8cca844ca4677b6190d19296ee967abf346be7f 100644 (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;
index d0644ffa822c0d032cc0c26019309f07bb078adc..297b2c675b857105a888d0b753f3e9ce1aea6dbc 100644 (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.
index 68e9819904452a1cbe520283d6e76f8633f39b56..0d14c7adaf6ecf4ab69266aae31a428d815ef4a3 100644 (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.
index 2eeee7fd938464464acf4b9716454813513ee1a0..85d2060d4afd9de4b8556b1d5d24626b798a9446 100644 (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;
This page took 0.058418 seconds and 5 git commands to generate.