diff options
author | Jonathan Earl Brassow <jbrassow@redhat.com> | 2011-12-06 19:30:15 +0000 |
---|---|---|
committer | Jonathan Earl Brassow <jbrassow@redhat.com> | 2011-12-06 19:30:15 +0000 |
commit | d0981401778dece2e3bc020e58da7bfc1db67f43 (patch) | |
tree | 7b0ed76053315feba1a1d6a5b72ae0be97339801 /daemons/dmeventd/plugins | |
parent | 707c49ab77c785aef7f36de2b0f31d1e43e68e9f (diff) | |
download | lvm2-d0981401778dece2e3bc020e58da7bfc1db67f43.tar.gz lvm2-d0981401778dece2e3bc020e58da7bfc1db67f43.tar.xz lvm2-d0981401778dece2e3bc020e58da7bfc1db67f43.zip |
Add policy based automated repair of RAID logical volumes
The RAID plug-in for dmeventd now calls 'lvconvert --repair' to address failures
of devices in a RAID logical volume. The action taken can be either to "warn"
or "allocate" a new device from any spares that may be available in the
volume group. The action is designated by setting 'raid_fault_policy' in
lvm.conf - the default being "warn".
Diffstat (limited to 'daemons/dmeventd/plugins')
-rw-r--r-- | daemons/dmeventd/plugins/raid/dmeventd_raid.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c index 71820c29..dd5e7eb0 100644 --- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c +++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c @@ -24,6 +24,41 @@ /* FIXME Replace most syslogs with log_error() style messages and add complete context. */ /* FIXME Reformat to 80 char lines. */ +/* + * run_repair is a close copy to + * plugins/mirror/dmeventd_mirror.c:_remove_failed_devices() + */ +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 */ + 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); + + return (r == ECMD_PROCESSED) ? 0 : -1; +} + static int _process_raid_event(char *params, const char *device) { int i, n, failure = 0; @@ -71,7 +106,7 @@ static int _process_raid_event(char *params, const char *device) break; } if (failure) - return 0; /* Don't bother parsing rest of status */ + return run_repair(device); } p = strstr(resync_ratio, "/"); |