Skip to contentSkip to conversation

stable-2.02 - libdm: validate thin-pool before sending messages

PATCH Zdenek Kabelac 1 participant 1 message Oct 18, 2020

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8792d417f3bcec4b9142234786c9a8d9474db3ae
Commit:        8792d417f3bcec4b9142234786c9a8d9474db3ae
Parent:        afffab09217ed30d4a358a13cac3eccae8e712c1
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Mon Sep 28 23:12:48 2020 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Sun Oct 18 00:28:17 2020 +0200

libdm: validate thin-pool before sending messages

Alhtough lvm2 does validation on its side, ensure DM code is not sending messages to failed thin pool.

---
 libdm/libdm-deptree.c | 9 +++++++++
 1 file changed, 9 insertions(+)
libdm/libdm-deptree.c +9 -0
index 6819d6471..92f262073 100644
@@ -1600,6 +1600,15 @@ static int _node_send_messages(struct dm_tree_node *dnode,
 	if (!have_messages || !send)
 		return 1; /* transaction_id is matching */
 
+	if (stp.fail || stp.read_only || stp.needs_check) {
+		log_error("Cannot send messages to thin pool %s%s%s%s.",
+			  _node_name(dnode),
+			  stp.fail ? " in failed state" : "",
+			  stp.read_only ? " with read only metadata" : "",
+			  stp.needs_check ? " which needs check first" : "");
+		return 0;
+	}
+
 	dm_list_iterate_items(tmsg, &seg->thin_messages) {
 		if (!(_thin_pool_node_message(dnode, tmsg)))
 			return_0;