1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-11-15 00:23:51 +03:00

Use new dmeventd_lvm2_command function in dmeventd plugins.

For snapshot, prepare whole command in front into private buffer.
Add also some missing '\n' for syslog messages.
For raid and mirror only convert creation of command line string.
This should avoid any unbound growth of mempool for dm_split_names.
This commit is contained in:
Zdenek Kabelac
2011-12-22 16:37:01 +00:00
parent ed1289140e
commit 1aae627433
4 changed files with 55 additions and 71 deletions

View File

@@ -33,28 +33,16 @@ static int run_repair(const char *device)
int r;
#define CMD_SIZE 256 /* FIXME Use system restriction */
char cmd_str[CMD_SIZE];
char *vg = NULL, *lv = NULL, *layer = NULL;
if (strlen(device) > 200) /* FIXME Use real restriction */
if (!dmeventd_lvm2_command(dmeventd_lvm2_pool(), cmd_str, sizeof(cmd_str),
"lvconvert --config devices{ignore_suspended_devices=1} "
"--repair --use-policies", device))
return -1;
if (!dm_split_lvm_name(dmeventd_lvm2_pool(), device, &vg, &lv, &layer)) {
syslog(LOG_ERR, "Unable to determine VG name from %s.",
device);
return -1;
}
/* FIXME Is any sanity-checking required on %s? */
if (CMD_SIZE <= snprintf(cmd_str, CMD_SIZE, "lvconvert --config devices{ignore_suspended_devices=1} --repair --use-policies %s/%s", vg, lv)) {
/* this error should be caught above, but doesn't hurt to check again */
syslog(LOG_ERR, "Unable to form LVM command: Device name too long.");
return -1;
}
r = dmeventd_lvm2_run(cmd_str);
if (r != ECMD_PROCESSED)
syslog(LOG_INFO, "Repair of RAID LV %s/%s failed.", vg, lv);
syslog(LOG_INFO, "Repair of RAID device %s failed.", device);
return (r == ECMD_PROCESSED) ? 0 : -1;
}
@@ -162,9 +150,12 @@ int register_device(const char *device,
int minor __attribute__((unused)),
void **unused __attribute__((unused)))
{
int r = dmeventd_lvm2_init();
if (!dmeventd_lvm2_init())
return 0;
syslog(LOG_INFO, "Monitoring RAID device %s for events.", device);
return r;
return 1;
}
int unregister_device(const char *device,
@@ -176,5 +167,6 @@ int unregister_device(const char *device,
syslog(LOG_INFO, "No longer monitoring RAID device %s for events.",
device);
dmeventd_lvm2_exit();
return 1;
}