summaryrefslogtreecommitdiffstats
path: root/libdm/libdm-file.c
diff options
context:
space:
mode:
authorJonathan Earl Brassow <jbrassow@redhat.com>2010-07-21 13:40:21 +0000
committerJonathan Earl Brassow <jbrassow@redhat.com>2010-07-21 13:40:21 +0000
commit405c4a45d8cea20437b75ad13ece15651167ff89 (patch)
tree319f111006a155aa09c93164291ccc605aa6d798 /libdm/libdm-file.c
parent54b362f9b08cd9fe48a6f87d6a7e3bf345ee06f9 (diff)
downloadlvm2-405c4a45d8cea20437b75ad13ece15651167ff89.tar.gz
lvm2-405c4a45d8cea20437b75ad13ece15651167ff89.tar.xz
lvm2-405c4a45d8cea20437b75ad13ece15651167ff89.zip
It's not enough to check for the kernel module in the case of cluster
mirrors, we must also check that the log daemon (cmirrord) is running. The log module can be auto-loaded, but the daemon cannot be "auto-started". Failing to check for the daemon produces cryptic messages that customers have a hard time deciphering. (The system messages do report that the log daemon is not running, but people don't seem to find this message easily.) Here are examples of what is printed when the module is available, but the log daemon has not been started. [root@bp-01 LVM2]# lvcreate -m1 -l1 -n lv vg Shared cluster mirrors are not available. [root@bp-01 LVM2]# lvcreate -m1 -l1 -n lv vg -v Setting logging type to disk Finding volume group "vg" Archiving volume group "vg" metadata (seqno 3). Creating logical volume lv Executing: /sbin/modprobe dm-log-userspace Cluster mirror log daemon is not running Shared cluster mirrors are not available. Creating volume group backup "/etc/lvm/backup/vg" (seqno 4).
Diffstat (limited to 'libdm/libdm-file.c')
-rw-r--r--libdm/libdm-file.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/libdm/libdm-file.c b/libdm/libdm-file.c
index ae2da76d..8dbf099c 100644
--- a/libdm/libdm-file.c
+++ b/libdm/libdm-file.c
@@ -166,3 +166,29 @@ fail:
return 0;
}
+
+int dm_daemon_is_running(const char* lockfile)
+{
+ int fd;
+ struct flock lock;
+
+ if((fd = open(lockfile, O_RDONLY)) < 0)
+ return 0;
+
+ lock.l_type = F_WRLCK;
+ lock.l_start = 0;
+ lock.l_whence = SEEK_SET;
+ lock.l_len = 0;
+ if (fcntl(fd, F_GETLK, &lock) < 0) {
+ log_error("Cannot check lock status of lockfile [%s], error was [%s]",
+ lockfile, strerror(errno));
+ if (close(fd))
+ stack;
+ return 0;
+ }
+
+ if (close(fd))
+ stack;
+
+ return (lock.l_type == F_UNLCK) ? 0 : 1;
+}