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

Tidy the clvmd backup code.

Move the backups inside the protection of the VG lock,
Don't backup if we have a suspended LV
Correct the vg_read() call
This commit is contained in:
Patrick Caulfield 2007-12-05 13:17:18 +00:00
parent ec0b80be6b
commit 8a0a9a93d9
3 changed files with 22 additions and 15 deletions

View File

@ -54,6 +54,7 @@ static struct dm_hash_table *lv_hash = NULL;
static pthread_mutex_t lv_hash_lock;
static pthread_mutex_t lvm_lock;
static char last_error[1024];
static int suspended = 0;
struct lv_info {
int lock_id;
@ -340,11 +341,15 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
case LCK_LV_SUSPEND:
status = do_suspend_lv(resource);
if (!status)
suspended++;
break;
case LCK_UNLOCK:
case LCK_LV_RESUME: /* if active */
status = do_resume_lv(resource);
if (!status)
suspended--;
break;
case LCK_LV_ACTIVATE:
@ -602,18 +607,21 @@ void init_lvhash()
}
/* Backups up the LVM metadata if it's changed */
void lvm_do_backup(char *vgname)
void lvm_do_backup(const char *vgname)
{
struct volume_group * vg;
int consistent;
int consistent = 0;
DEBUGLOG("Triggering backup of VG metadata for %s\n", vgname);
DEBUGLOG("Triggering backup of VG metadata for %s. suspended=%d\n", vgname, suspended);
vg = vg_read(cmd, vgname, NULL /*vgid*/, &consistent);
if (vg)
if (vg) {
if (consistent)
check_current_backup(vg);
else
}
else {
log_error("Error backing up metadata, can't find VG for group %s", vgname);
}
}
/* Called to initialise the LVM context of the daemon */

View File

@ -28,7 +28,7 @@ extern int do_check_lvm1(const char *vgname);
extern int do_refresh_cache(void);
extern int init_lvm(int using_gulm);
extern void init_lvhash(void);
extern void lvm_do_backup(char *vgname);
extern void lvm_do_backup(const char *vgname);
extern int hold_unlock(char *resource);
extern int hold_lock(char *resource, int mode, int flags);
extern void unlock_all(void);

View File

@ -378,7 +378,6 @@ int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags)
{
char lockname[PATH_MAX];
int cluster_cmd = 0;
int ret;
const char *lock_scope;
const char *lock_type = "";
@ -439,6 +438,12 @@ int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags)
return 0;
}
/* If we are unlocking a VG, then trigger remote metadata backups */
if (cluster_cmd == CLVMD_CMD_LOCK_VG && ((flags & LCK_TYPE_MASK) == LCK_UNLOCK)) {
log_very_verbose("Requesing backup of VG metadata for %s", resource);
_lock_for_cluster(CLVMD_CMD_VG_BACKUP, LCK_CLUSTER_VG, resource);
}
log_very_verbose("Locking %s %s %s %s%s%s%s (0x%x)", lock_scope, lockname,
lock_type,
flags & LCK_NONBLOCK ? "" : "B",
@ -448,13 +453,7 @@ int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags)
flags);
/* Send a message to the cluster manager */
ret = _lock_for_cluster(cluster_cmd, flags, lockname);
/* If we are unlocking a VG, then trigger remote metadata backups */
if (ret && cluster_cmd == CLVMD_CMD_LOCK_VG && ((flags & LCK_TYPE_MASK) == LCK_UNLOCK)) {
ret = _lock_for_cluster(CLVMD_CMD_VG_BACKUP, LCK_CLUSTER_VG, resource);
}
return ret;
return _lock_for_cluster(cluster_cmd, flags, lockname);
}
#ifdef CLUSTER_LOCKING_INTERNAL