1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +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:
Peter Rajnoha 2014-03-14 12:07:41 +01:00
parent 58e812a13f
commit ada47c164a
4 changed files with 14 additions and 9 deletions

View File

@ -1,5 +1,6 @@
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.
Add flag to lvmetad protocol to indicate the PV scanned has changed/is new.
Add man page for lvm2-activation-generator.

7
lib/cache/lvmetad.c vendored
View File

@ -749,7 +749,7 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct for
daemon_reply reply;
struct lvmcache_info *info;
struct dm_config_tree *pvmeta, *vgmeta;
const char *status, *vgid;
const char *status, *vgname, *vgid;
int64_t changed;
int result;
@ -819,12 +819,13 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct for
if (result && handler) {
status = daemon_reply_str(reply, "status", "<missing>");
vgname = daemon_reply_str(reply, "vgname", "<missing>");
vgid = daemon_reply_str(reply, "vgid", "<missing>");
changed = daemon_reply_int(reply, "changed", 0);
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"))
handler(_lvmetad_cmd, vgid, 0, changed, CHANGE_AAY);
handler(_lvmetad_cmd, vgname, vgid, 0, changed, CHANGE_AAY);
else if (!strcmp(status, "orphan"))
;
else

2
lib/cache/lvmetad.h vendored
View File

@ -23,7 +23,7 @@ struct dm_config_tree;
enum activation_change;
typedef int (*activation_handler) (struct cmd_context *cmd,
const char *vgid,
const char *vgname, const char *vgid,
int partial, int changed,
enum activation_change activate);

View File

@ -95,14 +95,13 @@ static void _pvscan_display_single(struct cmd_context *cmd,
#define REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY 100000
static int _auto_activation_handler(struct cmd_context *cmd,
const char *vgid,
const char *vgname, const char *vgid,
int partial, int changed,
activation_change_t activate)
{
unsigned int refresh_retries = REFRESH_BEFORE_AUTOACTIVATION_RETRIES;
int refresh_done = 0;
struct volume_group *vg;
int consistent = 0;
struct id vgid_raw;
int r = 0;
@ -114,8 +113,12 @@ static int _auto_activation_handler(struct cmd_context *cmd,
return_0;
/* 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)))
return 1;
vg = vg_read(cmd, vgname, (const char *)&vgid_raw, 0);
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)) {
r = 1; goto out;
@ -161,7 +164,7 @@ static int _auto_activation_handler(struct cmd_context *cmd,
r = 1;
out:
release_vg(vg);
unlock_and_release_vg(cmd, vg, vgname);
return r;
}