master - cleanup: update API for segment reporting
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d202f43fff6ff7d12540440ae6b16a0ec2c7de5e Commit: d202f43fff6ff7d12540440ae6b16a0ec2c7de5e Parent: cdd17eee377013a569e2aeed0cbe865749323def Author: Zdenek Kabelac <[email protected]> AuthorDate: Wed Jan 14 10:31:24 2015 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Wed Jan 14 14:50:08 2015 +0100
cleanup: update API for segment reporting
API for seg reporting is breaking internal lvm coding - it cannot use vgmem mem pool for allocation of reported value.
So use separate pool instead of 'vgmem' for non vg related allocations
Add consts for many function params - but still many other are left for now as non-const - needs deeper level of change even on libdm side.
--- lib/activate/activate.c | 20 +++++---- lib/activate/activate.h | 18 ++++---- lib/report/report.c | 66 +++++++++++++++------------- lib/report/report.h | 10 ++-- libdm/libdevmapper.h | 1 + tools/reporter.c | 110 +++++++++++++++++++++++++---------------------- 6 files changed, 121 insertions(+), 104 deletions(-)
lib/activate/activate.c +11 -9
@@ -619,7 +619,8 @@ int target_present(struct cmd_context *cmd, const char *target_name,static int _lv_info (struct cmd_context *cmd,const struct logical_volume *lv,int use_layer,struct lvinfo *info, -struct lv_segment *seg,struct lv_seg_status *seg_status, +const struct lv_segment *seg, +struct lv_seg_status *seg_status,int with_open_count,int with_read_ahead) {struct dm_info dminfo;
@@ -698,7 +699,7 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,* Returns 1 if lv_seg_status structure populated, * else 0 on failure or if device not active locally. */ -int lv_status (struct cmd_context *cmd,struct lv_segment *lv_seg, +int lv_status (struct cmd_context *cmd,const struct lv_segment *lv_seg,struct lv_seg_status *lv_seg_status) {if (!activation ())
@@ -712,18 +713,18 @@ int lv_status(struct cmd_context *cmd, struct lv_segment *lv_seg,* else 0 on failure or if device not active locally. * * This is the same as calling lv_info and lv_status, -* but* it's done in one go with one ioctl if possible! +* but* it's done in one go with one ioctl if possible! ] */ int lv_info_with_seg_status (struct cmd_context *cmd,const struct logical_volume *lv, -struct lv_segment *lv_seg,int use_layer, -struct lvinfo *lvinfo,struct lv_seg_status *lv_seg_status, -int with_open_count,int with_read_ahead) +const struct lv_segment *lv_seg,int use_layer, +struct lv_with_info_and_seg_status *status, +int with_open_count,int with_read_ahead) {if (!activation ())return 0 ;if (lv == lv_seg->lv) -return _lv_info (cmd, lv, use_layer, lvinfo, lv_seg, lv_seg_status, +return _lv_info (cmd, lv, use_layer, &status->info, lv_seg, &status->seg_status, with_open_count, with_read_ahead);/*
@@ -731,8 +732,9 @@ int lv_info_with_seg_status(struct cmd_context *cmd, const struct logical_volume* status for segment that belong to another LV, * we need to acquire info and status separately! */ -return _lv_info (cmd, lv, use_layer, lvinfo,NULL ,NULL , with_open_count, with_read_ahead) && -_lv_info (cmd, lv_seg->lv, use_layer,NULL , lv_seg, lv_seg_status,0 ,0 ); +return _lv_info (cmd, lv, use_layer, &status->info,NULL ,NULL , with_open_count, with_read_ahead) && +_lv_info (cmd, lv_seg->lv, use_layer,NULL , lv_seg, + &status->seg_status,0 ,0 ); }#define OPEN_COUNT_CHECK_RETRIES 25
lib/activate/activate.h +9 -9
@@ -41,16 +41,16 @@ typedef enum {struct lv_seg_status {struct dm_pool *mem;/* input */ -struct lv_segment *seg;/* input */ +const struct lv_segment *seg;/* input */ lv_seg_status_type_t type;/* output */ -void *status;/* struct dm_status_* */ /* output */ +const void *status;/* struct dm_status_* */ /* output */ };struct lv_with_info_and_seg_status { -struct logical_volume *lv;/* input */ -struct lvinfo *info;/* output */ +const struct logical_volume *lv;/* input */ +struct lvinfo info;/* output */ int seg_part_of_lv;/* output */ -struct lv_seg_status *seg_status;/* input/output, see lv_seg_status */ +struct lv_seg_status seg_status;/* input/output, see lv_seg_status */ };struct lv_activate_opts {
@@ -123,19 +123,19 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,* Returns 1 if lv_seg_status structure has been populated, * else 0 on failure or if device not active locally. */ -int lv_status (struct cmd_context *cmd,struct lv_segment *lv_seg, +int lv_status (struct cmd_context *cmd,const struct lv_segment *lv_seg,struct lv_seg_status *lv_seg_status);/* * Returns 1 if lv_info_and_seg_status structure has been populated, * else 0 on failure or if device not active locally. * -* lv_info_with_seg_status is the same as calling lv_info and then lv_seg_status, +* lv_info_with_seg_status is the same as calling lv_info and then lv_status, * but this fn tries to do that with one ioctl if possible. */ int lv_info_with_seg_status (struct cmd_context *cmd,const struct logical_volume *lv, -struct lv_segment *lv_seg,int use_layer, -struct lvinfo *lvinfo,struct lv_seg_status *lv_seg_status, +const struct lv_segment *lv_seg,int use_layer, +struct lv_with_info_and_seg_status *status,int with_open_count,int with_read_ahead);int lv_check_not_in_use (const struct logical_volume *lv);
lib/report/report.c +36 -30
143 lines not on this page · raw message
lib/report/report.h +5 -5
@@ -44,11 +44,11 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys, int aligned, int buffered, int headings, int field_prefixes, int quoted, int columns_as_rows, const char *selection);void report_free (void *handle); -int report_object (void *handle,struct volume_group *vg, -struct logical_volume *lv,struct physical_volume *pv, -struct lv_segment *seg,struct pv_segment *pvseg, -struct lvinfo *lvinfo,struct lv_seg_status *lv_seg_status, -struct label *label); +int report_object (void *handle,const struct volume_group *vg, +const struct logical_volume *lv,const struct physical_volume *pv, +const struct lv_segment *seg,const struct pv_segment *pvseg, +const struct lvinfo *lvinfo,const struct lv_seg_status *lv_seg_status, +const struct label *label);int report_devtypes (void *handle);int report_output (void *handle);
libdm/libdevmapper.h +1 -0
@@ -1647,6 +1647,7 @@ struct dm_report_object_type {uint32_t id;/* Powers of 2 */ const char *desc;const char *prefix;/* field id string prefix (optional) */ +/* FIXME: convert to proper usage of const pointers here */ void *(*data_fn)(void *object);/* callback from report_object() */ };
tools/reporter.c +59 -51
176 lines not on this page · raw message