mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvm: use configure proc dir in lvm.conf
Update some code parts to use configurer /proc from lvm.conf (so i.e. our testing can use some fake values)
This commit is contained in:
parent
84b084c9b6
commit
ecb8399005
@ -459,7 +459,7 @@ int thin_pool_prepare_metadata(struct logical_volume *metadata_lv,
|
||||
uint64_t data_length)
|
||||
{
|
||||
struct cmd_context *cmd = metadata_lv->vg->cmd;
|
||||
char lv_path[PATH_MAX], md_path[64], buffer[512];
|
||||
char lv_path[PATH_MAX], md_path[PATH_MAX], buffer[512];
|
||||
const char *argv[DEFAULT_MAX_EXEC_ARGS + 7] = {
|
||||
find_config_tree_str_allow_empty(cmd, global_thin_restore_executable_CFG, NULL)
|
||||
};
|
||||
@ -490,7 +490,8 @@ int thin_pool_prepare_metadata(struct logical_volume *metadata_lv,
|
||||
}
|
||||
|
||||
/* Build path for 'thin_restore' app with this 'hidden/deleted' tmpfile */
|
||||
(void) dm_snprintf(md_path, sizeof(md_path), "/proc/%u/fd/%u", getpid(), fileno(f));
|
||||
(void) dm_snprintf(md_path, sizeof(md_path), "%s/%u/fd/%u",
|
||||
cmd->proc_dir, getpid(), fileno(f));
|
||||
|
||||
argv[++args] = "-i";
|
||||
argv[++args] = md_path;
|
||||
|
@ -653,7 +653,7 @@ static int _compare_mem_table_s(const void *a, const void *b){
|
||||
return strcmp(((const mem_table_t*)a)->name, ((const mem_table_t*)b)->name);
|
||||
}
|
||||
|
||||
static int _get_memory_info(uint64_t *total_mb, uint64_t *available_mb)
|
||||
static int _get_memory_info(struct cmd_context *cmd, uint64_t *total_mb, uint64_t *available_mb)
|
||||
{
|
||||
uint64_t anon_pages = 0, mem_available = 0, mem_free = 0, mem_total = 0, shmem = 0, swap_free = 0;
|
||||
uint64_t can_swap;
|
||||
@ -667,11 +667,14 @@ static int _get_memory_info(uint64_t *total_mb, uint64_t *available_mb)
|
||||
};
|
||||
|
||||
char line[128], namebuf[32], *e, *tail;
|
||||
char proc_meminfo[PATH_MAX];
|
||||
FILE *fp;
|
||||
mem_table_t findme = { namebuf, NULL };
|
||||
mem_table_t *found;
|
||||
|
||||
if (!(fp = fopen("/proc/meminfo", "r")))
|
||||
if ((dm_snprintf(proc_meminfo, sizeof(proc_meminfo),
|
||||
"%s/meminfo", cmd->proc_dir) < 0) ||
|
||||
!(fp = fopen(proc_meminfo, "r")))
|
||||
return _get_sysinfo_memory(total_mb, available_mb);
|
||||
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
@ -760,7 +763,7 @@ int check_vdo_constrains(struct cmd_context *cmd, const struct vdo_pool_size_con
|
||||
// total required memory for VDO target
|
||||
req_mb = 38 + cfg->index_memory_size_mb + virt_mb + phy_mb + cache_mb;
|
||||
|
||||
_get_memory_info(&total_mb, &available_mb);
|
||||
_get_memory_info(cmd, &total_mb, &available_mb);
|
||||
|
||||
has_cnt = cnt = (phy_mb ? 1 : 0) +
|
||||
(virt_mb ? 1 : 0) +
|
||||
|
@ -6139,8 +6139,18 @@ static int _check_writecache_memory(struct cmd_context *cmd, struct logical_volu
|
||||
uint64_t need_mem_gb;
|
||||
uint64_t proc_mem_gb;
|
||||
unsigned long long proc_mem_kb = 0;
|
||||
char proc_meminfo[PATH_MAX];
|
||||
|
||||
if (!(fp = fopen("/proc/meminfo", "r")))
|
||||
if (*cmd->proc_dir)
|
||||
goto skip_proc;
|
||||
|
||||
if (dm_snprintf(proc_meminfo, sizeof(proc_meminfo),
|
||||
"%s/meminfo", cmd->proc_dir) < 0) {
|
||||
stack;
|
||||
goto skip_proc;
|
||||
}
|
||||
|
||||
if (!(fp = fopen(proc_meminfo, "r")))
|
||||
goto skip_proc;
|
||||
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
|
Loading…
Reference in New Issue
Block a user