master - pre-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=063b353b286652...
Commit: 063b353b286652d5ccc692cf636824b9b3270fe9
Parent: fedf15ffb0237d0bc44c13b0ce62122a2aed64ec
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sat Dec 5 15:33:19 2015 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sat Dec 5 15:33:19 2015 +0000
pre-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 9 +++++++--
WHATS_NEW_DM | 4 ++--
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/VERSION b/VERSION
index 759b847..a504b04 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.137(2)-git (2015-11-28)
+2.02.137(2)-git (2015-12-05)
diff --git a/VERSION_DM b/VERSION_DM
index 04ea29b..27520ef 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.113-git (2015-11-28)
+1.02.113-git (2015-12-05)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4b33708..95839a2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,12 +1,17 @@
-Version 2.02.137 -
-=====================================
+Version 2.02.137 - 5th December 2015
+====================================
Restore archiving before changing metadata in vgextend (2.02.117).
Dropped internal usage of log_suppress(2).
Cleaned logging code for buffer size usage.
Added internal id_read_format_try() function to check and read valid UUID.
+ Change lvcreate, lvrename, lvresize to use process_each_vg.
+ Change process_each_vg to handle single VG as separate arg.
+ Issue error if ambiguous VG name is supplied in most commands.
+ Make process_each fns always work through full list of known VG names.
Use dm_get_status_mirror() instead of individual parsers.
Add mem pool arg for check_transient_status() target function.
Avoid misleading error with -m is omitted with lvconvert to raid types.
+ Add system_id to vginfo cache.
Version 2.02.136 - 28th November 2015
=====================================
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 3357cec..4b119af 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,5 @@
-Version 1.02.113 -
-=====================================
+Version 1.02.113 - 5th December 2015
+====================================
Mirror plugin in dmeventd uses dm_get_status_mirror().
Add dm_get_status_mirror() for parsing mirror status line.
8 years, 4 months
master - tests: extend test
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fedf15ffb0237d...
Commit: fedf15ffb0237d0bc44c13b0ce62122a2aed64ec
Parent: 748b8158b5bb7d986fb26f2462c4909f723214fc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 4 22:09:05 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 4 22:10:30 2015 +0100
tests: extend test
---
test/shell/backup-read-only.sh | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/test/shell/backup-read-only.sh b/test/shell/backup-read-only.sh
index 810db0d..01ac741 100644
--- a/test/shell/backup-read-only.sh
+++ b/test/shell/backup-read-only.sh
@@ -42,7 +42,7 @@ mount -n -r "$etc_lv" "$mount_dir"
aux lvmconf "backup/archive = 1" "backup/backup = 1"
-# cannot archive to read-only
+# cannot archive to read-only - requires user to specify -An
not lvcreate -n $lv2 -l 10%FREE $vg
lvcreate -An -n $lv2 -l 10%FREE $vg
@@ -59,12 +59,24 @@ vgreduce $vg "$dev2"
mount_dir="etc/backup"
mount -n -r "$etc_lv" "$mount_dir"
-lvcreate -n $lv3 -l 10%FREE $vg
+# Must not fail on making backup
+vgscan
+
+lvcreate -An -n $lv3 -l 10%FREE $vg
+
vgextend $vg "$dev2"
+#
+# Now check both archive & backup read-only
+#
+rm -rf etc/archive
+ln -s backup etc/archive
+
+# Must not fail on making backup
+vgscan
+lvcreate -An -n $lv4 -l 10%FREE $vg
+
umount "$mount_dir" || true
-#ls -laR
-#grep "" etc/archive/*
# TODO maybe also support --ignorelockingfailure ??
vgremove -ff $vg
8 years, 4 months
master - archiver: fix reporting for check_current_backup
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=748b8158b5bb7d...
Commit: 748b8158b5bb7d986fb26f2462c4909f723214fc
Parent: 8b16efd17c8341af719a407aafa010c3c3ad3353
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 4 22:04:14 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 4 22:10:30 2015 +0100
archiver: fix reporting for check_current_backup
It's getting a bit more complex here.
Basic idea behind is - check_current_backup() should not
log error when a user is using a read-only filesystem,
so e.g. vgscan will not report any error when it tries
to take missing backup.
We still have cases when error could be reported though,
e.g. the backup this would be a symbolic link, but these
are rather misconfiguration and unexpected case.
---
lib/format_text/archiver.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
index 4f5ea25..04f9550 100644
--- a/lib/format_text/archiver.c
+++ b/lib/format_text/archiver.c
@@ -121,19 +121,20 @@ static int _archive(struct volume_group *vg, int compulsory)
}
if (!dm_create_dir(vg->cmd->archive_params->dir)) {
- /* FIXME: !compulsory logs error here */
- log_error("Cannot create archiving directory %s.",
- vg->cmd->archive_params->dir);
- return compulsory ? 0 : 1;
+ if (compulsory)
+ return_0;
+ return 1;
}
/* Trap a read-only file system */
if ((access(vg->cmd->archive_params->dir, R_OK | W_OK | X_OK) == -1) &&
(errno == EROFS)) {
- /* FIXME: !compulsory logs error here */
- log_error("Cannot archive volume group metadata for %s to read-only filesystem.",
- vg->name);
- return compulsory ? 0 : 1;
+ if (compulsory) {
+ log_error("Cannot archive volume group metadata for %s to read-only filesystem.",
+ vg->name);
+ return 0;
+ }
+ return 1;
}
log_verbose("Archiving volume group \"%s\" metadata (seqno %u).", vg->name,
@@ -249,8 +250,8 @@ int backup_locally(struct volume_group *vg)
/* Trap a read-only file system */
if ((access(vg->cmd->backup_params->dir, R_OK | W_OK | X_OK) == -1) &&
(errno == EROFS)) {
- log_warn("WARNING: Cannot backup of volume group %s metadata to read-only fs.",
- vg->name);
+ /* Will take a backup next time when FS is writable */
+ log_debug("Skipping backup of volume group on read-only filesystem.");
return 0;
}
@@ -493,6 +494,9 @@ int backup_to_file(const char *file, const char *desc, struct volume_group *vg)
/*
* Update backup (and archive) if they're out-of-date or don't exist.
+ *
+ * This function is not supposed to log_error
+ * when the filesystem with archive/backup dir is read-only.
*/
void check_current_backup(struct volume_group *vg)
{
8 years, 4 months
master - debug: correct stack tracing
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8b16efd17c8341...
Commit: 8b16efd17c8341af719a407aafa010c3c3ad3353
Parent: 45781161f49dcd9b31909ec40766ab4e71d0afa0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 4 22:02:24 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 4 22:10:30 2015 +0100
debug: correct stack tracing
Here the 'goto' is correct path, as !device_is_usable
is traceable with <backtrace>.
Keep the 'stack' for unusable device.
---
lib/activate/dev_manager.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 4d0b4d8..588031d 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -321,7 +321,8 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
.check_suspended = ignore_suspended_devices(),
.check_error_target = 1,
.check_reserved = 0 }))
- goto_out;
+ goto out; /* safe to use */
+ stack;
}
}
8 years, 4 months
master - libdm: add some doc for mirror status
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=45781161f49dcd...
Commit: 45781161f49dcd9b31909ec40766ab4e71d0afa0
Parent: c24d913c47d9639df277b613cee9b5a57aca0762
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 4 20:24:47 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 4 22:10:30 2015 +0100
libdm: add some doc for mirror status
Comment content of struct for mirror status.
---
libdm/libdevmapper.h | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 48f8682..12a665b 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -300,19 +300,19 @@ typedef enum {
struct dm_status_mirror {
uint64_t total_regions;
uint64_t insync_regions;
- uint32_t dev_count;
+ uint32_t dev_count; /* # of devs[] elements (<= 8) */
struct {
dm_status_mirror_health_t health;
uint32_t major;
uint32_t minor;
- } *devs;
- const char *log_type;
- uint32_t log_count;
+ } *devs; /* array with individual legs */
+ const char *log_type; /* core, disk,.... */
+ uint32_t log_count; /* # of logs[] elements */
struct {
dm_status_mirror_health_t health;
uint32_t major;
uint32_t minor;
- } *logs;
+ } *logs; /* array with individual logs */
};
int dm_get_status_mirror(struct dm_pool *mem, const char *params,
8 years, 4 months
master - lvconvert: Reinstate raid merge after splitmirror.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c24d913c47d963...
Commit: c24d913c47d9639df277b613cee9b5a57aca0762
Parent: 89418c1253db901eb6f22b342bc5d98d63aa32e5
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Dec 3 17:40:10 2015 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Dec 3 17:40:10 2015 +0000
lvconvert: Reinstate raid merge after splitmirror.
After commit 46c8d6bb8ae91ee67c8633496cc6c3d92bb4f3ce
(lvconvert: Improve message for raid without -m)
---
tools/lvconvert.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 82b804f..d480f6a 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1734,7 +1734,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
return 0;
}
- if (seg_is_linear(seg) && !arg_count(cmd, mirrors_ARG)) {
+ if (seg_is_linear(seg) && !lp->merge_mirror && !arg_count(cmd, mirrors_ARG)) {
log_error("Raid conversions require -m/--mirrors");
return 0;
}
8 years, 4 months
master - tests: check read-only backup archive
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=89418c1253db90...
Commit: 89418c1253db901eb6f22b342bc5d98d63aa32e5
Parent: d2524315e6e9ed6796555d8cafbaf56470260b11
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 3 18:16:07 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Dec 3 18:17:45 2015 +0100
tests: check read-only backup archive
---
test/shell/backup-read-only.sh | 70 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 70 insertions(+), 0 deletions(-)
diff --git a/test/shell/backup-read-only.sh b/test/shell/backup-read-only.sh
new file mode 100644
index 0000000..810db0d
--- /dev/null
+++ b/test/shell/backup-read-only.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+# Copyright (C) 2015 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+SKIP_WITH_CLVMD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+which mkfs.ext3 || skip
+
+aux prepare_vg 2
+
+# Note: inittest.sh sets LVM_SYSTEM_DIR to 'just' etc
+etc_lv="$DM_DEV_DIR/$vg/$lv1"
+
+cleanup_mounted_and_teardown()
+{
+ umount "$mount_dir" || true
+ aux teardown
+}
+
+vgreduce $vg "$dev2"
+
+lvcreate -n $lv1 -l 20%FREE $vg
+mkfs.ext3 -b4096 -j "$etc_lv"
+
+#
+# check read-only archive dir
+#
+mount_dir="etc/archive"
+trap 'cleanup_mounted_and_teardown' EXIT
+mkdir -p "$mount_dir"
+mount -n -r "$etc_lv" "$mount_dir"
+
+aux lvmconf "backup/archive = 1" "backup/backup = 1"
+
+# cannot archive to read-only
+not lvcreate -n $lv2 -l 10%FREE $vg
+lvcreate -An -n $lv2 -l 10%FREE $vg
+
+not vgextend $vg "$dev2"
+vgextend -An $vg "$dev2"
+
+umount "$mount_dir" || true
+
+vgreduce $vg "$dev2"
+
+#
+# check read-only backup dir
+#
+mount_dir="etc/backup"
+mount -n -r "$etc_lv" "$mount_dir"
+
+lvcreate -n $lv3 -l 10%FREE $vg
+vgextend $vg "$dev2"
+
+umount "$mount_dir" || true
+#ls -laR
+#grep "" etc/archive/*
+
+# TODO maybe also support --ignorelockingfailure ??
+vgremove -ff $vg
8 years, 4 months
master - vgextend: reinstantiate archiving
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d2524315e6e9ed...
Commit: d2524315e6e9ed6796555d8cafbaf56470260b11
Parent: e7978c5ab68b1dabfa886fa437646edfcf270b82
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 3 18:15:02 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Dec 3 18:17:45 2015 +0100
vgextend: reinstantiate archiving
Since commit f5d06efbab4c7c77298b18b95c23111575a8db1a we lost archiving.
Restore it now with process_each_vg.
---
WHATS_NEW | 1 +
tools/vgextend.c | 6 ++++++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 49d1dd6..4b33708 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.137 -
=====================================
+ Restore archiving before changing metadata in vgextend (2.02.117).
Dropped internal usage of log_suppress(2).
Cleaned logging code for buffer size usage.
Added internal id_read_format_try() function to check and read valid UUID.
diff --git a/tools/vgextend.c b/tools/vgextend.c
index a747113..761df75 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -52,6 +52,9 @@ static int _vgextend_restoremissing(struct cmd_context *cmd __attribute__((unuse
int fixed = 0;
int i;
+ if (!archive(vg))
+ return_0;
+
for (i = 0; i < vp->pv_count; i++)
if (_restore_pv(vg, vp->pv_names[i]))
fixed++;
@@ -88,6 +91,9 @@ static int _vgextend_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED;
}
+ if (!archive(vg))
+ return_ECMD_FAILED;
+
if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
log_error("Can't get lock for orphan PVs");
return ECMD_FAILED;
8 years, 4 months
master - cleanup: drop log_suppress(2) usage
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e7978c5ab68b1d...
Commit: e7978c5ab68b1dabfa886fa437646edfcf270b82
Parent: f40b3ba1e904f6c6a3e1264e6d734f558ec731d9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 3 17:51:43 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Dec 3 18:02:34 2015 +0100
cleanup: drop log_suppress(2) usage
No longer need to use log_suppress(2) instance so dropped.
---
WHATS_NEW | 1 +
lib/format_text/import_vsn1.c | 31 ++++++++++++++++---------------
lib/log/log.c | 3 ---
3 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c39eae4..49d1dd6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.137 -
=====================================
+ Dropped internal usage of log_suppress(2).
Cleaned logging code for buffer size usage.
Added internal id_read_format_try() function to check and read valid UUID.
Use dm_get_status_mirror() instead of individual parsers.
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 6aa227b..023c383 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -1019,14 +1019,13 @@ static struct volume_group *_read_vg(struct format_instance *fid,
static void _read_desc(struct dm_pool *mem,
const struct dm_config_tree *cft, time_t *when, char **desc)
{
- const char *d;
+ const char *str;
unsigned int u = 0u;
- int old_suppress;
- old_suppress = log_suppress(1);
- d = dm_config_find_str_allow_empty(cft->root, "description", "");
- log_suppress(old_suppress);
- *desc = dm_pool_strdup(mem, d);
+ if (!dm_config_get_str(cft->root, "description", &str))
+ str = "";
+
+ *desc = dm_pool_strdup(mem, str);
(void) dm_config_get_uint32(cft->root, "creation_time", &u);
*when = u;
@@ -1043,12 +1042,12 @@ static int _read_vgname(const struct format_type *fmt, const struct dm_config_tr
const struct dm_config_node *vgn;
struct dm_pool *mem = fmt->cmd->mem;
const char *str;
- int old_suppress;
- old_suppress = log_suppress(2);
- vgsummary->creation_host =
- dm_pool_strdup(mem, dm_config_find_str_allow_empty(cft->root, "creation_host", ""));
- log_suppress(old_suppress);
+ if (!dm_config_get_str(cft->root, "creation_host", &str))
+ str = "";
+
+ if (!(vgsummary->creation_host = dm_pool_strdup(mem, str)))
+ return_0;
/* skip any top-level values */
for (vgn = cft->root; (vgn && vgn->v); vgn = vgn->sib) ;
@@ -1074,11 +1073,13 @@ static int _read_vgname(const struct format_type *fmt, const struct dm_config_tr
return 0;
}
- if (dm_config_get_str(vgn, "system_id", &str))
- vgsummary->system_id = dm_pool_strdup(mem, str);
+ if (dm_config_get_str(vgn, "system_id", &str) &&
+ (!(vgsummary->system_id = dm_pool_strdup(mem, str))))
+ return_0;
- if (dm_config_get_str(vgn, "lock_type", &str))
- vgsummary->lock_type = dm_pool_strdup(mem, str);
+ if (dm_config_get_str(vgn, "lock_type", &str) &&
+ (!(vgsummary->lock_type = dm_pool_strdup(mem, str))))
+ return_0;
return 1;
}
diff --git a/lib/log/log.c b/lib/log/log.c
index fc52bdd..1c5ccd7 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -299,9 +299,6 @@ void print_log(int level, const char *file, int line, int dm_errno_or_class,
level = _LOG_FATAL;
}
- if (_log_suppress == 2)
- return;
-
if (level <= _LOG_ERR)
init_error_message_produced(1);
8 years, 4 months
master - archiver: inital change toward proper logging
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f40b3ba1e904f6...
Commit: f40b3ba1e904f6c6a3e1264e6d734f558ec731d9
Parent: 20acc66a237429d81b699b56be57d4d043362098
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Dec 3 17:32:47 2015 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Dec 3 18:01:45 2015 +0100
archiver: inital change toward proper logging
We have to modes of 'archive()' usage -
1. compulsory - fail stops command and user may try '-An' option
to do a command.
2. non-compulsory - some fails in archiving are ignorable (i.e.
read-only filesystem where archive dir is located).
Those 2 cases needs to be properly handle - i.e. the non-compulsory
logging should not be tampering error logging message production.
So more work here is needed
---
lib/format_text/archiver.c | 64 +++++++++++++++++++++++++------------------
1 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
index e3d3d57..4f5ea25 100644
--- a/lib/format_text/archiver.c
+++ b/lib/format_text/archiver.c
@@ -98,20 +98,10 @@ static char *_build_desc(struct dm_pool *mem, const char *line, int before)
return buffer;
}
-static int __archive(struct volume_group *vg)
+static int _archive(struct volume_group *vg, int compulsory)
{
char *desc;
- if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 1)))
- return_0;
-
- return archive_vg(vg, vg->cmd->archive_params->dir, desc,
- vg->cmd->archive_params->keep_days,
- vg->cmd->archive_params->keep_number);
-}
-
-int archive(struct volume_group *vg)
-{
/* Don't archive orphan VGs. */
if (is_orphan_vg(vg->name))
return 1;
@@ -130,27 +120,43 @@ int archive(struct volume_group *vg)
return 1;
}
- if (!dm_create_dir(vg->cmd->archive_params->dir))
- return 0;
+ if (!dm_create_dir(vg->cmd->archive_params->dir)) {
+ /* FIXME: !compulsory logs error here */
+ log_error("Cannot create archiving directory %s.",
+ vg->cmd->archive_params->dir);
+ return compulsory ? 0 : 1;
+ }
/* Trap a read-only file system */
if ((access(vg->cmd->archive_params->dir, R_OK | W_OK | X_OK) == -1) &&
- (errno == EROFS))
- return 0;
+ (errno == EROFS)) {
+ /* FIXME: !compulsory logs error here */
+ log_error("Cannot archive volume group metadata for %s to read-only filesystem.",
+ vg->name);
+ return compulsory ? 0 : 1;
+ }
log_verbose("Archiving volume group \"%s\" metadata (seqno %u).", vg->name,
vg->seqno);
- if (!__archive(vg)) {
- log_error("Volume group \"%s\" metadata archive failed.",
- vg->name);
- return 0;
- }
+
+ if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 1)))
+ return_0;
+
+ if (!archive_vg(vg, vg->cmd->archive_params->dir, desc,
+ vg->cmd->archive_params->keep_days,
+ vg->cmd->archive_params->keep_number))
+ return_0;
vg->status |= ARCHIVED_VG;
return 1;
}
+int archive(struct volume_group *vg)
+{
+ return _archive(vg, 1);
+}
+
int archive_display(struct cmd_context *cmd, const char *vg_name)
{
int r1, r2;
@@ -207,7 +213,7 @@ void backup_enable(struct cmd_context *cmd, int flag)
cmd->backup_params->enabled = flag;
}
-static int __backup(struct volume_group *vg)
+static int _backup(struct volume_group *vg)
{
char name[PATH_MAX];
char *desc;
@@ -242,10 +248,13 @@ int backup_locally(struct volume_group *vg)
/* Trap a read-only file system */
if ((access(vg->cmd->backup_params->dir, R_OK | W_OK | X_OK) == -1) &&
- (errno == EROFS))
+ (errno == EROFS)) {
+ log_warn("WARNING: Cannot backup of volume group %s metadata to read-only fs.",
+ vg->name);
return 0;
+ }
- if (!__backup(vg)) {
+ if (!_backup(vg)) {
log_error("Backup of volume group %s metadata failed.",
vg->name);
return 0;
@@ -500,8 +509,9 @@ void check_current_backup(struct volume_group *vg)
return;
if (dm_snprintf(path, sizeof(path), "%s/%s",
- vg->cmd->backup_params->dir, vg->name) < 0) {
- log_debug("Failed to generate backup filename.");
+ vg->cmd->backup_params->dir, vg->name) < 0) {
+ log_warn("WARNING: Failed to generate backup pathname %s/%s.",
+ vg->cmd->backup_params->dir, vg->name);
return;
}
@@ -517,11 +527,11 @@ void check_current_backup(struct volume_group *vg)
log_suppress(old_suppress);
if (vg_backup) {
- if (!archive(vg_backup))
+ if (!_archive(vg_backup, 0))
stack;
release_vg(vg_backup);
}
- if (!archive(vg))
+ if (!_archive(vg, 0))
stack;
if (!backup_locally(vg))
stack;
8 years, 4 months