mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
autoactivation: use VG read lock
The activation (including the refresh) should take the VG read lock like the usual activation/refresh.
This commit is contained in:
parent
58e812a13f
commit
ada47c164a
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.106 -
|
Version 2.02.106 -
|
||||||
====================================
|
====================================
|
||||||
|
Use VG read lock during 'pvscan --cache -aay' autoactivation.
|
||||||
Issue a VG refresh before autoactivation only if the PV has changed/is new.
|
Issue a VG refresh before autoactivation only if the PV has changed/is new.
|
||||||
Add flag to lvmetad protocol to indicate the PV scanned has changed/is new.
|
Add flag to lvmetad protocol to indicate the PV scanned has changed/is new.
|
||||||
Add man page for lvm2-activation-generator.
|
Add man page for lvm2-activation-generator.
|
||||||
|
7
lib/cache/lvmetad.c
vendored
7
lib/cache/lvmetad.c
vendored
@ -749,7 +749,7 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct for
|
|||||||
daemon_reply reply;
|
daemon_reply reply;
|
||||||
struct lvmcache_info *info;
|
struct lvmcache_info *info;
|
||||||
struct dm_config_tree *pvmeta, *vgmeta;
|
struct dm_config_tree *pvmeta, *vgmeta;
|
||||||
const char *status, *vgid;
|
const char *status, *vgname, *vgid;
|
||||||
int64_t changed;
|
int64_t changed;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
@ -819,12 +819,13 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct for
|
|||||||
|
|
||||||
if (result && handler) {
|
if (result && handler) {
|
||||||
status = daemon_reply_str(reply, "status", "<missing>");
|
status = daemon_reply_str(reply, "status", "<missing>");
|
||||||
|
vgname = daemon_reply_str(reply, "vgname", "<missing>");
|
||||||
vgid = daemon_reply_str(reply, "vgid", "<missing>");
|
vgid = daemon_reply_str(reply, "vgid", "<missing>");
|
||||||
changed = daemon_reply_int(reply, "changed", 0);
|
changed = daemon_reply_int(reply, "changed", 0);
|
||||||
if (!strcmp(status, "partial"))
|
if (!strcmp(status, "partial"))
|
||||||
handler(_lvmetad_cmd, vgid, 1, changed, CHANGE_AAY);
|
handler(_lvmetad_cmd, vgname, vgid, 1, changed, CHANGE_AAY);
|
||||||
else if (!strcmp(status, "complete"))
|
else if (!strcmp(status, "complete"))
|
||||||
handler(_lvmetad_cmd, vgid, 0, changed, CHANGE_AAY);
|
handler(_lvmetad_cmd, vgname, vgid, 0, changed, CHANGE_AAY);
|
||||||
else if (!strcmp(status, "orphan"))
|
else if (!strcmp(status, "orphan"))
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
|
2
lib/cache/lvmetad.h
vendored
2
lib/cache/lvmetad.h
vendored
@ -23,7 +23,7 @@ struct dm_config_tree;
|
|||||||
enum activation_change;
|
enum activation_change;
|
||||||
|
|
||||||
typedef int (*activation_handler) (struct cmd_context *cmd,
|
typedef int (*activation_handler) (struct cmd_context *cmd,
|
||||||
const char *vgid,
|
const char *vgname, const char *vgid,
|
||||||
int partial, int changed,
|
int partial, int changed,
|
||||||
enum activation_change activate);
|
enum activation_change activate);
|
||||||
|
|
||||||
|
@ -95,14 +95,13 @@ static void _pvscan_display_single(struct cmd_context *cmd,
|
|||||||
#define REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY 100000
|
#define REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY 100000
|
||||||
|
|
||||||
static int _auto_activation_handler(struct cmd_context *cmd,
|
static int _auto_activation_handler(struct cmd_context *cmd,
|
||||||
const char *vgid,
|
const char *vgname, const char *vgid,
|
||||||
int partial, int changed,
|
int partial, int changed,
|
||||||
activation_change_t activate)
|
activation_change_t activate)
|
||||||
{
|
{
|
||||||
unsigned int refresh_retries = REFRESH_BEFORE_AUTOACTIVATION_RETRIES;
|
unsigned int refresh_retries = REFRESH_BEFORE_AUTOACTIVATION_RETRIES;
|
||||||
int refresh_done = 0;
|
int refresh_done = 0;
|
||||||
struct volume_group *vg;
|
struct volume_group *vg;
|
||||||
int consistent = 0;
|
|
||||||
struct id vgid_raw;
|
struct id vgid_raw;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
@ -114,8 +113,12 @@ static int _auto_activation_handler(struct cmd_context *cmd,
|
|||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
/* NB. This is safe because we know lvmetad is running and we won't hit disk. */
|
/* NB. This is safe because we know lvmetad is running and we won't hit disk. */
|
||||||
if (!(vg = vg_read_internal(cmd, NULL, (const char *) &vgid_raw, 0, &consistent)))
|
vg = vg_read(cmd, vgname, (const char *)&vgid_raw, 0);
|
||||||
return 1;
|
if (vg_read_error(vg)) {
|
||||||
|
log_error("Failed to read Volume Group \"%s\" (%s) during autoactivation.", vgname, vgid);
|
||||||
|
release_vg(vg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (vg_is_clustered(vg)) {
|
if (vg_is_clustered(vg)) {
|
||||||
r = 1; goto out;
|
r = 1; goto out;
|
||||||
@ -161,7 +164,7 @@ static int _auto_activation_handler(struct cmd_context *cmd,
|
|||||||
r = 1;
|
r = 1;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
release_vg(vg);
|
unlock_and_release_vg(cmd, vg, vgname);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user