master - cleanup: constify activation usage of lv pointer
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=84cdf85bd2d682f11deeff51e39f3bfb98753829 Commit: 84cdf85bd2d682f11deeff51e39f3bfb98753829 Parent: af18e7cfbfee96ff8f5ec2ab795c830b4a6c7da4 Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Sep 22 15:50:07 2014 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Wed Sep 24 10:54:47 2014 +0200
cleanup: constify activation usage of lv pointer
Let's enforce cheking of write access to LV by compiler. Activation part does never need to write anything to LV so keep LV pointer const.
--- lib/activate/activate.c | 86 ++++++++++++++++++++------------------ lib/activate/activate.h | 25 ++++++----- lib/activate/dev_manager.c | 42 +++++++++--------- lib/activate/dev_manager.h | 12 +++--- lib/activate/fs.c | 4 +- lib/activate/fs.h | 2 +- lib/locking/cluster_locking.c | 6 +- lib/locking/external_locking.c | 2 +- lib/locking/file_locking.c | 2 +- lib/locking/locking.c | 4 +- lib/locking/locking.h | 2 +- lib/locking/locking_types.h | 2 +- lib/locking/no_locking.c | 4 +- lib/metadata/lv.h | 2 +- lib/metadata/metadata-exported.h | 14 +++--- lib/metadata/metadata.c | 2 +- lib/metadata/mirror.c | 10 ++-- lib/metadata/raid_manip.c | 5 +- lib/metadata/replicator_manip.c | 6 +- tools/polldaemon.h | 2 +- 20 files changed, 120 insertions(+), 114 deletions(-)
lib/activate/activate.c +45 -41
@@ -108,7 +108,7 @@ int list_lv_modules(struct dm_pool *mem, const struct logical_volume *lv,return 1 ; } -static int _lv_passes_volumes_filter (struct cmd_context *cmd,struct logical_volume *lv, +static int _lv_passes_volumes_filter (struct cmd_context *cmd,const struct logical_volume *lv,const struct dm_config_node *cn,const int cfg_id) {const struct dm_config_value *cv;
@@ -248,7 +248,7 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer, {return 0 ; } -int lv_check_not_in_use (struct cmd_context *cmd,struct logical_volume *lv, +int lv_check_not_in_use (struct cmd_context *cmd,const struct logical_volume *lv,struct lvinfo *info) {return 0 ;
@@ -328,35 +328,35 @@ int lv_suspend(struct cmd_context *cmd, const char *lvid_s)} *******/ int lv_suspend_if_active (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only,unsigned exclusive, -struct logical_volume *ondisk_lv,struct logical_volume *incore_lv) +const struct logical_volume *ondisk_lv,const struct logical_volume *incore_lv) {return 1 ; } -int lv_resume (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only,struct logical_volume *lv) +int lv_resume (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only,const struct logical_volume *lv) {return 1 ; }int lv_resume_if_active (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only, -unsigned exclusive,unsigned revert,struct logical_volume *lv) +unsigned exclusive,unsigned revert,const struct logical_volume *lv) {return 1 ; } -int lv_deactivate (struct cmd_context *cmd,const char *lvid_s,struct logical_volume *lv) +int lv_deactivate (struct cmd_context *cmd,const char *lvid_s,const struct logical_volume *lv) {return 1 ; }int lv_activation_filter (struct cmd_context *cmd,const char *lvid_s, -int *activate_lv,struct logical_volume *lv) +int *activate_lv,const struct logical_volume *lv) {return 1 ; }int lv_activate (struct cmd_context *cmd,const char *lvid_s,int exclusive,int noscan, -int temporary,struct logical_volume *lv) +int temporary,const struct logical_volume *lv) {return 1 ; }int lv_activate_with_filter (struct cmd_context *cmd,const char *lvid_s,int exclusive, -int noscan,int temporary,struct logical_volume *lv) +int noscan,int temporary,const struct logical_volume *lv) {return 1 ; }
@@ -405,7 +405,7 @@ int lv_check_transient(struct logical_volume *lv) {return 1 ; } -int monitor_dev_for_events (struct cmd_context *cmd,struct logical_volume *lv, +int monitor_dev_for_events (struct cmd_context *cmd,const struct logical_volume *lv,const struct lv_activate_opts *laopts,int monitor) {return 1 ;
@@ -426,7 +426,7 @@ int device_is_usable(struct device *dev) {return 0 ; } -int lv_has_target_type (struct dm_pool *mem,struct logical_volume *lv, +int lv_has_target_type (struct dm_pool *mem,const struct logical_volume *lv,const char *layer,const char *target_type) {return 0 ;
@@ -458,7 +458,7 @@ int activation(void) }static int _passes_activation_filter (struct cmd_context *cmd, -struct logical_volume *lv) +const struct logical_volume *lv) {const struct dm_config_node *cn;
@@ -487,7 +487,7 @@ static int _passes_activation_filter(struct cmd_context *cmd, }static int _passes_readonly_filter (struct cmd_context *cmd, -struct logical_volume *lv) +const struct logical_volume *lv) {const struct dm_config_node *cn;
@@ -695,7 +695,7 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,#define OPEN_COUNT_CHECK_RETRIES 25#define OPEN_COUNT_CHECK_USLEEP_DELAY 200000 -int lv_check_not_in_use (struct cmd_context *cmd,struct logical_volume *lv, +int lv_check_not_in_use (struct cmd_context *cmd,const struct logical_volume *lv,struct lvinfo *info) {unsigned int open_count_check_retries;
@@ -1256,7 +1256,7 @@ static int _lv_active(struct cmd_context *cmd, const struct logical_volume *lv)return info.exists; } -static int _lv_open_count (struct cmd_context *cmd,struct logical_volume *lv) +static int _lv_open_count (struct cmd_context *cmd,const struct logical_volume *lv) {struct lvinfo info;
@@ -1268,7 +1268,7 @@ static int _lv_open_count(struct cmd_context *cmd, struct logical_volume *lv)return info.open_count; } -static int _lv_activate_lv (struct logical_volume *lv,struct lv_activate_opts *laopts) +static int _lv_activate_lv (const struct logical_volume *lv,struct lv_activate_opts *laopts) {int r;struct dev_manager *dm;
@@ -1283,7 +1283,7 @@ static int _lv_activate_lv(struct logical_volume *lv, struct lv_activate_opts *lreturn r; } -static int _lv_preload (struct logical_volume *lv,struct lv_activate_opts *laopts, +static int _lv_preload (const struct logical_volume *lv,struct lv_activate_opts *laopts,int *flush_required) {int r =0 ;
@@ -1305,7 +1305,7 @@ out:return r; } -static int _lv_deactivate (struct logical_volume *lv) +static int _lv_deactivate (const struct logical_volume *lv) {int r;struct dev_manager *dm;
@@ -1320,7 +1320,7 @@ static int _lv_deactivate(struct logical_volume *lv)return r; } -static int _lv_suspend_lv (struct logical_volume *lv,struct lv_activate_opts *laopts, +static int _lv_suspend_lv (const struct logical_volume *lv,struct lv_activate_opts *laopts,int lockfs,int flush_required) {int r;
@@ -1538,7 +1538,7 @@ char *get_monitor_dso_path(struct cmd_context *cmd, const char *libpath)return path; } -static char *_build_target_uuid (struct cmd_context *cmd,struct logical_volume *lv) +static char *_build_target_uuid (struct cmd_context *cmd,const struct logical_volume *lv) {const char *layer;
@@ -1553,7 +1553,7 @@ static char *_build_target_uuid(struct cmd_context *cmd, struct logical_volume * }int target_registered_with_dmeventd (struct cmd_context *cmd,const char *dso, -struct logical_volume *lv,int *pending) +const struct logical_volume *lv,int *pending) {char *uuid;enum dm_event_mask evmask =0 ;
@@ -1585,7 +1585,7 @@ int target_registered_with_dmeventd(struct cmd_context *cmd, const char *dso,return evmask; } -int target_register_events (struct cmd_context *cmd,const char *dso,struct logical_volume *lv, +int target_register_events (struct cmd_context *cmd,const char *dso,const struct logical_volume *lv,int evmask __attribute__((unused)),int set,int timeout) {char *uuid;
@@ -1621,7 +1621,7 @@ int target_register_events(struct cmd_context *cmd, const char *dso, struct logi* Returns 0 if an attempt to (un)monitor the device failed. * Returns 1 otherwise. */ -int monitor_dev_for_events (struct cmd_context *cmd,struct logical_volume *lv, +int monitor_dev_for_events (struct cmd_context *cmd,const struct logical_volume *lv,const struct lv_activate_opts *laopts,int monitor) {#ifdef DMEVENTD
@@ -1796,7 +1796,7 @@ int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv, }struct detached_lv_data { -struct logical_volume *lv_pre; +const struct logical_volume *lv_pre;struct lv_activate_opts *laopts;int *flush_required; };
@@ -1817,9 +1817,11 @@ static int _preload_detached_lv(struct logical_volume *lv, void *data)static int _lv_suspend (struct cmd_context *cmd,const char *lvid_s,struct lv_activate_opts *laopts,int error_if_not_suspended, -struct logical_volume *ondisk_lv,struct logical_volume *incore_lv) +const struct logical_volume *ondisk_lv,const struct logical_volume *incore_lv) { -struct logical_volume *pvmove_lv =NULL , *ondisk_lv_to_free =NULL , *incore_lv_to_free =NULL ; +const struct logical_volume *pvmove_lv =NULL ; +const struct logical_volume *ondisk_lv_to_free =NULL ; +const struct logical_volume *incore_lv_to_free =NULL ;struct lv_list *lvl_pre;struct seg_list *sl;struct lv_segment *snap_seg;
@@ -1903,7 +1905,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, detached.laopts = laopts; detached.flush_required = &flush_required; -if (!for_each_sub_lv (ondisk_lv, &_preload_detached_lv, &detached)) +if (!for_each_sub_lv ((struct logical_volume *)ondisk_lv, &_preload_detached_lv, &detached)) goto_out;/*
@@ -1986,7 +1988,8 @@ out:* * Returns success if the device is not active */ -int lv_suspend_if_active (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only,unsigned exclusive,struct logical_volume *ondisk_lv,struct logical_volume *incore_lv) +int lv_suspend_if_active (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only,unsigned exclusive, +const struct logical_volume *ondisk_lv,const struct logical_volume *incore_lv) {struct lv_activate_opts laopts = { .origin_only = origin_only,
@@ -2006,9 +2009,9 @@ int lv_suspend(struct cmd_context *cmd, const char *lvid_s)static int _lv_resume (struct cmd_context *cmd,const char *lvid_s,struct lv_activate_opts *laopts,int error_if_not_active, -struct logical_volume *lv) +const struct logical_volume *lv) { -struct logical_volume *lv_to_free =NULL ; +const struct logical_volume *lv_to_free =NULL ;struct lvinfo info;int r =0 ;int messages_only =0 ;
@@ -2079,7 +2082,7 @@ out:*/ int lv_resume_if_active (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only,unsigned exclusive, -unsigned revert,struct logical_volume *lv) +unsigned revert,const struct logical_volume *lv) {struct lv_activate_opts laopts = { .origin_only = origin_only,
@@ -2090,14 +2093,15 @@ int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,return _lv_resume (cmd, lvid_s, &laopts,0 , lv); } -int lv_resume (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only,struct logical_volume *lv) +int lv_resume (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only, +const struct logical_volume *lv) {struct lv_activate_opts laopts = { .origin_only = origin_only, };return _lv_resume (cmd, lvid_s, &laopts,1 , lv); } -static int _lv_has_open_snapshots (struct logical_volume *lv) +static int _lv_has_open_snapshots (const struct logical_volume *lv) {struct lv_segment *snap_seg;struct lvinfo info;
@@ -2115,9 +2119,9 @@ static int _lv_has_open_snapshots(struct logical_volume *lv)return r; } -int lv_deactivate (struct cmd_context *cmd,const char *lvid_s,struct logical_volume *lv) +int lv_deactivate (struct cmd_context *cmd,const char *lvid_s,const struct logical_volume *lv) { -struct logical_volume *lv_to_free =NULL ; +const struct logical_volume *lv_to_free =NULL ;struct lvinfo info;static const struct lv_activate_opts laopts = { .skip_in_use =1 };int r =0 ;
@@ -2176,9 +2180,9 @@ out:/* Test if LV passes filter */ int lv_activation_filter (struct cmd_context *cmd,const char *lvid_s, -int *activate_lv,struct logical_volume *lv) +int *activate_lv,const struct logical_volume *lv) { -struct logical_volume *lv_to_free =NULL ; +const struct logical_volume *lv_to_free =NULL ;int r =0 ;if (!activation ()) {
@@ -2205,9 +2209,9 @@ out:static int _lv_activate (struct cmd_context *cmd,const char *lvid_s,struct lv_activate_opts *laopts,int filter, -struct logical_volume *lv) +const struct logical_volume *lv) { -struct logical_volume *lv_to_free =NULL ; +const struct logical_volume *lv_to_free =NULL ;struct lvinfo info;int r =0 ;
@@ -2297,7 +2301,7 @@ out:/* Activate LV */ int lv_activate (struct cmd_context *cmd,const char *lvid_s,int exclusive, -int noscan,int temporary,struct logical_volume *lv) +int noscan,int temporary,const struct logical_volume *lv) {struct lv_activate_opts laopts = { .exclusive = exclusive, .noscan = noscan,
@@ -2311,7 +2315,7 @@ int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive,/* Activate LV only if it passes filter */ int lv_activate_with_filter (struct cmd_context *cmd,const char *lvid_s,int exclusive, -int noscan,int temporary,struct logical_volume *lv) +int noscan,int temporary,const struct logical_volume *lv) {struct lv_activate_opts laopts = { .exclusive = exclusive, .noscan = noscan,
lib/activate/activate.h +13 -12
@@ -74,15 +74,16 @@ void activation_release(void);void activation_exit (void );/* int lv_suspend(struct cmd_context *cmd, const char *lvid_s); */ -int lv_suspend_if_active (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only,unsigned exclusive,struct logical_volume *lv_ondisk,struct logical_volume *lv_incore); -int lv_resume (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only,struct logical_volume *lv); +int lv_suspend_if_active (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only,unsigned exclusive, +const struct logical_volume *lv_ondisk,const struct logical_volume *lv_incore); +int lv_resume (struct cmd_context *cmd,const char *lvid_s,unsigned origin_only,const struct logical_volume *lv);int lv_resume_if_active (struct cmd_context *cmd,const char *lvid_s, -unsigned origin_only,unsigned exclusive,unsigned revert,struct logical_volume *lv); +unsigned origin_only,unsigned exclusive,unsigned revert,const struct logical_volume *lv);int lv_activate (struct cmd_context *cmd,const char *lvid_s,int exclusive, -int noscan,int temporary,struct logical_volume *lv); +int noscan,int temporary,const struct logical_volume *lv);int lv_activate_with_filter (struct cmd_context *cmd,const char *lvid_s,int exclusive, -int noscan,int temporary,struct logical_volume *lv); -int lv_deactivate (struct cmd_context *cmd,const char *lvid_s,struct logical_volume *lv); +int noscan,int temporary,const struct logical_volume *lv); +int lv_deactivate (struct cmd_context *cmd,const char *lvid_s,const struct logical_volume *lv);int lv_mknodes (struct cmd_context *cmd,const struct logical_volume *lv);
@@ -94,14 +95,14 @@ 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_check_not_in_use (struct cmd_context *cmd,struct logical_volume *lv, +int lv_check_not_in_use (struct cmd_context *cmd,const struct logical_volume *lv,struct lvinfo *info);/* * Returns 1 if activate_lv has been set: 1 = activate; 0 = don't. */ int lv_activation_filter (struct cmd_context *cmd,const char *lvid_s, -int *activate_lv,struct logical_volume *lv); +int *activate_lv,const struct logical_volume *lv);/* * Checks against the auto_activation_volume_list and * returns 1 if the LV should be activated, 0 otherwise.
@@ -147,18 +148,18 @@ int lv_is_active_exclusive(const struct logical_volume *lv);int lv_is_active_exclusive_locally (const struct logical_volume *lv);int lv_is_active_exclusive_remotely (const struct logical_volume *lv); -int lv_has_target_type (struct dm_pool *mem,struct logical_volume *lv, +int lv_has_target_type (struct dm_pool *mem,const struct logical_volume *lv,const char *layer,const char *target_type); -int monitor_dev_for_events (struct cmd_context *cmd,struct logical_volume *lv, +int monitor_dev_for_events (struct cmd_context *cmd,const struct logical_volume *lv,const struct lv_activate_opts *laopts,int do_reg);#ifdef DMEVENTD # include "libdevmapper-event.h" char *get_monitor_dso_path (struct cmd_context *cmd,const char *libpath);int target_registered_with_dmeventd (struct cmd_context *cmd,const char *libpath, -struct logical_volume *lv,int *pending); -int target_register_events (struct cmd_context *cmd,const char *dso,struct logical_volume *lv, +const struct logical_volume *lv,int *pending); +int target_register_events (struct cmd_context *cmd,const char *dso,const struct logical_volume *lv,int evmask __attribute__((unused)),int set,int timeout);#endif
lib/activate/dev_manager.c +21 -21
159 lines not on this page · raw message
lib/activate/dev_manager.h +6 -6
@@ -26,7 +26,7 @@ struct dev_manager;struct dm_info ;struct device ; -int read_only_lv (struct logical_volume *lv,struct lv_activate_opts *laopts); +int read_only_lv (const struct logical_volume *lv,const struct lv_activate_opts *laopts);/* * Constructor and destructor.
@@ -76,14 +76,14 @@ int dev_manager_thin_percent(struct dev_manager *dm,int dev_manager_thin_device_id (struct dev_manager *dm,const struct logical_volume *lv,uint32_t *device_id); -int dev_manager_suspend (struct dev_manager *dm,struct logical_volume *lv, +int dev_manager_suspend (struct dev_manager *dm,const struct logical_volume *lv,struct lv_activate_opts *laopts,int lockfs,int flush_required); -int dev_manager_activate (struct dev_manager *dm,struct logical_volume *lv, +int dev_manager_activate (struct dev_manager *dm,const struct logical_volume *lv,struct lv_activate_opts *laopts); -int dev_manager_preload (struct dev_manager *dm,struct logical_volume *lv, +int dev_manager_preload (struct dev_manager *dm,const struct logical_volume *lv,struct lv_activate_opts *laopts,int *flush_required); -int dev_manager_deactivate (struct dev_manager *dm,struct logical_volume *lv); -int dev_manager_transient (struct dev_manager *dm,struct logical_volume *lv) __attribute__((nonnull (1 ,2 ))); +int dev_manager_deactivate (struct dev_manager *dm,const struct logical_volume *lv); +int dev_manager_transient (struct dev_manager *dm,const struct logical_volume *lv) __attribute__((nonnull (1 ,2 )));int dev_manager_mknodes (const struct logical_volume *lv);
lib/activate/fs.c +2 -2
@@ -468,8 +468,8 @@ int fs_del_lv_byname(const char *dev_dir, const char *vg_name,return _fs_op (FS_DEL , dev_dir, vg_name, lv_name,"" ,"" , check_udev); } -int fs_rename_lv (struct logical_volume *lv,const char *dev, -const char *old_vgname,const char *old_lvname) +int fs_rename_lv (const struct logical_volume *lv,const char *dev, +const char *old_vgname,const char *old_lvname) {if (strcmp (old_vgname, lv->vg->name)) {return
lib/activate/fs.h +1 -1
@@ -27,7 +27,7 @@ int fs_add_lv(const struct logical_volume *lv, const char *dev);int fs_del_lv (const struct logical_volume *lv);int fs_del_lv_byname (const char *dev_dir,const char *vg_name,const char *lv_name,int check_udev); -int fs_rename_lv (struct logical_volume *lv,const char *dev, +int fs_rename_lv (const struct logical_volume *lv,const char *dev,const char *old_vgname,const char *old_lvname);/* void fs_unlock(void); moved to activate.h */ uint32_t fs_get_cookie (void );
lib/locking/cluster_locking.c +3 -3
@@ -33,7 +33,7 @@#include <unistd.h> #ifndef CLUSTER_LOCKING_INTERNAL -int lock_resource (struct cmd_context *cmd,const char *resource,uint32_t flags,struct logical_volume *lv __attribute__((unused))); +int lock_resource (struct cmd_context *cmd,const char *resource,uint32_t flags,const struct logical_volume *lv __attribute__((unused)));int query_resource (const char *resource,int *mode);void locking_end (void );int locking_init (int type,struct dm_config_tree *cf,uint32_t *flags);
@@ -411,9 +411,9 @@ static int _lock_for_cluster(struct cmd_context *cmd, unsigned char clvmd_cmd,/* API entry point for LVM */ #ifdef CLUSTER_LOCKING_INTERNAL static int _lock_resource (struct cmd_context *cmd,const char *resource, - uint32_t flags, struct logical_volume *lv __attribute__((unused))) + uint32_t flags, const struct logical_volume *lv __attribute__((unused)))#else - int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags, struct logical_volume *lv __attribute__((unused))) + int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags, const struct logical_volume *lv __attribute__((unused)))#endif {char lockname[PATH_MAX ];
lib/locking/external_locking.c +1 -1
@@ -30,7 +30,7 @@ static int (*_init_fn) (int type, struct dm_config_tree * cft,static int (*_lock_query_fn) (const char *resource,int *mode) =NULL ;static int _lock_resource (struct cmd_context *cmd,const char *resource, -uint32_t flags,struct logical_volume *lv __attribute__((unused))) +uint32_t flags,const struct logical_volume *lv __attribute__((unused))) {if (!_lock_fn)return 0 ;
lib/locking/file_locking.c +1 -1
@@ -42,7 +42,7 @@ static void _reset_file_locking(void) }static int _file_lock_resource (struct cmd_context *cmd,const char *resource, -uint32_t flags,struct logical_volume *lv) +uint32_t flags,const struct logical_volume *lv) {char lockfile[PATH_MAX ];unsigned origin_only = (flags &LCK_ORIGIN_ONLY ) ?1 :0 ;
lib/locking/locking.c +2 -2
@@ -244,7 +244,7 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname)* FIXME This should become VG uuid. */ static int _lock_vol (struct cmd_context *cmd,const char *resource, -uint32_t flags,lv_operation_t lv_op,struct logical_volume *lv) +uint32_t flags,lv_operation_t lv_op,const struct logical_volume *lv) {uint32_t lck_type = flags &LCK_TYPE_MASK ;uint32_t lck_scope = flags &LCK_SCOPE_MASK ;
@@ -295,7 +295,7 @@ out:return ret; } -int lock_vol (struct cmd_context *cmd,const char *vol,uint32_t flags,struct logical_volume *lv) +int lock_vol (struct cmd_context *cmd,const char *vol,uint32_t flags,const struct logical_volume *lv) { char resource[258] __attribute__((aligned(8)));lv_operation_t lv_op;
lib/locking/locking.h +1 -1
@@ -49,7 +49,7 @@ int remote_lock_held(const char *vol, int *exclusive);* Lock/unlock an individual logical volume * char *vol holds lvid */ -int lock_vol (struct cmd_context *cmd,const char *vol,uint32_t flags,struct logical_volume *lv); +int lock_vol (struct cmd_context *cmd,const char *vol,uint32_t flags,const struct logical_volume *lv);/* * Internal locking representation.
lib/locking/locking_types.h +1 -1
@@ -17,7 +17,7 @@#include "config.h" typedef int (*lock_resource_fn ) (struct cmd_context * cmd,const char *resource, -uint32_t flags,struct logical_volume *lv); +uint32_t flags,const struct logical_volume *lv);typedef int (*query_resource_fn ) (const char *resource,int *mode);typedef void (*fin_lock_fn ) (void );
lib/locking/no_locking.c +2 -2
@@ -34,7 +34,7 @@ static void _no_reset_locking(void) }static int _no_lock_resource (struct cmd_context *cmd,const char *resource, -uint32_t flags,struct logical_volume *lv) +uint32_t flags,const struct logical_volume *lv) {switch (flags &LCK_SCOPE_MASK ) {case LCK_ACTIVATION :
@@ -79,7 +79,7 @@ static int _no_query_resource(const char *resource, int *mode)static int _readonly_lock_resource (struct cmd_context *cmd,const char *resource, -uint32_t flags,struct logical_volume *lv) +uint32_t flags,const struct logical_volume *lv) { if ((flags & LCK_TYPE_MASK) == LCK_WRITE && (flags & LCK_SCOPE_MASK) == LCK_VG &&
lib/metadata/lv.h +1 -1
@@ -95,7 +95,7 @@ int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv, enum activation_change activate);char *lv_active_dup (struct dm_pool *mem,const struct logical_volume *lv);const struct logical_volume *lv_lock_holder (const struct logical_volume *lv); -struct logical_volume *lv_ondisk (struct logical_volume *lv); +const struct logical_volume *lv_ondisk (const struct logical_volume *lv);struct profile *lv_config_profile (const struct logical_volume *lv);char *lv_profile_dup (struct dm_pool *mem,const struct logical_volume *lv);int lv_mirror_image_in_sync (const struct logical_volume *lv);
lib/metadata/metadata-exported.h +7 -7
@@ -1065,7 +1065,7 @@ int lv_raid_reshape(struct logical_volume *lv,int lv_raid_replace (struct logical_volume *lv,struct dm_list *remove_pvs,struct dm_list *allocate_pvs);int lv_raid_remove_missing (struct logical_volume *lv); -int partial_raid_lv_supports_degraded_activation (struct logical_volume *lv); +int partial_raid_lv_supports_degraded_activation (const struct logical_volume *lv);/* -- metadata/raid_manip.c */ /* ++ metadata/cache_manip.c */
@@ -1087,10 +1087,10 @@ struct cmd_vg *cmd_vg_lookup(struct dm_list *cmd_vgs,int cmd_vg_read (struct cmd_context *cmd,struct dm_list *cmd_vgs);void free_cmd_vgs (struct dm_list *cmd_vgs); -int find_replicator_vgs (struct logical_volume *lv); +int find_replicator_vgs (const struct logical_volume *lv); -int lv_read_replicator_vgs (struct logical_volume *lv); -void lv_release_replicator_vgs (struct logical_volume *lv); +int lv_read_replicator_vgs (const struct logical_volume *lv); +void lv_release_replicator_vgs (const struct logical_volume *lv);struct logical_volume *find_pvmove_lv (struct volume_group *vg,struct device *dev,uint64_t lv_type);
@@ -1099,9 +1099,9 @@ struct logical_volume *find_pvmove_lv_from_pvname(struct cmd_context *cmd,const char *name, const char *uuid, uint64_t lv_type); -struct logical_volume *find_pvmove_lv_in_lv (struct logical_volume *lv); -const char *get_pvmove_pvname_from_lv (struct logical_volume *lv); -const char *get_pvmove_pvname_from_lv_mirr (struct logical_volume *lv_mirr); +const struct logical_volume *find_pvmove_lv_in_lv (const struct logical_volume *lv); +const char *get_pvmove_pvname_from_lv (const struct logical_volume *lv); +const char *get_pvmove_pvname_from_lv_mirr (const struct logical_volume *lv_mirr);struct dm_list *lvs_using_lv (struct cmd_context *cmd,struct volume_group *vg,struct logical_volume *lv);
lib/metadata/metadata.c +1 -1
@@ -4805,7 +4805,7 @@ char *tags_format_and_copy(struct dm_pool *mem, const struct dm_list *tagsl)return dm_pool_end_object (mem); } -struct logical_volume *lv_ondisk (struct logical_volume *lv) +const struct logical_volume *lv_ondisk (const struct logical_volume *lv) {struct volume_group *vg;struct lv_list *lvl;
lib/metadata/mirror.c +5 -5
@@ -1504,7 +1504,7 @@ int remove_mirrors_from_segments(struct logical_volume *lv,return 1 ; } -const char *get_pvmove_pvname_from_lv_mirr (struct logical_volume *lv_mirr) +const char *get_pvmove_pvname_from_lv_mirr (const struct logical_volume *lv_mirr) {struct lv_segment *seg;
@@ -1523,9 +1523,9 @@ const char *get_pvmove_pvname_from_lv_mirr(struct logical_volume *lv_mirr)/* * Find first pvmove LV referenced by a segment of an LV. */ -struct logical_volume *find_pvmove_lv_in_lv (struct logical_volume *lv) +const struct logical_volume *find_pvmove_lv_in_lv (const struct logical_volume *lv) { -struct lv_segment *seg; +const struct lv_segment *seg;uint32_t s; dm_list_iterate_items(seg, &lv->segments) {
@@ -1540,9 +1540,9 @@ struct logical_volume *find_pvmove_lv_in_lv(struct logical_volume *lv)return NULL ; } -const char *get_pvmove_pvname_from_lv (struct logical_volume *lv) +const char *get_pvmove_pvname_from_lv (const struct logical_volume *lv) { -struct logical_volume *pvmove_lv; +const struct logical_volume *pvmove_lv; pvmove_lv =find_pvmove_lv_in_lv (lv);
lib/metadata/raid_manip.c +3 -2
@@ -1822,7 +1822,7 @@ int lv_raid_remove_missing(struct logical_volume *lv) }/* Return 1 if a partial raid LV can be activated redundantly */ -static int _partial_raid_lv_is_redundant (struct logical_volume *lv) +static int _partial_raid_lv_is_redundant (const struct logical_volume *lv) {struct lv_segment *raid_seg =first_seg (lv);uint32_t copies;
@@ -1911,9 +1911,10 @@ static int _lv_may_be_activated_in_degraded_mode(struct logical_volume *lv, voidreturn 1 ; } -int partial_raid_lv_supports_degraded_activation (struct logical_volume *lv) +int partial_raid_lv_supports_degraded_activation (const struct logical_volume *clv) {int not_capable =0 ; +struct logical_volume * lv = (struct logical_volume *)clv;/* drop const */ if (!_lv_may_be_activated_in_degraded_mode (lv, ¬_capable) || not_capable) return_0;
lib/metadata/replicator_manip.c +3 -3
@@ -600,7 +600,7 @@ void free_cmd_vgs(struct dm_list *cmd_vgs)* Find all needed remote VGs for processing given LV. * Missing VGs are added to VG's cmd_vg list and flag cmd_missing_vgs is set. */ -int find_replicator_vgs (struct logical_volume *lv) +int find_replicator_vgs (const struct logical_volume *lv) {struct replicator_site *rsite;int ret =1 ;
@@ -632,7 +632,7 @@ int find_replicator_vgs(struct logical_volume *lv)* Read all remote VGs from lv's replicator sites. * Function is used in activation context and needs all VGs already locked. */ -int lv_read_replicator_vgs (struct logical_volume *lv) +int lv_read_replicator_vgs (const struct logical_volume *lv) {struct replicator_device *rdev;struct replicator_site *rsite;
@@ -670,7 +670,7 @@ bad:* Release all VG resources taken by lv's replicator sites. * Function is used in activation context and needs all VGs already locked. */ -void lv_release_replicator_vgs (struct logical_volume *lv) +void lv_release_replicator_vgs (const struct logical_volume *lv) {struct replicator_site *rsite;
tools/polldaemon.h +1 -1
@@ -28,7 +28,7 @@ typedef enum {struct daemon_parms ;struct poll_functions { -const char *(*get_copy_name_from_lv) (struct logical_volume *lv); +const char *(*get_copy_name_from_lv) (const struct logical_volume *lv);struct volume_group *(*get_copy_vg) (struct cmd_context *cmd,const char *name,const char *uuid);