]> git.proxmox.com Git - lvm.git/blob - patchdir/autodetect-locking-type.patch
2494085b380db05968495a67695e42743b708911
[lvm.git] / patchdir / autodetect-locking-type.patch
1 Index: new/lib/locking/locking.c
2 ===================================================================
3 --- new.orig/lib/locking/locking.c 2011-06-11 02:03:07.000000000 +0200
4 +++ new/lib/locking/locking.c 2011-09-21 10:01:47.000000000 +0200
5 @@ -225,7 +225,16 @@
6 suppress_messages = 1;
7
8 if (type < 0)
9 - type = find_config_tree_int(cmd, "global/locking_type", 1);
10 + type = find_config_tree_int(cmd, "global/locking_type", -1);
11 +
12 + if (type < 0) {
13 + struct stat info;
14 + if (stat("/etc/cluster/cluster.conf", &info) == 0) {
15 + type = 3;
16 + } else {
17 + type = 1;
18 + }
19 + }
20
21 _blocking_supported = find_config_tree_int(cmd,
22 "global/wait_for_locks", DEFAULT_WAIT_FOR_LOCKS);
23 Index: new/doc/example.conf.in
24 ===================================================================
25 --- new.orig/doc/example.conf.in 2011-07-01 16:09:19.000000000 +0200
26 +++ new/doc/example.conf.in 2011-09-21 10:01:47.000000000 +0200
27 @@ -350,13 +350,16 @@
28 proc = "/proc"
29
30 # Type of locking to use. Defaults to local file-based locking (1).
31 + # Proxmox VE sets default locking_type to 3 if file
32 + # /etc/cluster/cluster.conf exists. So there is normally no need
33 + # to set this value here.
34 # Turn locking off by setting to 0 (dangerous: risks metadata corruption
35 # if LVM2 commands get run concurrently).
36 # Type 2 uses the external shared library locking_library.
37 # Type 3 uses built-in clustered locking.
38 # Type 4 uses read-only locking which forbids any operations that might
39 # change metadata.
40 - locking_type = 1
41 + # locking_type = 1
42
43 # Set to 0 to fail when a lock request cannot be satisfied immediately.
44 wait_for_locks = 1
45 Index: new/lib/locking/cluster_locking.c
46 ===================================================================
47 --- new.orig/lib/locking/cluster_locking.c 2011-09-21 10:08:21.000000000 +0200
48 +++ new/lib/locking/cluster_locking.c 2011-09-21 10:10:55.000000000 +0200
49 @@ -66,10 +66,14 @@
50 {
51 int local_socket;
52 struct sockaddr_un sockaddr;
53 + int suppress_messages = 0;
54 +
55 + if (ignorelockingfailure() && getenv("LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES"))
56 + suppress_messages = 1;
57
58 /* Open local socket */
59 if ((local_socket = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
60 - log_error("Local socket creation failed: %s", strerror(errno));
61 + log_error_suppress(suppress_messages, "Local socket creation failed: %s", strerror(errno));
62 return -1;
63 }
64
65 @@ -82,7 +86,7 @@
66 sizeof(sockaddr))) {
67 int saved_errno = errno;
68
69 - log_error("connect() failed on local socket: %s",
70 + log_error_suppress(suppress_messages, "connect() failed on local socket: %s",
71 strerror(errno));
72 if (close(local_socket))
73 stack;