master - liblvm: add lv_rename_update
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=21c401006c3c12...
Commit: 21c401006c3c12b75354736db9a2f75e7993f489
Parent: 739092e64ac2776a0b0b0796349041b659d816b0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Sep 27 09:48:25 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 3 15:03:49 2012 +0200
liblvm: add lv_rename_update
Support lv_rename without directly updating metatata.
It can save some metadata commits in some cases,
i.e. when LVs are offline.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 19 ++++++++++++++++---
lib/metadata/metadata-exported.h | 2 ++
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 45ce574..bc0c778 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Add internal lv_rename_update() to rename LV without updating mda.
Ensure descriptors 0,1,2 are always available.
Use /proc/self/fd for closing openned descriptors.
Add missing pkg init with --enable-testing in configure.in (2.02.71).
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f2d99b8..eb5794c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -2938,8 +2938,8 @@ int for_each_sub_lv(struct cmd_context *cmd, struct logical_volume *lv,
* Core of LV renaming routine.
* VG must be locked by caller.
*/
-int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
- const char *new_name)
+int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
+ const char *new_name, int update_mda)
{
struct volume_group *vg = lv->vg;
struct lv_names lv_names;
@@ -2964,7 +2964,7 @@ int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
- if (!archive(vg))
+ if (update_mda && !archive(vg))
return 0;
/* rename sub LVs */
@@ -2986,6 +2986,9 @@ int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
if (lv_is_cow(lv) && lv_is_virtual_origin(lvl2.lv = origin_from_cow(lv)))
dm_list_add_h(&lvs_changed, &lvl2.list);
+ if (!update_mda)
+ return 1;
+
log_verbose("Writing out updated volume group");
if (!vg_write(vg))
return 0;
@@ -3009,6 +3012,16 @@ out:
return r;
}
+/*
+ * Core of LV renaming routine.
+ * VG must be locked by caller.
+ */
+int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
+ const char *new_name)
+{
+ return lv_rename_update(cmd, lv, new_name, 1);
+}
+
char *generate_lv_name(struct volume_group *vg, const char *format,
char *buffer, size_t len)
{
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 0658fad..d149f95 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -560,6 +560,8 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
const char *new_name);
+int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
+ const char *new_name, int update_mda);
uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
uint32_t extent_size);
11 years, 7 months
master - liblvm2cmd: ensure standard descriptors are ready
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=739092e64ac277...
Commit: 739092e64ac2776a0b0b0796349041b659d816b0
Parent: 1f30e048bd8b387e25baad4f82223b63dc516cf5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Sep 7 11:13:41 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 3 15:02:26 2012 +0200
liblvm2cmd: ensure standard descriptors are ready
Check if FDs 0,1,2 are available, and in case they are missing,
use /dev/null for them.
---
WHATS_NEW | 1 +
tools/lvmcmdline.c | 39 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5f82424..45ce574 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Ensure descriptors 0,1,2 are always available.
Use /proc/self/fd for closing openned descriptors.
Add missing pkg init with --enable-testing in configure.in (2.02.71).
Fix inability to create, extend or convert to a large (> 1TiB) RAID LV.
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index e015a12..bccf7a6 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -26,6 +26,7 @@
#include <time.h>
#include <sys/resource.h>
#include <dirent.h>
+#include <paths.h>
#ifdef HAVE_GETOPTLONG
# include <getopt.h>
@@ -1186,6 +1187,39 @@ int lvm_split(char *str, int *argc, char **argv, int max)
return *argc;
}
+/* Make sure we have always valid filedescriptors 0,1,2 */
+static int _check_standard_fds(void)
+{
+ int err = is_valid_fd(STDERR_FILENO);
+
+ if (!is_valid_fd(STDIN_FILENO) &&
+ !(stdin = fopen(_PATH_DEVNULL, "r"))) {
+ if (err)
+ perror("stdin stream open");
+ else
+ printf("stdin stream open: %s\n",
+ strerror(errno));
+ return 0;
+ }
+
+ if (!is_valid_fd(STDOUT_FILENO) &&
+ !(stdout = fopen(_PATH_DEVNULL, "w"))) {
+ if (err)
+ perror("stdout stream open");
+ /* else no stdout */
+ return 0;
+ }
+
+ if (!is_valid_fd(STDERR_FILENO) &&
+ !(stderr = fopen(_PATH_DEVNULL, "w"))) {
+ printf("stderr stream open: %s\n",
+ strerror(errno));
+ return 0;
+ }
+
+ return 1;
+}
+
static const char *_get_cmdline(pid_t pid)
{
static char _proc_cmdline[32];
@@ -1450,6 +1484,9 @@ int lvm2_main(int argc, char **argv)
strcmp(base, "initrd-lvm"))
alias = 1;
+ if (!_check_standard_fds())
+ return -1;
+
if (!_close_stray_fds(base))
return -1;
11 years, 7 months
master - liblvm2cmd: add return code for _close_stray_fds
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1f30e048bd8b38...
Commit: 1f30e048bd8b387e25baad4f82223b63dc516cf5
Parent: 98bcfdca837c8b56cc355e74672c932c1e8ed735
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 15 01:18:23 2012 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 3 15:01:23 2012 +0200
liblvm2cmd: add return code for _close_stray_fds
Close fds via /proc/self/fd parsing
Return error code if _close_stray_fds fails and quit application
if system is in some nonstandard state.
---
WHATS_NEW | 1 +
tools/lvmcmdline.c | 47 ++++++++++++++++++++++++++++++++++++-----------
2 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1868f99..5f82424 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Use /proc/self/fd for closing openned descriptors.
Add missing pkg init with --enable-testing in configure.in (2.02.71).
Fix inability to create, extend or convert to a large (> 1TiB) RAID LV.
Add (p)artial attribute to lvs.
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index c5341df..e015a12 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -25,6 +25,7 @@
#include <sys/stat.h>
#include <time.h>
#include <sys/resource.h>
+#include <dirent.h>
#ifdef HAVE_GETOPTLONG
# include <getopt.h>
@@ -1252,26 +1253,49 @@ static void _close_descriptor(int fd, unsigned suppress_warnings,
fprintf(stderr, " Parent PID %" PRIpid_t ": %s\n", ppid, parent_cmdline);
}
-static void _close_stray_fds(const char *command)
+static int _close_stray_fds(const char *command)
{
struct rlimit rlim;
int fd;
unsigned suppress_warnings = 0;
pid_t ppid = getppid();
const char *parent_cmdline = _get_cmdline(ppid);
-
- if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
- fprintf(stderr, "getrlimit(RLIMIT_NOFILE) failed: %s\n",
- strerror(errno));
- return;
- }
+ static const char _fd_dir[] = DEFAULT_PROC_DIR "/self/fd";
+ struct dirent *dirent;
+ DIR *d;
if (getenv("LVM_SUPPRESS_FD_WARNINGS"))
suppress_warnings = 1;
- for (fd = 3; fd < (int)rlim.rlim_cur; fd++)
- _close_descriptor(fd, suppress_warnings, command, ppid,
- parent_cmdline);
+ if (!(d = opendir(_fd_dir))) {
+ if (errno != ENOENT) {
+ log_sys_error("opendir", _fd_dir);
+ return 0; /* broken system */
+ }
+
+ /* Path does not exist, use the old way */
+ if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
+ log_sys_error("getrlimit", "RLIMIT_NOFILE");
+ return 1;
+ }
+
+ for (fd = 3; fd < (int)rlim.rlim_cur; fd++)
+ _close_descriptor(fd, suppress_warnings, command, ppid,
+ parent_cmdline);
+ return 1;
+ }
+
+ while ((dirent = readdir(d))) {
+ fd = atoi(dirent->d_name);
+ if (fd > 2 && fd != dirfd(d))
+ _close_descriptor(fd, suppress_warnings,
+ command, ppid, parent_cmdline);
+ }
+
+ if (closedir(d))
+ log_sys_error("closedir", _fd_dir);
+
+ return 1;
}
struct cmd_context *init_lvm(void)
@@ -1426,7 +1450,8 @@ int lvm2_main(int argc, char **argv)
strcmp(base, "initrd-lvm"))
alias = 1;
- _close_stray_fds(base);
+ if (!_close_stray_fds(base))
+ return -1;
if (is_static() && strcmp(base, "lvm.static") &&
path_exists(LVM_SHARED_PATH) &&
11 years, 7 months
master - configure: fix --enable-testing
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=98bcfdca837c8b...
Commit: 98bcfdca837c8b56cc355e74672c932c1e8ed735
Parent: 886656e4ac5e5c932d9fbe60d18c063136288a38
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Oct 1 14:34:07 2012 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 3 14:59:59 2012 +0200
configure: fix --enable-testing
Add missing pkg init for configure --enable-testing.
---
WHATS_NEW | 1 +
configure | 3 +++
configure.in | 3 +++
3 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index dc62d77..1868f99 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.98 -
=================================
+ Add missing pkg init with --enable-testing in configure.in (2.02.71).
Fix inability to create, extend or convert to a large (> 1TiB) RAID LV.
Add (p)artial attribute to lvs.
Don't try to issue discards to a missing PV to avoid segfault.
diff --git a/configure b/configure
index 52f0e36..13fb6d6 100755
--- a/configure
+++ b/configure
@@ -8704,6 +8704,9 @@ fi
$as_echo "$TESTING" >&6; }
if test "$TESTING" = yes; then
+ if test x$PKGCONFIG_INIT != x1; then
+ pkg_config_init
+ fi
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CUNIT" >&5
diff --git a/configure.in b/configure.in
index 1c908f9..2bdffca 100644
--- a/configure.in
+++ b/configure.in
@@ -856,6 +856,9 @@ AC_ARG_ENABLE(testing,
AC_MSG_RESULT($TESTING)
if test "$TESTING" = yes; then
+ if test x$PKGCONFIG_INIT != x1; then
+ pkg_config_init
+ fi
PKG_CHECK_MODULES(CUNIT, cunit >= 2.0)
fi
11 years, 7 months