[PATCH -next v2 2/4] fault-injection: skip stacktrace filtering by default

Wang Yufen posted 4 patches 2 years, 9 months ago
[PATCH -next v2 2/4] fault-injection: skip stacktrace filtering by default
Posted by Wang Yufen 2 years, 9 months ago
From: Wei Yongjun <weiyongjun1@huawei.com>

If FAULT_INJECTION_STACKTRACE_FILTER is enabled, the depth is default
to 32. This means fail_stacktrace() will iter each entry's stacktrace,
even if filter is not configured.

This patch change to quick return from fail_stacktrace() if stacktrace
filter is not set.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 lib/fault-inject.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index 1421818..fecc4d8 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -71,7 +71,7 @@ static bool fail_stacktrace(struct fault_attr *attr)
 	int n, nr_entries;
 	bool found = (attr->require_start == 0 && attr->require_end == ULONG_MAX);
 
-	if (depth == 0)
+	if (depth == 0 || (found && !attr->reject_start && !attr->reject_end))
 		return found;
 
 	nr_entries = stack_trace_save(entries, depth, 1);
-- 
1.8.3.1