]> sourceware.org Git - lvm2.git/commitdiff
Port process_each_pv to new vg_read.
authorPetr Rockai <prokai@redhat.com>
Wed, 15 Jul 2009 05:50:22 +0000 (05:50 +0000)
committerPetr Rockai <prokai@redhat.com>
Wed, 15 Jul 2009 05:50:22 +0000 (05:50 +0000)
lib/metadata/metadata-exported.h
lib/metadata/metadata.c
tools/pvdisplay.c
tools/pvresize.c
tools/reporter.c
tools/toollib.c
tools/vgreduce.c

index 4a46152ac7b7c2a0de2872d9ca059ef416efa3d9..9d8d5425d0d3df364b2df45931c37d782709a0aa 100644 (file)
@@ -95,6 +95,7 @@
 /* vg_read and vg_read_for_update flags */
 #define READ_ALLOW_INCONSISTENT        0x00010000U
 #define READ_ALLOW_EXPORTED    0x00020000U
+#define READ_WITHOUT_LOCK       0x00040000U
 
 /* A meta-flag, useful with toollib for_each_* functions. */
 #define READ_FOR_UPDATE        0x00100000U
index c8166ad84d85818999862e8d36b81b6d61ecdcf1..7f85d7ce473f7e110bda896bad8af7048ae8c6b6 100644 (file)
@@ -2897,7 +2897,8 @@ static vg_t *_vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
        lock_name = is_orphan_vg(vg_name) ? VG_ORPHANS : vg_name;
        already_locked = vgname_is_locked(lock_name);
 
-       if (!already_locked && !lock_vol(cmd, lock_name, lock_flags)) {
+       if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK) &&
+           !lock_vol(cmd, lock_name, lock_flags)) {
                log_error("Can't get lock for %s", vg_name);
                return _vg_make_handle(cmd, vg, FAILED_LOCKING);
        }
@@ -2953,7 +2954,7 @@ static vg_t *_vg_lock_and_read(struct cmd_context *cmd, const char *vg_name,
        return _vg_make_handle(cmd, vg, failure);
 
 bad:
-       if (!already_locked)
+       if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK))
                unlock_vg(cmd, lock_name);
 
        return _vg_make_handle(cmd, vg, failure);
index c8c4a88462d950624409f7dbb8fe4dbb6c603879..531f37a7957d57d1ef59dc2016b8cd69d7942a3f 100644 (file)
@@ -113,6 +113,6 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
                return EINVALID_CMD_LINE;
        }
 
-       return process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ, 0, NULL,
+       return process_each_pv(cmd, argc, argv, NULL, 0, 0, NULL,
                               _pvdisplay_single);
 }
index 964d6a548470a9fa02fc9e213fe7d98335f378dd..eafbd56d853436e73d4fe8c78dfa60a19c427053 100644 (file)
@@ -205,7 +205,7 @@ int pvresize(struct cmd_context *cmd, int argc, char **argv)
        params.done = 0;
        params.total = 0;
 
-       ret = process_each_pv(cmd, argc, argv, NULL, LCK_VG_WRITE, 0, &params,
+       ret = process_each_pv(cmd, argc, argv, NULL, READ_FOR_UPDATE, 0, &params,
                              _pvresize_single);
 
        log_print("%d physical volume(s) resized / %d physical volume(s) "
index d1368d4cd029b97d7e4ef25f56dbd51fd15cf2b6..e391ee20ebd3c73bd21a677a0befb71d00230e61 100644 (file)
@@ -378,12 +378,12 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
                                    report_handle, &_vgs_single);
                break;
        case LABEL:
-               r = process_each_pv(cmd, argc, argv, NULL, LCK_NONE,
+               r = process_each_pv(cmd, argc, argv, NULL, READ_WITHOUT_LOCK,
                                    1, report_handle, &_label_single);
                break;
        case PVS:
                if (args_are_pvs)
-                       r = process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ,
+                       r = process_each_pv(cmd, argc, argv, NULL, 0,
                                            0, report_handle, &_pvs_single);
                else
                        r = process_each_vg(cmd, argc, argv, 0,
@@ -395,7 +395,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
                break;
        case PVSEGS:
                if (args_are_pvs)
-                       r = process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ,
+                       r = process_each_pv(cmd, argc, argv, NULL, 0,
                                            0, report_handle, &_pvsegs_single);
                else
                        r = process_each_vg(cmd, argc, argv, 0,
index 0df5d6643d485f32f0f0d053f3719eb5ca8243b8..75ce4c0fa9ca729dbbee69fc1c45a90557b51f84 100644 (file)
@@ -615,7 +615,7 @@ static int _process_all_devs(struct cmd_context *cmd, void *handle,
  * This can pause alongide pvscan or vgscan process for a while.
  */
 int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
-                   struct volume_group *vg, uint32_t lock_type,
+                   struct volume_group *vg, uint32_t flags,
                    int scan_label_only, void *handle,
                    int (*process_single) (struct cmd_context * cmd,
                                           struct volume_group * vg,
@@ -625,7 +625,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
        int opt = 0;
        int ret_max = ECMD_PROCESSED;
        int ret = 0;
-       int lock_global = lock_type == LCK_VG_READ;
+       int lock_global = !(flags & READ_WITHOUT_LOCK) && !(flags & READ_FOR_UPDATE);
 
        struct pv_list *pvl;
        struct physical_volume *pv;
@@ -633,12 +633,11 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
        struct dm_list tags;
        struct str_list *sll;
        char *tagname;
-       int consistent = 1;
        int scanned = 0;
 
        dm_list_init(&tags);
 
-       if (lock_global && !lock_vol(cmd, VG_GLOBAL, lock_type)) {
+       if (lock_global && !lock_vol(cmd, VG_GLOBAL, LCK_READ)) {
                log_error("Unable to obtain global lock.");
                return ECMD_FAILED;
        }
@@ -719,26 +718,11 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
                if (!dm_list_empty(&tags) && (vgnames = get_vgnames(cmd, 0)) &&
                           !dm_list_empty(vgnames)) {
                        dm_list_iterate_items(sll, vgnames) {
-                               if (!lock_vol(cmd, sll->str, lock_type)) {
-                                       log_error("Can't lock %s: skipping", sll->str);
+                               vg = vg_read(cmd, sll->str, NULL, flags);
+                               if (vg_read_error(vg)) {
                                        ret_max = ECMD_FAILED;
                                        continue;
                                }
-                               if (!(vg = vg_read_internal(cmd, sll->str, NULL, &consistent))) {
-                                       log_error("Volume group \"%s\" not found", sll->str);
-                                       unlock_vg(cmd, sll->str);
-                                       ret_max = ECMD_FAILED;
-                                       continue;
-                               }
-                               if (!consistent) {
-                                       unlock_and_release_vg(cmd, vg, sll->str);
-                                       continue;
-                               }
-
-                               if (!vg_check_status(vg, CLUSTERED)) {
-                                       unlock_and_release_vg(cmd, vg, sll->str);
-                                       continue;
-                               }
 
                                ret = process_each_pv_in_vg(cmd, vg, &tags,
                                                            handle,
index f22363edbca31e1598a89103d58fde3e0d22f5ae..be48993d1cc6a8ef103f6e7382d53a2fca588f6f 100644 (file)
@@ -573,7 +573,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
 
                /* FIXME: Pass private struct through to all these functions */
                /* and update in batch here? */
-               ret = process_each_pv(cmd, argc, argv, vg, LCK_NONE, 0, NULL,
+               ret = process_each_pv(cmd, argc, argv, vg, READ_FOR_UPDATE, 0, NULL,
                                      _vgreduce_single);
 
        }
This page took 0.040927 seconds and 5 git commands to generate.