From patchwork Thu Apr 28 17:33:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 8973851 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 56332BF440 for ; Thu, 28 Apr 2016 17:34:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4CDE9202E9 for ; Thu, 28 Apr 2016 17:33:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 467E5202E5 for ; Thu, 28 Apr 2016 17:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753346AbcD1Rdz (ORCPT ); Thu, 28 Apr 2016 13:33:55 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:34678 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753355AbcD1Rdv (ORCPT ); Thu, 28 Apr 2016 13:33:51 -0400 Received: by mail-pf0-f172.google.com with SMTP id y69so36305243pfb.1 for ; Thu, 28 Apr 2016 10:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=1i1x1HhoVjrK52OeXXgC2Sx+yMcm5zw3iNExJJ0w+YE=; b=TLpwY4JymBDOt5WvFxqm9zCfmrXdzOP4TMBK5TcDmHOoHFWrKftvTXKH33cUk9Nq8a ZVSjnVgDR4BLYMsbTDxu+A+5uaZoDsOUBz7L2Epz2ccJt5258QK20ip4SFo4RHstX4+s TidaC3irZvnGtbX48JdOn4UmBEpQso6nZryqR+n47/es/W/KzZTAejW+HIGgXnEeeeFr tMmy8KWhjjos+SdybxAY6EuI5EwAkm4LxwIaWGlsRpexGfsykusRfzL6wYbjaTM9lvPU qTbIzdlfurvLIs02LbKopdHImYuYFQX9ahW53WxazL7H5A/m+NxX79cc+N8PKNtnN8RY 4SOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=1i1x1HhoVjrK52OeXXgC2Sx+yMcm5zw3iNExJJ0w+YE=; b=jrQOngfrI3WRYdpkWP7up5HDWd/5piaKcN/K3yZfCYDyyC7U6CmfcrHkem/IGYg+aR nD8hZY/SULjiThN8hghNq3KgNhOSbsSRPVJ6iZYiElB5EPxCzPjXyzWltsGe4eWHwt1F MewToEtHFO9EdvxY8jqJIluIKFwROiCtH+oXkFPzL+HGHFHg9lrk44PzIegA4v1xoJkP F/A5+KpAlon7KKMAwZG7C5rDaajX0K2csB4vTfcWi6DQsjbCRaaH4OQRY3Kn5tg/z6Up mX6NifCwGZcsZDFKDvl4CN7H9V0B4cjgjhLcsxZadPamnBU7W0Fq/ZbtluczEOi5rGJV OBBg== X-Gm-Message-State: AOPr4FVc7T21qd37ymugGbFRgLai7Uauf///Zg1rX0Cz82kyAtszbazv4SOABHO+Hv5n0tOJ X-Received: by 10.98.44.70 with SMTP id s67mr22380271pfs.59.1461864830561; Thu, 28 Apr 2016 10:33:50 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::c:8cff]) by smtp.gmail.com with ESMTPSA id ba9sm16842886pab.24.2016.04.28.10.33.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Apr 2016 10:33:49 -0700 (PDT) From: Omar Sandoval X-Google-Original-From: Omar Sandoval To: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org Cc: kernel-team@fb.com, Omar Sandoval Subject: [PATCH v2 2/2] btrfs: add test for replacing a missing device Date: Thu, 28 Apr 2016 10:33:37 -0700 Message-Id: <93ac31a65c1b4105064487927ce5a523959ae0b9.1461864695.git.osandov@fb.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 From: Omar Sandoval Now that _btrfs_get_profile_configs supports replace missing and the kernel doesn't crash when replacing a missing RAID 5/6 device, test it. Based on an earlier test from Wang Yanfeng. Reviewed-by: Josef Bacik Signed-off-by: Omar Sandoval --- tests/btrfs/027 | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/027.out | 2 + tests/btrfs/group | 1 + 3 files changed, 122 insertions(+) create mode 100755 tests/btrfs/027 create mode 100644 tests/btrfs/027.out diff --git a/tests/btrfs/027 b/tests/btrfs/027 new file mode 100755 index 000000000000..9f53d0fcdd89 --- /dev/null +++ b/tests/btrfs/027 @@ -0,0 +1,119 @@ +#! /bin/bash +# FS QA Test 027 +# +# Test replace of a missing device on various data and metadata profiles. +# +#----------------------------------------------------------------------- +# Copyright (c) 2016 Facebook. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +_supported_fs btrfs +_supported_os Linux +# we check scratch dev after each loop +_require_scratch_nocheck +_require_scratch_dev_pool 5 +_require_scratch_dev_pool_equal_size +_btrfs_get_profile_configs replace-missing +_require_command "$WIPEFS_PROG" wipefs + +run_test() +{ + local mkfs_opts=$1 + local saved_scratch_dev_pool=$SCRATCH_DEV_POOL + local replace_dev=`echo $SCRATCH_DEV_POOL | awk '{print $NF}'` + + echo "Test $mkfs_opts" >>$seqres.full + + SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | sed -e "s# *$replace_dev *##"` + _scratch_pool_mkfs $mkfs_opts >>$seqres.full 2>&1 + # make sure we created btrfs with desired options + if [ $? -ne 0 ]; then + echo "mkfs $mkfs_opts failed" + SCRATCH_DEV_POOL=$saved_scratch_dev_pool + return + fi + _scratch_mount >>$seqres.full 2>&1 + + local missing_dev=`echo $SCRATCH_DEV_POOL | awk '{print $2}'` + local missing_dev_id=`$BTRFS_UTIL_PROG fi show $SCRATCH_MNT | grep $missing_dev | awk '{print $2}'` + + # get some data on the filesystem so there's something to replace + dd if=/dev/urandom of="$SCRATCH_MNT"/file1 bs=1M count=1 \ + >>$seqres.full 2>&1 + dd if=/dev/urandom of="$SCRATCH_MNT"/file2 bs=1M count=2 \ + >>$seqres.full 2>&1 + dd if=/dev/urandom of="$SCRATCH_MNT"/file3 bs=1M count=4 \ + >>$seqres.full 2>&1 + + # nuke a device and remount in degraded mode + _scratch_unmount + $WIPEFS_PROG -a "$missing_dev" >>$seqres.full 2>&1 + _scratch_mount -o degraded >>$seqres.full 2>&1 + + # replace $missing_dev with $replace_dev and scrub it to double-check + $BTRFS_UTIL_PROG replace start -B -r $missing_dev_id $replace_dev \ + $SCRATCH_MNT -f >>$seqres.full 2>&1 + if [ $? -ne 0 ]; then + echo "btrfs replace failed" + SCRATCH_DEV_POOL=$saved_scratch_dev_pool + return + fi + $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >>$seqres.full 2>&1 + if [ $? -ne 0 ]; then + echo "btrfs scrub failed" + SCRATCH_DEV_POOL=$saved_scratch_dev_pool + return + fi + + _scratch_unmount + # we called _require_scratch_nocheck instead of _require_scratch + # do check after test for each profile config + _check_scratch_fs + SCRATCH_DEV_POOL=$saved_scratch_dev_pool +} + +echo "Silence is golden" +for t in "${_btrfs_profile_configs[@]}"; do + run_test "$t" +done + +status=0 +exit diff --git a/tests/btrfs/027.out b/tests/btrfs/027.out new file mode 100644 index 000000000000..ef78cdae50e8 --- /dev/null +++ b/tests/btrfs/027.out @@ -0,0 +1,2 @@ +QA output created by 027 +Silence is golden diff --git a/tests/btrfs/group b/tests/btrfs/group index 13aa1e57d61e..90af8fc2d106 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -29,6 +29,7 @@ 024 auto quick compress 025 auto quick send clone 026 auto quick compress prealloc +027 auto replace 029 auto quick clone 030 auto quick send 031 auto quick subvol clone