Add flag to LV interators to indicate whether to process hidden LVs.
PATCH 1/1 Add flag to LV interators to indicate whether to process hidden LVs.
Fixes rhbz 232499.
Signed-off-by Dave Wysochanski <[email protected]>
--- tools/lvchange.c | 2 +- tools/lvdisplay.c | 2 +- tools/lvremove.c | 2 +- tools/lvscan.c | 2 +- tools/reporter.c | 4 ++-- tools/toollib.c | 15 +++++++++++++-- tools/toollib.h | 12 +++++++++++- tools/vgdisplay.c | 2 +- tools/vgmknodes.c | 4 ++-- 9 files changed, 33 insertions(+), 12 deletions(-)
tools/lvchange.c +1 -1
@@ -728,6 +728,6 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)return EINVALID_CMD_LINE ; } -return process_each_lv (cmd, argc, argv,LCK_VG_WRITE ,NULL , +return process_each_lv (cmd, argc, argv,LCK_VG_WRITE ,0 ,NULL , &lvchange_single); }
tools/lvdisplay.c +1 -1
@@ -54,6 +54,6 @@ int lvdisplay(struct cmd_context *cmd, int argc, char **argv)return EINVALID_CMD_LINE ; } -return process_each_lv (cmd, argc, argv,LCK_VG_READ ,NULL , +return process_each_lv (cmd, argc, argv,LCK_VG_READ ,0 ,NULL , &_lvdisplay_single); }
tools/lvremove.c +1 -1
@@ -33,6 +33,6 @@ int lvremove(struct cmd_context *cmd, int argc, char **argv) cmd->handles_missing_pvs =1 ; -return process_each_lv (cmd, argc, argv,LCK_VG_WRITE ,NULL , +return process_each_lv (cmd, argc, argv,LCK_VG_WRITE ,0 ,NULL , &lvremove_single); }
tools/lvscan.c +1 -1
@@ -80,6 +80,6 @@ int lvscan(struct cmd_context *cmd, int argc, char **argv)return EINVALID_CMD_LINE ; } -return process_each_lv (cmd, argc, argv,LCK_VG_READ ,NULL , +return process_each_lv (cmd, argc, argv,LCK_VG_READ ,0 ,NULL , &lvscan_single); }
tools/reporter.c +2 -2
@@ -352,7 +352,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,switch (report_type) {case LVS : - r =process_each_lv (cmd, argc, argv,LCK_VG_READ , report_handle, + r =process_each_lv (cmd, argc, argv,LCK_VG_READ ,0 , report_handle, &_lvs_single);break ;case VGS :
@@ -368,7 +368,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, report_handle, &_pvs_in_vg);break ;case SEGS : - r =process_each_lv (cmd, argc, argv,LCK_VG_READ , report_handle, + r =process_each_lv (cmd, argc, argv,LCK_VG_READ ,0 , report_handle, &_lvsegs_single);break ;case PVSEGS :
tools/toollib.c +13 -2
@@ -86,6 +86,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd,const struct volume_group *vg, const struct dm_list *arg_lvnames, const struct dm_list *tags, + uint32_t flags, void *handle, process_single_lv_fn_t process_single) {
@@ -121,6 +122,15 @@ int process_each_lv_in_vg(struct cmd_context *cmd, dm_list_iterate_items(lvl, &vg->lvs) {if (lvl->lv->status &SNAPSHOT )continue ; +/* +* If no LVs given on the cmdline, and this is not +* a visible LV, then skip the LV if we were told +* to only process visible ones. +*/ +if (!lvargs_supplied && + !lv_is_visible (lvl->lv) && + (flags &PROCESS_ONLY_VISIBLE_LVS )) +continue ;/* Should we process this LV? */ if (process_all)
@@ -161,7 +171,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, }int process_each_lv (struct cmd_context *cmd,int argc,char **argv, -uint32_t lock_type,void *handle, +uint32_t lock_type,uint32_t flags, +void *handle,int (*process_single) (struct cmd_context * cmd,struct logical_volume * lv,void *handle))
@@ -343,7 +354,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, } ret =process_each_lv_in_vg (cmd, vg, &lvnames, tags_arg, - handle, process_single); + flags, handle, process_single);unlock_vg (cmd, vgname);if (ret > ret_max) ret_max = ret;
tools/toollib.h +11 -1
@@ -47,9 +47,18 @@ int process_each_segment_in_pv(struct cmd_context *cmd,struct volume_group * vg, struct pv_segment * pvseg, void *handle)); +/* +* Indicates whether we should process only visible LVs when looping +* through a list of LVs on a VG. +* NOTE: This does not apply if a hidden/non-visible LV is given on the +* commandline for a tool, only if another option is given (e.g. a VG) that +* implies a list of LVs and the tools need to make a decision. +*/ +#define PROCESS_ONLY_VISIBLE_LVS 0x1int process_each_lv (struct cmd_context *cmd,int argc,char **argv, -uint32_t lock_type,void *handle, +uint32_t lock_type,uint32_t flags, +void *handle,int (*process_single) (struct cmd_context * cmd,struct logical_volume * lv,void *handle));
@@ -77,6 +86,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd,const struct volume_group *vg, const struct dm_list *arg_lvnames, const struct dm_list *tags, + uint32_t flags, void *handle, process_single_lv_fn_t process_single);
tools/vgdisplay.c +1 -1
@@ -45,7 +45,7 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,if (arg_count (cmd, verbose_ARG)) {vgdisplay_extents (vg); -process_each_lv_in_vg (cmd, vg,NULL ,NULL ,NULL , +process_each_lv_in_vg (cmd, vg,NULL ,NULL ,0 ,NULL , (process_single_lv_fn_t )lvdisplay_full);log_print ("--- Physical volumes ---" );
tools/vgmknodes.c +2 -2
@@ -33,6 +33,6 @@ int vgmknodes(struct cmd_context *cmd, int argc, char **argv)if (!lv_mknodes (cmd,NULL ))return ECMD_FAILED ; -return process_each_lv (cmd, argc, argv,LCK_VG_READ ,NULL , - &_vgmknodes_single); +return process_each_lv (cmd, argc, argv,LCK_VG_READ ,0 ,NULL , + &_vgmknodes_single); }
Signature · 1 line
1.6.0.5
PATCH 1/1 Add flag to LV interators to indicate whether to process hidden LVs.
This patch does not work - I didn't set the flag anywhere!
It's also questionable to be introducing a flag to pass around for only one instance so this needs more thought.
Quoted 190 lines · Dave Wysochanski
Fixes rhbz 232499.
Signed-off-by Dave Wysochanski <[email protected]>--- tools/lvchange.c | 2 +- tools/lvdisplay.c | 2 +- tools/lvremove.c | 2 +- tools/lvscan.c | 2 +- tools/reporter.c | 4 ++-- tools/toollib.c | 15 +++++++++++++-- tools/toollib.h | 12 +++++++++++- tools/vgdisplay.c | 2 +- tools/vgmknodes.c | 4 ++-- 9 files changed, 33 insertions(+), 12 deletions(-)tools/lvchange.c +1
-1@@ -728,6 +728,6 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)return EINVALID_CMD_LINE ; } -return process_each_lv (cmd, argc, argv,LCK_VG_WRITE ,NULL , +return process_each_lv (cmd, argc, argv,LCK_VG_WRITE ,0 ,NULL , &lvchange_single); }tools/lvdisplay.c +1
-1@@ -54,6 +54,6 @@ int lvdisplay(struct cmd_context *cmd, int argc, char **argv)return EINVALID_CMD_LINE ; } -return process_each_lv (cmd, argc, argv,LCK_VG_READ ,NULL , +return process_each_lv (cmd, argc, argv,LCK_VG_READ ,0 ,NULL , &_lvdisplay_single); }tools/lvremove.c +1
-1@@ -33,6 +33,6 @@ int lvremove(struct cmd_context *cmd, int argc, char **argv) cmd->handles_missing_pvs =1 ; -return process_each_lv (cmd, argc, argv,LCK_VG_WRITE ,NULL , +return process_each_lv (cmd, argc, argv,LCK_VG_WRITE ,0 ,NULL , &lvremove_single); }tools/lvscan.c +1
-1@@ -80,6 +80,6 @@ int lvscan(struct cmd_context *cmd, int argc, char **argv)return EINVALID_CMD_LINE ; } -return process_each_lv (cmd, argc, argv,LCK_VG_READ ,NULL , +return process_each_lv (cmd, argc, argv,LCK_VG_READ ,0 ,NULL , &lvscan_single); }tools/reporter.c +2
-2@@ -352,7 +352,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,switch (report_type) {case LVS : - r =process_each_lv (cmd, argc, argv,LCK_VG_READ , report_handle, + r =process_each_lv (cmd, argc, argv,LCK_VG_READ ,0 , report_handle, &_lvs_single);break ;case VGS :@@ -368,7 +368,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, report_handle, &_pvs_in_vg);break ;case SEGS : - r =process_each_lv (cmd, argc, argv,LCK_VG_READ , report_handle, + r =process_each_lv (cmd, argc, argv,LCK_VG_READ ,0 , report_handle, &_lvsegs_single);break ;case PVSEGS :tools/toollib.c +13
-2@@ -86,6 +86,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd,const struct volume_group *vg, const struct dm_list *arg_lvnames, const struct dm_list *tags, + uint32_t flags, void *handle, process_single_lv_fn_t process_single) {@@ -121,6 +122,15 @@ int process_each_lv_in_vg(struct cmd_context *cmd, dm_list_iterate_items(lvl, &vg->lvs) {if (lvl->lv->status &SNAPSHOT )continue ; +/* +* If no LVs given on the cmdline, and this is not +* a visible LV, then skip the LV if we were told +* to only process visible ones. +*/ +if (!lvargs_supplied && + !lv_is_visible (lvl->lv) && + (flags &PROCESS_ONLY_VISIBLE_LVS )) +continue ;/* Should we process this LV? */ if (process_all)@@ -161,7 +171,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, }int process_each_lv (struct cmd_context *cmd,int argc,char **argv, -uint32_t lock_type,void *handle, +uint32_t lock_type,uint32_t flags, +void *handle,int (*process_single) (struct cmd_context * cmd,struct logical_volume * lv,void *handle))@@ -343,7 +354,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, } ret =process_each_lv_in_vg (cmd, vg, &lvnames, tags_arg, - handle, process_single); + flags, handle, process_single);unlock_vg (cmd, vgname);if (ret > ret_max) ret_max = ret;tools/toollib.h +11
-1@@ -47,9 +47,18 @@ int process_each_segment_in_pv(struct cmd_context *cmd,struct volume_group * vg, struct pv_segment * pvseg, void *handle)); +/* +* Indicates whether we should process only visible LVs when looping +* through a list of LVs on a VG. +* NOTE: This does not apply if a hidden/non-visible LV is given on the +* commandline for a tool, only if another option is given (e.g. a VG) that +* implies a list of LVs and the tools need to make a decision. +*/ +#define PROCESS_ONLY_VISIBLE_LVS 0x1int process_each_lv (struct cmd_context *cmd,int argc,char **argv, -uint32_t lock_type,void *handle, +uint32_t lock_type,uint32_t flags, +void *handle,int (*process_single) (struct cmd_context * cmd,struct logical_volume * lv,void *handle));@@ -77,6 +86,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd,const struct volume_group *vg, const struct dm_list *arg_lvnames, const struct dm_list *tags, + uint32_t flags, void *handle, process_single_lv_fn_t process_single);tools/vgdisplay.c +1
-1@@ -45,7 +45,7 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,if (arg_count (cmd, verbose_ARG)) {vgdisplay_extents (vg); -process_each_lv_in_vg (cmd, vg,NULL ,NULL ,NULL , +process_each_lv_in_vg (cmd, vg,NULL ,NULL ,0 ,NULL , (process_single_lv_fn_t )lvdisplay_full);log_print ("--- Physical volumes ---" );tools/vgmknodes.c +2
-2@@ -33,6 +33,6 @@ int vgmknodes(struct cmd_context *cmd, int argc, char **argv)if (!lv_mknodes (cmd,NULL ))return ECMD_FAILED ; -return process_each_lv (cmd, argc, argv,LCK_VG_READ ,NULL , - &_vgmknodes_single); +return process_each_lv (cmd, argc, argv,LCK_VG_READ ,0 ,NULL , + &_vgmknodes_single); }