mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
When we unlock a VG tell the clvmds to see if a backup of the metadata needs
to be done.
This commit is contained in:
parent
f2aae88a7c
commit
3303289137
@ -1,5 +1,6 @@
|
||||
Version 2.02.29 -
|
||||
==================================
|
||||
Make clvmd backup vg metadata on remote nodes.
|
||||
Refactor pvmove allocation code.
|
||||
Decode cluster locking state in log message.
|
||||
Change file locking state messages from debug to very verbose.
|
||||
|
@ -67,4 +67,5 @@ static const char CLVMD_SOCKNAME[] = "\0clvmd";
|
||||
#define CLVMD_CMD_REFRESH 40
|
||||
#define CLVMD_CMD_GET_CLUSTERNAME 41
|
||||
#define CLVMD_CMD_SET_DEBUG 42
|
||||
#define CLVMD_CMD_VG_BACKUP 43
|
||||
#endif
|
||||
|
@ -153,6 +153,10 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
|
||||
*retlen = strlen(*buf)+1;
|
||||
break;
|
||||
|
||||
case CLVMD_CMD_VG_BACKUP:
|
||||
lvm_do_backup(&args[2]);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Won't get here because command is validated in pre_command */
|
||||
break;
|
||||
@ -260,6 +264,7 @@ int do_pre_command(struct local_client *client)
|
||||
case CLVMD_CMD_REFRESH:
|
||||
case CLVMD_CMD_GET_CLUSTERNAME:
|
||||
case CLVMD_CMD_SET_DEBUG:
|
||||
case CLVMD_CMD_VG_BACKUP:
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -289,6 +294,7 @@ int do_post_command(struct local_client *client)
|
||||
break;
|
||||
|
||||
case CLVMD_CMD_LOCK_VG:
|
||||
case CLVMD_CMD_VG_BACKUP:
|
||||
/* Nothing to do here */
|
||||
break;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
|
||||
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
|
||||
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
@ -46,6 +46,7 @@
|
||||
#include "log.h"
|
||||
#include "activate.h"
|
||||
#include "locking.h"
|
||||
#include "archiver.h"
|
||||
#include "defaults.h"
|
||||
|
||||
static struct cmd_context *cmd = NULL;
|
||||
@ -550,7 +551,7 @@ static void lvm2_log_fn(int level, const char *file, int line,
|
||||
{
|
||||
|
||||
/* Send messages to the normal LVM2 logging system too,
|
||||
so we get debug output when it's asked for.
|
||||
so we get debug output when it's asked for.
|
||||
We need to NULL the function ptr otherwise it will just call
|
||||
back into here! */
|
||||
init_log_fn(NULL);
|
||||
@ -600,6 +601,21 @@ void init_lvhash()
|
||||
pthread_mutex_init(&lvm_lock, NULL);
|
||||
}
|
||||
|
||||
/* Backups up the LVM metadata if it's changed */
|
||||
void lvm_do_backup(char *vgname)
|
||||
{
|
||||
struct volume_group * vg;
|
||||
int consistent;
|
||||
|
||||
DEBUGLOG("Triggering backup of VG metadata for %s\n", vgname);
|
||||
|
||||
vg = vg_read(cmd, vgname, NULL /*vgid*/, &consistent);
|
||||
if (vg)
|
||||
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 */
|
||||
int init_lvm(int using_gulm)
|
||||
{
|
||||
@ -614,6 +630,9 @@ int init_lvm(int using_gulm)
|
||||
init_debug(cmd->current_settings.debug);
|
||||
init_verbose(cmd->current_settings.verbose + VERBOSE_BASE_LEVEL);
|
||||
set_activation(cmd->current_settings.activation);
|
||||
archive_enable(cmd, cmd->current_settings.archive);
|
||||
backup_enable(cmd, cmd->current_settings.backup);
|
||||
cmd->cmd_line = (char *)"clvmd";
|
||||
|
||||
/* Check lvm.conf is setup for cluster-LVM */
|
||||
check_config();
|
||||
|
@ -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 int hold_unlock(char *resource);
|
||||
extern int hold_lock(char *resource, int mode, int flags);
|
||||
extern void unlock_all(void);
|
||||
|
@ -295,7 +295,7 @@ static int _cluster_free_request(lvm_response_t * response, int num)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _lock_for_cluster(unsigned char cmd, uint32_t flags, char *name)
|
||||
static int _lock_for_cluster(unsigned char cmd, uint32_t flags, const char *name)
|
||||
{
|
||||
int status;
|
||||
int i;
|
||||
@ -378,6 +378,7 @@ 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 = "";
|
||||
|
||||
@ -447,7 +448,13 @@ int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags)
|
||||
flags);
|
||||
|
||||
/* Send a message to the cluster manager */
|
||||
return _lock_for_cluster(cluster_cmd, flags, lockname);
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef CLUSTER_LOCKING_INTERNAL
|
||||
|
Loading…
Reference in New Issue
Block a user