Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5de944420224f3b629e84…
Commit: 5de944420224f3b629e843f9c190132ed9ff3dca
Parent: 043ff47b0579bffaa63cb023d8850b0e749eb9ce
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Aug 25 11:59:19 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Aug 25 14:12:55 2017 +0200
locking: avoid descriptor leak for nonblocking mode
When file-locking mode failed on locking, such description was leaked
(typically not an issue since command usually exists afterwards).
So shirt close() at the end of function and use it in all error paths.
Also make sure, when interrrupt is detected, it's really not holding
lock and returns 0.
---
WHATS_NEW | 1 +
lib/misc/lvm-flock.c | 13 ++++++++-----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c8f072f..ac69c16 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.174 -
=================================
+ Fix leaking of file descriptor for non-blocking filebased locking.
Fix check for 2nd mda at end of disk fits if using pvcreate --restorefile.
Use maximum metadataarea size that fits with pvcreate --restorefile.
Always clear cached bootloaderarea when wiping label e.g. in pvcreate.
diff --git a/lib/misc/lvm-flock.c b/lib/misc/lvm-flock.c
index 22eb128..4196313 100644
--- a/lib/misc/lvm-flock.c
+++ b/lib/misc/lvm-flock.c
@@ -116,17 +116,16 @@ static int _do_flock(const char *file, int *fd, int operation, uint32_t nonblock
old_errno = errno;
if (!nonblock) {
sigint_restore();
- if (sigint_caught())
+ if (sigint_caught()) {
log_error("Giving up waiting for lock.");
+ break;
+ }
}
if (r) {
errno = old_errno;
log_sys_error("flock", file);
- if (close(*fd))
- log_sys_debug("close", file);
- *fd = -1;
- return 0;
+ break;
}
if (!stat(file, &buf1) && !fstat(*fd, &buf2) &&
@@ -134,6 +133,10 @@ static int _do_flock(const char *file, int *fd, int operation, uint32_t nonblock
return 1;
} while (!nonblock);
+ if (close(*fd))
+ log_sys_debug("close", file);
+ *fd = -1;
+
return_0;
}
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=043ff47b0579bffaa63cb…
Commit: 043ff47b0579bffaa63cb023d8850b0e749eb9ce
Parent: e71c3ff18719f240e92bb641b9b9a01b2619cc93
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Aug 24 10:25:01 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Aug 24 10:25:01 2017 -0500
man lvmthin: change fsck references
to more generic terms like repair.
---
man/lvmthin.7_main | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/man/lvmthin.7_main b/man/lvmthin.7_main
index 1ebeb65..251ba12 100644
--- a/man/lvmthin.7_main
+++ b/man/lvmthin.7_main
@@ -397,7 +397,7 @@ the pmspare LV.
If thin pool metadata is damaged, it may be repairable.
Checking and repairing thin pool metadata is analagous to
-running fsck on a file system.
+running fsck/repair on a file system.
When a thin pool LV is activated, lvm runs the thin_check command
to check the correctness of the metadata on the pool metadata LV.
@@ -774,7 +774,7 @@ While waiting to be extended, the thin pool will queue writes for up to 60
seconds (the default). If data space has not been extended after this
time, the queued writes will return an error to the caller, e.g. the file
system. This can result in file system corruption for non-journaled file
-systems that may require fsck. When a thin pool returns errors for writes
+systems that may require repair. When a thin pool returns errors for writes
to a thin LV, any file system is subject to losing unsynced user data.
The 60 second timeout can be changed or disabled with the dm-thin-pool
@@ -789,7 +789,7 @@ deadlocks. (The timeout applies to all thin pools on the system.)
Writes to thin LVs immediately return an error, and no writes are queued.
In the case of a file system, this can result in corruption that may
-require fsck (the specific consequences depend on the thin LV user.)
+require fs repair (the specific consequences depend on the thin LV user.)
.I data percent
@@ -858,7 +858,7 @@ repair.
.br
See "Manually manage free metadata space of a thin pool LV".
-4. Check and repair file system with fsck.
+4. Check and repair file system.
.SS Automatic extend settings
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=46ddd5520cd4d5415ee93…
Commit: 46ddd5520cd4d5415ee936b6cbdb6e1936bc7d26
Parent: 539a48a328a7ddd1030dd5809a2f9f0df6c1fe70
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Aug 23 11:25:18 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Aug 23 11:25:18 2017 -0500
lvmlockd: add comment about temp ls name
---
daemons/lvmlockd/lvmlockd-core.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 6fd4b88..da17b71 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -2652,8 +2652,14 @@ out_act:
ls->drop_vg = drop_vg;
if (ls->lm_type == LD_LM_DLM && !strcmp(ls->name, gl_lsname_dlm))
global_dlm_lockspace_exists = 0;
- /* Avoid a name collision of the same lockspace is added again before this thread is cleaned up. */
- /* FIXME: detect loss of 4 chars? (use 'size(tmp_name) == (MAX_NAME - 4)' and fail??) */
+
+ /*
+ * Avoid a name collision of the same lockspace is added again before
+ * this thread is cleaned up. We just set ls->name to a "junk" value
+ * for the short period until the struct is freed. We could make it
+ * blank or fill it with garbage, but instead set it to REM:<name>
+ * to make it easier to follow progress of freeing is via log_debug.
+ */
dm_strncpy(tmp_name, ls->name, sizeof(tmp_name));
snprintf(ls->name, sizeof(ls->name), "REM:%s", tmp_name);
pthread_mutex_unlock(&lockspaces_mutex);
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d4ce98de4d6c7c3ddeca0…
Commit: d4ce98de4d6c7c3ddeca0e380a18bbdc102e6c3a
Parent: 0e42b31dc3be45c29abd90369c02c077d1763ff0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Aug 16 14:12:48 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Aug 22 10:23:31 2017 +0200
lvmlockd: shorter code
gcc warns here about storring 69 bytes in 64 byte array (losing
potentially 4 bytes from 'ls->name').
lvmlockd-core.c:2657:36: warning: ���%s��� directive output may be truncated writing up to 64 bytes into a region of size 60 [-Wformat-truncation=]
snprintf(tmp_name, MAX_NAME, "REM:%s", ls->name);
^~
lvmlockd-core.c:2657:2: note: ���snprintf��� output between 5 and 69 bytes into a destination of size 64
snprintf(tmp_name, MAX_NAME, "REM:%s", ls->name);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Replaced with slightly better code - but it still misses error path what
to do if the name would be truncated... - so added FIXME.
Also using all bytes for snprintf() buffer size
(as the size is with \0 included)
---
daemons/lvmlockd/lvmlockd-core.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index aefa98a..6fd4b88 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -2653,9 +2653,9 @@ out_act:
if (ls->lm_type == LD_LM_DLM && !strcmp(ls->name, gl_lsname_dlm))
global_dlm_lockspace_exists = 0;
/* Avoid a name collision of the same lockspace is added again before this thread is cleaned up. */
- memset(tmp_name, 0, sizeof(tmp_name));
- snprintf(tmp_name, MAX_NAME, "REM:%s", ls->name);
- memcpy(ls->name, tmp_name, MAX_NAME);
+ /* FIXME: detect loss of 4 chars? (use 'size(tmp_name) == (MAX_NAME - 4)' and fail??) */
+ dm_strncpy(tmp_name, ls->name, sizeof(tmp_name));
+ snprintf(ls->name, sizeof(ls->name), "REM:%s", tmp_name);
pthread_mutex_unlock(&lockspaces_mutex);
/* worker_thread will join this thread, and free the ls */