master - dev_manager: enhance dev_manager_info to acquire LV segment status if requested, add lv_info_with_seg_status fn
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a2c1024f6ac7e22ac5c010a267d0c1df331ee416 Commit: a2c1024f6ac7e22ac5c010a267d0c1df331ee416 Parent: 7f90ad84c1f9bbc51a833b7ebb6459842405de52 Author: Peter Rajnoha <[email protected]> AuthorDate: Tue Nov 4 15:00:32 2014 +0100 Committer: Peter Rajnoha <[email protected]> CommitterDate: Tue Nov 11 13:04:02 2014 +0100
dev_manager: enhance dev_manager_info to acquire LV segment status if requested, add lv_info_with_seg_status fn
--- lib/activate/activate.c | 42 ++++++++++--- lib/activate/activate.h | 5 ++ lib/activate/dev_manager.c | 140 ++++++++++++++++++++++++++++++++++++------- lib/activate/dev_manager.h | 4 +- tools/reporter.c | 2 + 5 files changed, 160 insertions(+), 33 deletions(-)
lib/activate/activate.c +33 -9
@@ -617,17 +617,12 @@ int target_present(struct cmd_context *cmd, const char *target_name,return target_version (target_name, &maj, &min, &patchlevel); } -/* -* Returns 1 if info structure populated, else 0 on failure. -* When lvinfo* is NULL, it returns 1 if the device is locally active, 0 otherwise. -*/ -int lv_info (struct cmd_context *cmd,const struct logical_volume *lv,int use_layer, -struct lvinfo *info,int with_open_count,int with_read_ahead) +static int _lv_info (struct cmd_context *cmd,const struct logical_volume *lv, +int use_layer,struct lvinfo *info,struct lv_seg_status *seg_status, +int with_open_count,int with_read_ahead) {struct dm_info dminfo; -if (!activation ()) -return 0 ;/* * If open_count info is requested and we have to be sure our own udev * transactions are finished
@@ -648,7 +643,8 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_laif (!dev_manager_info (cmd->mem, lv, (use_layer) ?lv_layer (lv) :NULL , with_open_count, with_read_ahead, - &dminfo, (info) ? &info->read_ahead :NULL )) + &dminfo, (info) ? &info->read_ahead :NULL , + seg_status)) return_0;if (!info)
@@ -666,6 +662,19 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_lareturn 1 ; } +/* +* Returns 1 if info structure populated, else 0 on failure. +* When lvinfo* is NULL, it returns 1 if the device is locally active, 0 otherwise. +*/ +int lv_info (struct cmd_context *cmd,const struct logical_volume *lv,int use_layer, +struct lvinfo *info,int with_open_count,int with_read_ahead) +{ +if (!activation ()) +return 0 ; + +return _lv_info (cmd, lv, use_layer, info,NULL , with_open_count, with_read_ahead); +} +int lv_info_by_lvid (struct cmd_context *cmd,const char *lvid_s,int use_layer,struct lvinfo *info,int with_open_count,int with_read_ahead) {
@@ -681,6 +690,21 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,return r; } +int lv_info_with_seg_status (struct cmd_context *cmd,const struct logical_volume *lv, +const struct lv_segment *lv_seg,int use_layer, +struct lv_with_info_and_seg_status *lvdm, +int with_open_count,int with_read_ahead) +{ +if (!activation ()) +return 0 ; + +if (!_lv_info (cmd, lv, use_layer, lvdm->info, lvdm->seg_status, + with_open_count, with_read_ahead)) +return 0 ; + +return 1 ; +} +#define OPEN_COUNT_CHECK_RETRIES 25#define OPEN_COUNT_CHECK_USLEEP_DELAY 200000
lib/activate/activate.h +5 -0
@@ -118,6 +118,11 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_laint lv_info_by_lvid (struct cmd_context *cmd,const char *lvid_s,int use_layer,struct lvinfo *info,int with_open_count,int with_read_ahead); +int lv_info_with_seg_status (struct cmd_context *cmd,const struct logical_volume *lv, +const struct lv_segment *lv_seg,int use_layer, +struct lv_with_info_and_seg_status *lvdm, +int with_open_count,int with_read_ahead); +int lv_check_not_in_use (const struct logical_volume *lv);/*
lib/activate/dev_manager.c +117 -23
221 lines not on this page · raw message
lib/activate/dev_manager.h +3 -1
@@ -25,6 +25,7 @@ struct cmd_context;struct dev_manager ;struct dm_info ;struct device ; +struct lv_seg_status ;int read_only_lv (const struct logical_volume *lv,const struct lv_activate_opts *laopts);
@@ -47,7 +48,8 @@ void dev_manager_exit(void);int dev_manager_info (struct dm_pool *mem,const struct logical_volume *lv,const char *layer,int with_open_count,int with_read_ahead, -struct dm_info *info,uint32_t *read_ahead); +struct dm_info *dminfo,uint32_t *read_ahead, +struct lv_seg_status *seg_status);int dev_manager_snapshot_percent (struct dev_manager *dm,const struct logical_volume *lv,dm_percent_t *percent);
tools/reporter.c +2 -0
@@ -59,6 +59,8 @@ static void _get_lv_info_for_report(struct cmd_context *cmd,static void _get_lv_info_with_segment_status_for_report (struct cmd_context *cmd,struct lv_with_info_and_seg_status *lvdm) { +if (!lv_info_with_seg_status (cmd, lvdm->seg_status->seg->lv, lvdm->seg_status->seg,0 , lvdm,1 ,1 )) + lvdm->info->exists =0 ; } static int _lvs_with_info_single(struct cmd_context *cmd, struct logical_volume *lv,