mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
sigint: support breaking parsing of VG metadata
Allow breaking lvm2 'read-only' commands (not taking write-lock) while parsing VG.
This commit is contained in:
parent
bcb179efeb
commit
6f1f6471d6
@ -29,6 +29,7 @@
|
||||
#include "lib/label/label.h"
|
||||
#include "lib/cache/lvmcache.h"
|
||||
#include "libdaemon/client/config-util.h"
|
||||
#include "lib/misc/lvm-signal.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
@ -464,6 +465,8 @@ static struct volume_group *_vg_read_raw(struct cmd_context *cmd,
|
||||
struct volume_group *vg;
|
||||
|
||||
vg = _vg_read_raw_area(cmd, fid, vgname, &mdac->area, vg_fmtdata, use_previous_vg, 0, mda_is_primary(mda));
|
||||
if (sigint_caught())
|
||||
return_NULL;
|
||||
|
||||
if (!vg && use_previous_vg && !*use_previous_vg) {
|
||||
/*
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "lib/config/defaults.h"
|
||||
#include "lib/datastruct/str_list.h"
|
||||
#include "base/data-struct/radix-tree.h"
|
||||
#include "lib/misc/lvm-signal.h"
|
||||
|
||||
typedef int (*section_fn) (struct cmd_context *cmd,
|
||||
struct format_type *fmt,
|
||||
@ -1120,6 +1121,10 @@ static int _read_sections(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
for (n = n->child; n; n = n->sib) {
|
||||
if (sigint_caught()) {
|
||||
log_error("Interrupted reading of metadata section.");
|
||||
return 0;
|
||||
}
|
||||
if (!fn(cmd, (struct format_type *)fmt, fid, mem, vg, vgsummary, n, vgn))
|
||||
return_0;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "lib/locking/lvmlockd.h"
|
||||
#include "lib/notify/lvmnotify.h"
|
||||
#include "base/data-struct/radix-tree.h"
|
||||
#include "lib/misc/lvm-signal.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
@ -4839,8 +4840,19 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
log_debug_metadata("Reading VG %s metadata from %s %llu",
|
||||
vgname, dev_name(mda_dev), (unsigned long long)mda->header_start);
|
||||
|
||||
if (!vg_write_lock_held()) /* read-only */
|
||||
sigint_allow();
|
||||
|
||||
vg = mda->ops->vg_read(cmd, fid, vgname, mda, &vg_fmtdata, &use_previous_vg);
|
||||
|
||||
if (!vg_write_lock_held()) {
|
||||
sigint_restore();
|
||||
if (!vg && sigint_caught()) {
|
||||
_destroy_fid(&fid);
|
||||
return_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vg && !use_previous_vg) {
|
||||
log_warn("WARNING: Reading VG %s on %s failed.", vgname, dev_name(mda_dev));
|
||||
vg_fmtdata = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user