mirror of
git://sourceware.org/git/lvm2.git
synced 2025-09-27 05:44:18 +03:00
Compare commits
14 Commits
old-v1_02_
...
v1_02_04
Author | SHA1 | Date | |
---|---|---|---|
|
ed43dc842b | ||
|
49d4db6cd2 | ||
|
ea80ab2cae | ||
|
382e808b8d | ||
|
846befa7e0 | ||
|
74dd29f843 | ||
|
b0473bffcb | ||
|
24dd9ab1a7 | ||
|
49d3037e87 | ||
|
37ad2bd4e8 | ||
|
7d7b332b02 | ||
|
ac033b8612 | ||
|
a7b98dfe25 | ||
|
7fb7c86c46 |
@@ -1,5 +1,9 @@
|
||||
Version 2.02.02 -
|
||||
====================================
|
||||
Version 2.02.03 -
|
||||
===================================
|
||||
Fix dmeventd build.
|
||||
|
||||
Version 2.02.02 - 7th February 2006
|
||||
===================================
|
||||
Add %.so: %.a make template rule.
|
||||
Switchover library building to use LIB_SUFFIX.
|
||||
Only do lockfs filesystem sync when suspending snapshots.
|
||||
|
@@ -1,4 +1,8 @@
|
||||
Version 1.02.03 -
|
||||
Version 1.02.04 -
|
||||
============================
|
||||
Add setgeometry.
|
||||
|
||||
Version 1.02.03 - 7 Feb 2006
|
||||
============================
|
||||
Add exported functions to set uid, gid and mode.
|
||||
Rename _log to dm_log and export.
|
||||
|
@@ -53,10 +53,19 @@ endif
|
||||
TARGETS = \
|
||||
clvmd
|
||||
|
||||
include $(top_srcdir)/make.tmpl
|
||||
LVMLIBS = -llvm
|
||||
|
||||
ifeq ("@DMEVENTD@", "yes")
|
||||
LVMLIBS += -ldevmapper-event -lpthread
|
||||
endif
|
||||
|
||||
ifeq ("@DEVMAPPER@", "yes")
|
||||
LVMLIBS += -ldevmapper
|
||||
endif
|
||||
|
||||
CFLAGS += -D_REENTRANT -fno-strict-aliasing
|
||||
LIBS += -ldevmapper -llvm -lpthread
|
||||
|
||||
include $(top_srcdir)/make.tmpl
|
||||
|
||||
INSTALL_TARGETS = \
|
||||
install_clvmd
|
||||
|
@@ -311,13 +311,23 @@ static int storepid(int lf)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* FIXME This is unreliable: should use DM_DEVICE_INFO ioctl instead. */
|
||||
/* Check, if a device exists. */
|
||||
static int device_exists(char *device)
|
||||
{
|
||||
struct stat st_buf;
|
||||
char path2[PATH_MAX];
|
||||
|
||||
return !stat(device, &st_buf) && S_ISBLK(st_buf.st_mode);
|
||||
if (!device)
|
||||
return 0;
|
||||
|
||||
if (device[0] == '/') /* absolute path */
|
||||
return !stat(device, &st_buf) && S_ISBLK(st_buf.st_mode);
|
||||
|
||||
if (PATH_MAX <= snprintf(path2, PATH_MAX, "%s/%s", dm_dir(), device))
|
||||
return 0;
|
||||
|
||||
return !stat(path2, &st_buf) && S_ISBLK(st_buf.st_mode);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -702,41 +712,27 @@ static int lookup_symbols(void *dl, struct dso_data *data)
|
||||
"unregister_device");
|
||||
}
|
||||
|
||||
/* Create a DSO file name based on its name. */
|
||||
static char *create_dso_file_name(char *dso_name)
|
||||
{
|
||||
char *ret;
|
||||
static char prefix[] = "libdevmapper-event-";
|
||||
static char suffix[] = ".so";
|
||||
|
||||
if ((ret = dm_malloc(strlen(prefix) +
|
||||
strlen(dso_name) +
|
||||
strlen(suffix) + 1)))
|
||||
sprintf(ret, "%s%s%s", prefix, dso_name, suffix);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Load an application specific DSO. */
|
||||
static struct dso_data *load_dso(struct message_data *data)
|
||||
{
|
||||
void *dl;
|
||||
struct dso_data *ret = NULL;
|
||||
char *dso_file;
|
||||
|
||||
if (!(dso_file = create_dso_file_name(data->dso_name)))
|
||||
return NULL;
|
||||
|
||||
if (!(dl = dlopen(dso_file, RTLD_NOW))){
|
||||
if (!(dl = dlopen(data->dso_name, RTLD_NOW))){
|
||||
log_error("%s\n", dlerror());
|
||||
goto free_dso_file;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(ret = alloc_dso_data(data)))
|
||||
goto close;
|
||||
if (!(ret = alloc_dso_data(data))) {
|
||||
dlclose(dl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(lookup_symbols(dl, ret)))
|
||||
goto free_all;
|
||||
if (!(lookup_symbols(dl, ret))) {
|
||||
free_dso_data(ret);
|
||||
dlclose(dl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Keep handle to close the library once
|
||||
@@ -749,17 +745,6 @@ static struct dso_data *load_dso(struct message_data *data)
|
||||
LINK_DSO(ret);
|
||||
unlock_mutex();
|
||||
|
||||
goto free_dso_file;
|
||||
|
||||
free_all:
|
||||
free_dso_data(ret);
|
||||
|
||||
close:
|
||||
dlclose(dl);
|
||||
|
||||
free_dso_file:
|
||||
dm_free(dso_file);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@@ -16,8 +16,8 @@ srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
CFLAGS += -I${top_srcdir}/tools -I${top_srcdir}/include
|
||||
CLDFLAGS += -ldevmapper -llvm2cmd
|
||||
INCLUDES += -I${top_srcdir}/tools
|
||||
CLDFLAGS += -L${top_srcdir}/tools -ldevmapper -llvm2cmd
|
||||
|
||||
SOURCES = dmeventd_mirror.c
|
||||
|
||||
@@ -32,5 +32,5 @@ include $(top_srcdir)/make.tmpl
|
||||
install: libdevmapper-event-lvm2mirror.$(LIB_SUFFIX)
|
||||
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
|
||||
$(libdir)/$<.$(LIB_VERSION)
|
||||
$(LN_S) -f $(libdir)/$<.$(LIB_VERSION) $(libdir)/$<
|
||||
$(LN_S) -f $<.$(LIB_VERSION) $(libdir)/$<
|
||||
|
||||
|
@@ -147,8 +147,6 @@ void process_event(const char *device, enum dm_event_type event)
|
||||
char *target_type = NULL;
|
||||
char *params;
|
||||
|
||||
syslog(LOG_NOTICE, "An event occurred on %s\n", device);
|
||||
|
||||
/* FIXME Move inside libdevmapper */
|
||||
if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) {
|
||||
syslog(LOG_ERR, "Unable to create dm_task.\n");
|
||||
|
@@ -16,8 +16,8 @@ srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
CFLAGS += -I${top_srcdir}/tools -I${top_srcdir}/include
|
||||
CLDFLAGS += -ldevmapper -llvm2cmd
|
||||
INCLUDES += -I${top_srcdir}/tools
|
||||
CLDFLAGS += -L${top_srcdir}/tools -ldevmapper -llvm2cmd
|
||||
|
||||
SOURCES = dmeventd_mirror.c
|
||||
|
||||
@@ -32,5 +32,5 @@ include $(top_srcdir)/make.tmpl
|
||||
install: libdevmapper-event-lvm2mirror.$(LIB_SUFFIX)
|
||||
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
|
||||
$(libdir)/$<.$(LIB_VERSION)
|
||||
$(LN_S) -f $(libdir)/$<.$(LIB_VERSION) $(libdir)/$<
|
||||
$(LN_S) -f $<.$(LIB_VERSION) $(libdir)/$<
|
||||
|
||||
|
@@ -147,8 +147,6 @@ void process_event(const char *device, enum dm_event_type event)
|
||||
char *target_type = NULL;
|
||||
char *params;
|
||||
|
||||
syslog(LOG_NOTICE, "An event occurred on %s\n", device);
|
||||
|
||||
/* FIXME Move inside libdevmapper */
|
||||
if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) {
|
||||
syslog(LOG_ERR, "Unable to create dm_task.\n");
|
||||
|
@@ -616,11 +616,11 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
|
||||
return 1;
|
||||
|
||||
if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
|
||||
return 0;
|
||||
return_0;
|
||||
|
||||
/* Use precommitted metadata if present */
|
||||
if (!(lv_pre = lv_from_lvid(cmd, lvid_s, 1)))
|
||||
return 0;
|
||||
return_0;
|
||||
|
||||
if (test_mode()) {
|
||||
_skip("Suspending '%s'.", lv->name);
|
||||
@@ -645,7 +645,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
|
||||
stack;
|
||||
|
||||
memlock_inc();
|
||||
if (!_lv_suspend_lv(lv_pre)) {
|
||||
if (!_lv_suspend_lv(lv)) {
|
||||
memlock_dec();
|
||||
fs_unlock();
|
||||
return 0;
|
||||
|
@@ -108,3 +108,4 @@ dm_hash_get_data
|
||||
dm_hash_get_first
|
||||
dm_hash_get_next
|
||||
dm_set_selinux_context
|
||||
dm_task_set_geometry
|
||||
|
@@ -116,6 +116,7 @@ static struct cmd_data _cmd_data_v1[] = {
|
||||
{ "mknodes", 0, {4, 0, 0} },
|
||||
{ "versions", 0, {4, 1, 0} },
|
||||
{ "message", 0, {4, 2, 0} },
|
||||
{ "setgeometry",0, {4, 6, 0} },
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
|
@@ -103,6 +103,9 @@ static struct cmd_data _cmd_data_v4[] = {
|
||||
#ifdef DM_TARGET_MSG
|
||||
{"message", DM_TARGET_MSG, {4, 2, 0}},
|
||||
#endif
|
||||
#ifdef DM_DEV_SET_GEOMETRY
|
||||
{"setgeometry", DM_DEV_SET_GEOMETRY, {4, 6, 0}},
|
||||
#endif
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
@@ -1001,6 +1004,23 @@ int dm_task_set_sector(struct dm_task *dmt, uint64_t sector)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dm_task_set_geometry(struct dm_task *dmt, const char *cylinders, const char *heads, const char *sectors, const char *start)
|
||||
{
|
||||
size_t len = strlen(cylinders) + 1 + strlen(heads) + 1 + strlen(sectors) + 1 + strlen(start) + 1;
|
||||
|
||||
if (!(dmt->geometry = dm_malloc(len))) {
|
||||
log_error("dm_task_set_geometry: dm_malloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sprintf(dmt->geometry, "%s %s %s %s", cylinders, heads, sectors, start) < 0) {
|
||||
log_error("dm_task_set_geometry: sprintf failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dm_task_no_open_count(struct dm_task *dmt)
|
||||
{
|
||||
dmt->no_open_count = 1;
|
||||
@@ -1123,11 +1143,26 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (count && dmt->geometry) {
|
||||
log_error("targets and geometry are incompatible");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dmt->newname && (dmt->sector || dmt->message)) {
|
||||
log_error("message and newname are incompatible");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dmt->newname && dmt->geometry) {
|
||||
log_error("geometry and newname are incompatible");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dmt->geometry && (dmt->sector || dmt->message)) {
|
||||
log_error("geometry and message are incompatible");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dmt->sector && !dmt->message) {
|
||||
log_error("message is required with sector");
|
||||
return NULL;
|
||||
@@ -1139,6 +1174,9 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
||||
if (dmt->message)
|
||||
len += sizeof(struct dm_target_msg) + strlen(dmt->message) + 1;
|
||||
|
||||
if (dmt->geometry)
|
||||
len += strlen(dmt->geometry) + 1;
|
||||
|
||||
/*
|
||||
* Give len a minimum size so that we have space to store
|
||||
* dependencies or status information.
|
||||
@@ -1205,6 +1243,9 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
||||
strcpy(tmsg->message, dmt->message);
|
||||
}
|
||||
|
||||
if (dmt->geometry)
|
||||
strcpy(b, dmt->geometry);
|
||||
|
||||
return dmi;
|
||||
|
||||
bad:
|
||||
|
@@ -50,6 +50,7 @@ struct dm_task {
|
||||
} dmi;
|
||||
char *newname;
|
||||
char *message;
|
||||
char *geometry;
|
||||
uint64_t sector;
|
||||
int no_open_count;
|
||||
int skip_lockfs;
|
||||
|
@@ -80,7 +80,9 @@ enum {
|
||||
|
||||
DM_DEVICE_LIST_VERSIONS,
|
||||
|
||||
DM_DEVICE_TARGET_MSG
|
||||
DM_DEVICE_TARGET_MSG,
|
||||
|
||||
DM_DEVICE_SET_GEOMETRY
|
||||
};
|
||||
|
||||
struct dm_task;
|
||||
@@ -145,6 +147,7 @@ int dm_task_set_uid(struct dm_task *dmt, uid_t uid);
|
||||
int dm_task_set_gid(struct dm_task *dmt, gid_t gid);
|
||||
int dm_task_set_mode(struct dm_task *dmt, mode_t mode);
|
||||
int dm_task_set_event_nr(struct dm_task *dmt, uint32_t event_nr);
|
||||
int dm_task_set_geometry(struct dm_task *dmt, const char *cylinders, const char *heads, const char *sectors, const char *start);
|
||||
int dm_task_set_message(struct dm_task *dmt, const char *message);
|
||||
int dm_task_set_sector(struct dm_task *dmt, uint64_t sector);
|
||||
int dm_task_no_open_count(struct dm_task *dmt);
|
||||
|
@@ -510,3 +510,4 @@ out:
|
||||
dm_task_destroy(dmt);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@@ -86,6 +86,7 @@ struct load_segment {
|
||||
unsigned clustered; /* Mirror */
|
||||
unsigned mirror_area_count; /* Mirror */
|
||||
uint32_t flags; /* Mirror log */
|
||||
char *uuid; /* Clustered mirror log */
|
||||
};
|
||||
|
||||
/* Per-device properties */
|
||||
@@ -1238,16 +1239,19 @@ static int _emit_segment_line(struct dm_task *dmt, struct load_segment *seg, uin
|
||||
case SEG_LINEAR:
|
||||
break;
|
||||
case SEG_MIRRORED:
|
||||
log_parm_count = 1; /* Region size */
|
||||
log_parm_count += hweight32(seg->flags); /* [no]sync, block_on_error etc. */
|
||||
|
||||
if (seg->clustered) {
|
||||
if ((tw = _dm_snprintf(params + pos, paramsize - pos, "clustered ")) < 0) {
|
||||
if (seg->uuid)
|
||||
log_parm_count++; /* uuid */
|
||||
if ((tw = _dm_snprintf(params + pos, paramsize - pos, "clustered_")) < 0) {
|
||||
stack; /* Out of space */
|
||||
return -1;
|
||||
}
|
||||
pos += tw;
|
||||
}
|
||||
|
||||
log_parm_count = hweight32(seg->flags) + 1;
|
||||
|
||||
if (!seg->log)
|
||||
logtype = "core";
|
||||
else {
|
||||
@@ -1277,6 +1281,14 @@ static int _emit_segment_line(struct dm_task *dmt, struct load_segment *seg, uin
|
||||
}
|
||||
pos += tw;
|
||||
|
||||
if (seg->clustered && seg->uuid) {
|
||||
if ((tw = _dm_snprintf(params + pos, paramsize - pos, "%s ", seg->uuid)) < 0) {
|
||||
stack; /* Out of space */
|
||||
return -1;
|
||||
}
|
||||
pos += tw;
|
||||
}
|
||||
|
||||
if ((seg->flags & DM_NOSYNC)) {
|
||||
if ((tw = _dm_snprintf(params + pos, paramsize - pos, "nosync ")) < 0) {
|
||||
stack; /* Out of space */
|
||||
@@ -1693,8 +1705,14 @@ int dm_tree_node_add_mirror_target_log(struct dm_tree_node *node,
|
||||
log_error("Couldn't find mirror log uuid %s.", log_uuid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_link_tree_nodes(node, log_node))
|
||||
return_0;
|
||||
|
||||
if (!(seg->uuid = dm_pool_strdup(node->dtree->mem, log_uuid))) {
|
||||
log_error("log uuid pool_strdup failed");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
seg->log = log_node;
|
||||
|
@@ -508,6 +508,39 @@ static int _message(int argc, char **argv, void *data)
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _setgeometry(int argc, char **argv, void *data)
|
||||
{
|
||||
int r = 0;
|
||||
struct dm_task *dmt;
|
||||
|
||||
if (!(dmt = dm_task_create(DM_DEVICE_SET_GEOMETRY)))
|
||||
return 0;
|
||||
|
||||
if (_switches[UUID_ARG] || _switches[MAJOR_ARG]) {
|
||||
if (!_set_task_device(dmt, NULL, 0))
|
||||
goto out;
|
||||
} else {
|
||||
if (!_set_task_device(dmt, argv[1], 0))
|
||||
goto out;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (!dm_task_set_geometry(dmt, argv[1], argv[2], argv[3], argv[4]))
|
||||
goto out;
|
||||
|
||||
/* run the task */
|
||||
if (!dm_task_run(dmt))
|
||||
goto out;
|
||||
|
||||
r = 1;
|
||||
|
||||
out:
|
||||
dm_task_destroy(dmt);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _version(int argc, char **argv, void *data)
|
||||
{
|
||||
char version[80];
|
||||
@@ -1326,6 +1359,7 @@ static struct command _commands[] = {
|
||||
{"mknodes", "[<device>]", 0, 1, _mknodes},
|
||||
{"targets", "", 0, 0, _targets},
|
||||
{"version", "", 0, 0, _version},
|
||||
{"setgeometry", "<device> <cyl> <head> <sect> <start>", 5, 5, _setgeometry},
|
||||
{NULL, NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
|
@@ -230,11 +230,14 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
|
||||
|
||||
if (!test_mode()) {
|
||||
/* Suspend lvs_changed */
|
||||
init_partial(1);
|
||||
if (!suspend_lvs(cmd, &lvs_changed)) {
|
||||
stack;
|
||||
init_partial(0);
|
||||
vg_revert(vg);
|
||||
return 0;
|
||||
}
|
||||
init_partial(0);
|
||||
}
|
||||
|
||||
if (!vg_commit(vg)) {
|
||||
|
Reference in New Issue
Block a user