From patchwork Mon Oct 23 20:57:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 10023271 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 8C2DB60381 for ; Mon, 23 Oct 2017 22:00:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C21B28634 for ; Mon, 23 Oct 2017 22:00:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D27B28748; Mon, 23 Oct 2017 22:00:16 +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, UNPARSEABLE_RELAY 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 30D6528634 for ; Mon, 23 Oct 2017 22:00:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751691AbdJWWAO (ORCPT ); Mon, 23 Oct 2017 18:00:14 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:26733 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751662AbdJWWAO (ORCPT ); Mon, 23 Oct 2017 18:00:14 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9NM0DUJ029128 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Oct 2017 22:00:13 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v9NM0C7s002646 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Oct 2017 22:00:13 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v9NM0CnY027286; Mon, 23 Oct 2017 22:00:12 GMT Received: from dhcp-10-211-47-181.usdhcp.oraclecorp.com.com (/10.211.47.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 23 Oct 2017 15:00:12 -0700 From: Liu Bo To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH] fstests: btrfs/143: make test case more reliable Date: Mon, 23 Oct 2017 14:57:33 -0600 Message-Id: <20171023205733.14896-1-bo.li.liu@oracle.com> X-Mailer: git-send-email 2.9.4 X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently drop_caches is used to invalidate file's page cache so that buffered read can hit disk, but the problem is that it may also invalidate metadata's page cache, so the test case may not get read errors (and repair) if reading metadata has consumed the injected faults. This changes it to do 'fadvise -d' to firstly access all metadata it needs to locate the file and then only drops the test file's page cache. Also this changes it to read the file only if pid%2 == 1. Reported-by: Nikolay Borisov Signed-off-by: Liu Bo Tested-by: Nikolay Borisov --- tests/btrfs/143 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/btrfs/143 b/tests/btrfs/143 index da7bfd8..dabd03d 100755 --- a/tests/btrfs/143 +++ b/tests/btrfs/143 @@ -127,16 +127,16 @@ echo "step 3......repair the bad copy" >>$seqres.full # since raid1 consists of two copies, and the bad copy was put on stripe #1 # while the good copy lies on stripe #0, the bad copy only gets access when the # reader's pid % 2 == 1 is true -while true; do - # start_fail only fails the following buffered read so the repair is - # supposed to work. - echo 3 > /proc/sys/vm/drop_caches - start_fail - $XFS_IO_PROG -c "pread 0 4K" "$SCRATCH_MNT/foobar" > /dev/null & - pid=$! - wait - stop_fail - [ $((pid % 2)) == 1 ] && break +while [[ -z ${result} ]]; do + # invalidate the page cache. + $XFS_IO_PROG -c "fadvise -d 0 128K" $SCRATCH_MNT/foobar + + start_fail + result=$(bash -c " + if [[ \$((\$\$ % 2)) -eq 1 ]]; then + exec $XFS_IO_PROG -c \"pread 0 4K\" \"$SCRATCH_MNT/foobar\" + fi"); + stop_fail done _scratch_unmount