From patchwork Thu Sep 13 09:48:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 968945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429HzG1mblz9sB5 for ; Wed, 12 Sep 2018 20:27:35 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 653283E60CD for ; Wed, 12 Sep 2018 12:27:32 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id E846B3E60B0 for ; Wed, 12 Sep 2018 12:27:30 +0200 (CEST) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-7.smtp.seeweb.it (Postfix) with ESMTP id 4680D200FF2 for ; Wed, 12 Sep 2018 12:27:28 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="44824227" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 12 Sep 2018 18:27:26 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id D213A4B69E01 for ; Wed, 12 Sep 2018 18:27:25 +0800 (CST) Received: from RHEL7U5GA_Intel64.g08.fujitsu.local (10.167.220.156) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 12 Sep 2018 18:27:24 +0800 From: Xiao Yang To: Date: Thu, 13 Sep 2018 17:48:05 +0800 Message-ID: <1536832085-8071-1-git-send-email-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.167.220.156] X-yoursite-MailScanner-ID: D213A4B69E01.A8667 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com X-Spam-Status: No, score=2.5 required=7.0 tests=DATE_IN_FUTURE_12_24 autolearn=disabled version=3.4.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH] lib/tst_device.c: Make sure all loop deivces fot test are detached X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Running statx05 by runltp without -b option every time attached a loop device but didn't detach it, as below: ------------------------------------------------------------------ ... tst_device.c:230: INFO: Using test device LTP_DEV='/dev/loop0' tst_device.c:268: INFO: Skipping $LTP_DEV size 256MB, requested size 512MB tst_device.c:83: INFO: Found free device '/dev/loop1' tst_mkfs.c:83: INFO: Formatting /dev/loop1 with ext4 opts='' extra opts='-O encrypt' ... NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO /dev/loop1 0 0 0 0 /tmp/ltp-gsrcFAkGpZ/Wka3bp/test_dev.img (deleted) 0 ------------------------------------------------------------------ runltp created a block device with default 256M size by attaching a free loop device and set LTP_DEV variable, but statx05 needed a 512M block device, so tst_acquire_device__() in setup skipped the $LTP_DEV device and created another block device with 512M size by attaching another free loop device. Unfortunately, tst_release_device() in cleanup cannot detach the 512M block device due to the defined LTP_DEV. We should just skip the detach in tst_release_device() when LTP_DEV variable is set and device_acquired flag is not set. Signed-off-by: Xiao Yang --- lib/tst_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tst_device.c b/lib/tst_device.c index 463743443..23c99dba2 100644 --- a/lib/tst_device.c +++ b/lib/tst_device.c @@ -313,7 +313,7 @@ int tst_release_device(const char *dev) { int ret; - if (getenv("LTP_DEV")) + if (getenv("LTP_DEV") && !device_acquired) return 0; /*