]> sourceware.org Git - lvm2.git/commitdiff
Add udevcomplete and --noudevwait to dmsetup.
authorAlasdair Kergon <agk@redhat.com>
Fri, 31 Jul 2009 17:51:45 +0000 (17:51 +0000)
committerAlasdair Kergon <agk@redhat.com>
Fri, 31 Jul 2009 17:51:45 +0000 (17:51 +0000)
WHATS_NEW
libdm/.exported_symbols
libdm/libdevmapper.h
libdm/libdm-common.c
man/dmsetup.8.in
tools/dmsetup.c

index 4cc70bb98caa5c53710894a46039a3c04160019b..ef74155408a8e4f210b851041d0b974da2a689a1 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.51 - 
 ================================
+  Add udevcomplete and --noudevwait to dmsetup.
   Add libdevmapper functions to support synchronisation with udev.
   Added configure --enable-udev_rules --enable-udev_sync.
   Added configure --with-udev-prefix --with-udevdir.
index c829fa764524c67f93377c798fabb5056807c1c6..d7d89d60c5e93f418a53900669b921395ae6037c 100644 (file)
@@ -157,6 +157,6 @@ dm_list_next
 dm_list_size
 dm_udev_set_sync_support
 dm_udev_get_sync_support
-dm_udev_notify
+dm_udev_complete
 dm_udev_wait
 dm_udev_cleanup
index 6bf9dab603a60e62cc8ea4d6a87904f770a78c82..f1692f3efb844a6a1dc3c8cf20ad12ad0149f15a 100644 (file)
@@ -1018,7 +1018,7 @@ int dm_cookie_supported(void);
  */
 void dm_udev_set_sync_support(int sync_with_udev);
 int dm_udev_get_sync_support(void);
-int dm_udev_notify(uint32_t cookie);
+int dm_udev_complete(uint32_t cookie);
 int dm_udev_wait(uint32_t cookie);
 int dm_udev_cleanup(uint32_t cookie);
 
index b488b02e24cddc616b3501be0b64434145703e86..bc365b6ee213549c3f09a39a78d4e145168d65c6 100644 (file)
@@ -789,7 +789,7 @@ int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie)
        return 1;
 }
 
-int dm_udev_notify(uint32_t cookie)
+int dm_udev_complete(uint32_t cookie)
 {
        return 1;
 }
@@ -983,7 +983,7 @@ bad:
        return 0;
 }
 
-int dm_udev_notify(uint32_t cookie)
+int dm_udev_complete(uint32_t cookie)
 {
        int semid;
 
index 4fcb0845ecbcc068b4e8b3324289050b07b4adb9..c22f7978e69d6ea6d4ca1ea70fdf7a5302530faa 100644 (file)
@@ -64,6 +64,9 @@ dmsetup \- low level logical volume management
 .B dmsetup mknodes
 .I [device_name]
 .br
+.B dmsetup udevcomplete
+.I cookie
+.br
 .B dmsetup targets
 .br
 .B dmsetup version
@@ -108,6 +111,9 @@ 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--noudevsync
+Do not synchronise with udev when creating, renaming or removing devices.
+.br
 .IP \fB-o|--options
 .br
 Specify which fields to display.
@@ -280,6 +286,11 @@ is displayed.
 .IP \fBtargets
 .br
 Displays the names and versions of the currently-loaded targets.
+.IP \fBudevcomplete
+.I cookie
+.br
+Wake any processes that are waiting for udev to complete processing the specified cookie.
+.br
 .IP \fBversion
 .br
 Outputs version information.
index 94ac9fd8c20f04935c7793cf77d9cd06555fb7c7..e189cc88c0f1aec05f0ab002af141c85dab08c24 100644 (file)
@@ -119,6 +119,7 @@ enum {
        NOLOCKFS_ARG,
        NOOPENCOUNT_ARG,
        NOTABLE_ARG,
+       NOUDEVSYNC_ARG,
        OPTIONS_ARG,
        READAHEAD_ARG,
        ROWS_ARG,
@@ -540,6 +541,7 @@ static int _create(int argc, char **argv, void *data __attribute((unused)))
        int r = 0;
        struct dm_task *dmt;
        const char *file = NULL;
+       uint32_t cookie = 0;
 
        if (argc == 3)
                file = argv[2];
@@ -582,8 +584,16 @@ static int _create(int argc, char **argv, void *data __attribute((unused)))
                                    _read_ahead_flags))
                goto out;
 
-       if (!dm_task_run(dmt))
+       if (_switches[NOTABLE_ARG])
+               dm_udev_set_sync_support(0);
+
+       if (!dm_task_set_cookie(dmt, &cookie) ||
+           !dm_task_run(dmt)) {
+               (void) dm_udev_cleanup(cookie);
                goto out;
+       }
+
+       dm_udev_wait(cookie);
 
        r = 1;
 
@@ -600,6 +610,7 @@ static int _rename(int argc, char **argv, void *data __attribute((unused)))
 {
        int r = 0;
        struct dm_task *dmt;
+       uint32_t cookie = 0;
 
        if (!(dmt = dm_task_create(DM_DEVICE_RENAME)))
                return 0;
@@ -614,8 +625,13 @@ static int _rename(int argc, char **argv, void *data __attribute((unused)))
        if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
                goto out;
 
-       if (!dm_task_run(dmt))
+       if (!dm_task_set_cookie(dmt, &cookie) ||
+           !dm_task_run(dmt)) {
+               (void) dm_udev_cleanup(cookie);
                goto out;
+       }
+
+       dm_udev_wait(cookie);
 
        r = 1;
 
@@ -740,6 +756,19 @@ static int _splitname(int argc, char **argv, void *data __attribute((unused)))
        return r;
 }
 
+static int _udevcomplete(int argc, char **argv, void *data __attribute((unused)))
+{
+       uint32_t cookie;
+       char *p;
+
+       if (!(cookie = (uint32_t) strtoul(argv[1], &p, 0)) || *p) {
+               err("Incorrect cookie value");
+               return 0;
+       }
+
+       return dm_udev_complete(cookie);
+}
+
 static int _version(int argc __attribute((unused)), char **argv __attribute((unused)), void *data __attribute((unused)))
 {
        char version[80];
@@ -757,6 +786,9 @@ static int _version(int argc __attribute((unused)), char **argv __attribute((unu
 
 static int _simple(int task, const char *name, uint32_t event_nr, int display)
 {
+       uint32_t cookie = 0;
+       int udev_wait_flag = task == DM_DEVICE_RESUME ||
+                            task == DM_DEVICE_REMOVE;
        int r = 0;
 
        struct dm_task *dmt;
@@ -784,8 +816,20 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
                                    _read_ahead_flags))
                goto out;
 
+       if (udev_wait_flag && !dm_task_set_cookie(dmt, &cookie)) {
+               (void) dm_udev_cleanup(cookie);
+               goto out;
+       }
+
        r = dm_task_run(dmt);
 
+       if (udev_wait_flag) {
+               if (r)
+                       (void) dm_udev_wait(cookie);
+               else
+                       (void) dm_udev_cleanup(cookie);
+       }
+
        if (r && display && _switches[VERBOSE_ARG])
                r = _display_info(dmt);
 
@@ -2261,6 +2305,7 @@ static struct command _commands[] = {
        {"table", "[<device>] [--target <target_type>] [--showkeys]", 0, 1, _status},
        {"wait", "<device> [<event_nr>]", 0, 2, _wait},
        {"mknodes", "[<device>]", 0, 1, _mknodes},
+       {"udevcomplete", "<cookie>", 1, 1, _udevcomplete},
        {"targets", "", 0, 0, _targets},
        {"version", "", 0, 0, _version},
        {"setgeometry", "<device> <cyl> <head> <sect> <start>", 5, 5, _setgeometry},
@@ -2275,7 +2320,7 @@ static void _usage(FILE *out)
        fprintf(out, "Usage:\n\n");
        fprintf(out, "dmsetup [--version] [-v|--verbose [-v|--verbose ...]]\n"
                "        [-r|--readonly] [--noopencount] [--nolockfs]\n"
-               "        [--readahead [+]<sectors>|auto|none]\n"
+               "        [--noudevsync] [--readahead [+]<sectors>|auto|none]\n"
                "        [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
                "        [--nameprefixes] [--noheadings] [--separator <separator>]\n\n");
        for (i = 0; _commands[i].name; i++)
@@ -2639,6 +2684,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
                {"nolockfs", 0, &ind, NOLOCKFS_ARG},
                {"noopencount", 0, &ind, NOOPENCOUNT_ARG},
                {"notable", 0, &ind, NOTABLE_ARG},
+               {"noudevsync", 0, &ind, NOUDEVSYNC_ARG},
                {"options", 1, &ind, OPTIONS_ARG},
                {"readahead", 1, &ind, READAHEAD_ARG},
                {"rows", 0, &ind, ROWS_ARG},
@@ -2747,6 +2793,8 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
                        _switches[UUID_ARG]++;
                        _uuid = optarg;
                }
+               if (ind == NOUDEVSYNC_ARG)
+                       _switches[NOUDEVSYNC_ARG]++;
                if (c == 'G' || ind == GID_ARG) {
                        _switches[GID_ARG]++;
                        _int_args[GID_ARG] = atoi(optarg);
@@ -2888,6 +2936,9 @@ int main(int argc, char **argv)
        if (_switches[COLS_ARG] && !_report_init(c))
                goto out;
 
+       if (_switches[NOUDEVSYNC_ARG])
+               dm_udev_set_sync_support(0);
+
       doit:
        if (!c->fn(argc, argv, NULL)) {
                fprintf(stderr, "Command failed\n");
This page took 0.086415 seconds and 5 git commands to generate.