From patchwork Tue Sep 3 22:19:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Mahoney X-Patchwork-Id: 2853431 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 B807EC0AB5 for ; Tue, 3 Sep 2013 22:19:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C82020319 for ; Tue, 3 Sep 2013 22:19:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4FD6201E0 for ; Tue, 3 Sep 2013 22:19:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755254Ab3ICWTK (ORCPT ); Tue, 3 Sep 2013 18:19:10 -0400 Received: from cantor2.suse.de ([195.135.220.15]:58071 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754129Ab3ICWTJ (ORCPT ); Tue, 3 Sep 2013 18:19:09 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CD30AA51BB; Wed, 4 Sep 2013 00:19:07 +0200 (CEST) Message-ID: <52266055.9050004@suse.com> Date: Tue, 03 Sep 2013 18:19:01 -0400 From: Jeff Mahoney User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Linux FS Maling List , linux-btrfs Subject: [PATCH] xfstests: fix device lookup in btrfs/003 X-Enigmail-Version: 1.5.2 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-9.3 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 The DEVHTL lookup in btrfs/003 is broken. It can only handle full LUNs and not partitions on a disk. Rather than returning 2:0:0:0 for /dev/sdc7, it returns 'block' and we see: ./common/rc: line 2081: /sys/class/scsi_device/block/device/delete: No such file or directory If we look up the device by dev instead of by name, we can handle working with full disks and partitions more easily and get the ability to use any device name rather than just the ones that match sysfs. Signed-off-by: Jeff Mahoney --- tests/btrfs/003 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) -- Jeff Mahoney SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/tests/btrfs/003 +++ b/tests/btrfs/003 @@ -137,9 +137,21 @@ _test_replace() #pick the 2nd last disk ds=${devs[@]:$(($n-1)):1} - # retrive the HTL for this scsi disk - d=`echo $ds|cut -d"/" -f3` - DEVHTL=`ls -l /sys/class/block/${d} | rev | cut -d "/" -f 3 | rev` + HEXMAJOR="$(stat -c "%t" "$ds")" + HEXMINOR="$(stat -c "%T" "$ds")" + if [ -z "$HEXMAJOR" -o -z "$HEXMINOR" ]; then + _fail "tr: HEXMAJOR and/or HEXMINOR is unset for $ds" + fi + + DIR="/sys/dev/block/$(( 0x$HEXMAJOR )):$(( 0x$HEXMINOR ))" + + if [ -L "$DIR/device" ]; then # whole disk + DEVHTL="$(basename $(readlink "$DIR/device"))" + elif [ -L "$DIR/../device" ]; then # partition + DEVHTL="$(basename $(readlink "$DIR/../device"))" + else + _fail "tr: Can't locate device backing $ds" + fi #fail disk _devmgt_remove ${DEVHTL}