summaryrefslogtreecommitdiffstats
path: root/daemons/clvmd/lvm-functions.c
diff options
context:
space:
mode:
authorPatrick Caulfield <pcaulfie@redhat.com>2007-12-05 13:17:18 +0000
committerPatrick Caulfield <pcaulfie@redhat.com>2007-12-05 13:17:18 +0000
commit8a0a9a93d9de3f01493756cdd79e1e3ece407f29 (patch)
tree717d7db270fa999a82b21fff3b28a78ff23c4022 /daemons/clvmd/lvm-functions.c
parentec0b80be6b69bc743fe09c76c85c93ada16e5efa (diff)
downloadlvm2-8a0a9a93d9de3f01493756cdd79e1e3ece407f29.tar.gz
lvm2-8a0a9a93d9de3f01493756cdd79e1e3ece407f29.tar.xz
lvm2-8a0a9a93d9de3f01493756cdd79e1e3ece407f29.zip
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
Diffstat (limited to 'daemons/clvmd/lvm-functions.c')
-rw-r--r--daemons/clvmd/lvm-functions.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c
index ced1f47b..0428e919 100644
--- a/daemons/clvmd/lvm-functions.c
+++ b/daemons/clvmd/lvm-functions.c
@@ -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)
- check_current_backup(vg);
- else
+ if (vg) {
+ if (consistent)
+ check_current_backup(vg);
+ }
+ else {
log_error("Error backing up metadata, can't find VG for group %s", vgname);
+ }
}
/* Called to initialise the LVM context of the daemon */