Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751145AbdHBEPv (ORCPT ); Wed, 2 Aug 2017 00:15:51 -0400 Received: from [183.91.158.132] ([183.91.158.132]:59502 "EHLO heian.cn.fujitsu.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751081AbdHBEPu (ORCPT ); Wed, 2 Aug 2017 00:15:50 -0400 X-IronPort-AV: E=Sophos;i="5.41,309,1498492800"; d="scan'208";a="22090086" Date: Wed, 2 Aug 2017 12:15:38 +0800 From: Lu Fengqi To: Akinobu Mita CC: , , Dmitry Vyukov Subject: Re: [PATCH] fault-inject: fix wrong should_fail() decision in task context Message-ID: <20170802041538.GE3359@fnst> References: <1501633700-3488-1-git-send-email-akinobu.mita@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1501633700-3488-1-git-send-email-akinobu.mita@gmail.com> User-Agent: Mutt/1.8.3 (2017-05-23) X-Originating-IP: [10.167.226.155] X-yoursite-MailScanner-ID: E44C046B5FD1.ABF47 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lufq.fnst@cn.fujitsu.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1428 Lines: 49 On Wed, Aug 02, 2017 at 09:28:20AM +0900, Akinobu Mita wrote: >Commit 1203c8e6fb0a ("fault-inject: simplify access check for fail-nth") >unintentionally broke a conditional statement in should_fail(). Any faults >are not injected in the task context by the change when the systematic >fault injection is not used. > >This change restores to the previous correct behaviour. > >Fixes: 1203c8e6fb0a ("fault-inject: simplify access check for fail-nth") >Cc: Dmitry Vyukov >Cc: Lu Fengqi >Reported-by: Lu Fengqi >Signed-off-by: Akinobu Mita >--- > lib/fault-inject.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > >diff --git a/lib/fault-inject.c b/lib/fault-inject.c >index 7d315fd..cf7b129 100644 >--- a/lib/fault-inject.c >+++ b/lib/fault-inject.c >@@ -110,10 +110,12 @@ bool should_fail(struct fault_attr *attr, ssize_t size) > if (in_task()) { > unsigned int fail_nth = READ_ONCE(current->fail_nth); > >- if (fail_nth && !WRITE_ONCE(current->fail_nth, fail_nth - 1)) >- goto fail; >+ if (fail_nth) { >+ if (!WRITE_ONCE(current->fail_nth, fail_nth - 1)) >+ goto fail; > >- return false; >+ return false; >+ } > } > > /* No need to check any other properties if the probability is 0 */ >-- >2.7.4 > > > With this fix, I can produce the IO ERROR by the fail_make_request. -- Thanks, Lu