diff options
author | Alasdair Kergon <agk@redhat.com> | 2002-04-15 16:27:39 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2002-04-15 16:27:39 +0000 |
commit | d6a766f138783e7b6fde7c44e7ca403d7bf32b24 (patch) | |
tree | 6e0731102afc6118d64a586ac4f5cdf9bebcc71f | |
parent | 70d79186343fffbddbe67712c0af75da87c54bfb (diff) | |
download | lvm2-d6a766f138783e7b6fde7c44e7ca403d7bf32b24.tar.gz lvm2-d6a766f138783e7b6fde7c44e7ca403d7bf32b24.tar.xz lvm2-d6a766f138783e7b6fde7c44e7ca403d7bf32b24.zip |
Missing VG lock when iterating through all LVs.
-rw-r--r-- | tools/lvchange.c | 2 | ||||
-rw-r--r-- | tools/lvdisplay.c | 2 | ||||
-rw-r--r-- | tools/lvremove.c | 2 | ||||
-rw-r--r-- | tools/lvscan.c | 2 | ||||
-rw-r--r-- | tools/toollib.c | 15 | ||||
-rw-r--r-- | tools/toollib.h | 1 |
6 files changed, 20 insertions, 4 deletions
diff --git a/tools/lvchange.c b/tools/lvchange.c index 6504bdb9..896a8854 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -51,7 +51,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv) return EINVALID_CMD_LINE; } - return process_each_lv(cmd, argc, argv, &lvchange_single); + return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, &lvchange_single); } static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv) diff --git a/tools/lvdisplay.c b/tools/lvdisplay.c index c1fef9a6..9fb157aa 100644 --- a/tools/lvdisplay.c +++ b/tools/lvdisplay.c @@ -42,5 +42,5 @@ int lvdisplay(struct cmd_context *cmd, int argc, char **argv) return EINVALID_CMD_LINE; } - return process_each_lv(cmd, argc, argv, &lvdisplay_single); + return process_each_lv(cmd, argc, argv, LCK_VG_READ, &lvdisplay_single); } diff --git a/tools/lvremove.c b/tools/lvremove.c index 9857c527..b00f8c97 100644 --- a/tools/lvremove.c +++ b/tools/lvremove.c @@ -29,7 +29,7 @@ int lvremove(struct cmd_context *cmd, int argc, char **argv) return EINVALID_CMD_LINE; } - return process_each_lv(cmd, argc, argv, &lvremove_single); + return process_each_lv(cmd, argc, argv, LCK_VG_READ, &lvremove_single); } static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv) diff --git a/tools/lvscan.c b/tools/lvscan.c index 978a76f2..a571e6c4 100644 --- a/tools/lvscan.c +++ b/tools/lvscan.c @@ -29,7 +29,7 @@ int lvscan(struct cmd_context *cmd, int argc, char **argv) return EINVALID_CMD_LINE; } - return process_each_lv(cmd, argc, argv, &lvscan_single); + return process_each_lv(cmd, argc, argv, LCK_VG_READ, &lvscan_single); /*********** FIXME Count! Add private struct to process_each* * if (!lv_total) diff --git a/tools/toollib.c b/tools/toollib.c index a3d6fbf3..935d9f37 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -35,6 +35,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg, } int process_each_lv(struct cmd_context *cmd, int argc, char **argv, + int lock_type, int (*process_single) (struct cmd_context * cmd, struct logical_volume * lv)) { @@ -63,17 +64,23 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, } log_verbose("Finding volume group \"%s\"", vg_name); + if (!lock_vol(cmd, vg_name, lock_type)) { + log_error("Can't lock %s: skipping", vg_name); + continue; + } if (!(vg = cmd->fid->ops->vg_read(cmd->fid, vg_name))) { log_error("Volume group \"%s\" doesn't exist", vg_name); if (ret_max < ECMD_FAILED) ret_max = ECMD_FAILED; + unlock_vg(cmd, vg_name); continue; } if (vg->status & EXPORTED_VG) { log_error("Volume group \"%s\" is exported", vg->name); + unlock_vg(cmd, vg_name); return ECMD_FAILED; } @@ -83,6 +90,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, lv_name, vg_name); if (ret_max < ECMD_FAILED) ret_max = ECMD_FAILED; + unlock_vg(cmd, vg_name); continue; } @@ -90,6 +98,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, if ((ret = process_single(cmd, lv)) > ret_max) ret_max = ret; + unlock_vg(cmd, vg_name); } } else { log_verbose("Finding all logical volumes"); @@ -99,14 +108,20 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, } list_iterate(vgh, vgs) { vg_name = list_item(vgh, struct name_list)->name; + if (!lock_vol(cmd, vg_name, lock_type)) { + log_error("Can't lock %s: skipping", vg_name); + continue; + } if (!(vg = cmd->fid->ops->vg_read(cmd->fid, vg_name))) { log_error("Volume group \"%s\" not found", vg_name); if (ret_max < ECMD_FAILED) ret_max = ECMD_FAILED; + unlock_vg(cmd, vg_name); continue; } ret = process_each_lv_in_vg(cmd, vg, process_single); + unlock_vg(cmd, vg_name); if (ret > ret_max) ret_max = ret; vg_count++; diff --git a/tools/toollib.h b/tools/toollib.h index 3a1aa5b4..aa2f7f9e 100644 --- a/tools/toollib.h +++ b/tools/toollib.h @@ -40,6 +40,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv, struct volume_group * vg, struct physical_volume * pv)); int process_each_lv(struct cmd_context *cmd, int argc, char **argv, + int lock_type, int (*process_single) (struct cmd_context * cmd, struct logical_volume * lv)); |