Skip to contentSkip to conversation

master - thin: fix condition for kernels without discards

PATCH Zdenek Kabelac 1 participant 1 message Aug 9, 2012

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b8a6efbcc03dd21cfc765176c3e406075bfa1e02
Commit:        b8a6efbcc03dd21cfc765176c3e406075bfa1e02
Parent:        1f1c664b78d5f8464e0bbee5a00402cad93c7029
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu Aug 9 11:25:41 2012 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Thu Aug 9 16:24:42 2012 +0200

thin: fix condition for kernels without discards

Report warning if the kernel is not support given discards settings. (In this case the behavior is equal to IGNORE.)

---
 WHATS_NEW       |    1 +
 lib/thin/thin.c |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
WHATS_NEW +1 -0
index c7d3a2d..b0fa32f 100644
@@ -1,6 +1,7 @@
 Version 2.02.98
 =================================
   Use 'ignore' discards for thin metadata created with older versions.
+  Use proper condition to check for unsupported discards settings.
 
 Version 2.02.97 - 7th August 2012
 =================================
lib/thin/thin.c +2 -2
index 25c1947..d95b68e 100644
@@ -276,13 +276,13 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,
 					       seg->zero_new_blocks ? 0 : 1))
 		return_0;
 
-	if ((seg->discards != THIN_DISCARDS_PASSDOWN) && (attr & THIN_FEATURE_DISCARDS)) {
+	if (attr & THIN_FEATURE_DISCARDS) {
 		/* FIXME: Check whether underlying dev supports discards */
 		if (!dm_tree_node_set_thin_pool_discard(node,
 							seg->discards == THIN_DISCARDS_IGNORE,
 							seg->discards == THIN_DISCARDS_NO_PASSDOWN))
 			return_0;
-	} else
+	} else if (seg->discards != THIN_DISCARDS_IGNORE)
 		log_warn_suppress(_no_discards++, "WARNING: Thin pool target does "
 				  "not support discards (needs kernel >= 3.4).");