main - vdo: check vdo memory constrains
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ebad057579aeff0980a1b8af7eaacd56e62ed0c9 Commit: ebad057579aeff0980a1b8af7eaacd56e62ed0c9 Parent: 9f3eff002cc229d3c22dfd7db6da69dadc0bd460 Author: Zdenek Kabelac <[email protected]> AuthorDate: Fri Jul 8 23:33:29 2022 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Mon Jul 11 01:18:24 2022 +0200
vdo: check vdo memory constrains
Add function to check for avaialble memory for particular VDO configuration - to avoid unnecessary machine swapping for configs that will not fit into memory (possibly in locked section).
Formula tries to estimate RAM size machine can use also with swapping for kernel target - but still leaving some amount of usable RAM.
Estimation is based on documented RAM usage of VDO target.
If the /proc/meminfo would be theoretically unavailable, try to use 'sysinfo()' function, however this is giving only free RAM without the knowledge about how much RAM could be eventually swapped.
TODO: move _get_memory_info() into generic lvm2 API function used by other targets with non-trivial memory requirements.
--- lib/metadata/metadata-exported.h | 2 + lib/metadata/vdo_manip.c | 144 +++++++++++++++++++++++++++++++++++++++ lib/vdo/vdo.c | 8 ++- tools/lvcreate.c | 4 ++ 4 files changed, 156 insertions(+), 2 deletions(-)
lib/metadata/metadata-exported.h +2 -0
@@ -1377,6 +1377,8 @@ int fill_vdo_target_params(struct cmd_context *cmd,struct dm_vdo_target_params *vtp, uint64_t *vdo_pool_header_size, struct profile *profile); +int check_vdo_constrains (struct cmd_context *cmd,uint64_t physical_size, +uint64_t virtual_size,struct dm_vdo_target_params *vtp);/* -- metadata/vdo_manip.c */ struct logical_volume *find_pvmove_lv(struct volume_group *vg,
lib/metadata/vdo_manip.c +144 -0
153 lines not on this page · raw message
lib/vdo/vdo.c +6 -2
@@ -355,8 +355,8 @@ static int _vdo_pool_target_status_compatible(const char *type) } static int _vdo_pool_add_target_line(struct dev_manager *dm, - struct dm_pool *mem __attribute__((unused)), - struct cmd_context *cmd __attribute__((unused)), + struct dm_pool *mem, + struct cmd_context *cmd, void **target_state __attribute__((unused)), struct lv_segment *seg, const struct lv_activate_opts *laopts __attribute__((unused)),
@@ -369,6 +369,10 @@ static int _vdo_pool_add_target_line(struct dev_manager *dm,log_error (INTERNAL_ERROR "Passed segment is not VDO pool." );return 0 ; } + +if (!check_vdo_constrains (cmd, seg->lv->size,seg_lv (seg,0 )->size, &seg->vdo_params)) + return_0; +if (!(vdo_pool_name =dm_build_dm_name (mem, seg->lv->vg->name, seg->lv->name,lv_layer (seg->lv)))) return_0;
tools/lvcreate.c +4 -0
@@ -1730,6 +1730,10 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name,if (!_update_extents_params (vg, lp, lcp)) goto_out; +if (seg_is_vdo (lp) && !check_vdo_constrains (cmd, (uint64_t )lp->extents * vg->extent_size, + lcp->virtual_size, &lp->vdo_params)) + return_0; +if (seg_is_thin (lp) && !_validate_internal_thin_processing (lp)) goto_out;