From patchwork Tue Aug 22 16:52:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9915735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3FB16603FF for ; Tue, 22 Aug 2017 16:54:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4770328660 for ; Tue, 22 Aug 2017 16:54:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BFB1288FA; Tue, 22 Aug 2017 16:54:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C38728660 for ; Tue, 22 Aug 2017 16:54:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751244AbdHVQxx (ORCPT ); Tue, 22 Aug 2017 12:53:53 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:24498 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750962AbdHVQxw (ORCPT ); Tue, 22 Aug 2017 12:53:52 -0400 X-IronPort-AV: E=Sophos;i="5.41,412,1498492800"; d="scan'208";a="146773876" Received: from sjappemgw11.hgst.com (HELO sjappemgw12.hgst.com) ([199.255.44.62]) by ob1.hgst.iphmx.com with ESMTP; 23 Aug 2017 00:52:36 +0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.172.152]) by sjappemgw12.hgst.com with ESMTP; 22 Aug 2017 09:52:36 -0700 From: Bart Van Assche To: Andrew Morton Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Bart Van Assche , Dmitry Vyukov , Akinobu Mita , Michal Hocko Subject: [PATCH 1/2] fault-inject: Restore support for task-independent fault injection Date: Tue, 22 Aug 2017 09:52:35 -0700 Message-Id: <20170822165236.12275-2-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.0 In-Reply-To: <20170822165236.12275-1-bart.vanassche@wdc.com> References: <20170822165236.12275-1-bart.vanassche@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Certain faults should be injected independent of the context in which these occur. Commit e41d58185f14 made it impossible to inject faults independent of their context. Restore support for task-independent fault injection by adding the attribute 'global'. References: commit e41d58185f14 ("fault-inject: support systematic fault injection") Signed-off-by: Bart Van Assche Cc: Dmitry Vyukov Cc: Akinobu Mita Cc: Michal Hocko Cc: Andrew Morton --- include/linux/fault-inject.h | 9 +++++++-- lib/fault-inject.c | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/linux/fault-inject.h b/include/linux/fault-inject.h index 728d4e0292aa..8851646d2698 100644 --- a/include/linux/fault-inject.h +++ b/include/linux/fault-inject.h @@ -18,6 +18,7 @@ struct fault_attr { atomic_t times; atomic_t space; unsigned long verbose; + bool global; bool task_filter; unsigned long stacktrace_depth; unsigned long require_start; @@ -30,17 +31,21 @@ struct fault_attr { struct dentry *dname; }; -#define FAULT_ATTR_INITIALIZER { \ +#define FAULT_ATTR_INITIALIZER(__global) { \ .interval = 1, \ .times = ATOMIC_INIT(1), \ .require_end = ULONG_MAX, \ + .global = (__global), \ .stacktrace_depth = 32, \ .ratelimit_state = RATELIMIT_STATE_INIT_DISABLED, \ .verbose = 2, \ .dname = NULL, \ } -#define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER +#define DECLARE_FAULT_ATTR(name) \ + struct fault_attr name = FAULT_ATTR_INITIALIZER(false) +#define DECLARE_GLOBAL_FAULT_ATTR(name) \ + struct fault_attr name = FAULT_ATTR_INITIALIZER(true) int setup_fault_attr(struct fault_attr *attr, char *str); bool should_fail(struct fault_attr *attr, ssize_t size); diff --git a/lib/fault-inject.c b/lib/fault-inject.c index 7d315fdb9f13..c8f6ef5df3c6 100644 --- a/lib/fault-inject.c +++ b/lib/fault-inject.c @@ -107,7 +107,7 @@ static inline bool fail_stacktrace(struct fault_attr *attr) bool should_fail(struct fault_attr *attr, ssize_t size) { - if (in_task()) { + if (!attr->global && in_task()) { unsigned int fail_nth = READ_ONCE(current->fail_nth); if (fail_nth && !WRITE_ONCE(current->fail_nth, fail_nth - 1)) @@ -224,6 +224,8 @@ struct dentry *fault_create_debugfs_attr(const char *name, if (!debugfs_create_u32("verbose_ratelimit_burst", mode, dir, &attr->ratelimit_state.burst)) goto fail; + if (!debugfs_create_bool("global", mode, dir, &attr->global)) + goto fail; if (!debugfs_create_bool("task-filter", mode, dir, &attr->task_filter)) goto fail;