From patchwork Wed Oct 24 04:31:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 10654163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A88913B5 for ; Wed, 24 Oct 2018 04:32:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 459EE2A11D for ; Wed, 24 Oct 2018 04:32:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A6312A130; Wed, 24 Oct 2018 04:32:04 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 5E5AF2A125 for ; Wed, 24 Oct 2018 04:32:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726285AbeJXM6W (ORCPT ); Wed, 24 Oct 2018 08:58:22 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:33710 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725928AbeJXM6W (ORCPT ); Wed, 24 Oct 2018 08:58:22 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9O4TSjA003166 for ; Wed, 24 Oct 2018 04:31:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=a35QQRyhcBJeTYt2wJIZ2jii2BXiCXNOq9VJ8o3vo24=; b=khtfAlY4U37IKxVsqLbFp7JilaBrdp01vSRhB9GOIuHHXUAlF60Gnkze24q4ISXv42Vd J+qCwkP9MeCD1g3q1yxiHyjJ6SGoDKsF/LHE2PdK02hUxVsrX7eVt9L0DqzomSAucNcL MiIyvlcAwsgUWHGGLbC0atkZ2456VSn887xD7u6iReXzZZVgo3pAf8eEmzmOR+uW6c0C 8fVaZ2ECM5EX9z4n+d4ta5/k9Mk+xZKsuytlMQbweHvQhwnlFzKmiDEspzuDFVI9+7f7 JFtSCUT7lxZbh6gqNAzmdHeIsP4aHk4fFN7rSzq9c6a9be5CUbNxXGZSYyM9kK2loQMu qg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2n7usu93qc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 24 Oct 2018 04:31:59 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9O4VwU4027983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 24 Oct 2018 04:31:58 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9O4VwsM020176 for ; Wed, 24 Oct 2018 04:31:58 GMT Received: from tpasj.oracle.com (/192.188.170.107) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 23 Oct 2018 21:31:58 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Subject: [PATCH] fstests: btrfs use forget if not reload Date: Wed, 24 Oct 2018 12:31:42 +0800 Message-Id: <1540355502-22489-4-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540355502-22489-1-git-send-email-anand.jain@oracle.com> References: <1540355502-22489-1-git-send-email-anand.jain@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9055 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810240039 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP btrfs reload was introduced to cleanup the device list inside the btrfs kernel module. The problem with the reload approach is that you can't run btrfs test cases 124,125, 154 and 164 on the system with btrfs as root fs. Now as we are introducing the btrfs forget feature as an btrfs device scan option [1], so here are its pertaining changes in the fstests. So these changes ensures we use the forget feature where available and if its not then falls back to the reload approach. [1] btrfs-progs: add cli to forget one or all scanned devices btrfs: introduce feature to forget a btrfs device Signed-off-by: Anand Jain --- common/btrfs | 20 ++++++++++++++++++++ tests/btrfs/124 | 6 +++--- tests/btrfs/125 | 6 +++--- tests/btrfs/154 | 6 +++--- tests/btrfs/164 | 4 ++-- 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/common/btrfs b/common/btrfs index 26dc0bb9600f..c7fbec11c8c1 100644 --- a/common/btrfs +++ b/common/btrfs @@ -374,3 +374,23 @@ _scratch_btrfs_sectorsize() $BTRFS_UTIL_PROG inspect-internal dump-super $SCRATCH_DEV |\ grep sectorsize | awk '{print $2}' } + +_btrfs_supports_forget() +{ + $BTRFS_UTIL_PROG device scan --help | grep -wq forget && \ + $BTRFS_UTIL_PROG device scan --forget > /dev/null 2>&1 +} + +_require_btrfs_forget_if_not_fs_loadable() +{ + _btrfs_supports_forget && return + + _require_loadable_fs_module "btrfs" +} + +_btrfs_forget_if_not_fs_reload() +{ + _btrfs_supports_forget && return + + _reload_fs_module "btrfs" +} diff --git a/tests/btrfs/124 b/tests/btrfs/124 index ce3ad6aa3a58..edbeff1443f5 100755 --- a/tests/btrfs/124 +++ b/tests/btrfs/124 @@ -51,7 +51,7 @@ _supported_fs btrfs _supported_os Linux _require_scratch_dev_pool 2 _test_unmount -_require_loadable_fs_module "btrfs" +_require_btrfs_forget_if_not_fs_loadable _scratch_dev_pool_get 2 @@ -86,7 +86,7 @@ echo "clean btrfs ko" >> $seqres.full _scratch_unmount # un-scan the btrfs devices -_reload_fs_module "btrfs" +_btrfs_forget_if_not_fs_reload echo >> $seqres.full echo "-----Write degraded mount fill upto $max_fs_sz bytes-----" >> $seqres.full @@ -125,7 +125,7 @@ echo echo "Mount degraded with the other dev" _scratch_unmount # un-scan the btrfs devices -_reload_fs_module "btrfs" +_btrfs_forget_if_not_fs_reload _mount -o degraded $dev2 $SCRATCH_MNT >>$seqres.full 2>&1 _run_btrfs_util_prog filesystem show checkpoint3=`md5sum $SCRATCH_MNT/tf2` diff --git a/tests/btrfs/125 b/tests/btrfs/125 index e38de264b28e..9161a2ddeaad 100755 --- a/tests/btrfs/125 +++ b/tests/btrfs/125 @@ -50,7 +50,7 @@ _supported_fs btrfs _supported_os Linux _require_scratch_dev_pool 3 _test_unmount -_require_loadable_fs_module "btrfs" +_require_btrfs_forget_if_not_fs_loadable _scratch_dev_pool_get 3 @@ -102,7 +102,7 @@ echo "unmount" >> $seqres.full _scratch_unmount echo "clean btrfs ko" >> $seqres.full # un-scan the btrfs devices -_reload_fs_module "btrfs" +_btrfs_forget_if_not_fs_reload _mount -o degraded,device=$dev2 $dev1 $SCRATCH_MNT >>$seqres.full 2>&1 dd if=/dev/zero of="$SCRATCH_MNT"/tf2 bs=$bs count=$count \ >>$seqres.full 2>&1 @@ -138,7 +138,7 @@ echo "Mount degraded but with other dev" _scratch_unmount # un-scan the btrfs devices -_reload_fs_module "btrfs" +_btrfs_forget_if_not_fs_reload _mount -o degraded,device=${dev2} $dev3 $SCRATCH_MNT >>$seqres.full 2>&1 diff --git a/tests/btrfs/154 b/tests/btrfs/154 index 99ea232aba4c..01745d20e9fc 100755 --- a/tests/btrfs/154 +++ b/tests/btrfs/154 @@ -36,7 +36,7 @@ rm -f $seqres.full _supported_fs btrfs _supported_os Linux _require_scratch_dev_pool 2 -_require_loadable_fs_module "btrfs" +_require_btrfs_forget_if_not_fs_loadable _scratch_dev_pool_get 2 @@ -90,7 +90,7 @@ degrade_mount_write() echo "clean btrfs ko" >> $seqres.full # un-scan the btrfs devices - _reload_fs_module "btrfs" + _btrfs_forget_if_not_fs_reload _mount -o degraded $DEV1 $SCRATCH_MNT >>$seqres.full 2>&1 cnt=$(( $COUNT/10 )) dd if=/dev/urandom of="$SCRATCH_MNT"/tf1 bs=$bs count=$cnt \ @@ -142,7 +142,7 @@ verify() echo "unmount" >> $seqres.full _scratch_unmount - _reload_fs_module "btrfs" + _btrfs_forget_if_not_fs_reload _mount -o degraded $DEV2 $SCRATCH_MNT >>$seqres.full 2>&1 verify_checkpoint1=`md5sum $SCRATCH_MNT/tf1` verify_checkpoint2=`md5sum $SCRATCH_MNT/tf2` diff --git a/tests/btrfs/164 b/tests/btrfs/164 index 097191a0e493..55042c4035e0 100755 --- a/tests/btrfs/164 +++ b/tests/btrfs/164 @@ -36,7 +36,7 @@ rm -f $seqres.full # Modify as appropriate. _supported_fs btrfs _supported_os Linux -_require_loadable_fs_module "btrfs" +_require_btrfs_forget_if_not_fs_loadable _require_scratch_dev_pool 2 _scratch_dev_pool_get 2 @@ -69,7 +69,7 @@ delete_seed() { _run_btrfs_util_prog device delete $dev_seed $SCRATCH_MNT _scratch_unmount - _reload_fs_module "btrfs" + _btrfs_forget_if_not_fs_reload run_check _mount $dev_sprout $SCRATCH_MNT _run_btrfs_util_prog filesystem show -m $SCRATCH_MNT echo -- sprout --