From patchwork Thu Jul 17 07:17:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 4572971 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AED97C0514 for ; Thu, 17 Jul 2014 06:56:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0CA020125 for ; Thu, 17 Jul 2014 06:56:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A79B2011B for ; Thu, 17 Jul 2014 06:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754267AbaGQG4u (ORCPT ); Thu, 17 Jul 2014 02:56:50 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:45023 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753658AbaGQG4t (ORCPT ); Thu, 17 Jul 2014 02:56:49 -0400 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s6H6umhO016604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 17 Jul 2014 06:56:49 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s6H6ulKn019527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 17 Jul 2014 06:56:47 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id s6H6uk4d019493; Thu, 17 Jul 2014 06:56:47 GMT Received: from OL.sg.oracle.com (/10.186.101.34) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 16 Jul 2014 23:56:45 -0700 From: Anand Jain To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org Subject: [PATCH] xfstests/btrfs: _devmgt_add() to check if the device is back online Date: Thu, 17 Jul 2014 15:17:41 +0800 Message-Id: <1405581461-12379-1-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.0.0.153.g79dcccc X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP btrfs/003 uses a method to remove the device as part of the test case, and after the test completes the removed device is added back to the system. However on certain system, albeit the slow running system the device comes back a bit later, and so the latter occurring sub-test with in the btrfs/003 fails. This patch adds script to wait and test if the device is back online, and thus report the same to to the full log. Signed-off-by: Anand Jain --- common/rc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/common/rc b/common/rc index 2c83340..4a6511f 100644 --- a/common/rc +++ b/common/rc @@ -2054,6 +2054,31 @@ _devmgt_add() tdl=`echo ${1} | cut -d":" -f 2-|sed 's/:/ /g'` echo ${tdl} > /sys/class/scsi_host/host${h}/scan || _fail "Add disk failed" + + # ensure the device comes online + dev_back_oneline=0 + for i in `seq 1 10`; do + if [ -d /sys/class/scsi_device/${1}/device/block ]; then + dev=`ls /sys/class/scsi_device/${1}/device/block` + for j in `seq 1 10`; + do + stat /dev/$dev > /dev/null 2>&1 + if [ $? -eq 0 ]; then + dev_back_oneline=1 + break + fi + sleep 1 + done + break + else + sleep 1 + fi + done + if [ $dev_back_oneline -eq 0 ]; then + echo "/dev/$dev online failed" >> $seqres.full + else + echo "/dev/$dev is back online" >> $seqres.full + fi } _require_fstrim()