Skip to contentSkip to conversation

master - lvmlockd: fix sparse snapshot case

PATCH David Teigland 1 participant 1 message Feb 23, 2016

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e79325308454814d968dd3e06cd261a269716675
Commit:        e79325308454814d968dd3e06cd261a269716675
Parent:        79809d6cdc3a1e4dfb4466fc0e10040bd069211d
Author:        David Teigland <[email protected]>
AuthorDate:    Tue Feb 23 15:44:14 2016 -0600
Committer:     David Teigland <[email protected]>
CommitterDate: Tue Feb 23 15:45:25 2016 -0600

lvmlockd: fix sparse snapshot case

A snapshot can be created without a real origin LV in this case, so there's no lock to use.

---
 lib/locking/lvmlockd.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
lib/locking/lvmlockd.c +6 -0
index e78e2cb..c55f2b5 100644
@@ -2331,6 +2331,12 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logic
 		 * represents itself and all associated cow snapshots.
 		 */
 
+		if (!lp->origin_name) {
+			/* Sparse LV case. We require a lock from the origin LV. */
+			log_error("Cannot create snapshot without origin LV in shared VG.");
+			return 0;
+		}
+
 		if (!(origin_lv = find_lv(vg, lp->origin_name))) {
 			log_error("Failed to find origin LV %s/%s", vg->name, lp->origin_name);
 			return 0;