1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

More dmeventd mirror cleanups.

This commit is contained in:
Alasdair Kergon 2006-01-27 20:48:19 +00:00
parent 17840c21c3
commit f0b4c52d4a
2 changed files with 30 additions and 54 deletions

View File

@ -61,12 +61,6 @@ static int _get_mirror_event(char *params)
log_status_str = args[4 + num_devs + log_argc]; log_status_str = args[4 + num_devs + log_argc];
sync_str = args[1 + num_devs]; sync_str = args[1 + num_devs];
syslog(LOG_DEBUG, " num_devs = %d", num_devs);
syslog(LOG_DEBUG, " dev_status_str: %s", dev_status_str);
syslog(LOG_DEBUG, " log_argc = %d", log_argc);
syslog(LOG_DEBUG, " log_status_str: %s", log_status_str);
syslog(LOG_DEBUG, " sync_str: %s", sync_str);
/* Check for bad mirror devices */ /* Check for bad mirror devices */
for (i = 0; i < num_devs; i++) { for (i = 0; i < num_devs; i++) {
if (dev_status_str[i] == 'D') { if (dev_status_str[i] == 'D') {
@ -87,23 +81,27 @@ static int _get_mirror_event(char *params)
goto out; goto out;
} }
for(p = strstr(sync_str, "/"), i = (p - sync_str) - 1; p = strstr(sync_str, "/");
p && (i >= 0); if (p) {
i--) { p[0] = '\0';
syslog(LOG_DEBUG, "p[%d] (%c) ?= sync_str[%d] (%c)", if (strcmp(sync_str, p+1))
i+1, p[i+1], i, sync_str[i]);
if(p[i+1] != sync_str[i]){
rtn = ME_IGNORE; rtn = ME_IGNORE;
break; p[0] = '/';
} } else {
/*
* How the hell did we get this?
* Might mean all our parameters are screwed.
*/
syslog(LOG_ERR, "Unable to parse sync string.");
rtn = ME_IGNORE;
} }
out: out:
return rtn; return rtn;
} }
static void _temporary_log_fn(int level, const char *file, int line, const char *format) static void _temporary_log_fn(int level, const char *file, int line, const char *format)
{ {
return;
syslog(LOG_DEBUG, "%s", format); syslog(LOG_DEBUG, "%s", format);
} }
@ -115,7 +113,6 @@ static int _remove_failed_devices(const char *device)
char cmd_str[cmd_size]; char cmd_str[cmd_size];
char *vg = NULL, *lv = NULL, *layer = NULL; char *vg = NULL, *lv = NULL, *layer = NULL;
// syslog(LOG_DEBUG, "Entering remove_failed_device\n");
if (strlen(device) > 200) if (strlen(device) > 200)
return -ENAMETOOLONG; return -ENAMETOOLONG;
@ -126,7 +123,6 @@ static int _remove_failed_devices(const char *device)
} }
/* FIXME Is any sanity-checking required on %s? */ /* FIXME Is any sanity-checking required on %s? */
syslog(LOG_INFO, "vgreduce --removemissing %s\n", vg);
if (cmd_size <= snprintf(cmd_str, cmd_size, "vgreduce --removemissing %s", vg)) { if (cmd_size <= snprintf(cmd_str, cmd_size, "vgreduce --removemissing %s", vg)) {
/* this error should be caught above, but doesn't hurt to check again */ /* 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"); syslog(LOG_ERR, "Unable to form LVM command: Device name too long");
@ -139,16 +135,6 @@ static int _remove_failed_devices(const char *device)
lvm2_log_level(handle, 1); lvm2_log_level(handle, 1);
r = lvm2_run(handle, cmd_str); r = lvm2_run(handle, cmd_str);
syslog(LOG_INFO, "lvconvert -m0 %s/%s\n", vg, lv);
if (cmd_size <= snprintf(cmd_str, cmd_size, "lvconvert -m0 %s/%s\n", 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 -ENAMETOOLONG;
}
r = lvm2_run(handle, cmd_str);
// syslog(LOG_DEBUG, "Exiting remove_failed_device\n");
dm_pool_empty(mem_pool); /* FIXME: not safe with multiple threads */ dm_pool_empty(mem_pool); /* FIXME: not safe with multiple threads */
return (r == 1)? 0: -1; return (r == 1)? 0: -1;
} }
@ -201,9 +187,11 @@ void process_event(const char *device, enum dm_event_type event)
if (_remove_failed_devices(device)) if (_remove_failed_devices(device))
syslog(LOG_ERR, "Failed to remove faulty devices in %s\n", syslog(LOG_ERR, "Failed to remove faulty devices in %s\n",
device); device);
/* Should check before warning user that device is now linear
else else
syslog(LOG_NOTICE, "%s is now a linear device.\n", syslog(LOG_NOTICE, "%s is now a linear device.\n",
device); device);
*/
break; break;
case ME_IGNORE: case ME_IGNORE:
break; break;

View File

@ -61,12 +61,6 @@ static int _get_mirror_event(char *params)
log_status_str = args[4 + num_devs + log_argc]; log_status_str = args[4 + num_devs + log_argc];
sync_str = args[1 + num_devs]; sync_str = args[1 + num_devs];
syslog(LOG_DEBUG, " num_devs = %d", num_devs);
syslog(LOG_DEBUG, " dev_status_str: %s", dev_status_str);
syslog(LOG_DEBUG, " log_argc = %d", log_argc);
syslog(LOG_DEBUG, " log_status_str: %s", log_status_str);
syslog(LOG_DEBUG, " sync_str: %s", sync_str);
/* Check for bad mirror devices */ /* Check for bad mirror devices */
for (i = 0; i < num_devs; i++) { for (i = 0; i < num_devs; i++) {
if (dev_status_str[i] == 'D') { if (dev_status_str[i] == 'D') {
@ -87,23 +81,27 @@ static int _get_mirror_event(char *params)
goto out; goto out;
} }
for(p = strstr(sync_str, "/"), i = (p - sync_str) - 1; p = strstr(sync_str, "/");
p && (i >= 0); if (p) {
i--) { p[0] = '\0';
syslog(LOG_DEBUG, "p[%d] (%c) ?= sync_str[%d] (%c)", if (strcmp(sync_str, p+1))
i+1, p[i+1], i, sync_str[i]);
if(p[i+1] != sync_str[i]){
rtn = ME_IGNORE; rtn = ME_IGNORE;
break; p[0] = '/';
} } else {
/*
* How the hell did we get this?
* Might mean all our parameters are screwed.
*/
syslog(LOG_ERR, "Unable to parse sync string.");
rtn = ME_IGNORE;
} }
out: out:
return rtn; return rtn;
} }
static void _temporary_log_fn(int level, const char *file, int line, const char *format) static void _temporary_log_fn(int level, const char *file, int line, const char *format)
{ {
return;
syslog(LOG_DEBUG, "%s", format); syslog(LOG_DEBUG, "%s", format);
} }
@ -115,7 +113,6 @@ static int _remove_failed_devices(const char *device)
char cmd_str[cmd_size]; char cmd_str[cmd_size];
char *vg = NULL, *lv = NULL, *layer = NULL; char *vg = NULL, *lv = NULL, *layer = NULL;
// syslog(LOG_DEBUG, "Entering remove_failed_device\n");
if (strlen(device) > 200) if (strlen(device) > 200)
return -ENAMETOOLONG; return -ENAMETOOLONG;
@ -126,7 +123,6 @@ static int _remove_failed_devices(const char *device)
} }
/* FIXME Is any sanity-checking required on %s? */ /* FIXME Is any sanity-checking required on %s? */
syslog(LOG_INFO, "vgreduce --removemissing %s\n", vg);
if (cmd_size <= snprintf(cmd_str, cmd_size, "vgreduce --removemissing %s", vg)) { if (cmd_size <= snprintf(cmd_str, cmd_size, "vgreduce --removemissing %s", vg)) {
/* this error should be caught above, but doesn't hurt to check again */ /* 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"); syslog(LOG_ERR, "Unable to form LVM command: Device name too long");
@ -139,16 +135,6 @@ static int _remove_failed_devices(const char *device)
lvm2_log_level(handle, 1); lvm2_log_level(handle, 1);
r = lvm2_run(handle, cmd_str); r = lvm2_run(handle, cmd_str);
syslog(LOG_INFO, "lvconvert -m0 %s/%s\n", vg, lv);
if (cmd_size <= snprintf(cmd_str, cmd_size, "lvconvert -m0 %s/%s\n", 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 -ENAMETOOLONG;
}
r = lvm2_run(handle, cmd_str);
// syslog(LOG_DEBUG, "Exiting remove_failed_device\n");
dm_pool_empty(mem_pool); /* FIXME: not safe with multiple threads */ dm_pool_empty(mem_pool); /* FIXME: not safe with multiple threads */
return (r == 1)? 0: -1; return (r == 1)? 0: -1;
} }
@ -201,9 +187,11 @@ void process_event(const char *device, enum dm_event_type event)
if (_remove_failed_devices(device)) if (_remove_failed_devices(device))
syslog(LOG_ERR, "Failed to remove faulty devices in %s\n", syslog(LOG_ERR, "Failed to remove faulty devices in %s\n",
device); device);
/* Should check before warning user that device is now linear
else else
syslog(LOG_NOTICE, "%s is now a linear device.\n", syslog(LOG_NOTICE, "%s is now a linear device.\n",
device); device);
*/
break; break;
case ME_IGNORE: case ME_IGNORE:
break; break;