1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

locking: Add missing error handling.

Add missing error logging and detection to unlock_vg and callers
of sync_local_dev_names etc.
This commit is contained in:
Alasdair G Kergon 2015-06-30 18:54:38 +01:00
parent 3489e68ef7
commit 4c629a5257
12 changed files with 68 additions and 21 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.124 -
=================================
Add missing error logging to unlock_vg and sync_local_dev_names callers.
Version 2.02.123 - 30th June 2015
=================================

View File

@ -648,8 +648,8 @@ static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
* in progress - as only those could lead to opened files
*/
if (with_open_count) {
if (locking_is_clustered())
sync_local_dev_names(cmd); /* Wait to have udev in sync */
if (locking_is_clustered() && !sync_local_dev_names(cmd)) /* Wait to have udev in sync */
return_0;
else if (fs_has_non_delete_ops())
fs_unlock(); /* For non clustered - wait if there are non-delete ops */
}

View File

@ -195,9 +195,10 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
#define unlock_vg(cmd, vol) \
do { \
if (is_real_vg(vol)) \
sync_dev_names(cmd); \
(void) lock_vol(cmd, vol, LCK_VG_UNLOCK, NULL); \
if (is_real_vg(vol) && !sync_dev_names(cmd)) \
stack; \
if (!lock_vol(cmd, vol, LCK_VG_UNLOCK, NULL)) \
stack; \
} while (0)
#define unlock_and_release_vg(cmd, vg, vol) \
do { \

View File

@ -6633,7 +6633,12 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
/* nothing to do */
return 1;
sync_local_dev_names(lv->vg->cmd); /* Wait until devices are available */
/* Wait until devices are available */
if (!sync_local_dev_names(lv->vg->cmd)) {
log_error("Failed to sync local devices before wiping LV %s.",
display_lvname(lv));
return 0;
}
if (!lv_is_active_locally(lv)) {
log_error("Volume \"%s/%s\" is not active locally.",
@ -7447,7 +7452,11 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
/* Get in sync with deactivation, before reusing LV as snapshot */
sync_local_dev_names(lv->vg->cmd);
if (!sync_local_dev_names(lv->vg->cmd)) {
log_error("Failed to sync local devices before creating snapshot using %s.",
display_lvname(lv));
goto revert_new_lv;
}
/* Create zero origin volume for spare snapshot */
if (lp->virtual_extents &&

View File

@ -3241,7 +3241,10 @@ static int _wipe_outdated_pvs(struct cmd_context *cmd, struct volume_group *vg,
return_0;
/* Refresh metadata after orphan write */
drop_cached_metadata(vg);
if (!drop_cached_metadata(vg)) {
log_error("Unable to drop cached metadata for VG %s while wiping outdated PVs.", vg->name);
return 0;
}
next_pv:
;
}

View File

@ -368,7 +368,11 @@ static int _init_mirror_log(struct cmd_context *cmd,
backup(log_lv->vg);
/* Wait for events following any deactivation before reactivating */
sync_local_dev_names(cmd);
if (!sync_local_dev_names(cmd)) {
log_error("Aborting. Failed to sync local devices before initialising mirror log %s.",
display_lvname(log_lv));
goto revert_new_lv;
}
if (!activate_lv(cmd, log_lv)) {
log_error("Aborting. Failed to activate mirror log.");
@ -484,7 +488,11 @@ static int _delete_lv(struct logical_volume *mirror_lv, struct logical_volume *l
return_0;
/* FIXME Is this superfluous now? */
sync_local_dev_names(cmd);
if (!sync_local_dev_names(cmd)) {
log_error("Failed to sync local devices when reactivating %s.",
display_lvname(lv));
return 0;
}
if (!deactivate_lv(cmd, lv))
return_0;

View File

@ -1007,10 +1007,15 @@ static int _raid_remove_images(struct logical_volume *lv,
return 0;
}
if (!sync_local_dev_names(lv->vg->cmd)) {
log_error("Failed to sync local devices after committing changes for %s.",
display_lvname(lv));
return 0;
}
/*
* Eliminate the extracted LVs
*/
sync_local_dev_names(lv->vg->cmd);
if (!dm_list_empty(&removal_list)) {
dm_list_iterate_items(lvl, &removal_list) {
if (!deactivate_lv(lv->vg->cmd, lvl->lv))

View File

@ -62,8 +62,11 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[],
*rstatus = -1;
if (sync_needed)
if (!sync_local_dev_names(cmd)) /* Flush ops and reset dm cookie */
return_0;
/* Flush ops and reset dm cookie */
if (!sync_local_dev_names(cmd)) {
log_error("Failed to sync local device names before forking.");
return 0;
}
log_verbose("Executing:%s", _verbose_args(argv, buf, sizeof(buf)));
@ -148,8 +151,11 @@ FILE *pipe_open(struct cmd_context *cmd, const char *const argv[],
char buf[PATH_MAX * 2];
if (sync_needed)
if (!sync_local_dev_names(cmd)) /* Flush ops and reset dm cookie */
return_0;
/* Flush ops and reset dm cookie */
if (!sync_local_dev_names(cmd)) {
log_error("Failed to sync local device names before forking.");
return 0;
}
if (pipe(pipefd)) {
log_sys_error("pipe", "");

View File

@ -472,7 +472,12 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
}
}
sync_local_dev_names(lv->vg->cmd); /* Wait until devices are away */
/* Wait until devices are away */
if (!sync_local_dev_names(lv->vg->cmd)) {
log_error("Failed to sync local devices after updating %s",
display_lvname(lv));
return 0;
}
/* Put metadata sub-LVs back in place */
if (!attach_metadata_devices(seg, &device_list)) {

View File

@ -319,7 +319,8 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
}
out:
sync_local_dev_names(cmd);
if (!sync_local_dev_names(cmd))
stack;
unlock_vg(cmd, VG_GLOBAL);
return ret;

View File

@ -56,7 +56,10 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm)
sigaction(SIGCHLD, &act, NULL);
if (!skip_lvm)
sync_local_dev_names(cmd); /* Flush ops and reset dm cookie */
if (!sync_local_dev_names(cmd)) { /* Flush ops and reset dm cookie */
log_error("Failed to sync local devices before forking.");
return -1;
}
if ((pid = fork()) == -1) {
log_error("fork failed: %s", strerror(errno));

View File

@ -85,7 +85,7 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
{
struct lv_list *lvl;
struct logical_volume *lv;
int count = 0, expected_count = 0;
int count = 0, expected_count = 0, r = 1;
sigint_allow();
dm_list_iterate_items(lvl, &vg->lvs) {
@ -142,14 +142,19 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
}
sigint_restore();
sync_local_dev_names(vg->cmd); /* Wait until devices are available */
/* Wait until devices are available */
if (!sync_local_dev_names(vg->cmd)) {
log_error("Failed to sync local devices for VG %s.", vg->name);
r = 0;
}
if (expected_count)
log_verbose("%s %d logical volumes in volume group %s",
is_change_activating(activate) ?
"Activated" : "Deactivated", count, vg->name);
return (expected_count != count) ? 0 : 1;
return (expected_count != count) ? 0 : r;
}
static int _vgchange_monitoring(struct cmd_context *cmd, struct volume_group *vg)