From patchwork Thu Sep 22 19:34:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9346827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B59CE60757 for ; Thu, 22 Sep 2016 19:34:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BAB72ACB7 for ; Thu, 22 Sep 2016 19:34:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FCAB2ACCB; Thu, 22 Sep 2016 19:34:47 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 C49CB2ACB7 for ; Thu, 22 Sep 2016 19:34:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934791AbcIVTen (ORCPT ); Thu, 22 Sep 2016 15:34:43 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:33961 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934196AbcIVTem (ORCPT ); Thu, 22 Sep 2016 15:34:42 -0400 Received: by mail-pa0-f48.google.com with SMTP id wk8so32133224pab.1 for ; Thu, 22 Sep 2016 12:34:42 -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; bh=NaKEaJsz4dH5r9Qn1F+dB4nAI2FhFVSGLDSwJhX5vss=; b=CaKP0OjXxqkjUNlVJCTtZZSBDY0B/Qpw6PkF9mAxfHsxBiRcr9TQLMma5bnrpEmvdP l14uOJlaBqX4a7r2LT2gu63Cu5BZ7sN8I5YCdNJ5fzNMVjcbD5YF10iOeHF6U71mOgCs FJKU5C5zetyEjDtG5rjZ+M9+cgDt+it8QLqV+4vXaEq5xy5hbkOn737FjyfsZN7OYMs1 dtZEA4Y4XNYzokI/2WjTyZpGVHxma9AD7ed0ygm4BUNEgRdbOuTG8bLUlIxiYuANskHd wlOL9A/mXeinCepaK3Jm9pkjrXrBVTs3A+Dh8djqeIFxSV5eIK0VZjTEmeoWqCUw0ei7 rmbQ== 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; bh=NaKEaJsz4dH5r9Qn1F+dB4nAI2FhFVSGLDSwJhX5vss=; b=b9pb3aA0NT6bV5GSQxsD946vziX9+xxEO1H/eD4kU2nzOT7H+39gaqVyrJlQhJVQqj n4sVguQNWVX3hGTMxwgjnSlpLKgD9SC5ugkwC2nRpLWIYFGHt+J+JvIgOqZqka6UpJy9 yGhqIw5+dpIEuRZICzxTUrKDINGnbAT8AfeXwSNz1+b/bv8NSybXQEKbsmCxq0GmnF0Y rRp6GwvTNoYd/vYgj5wI2RZsOI0f4LV+/NKj0zE1QpO4Jvj36A6IZD6lADN2qVtdp581 rlwnnZo2HGU2Y2l0YW8JlHYOzOeAO/1GKQ4Nhu36l6j2nGSw3X7kFvanZocMcnNBdl7F 6WWQ== X-Gm-Message-State: AE9vXwOwdDZHI5h51Jo4rQXoAnzY3sDykjGuiD08K8NK9O3rUScs6AVEAzrbVt+4hRHXsYQM X-Received: by 10.66.150.169 with SMTP id uj9mr5977773pab.23.1474572881149; Thu, 22 Sep 2016 12:34:41 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::6:58ae]) by smtp.gmail.com with ESMTPSA id 83sm5963224pfv.17.2016.09.22.12.34.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 12:34:40 -0700 (PDT) From: Omar Sandoval To: linux-fstests@vger.kernel.org, linux-btrfs@vger.kernel.org Cc: kernel-team@fb.com Subject: [PATCH] btrfs: test free space tree mount options Date: Thu, 22 Sep 2016 12:34:36 -0700 Message-Id: X-Mailer: git-send-email 2.10.0 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 From: Omar Sandoval The behavior of different combinations of space_cache mount options wasn't well defined, which led to a regression between my initial patches adding the free space tree and the 4.5 release. Add a test to exercise all of the meaningful permutations of clear_cache, nospace_cache, and space_cache. This is a regression test for Linux kernel commit "Btrfs: fix mount -o clear_cache,space_cache=v2". Signed-off-by: Omar Sandoval --- The patch to fix this is coming out soon as part of my free space tree fixes. tests/btrfs/131 | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/131.out | 20 +++++++ tests/btrfs/group | 1 + 3 files changed, 171 insertions(+) create mode 100755 tests/btrfs/131 create mode 100644 tests/btrfs/131.out diff --git a/tests/btrfs/131 b/tests/btrfs/131 new file mode 100755 index 0000000..cc75153 --- /dev/null +++ b/tests/btrfs/131 @@ -0,0 +1,150 @@ +#! /bin/bash +# FS QA Test 131 +# +# Test free space tree mount options. +# +#----------------------------------------------------------------------- +# 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 +_require_scratch +_require_btrfs inspect-internal + +_mkfs_v1() { + _scratch_mkfs >/dev/null 2>&1 + # Future proof against btrfs-progs making space_cache=v2 filesystems by + # default. + _scratch_mount -o clear_cache,space_cache=v1 + _scratch_unmount +} + +_mkfs_v2() { + _scratch_mkfs >/dev/null 2>&1 + _scratch_mount -o space_cache=v2 + _scratch_unmount +} + +_check_fst_compat() { + compat_ro="$($BTRFS_UTIL_PROG inspect-internal dump-super "$SCRATCH_DEV" | \ + sed -rn 's/^compat_ro_flags\s+(.*)$/\1/p')" + if ((compat_ro & 0x1)); then + echo "free space tree is enabled" + else + echo "free space tree is disabled" + fi +} + +# Mount options might interfere. +export MOUNT_OPTIONS="" + +# When the free space tree is not enabled: +# -o space_cache=v1: keep using the old free space cache +# -o space_cache=v2: enable the free space tree +# -o clear_cache,space_cache=v2: clear the free space cache and enable the free space tree +# We don't check the no options case or plain space_cache as that will change +# in the future to turn on space_cache=v2. + +_mkfs_v1 +echo "Using free space cache" +_scratch_mount -o space_cache=v1 +_check_fst_compat +_scratch_unmount + +_mkfs_v1 +echo "Enabling free space tree" +_scratch_mount -o space_cache=v2 +_check_fst_compat +_scratch_unmount + +_mkfs_v1 +echo "Disabling free space cache and enabling free space tree" +_scratch_mount -o clear_cache,space_cache=v2 +_check_fst_compat +_scratch_unmount + +# When the free space tree is enabled: +# -o nospace_cache, -o space_cache=v1: error +# no options, -o space_cache=v2: keep using the free space tree +# -o clear_cache, -o clear_cache,space_cache=v2: clear and recreate the free space tree +# -o clear_cache,nospace_cache: clear the free space tree +# -o clear_cache,space_cache=v1: clear the free space tree, enable the free space cache + +_mkfs_v2 +echo "Trying to mount without free space tree" +_scratch_mount -o nospace_cache >/dev/null 2>&1 || echo "mount failed" +_scratch_mount -o space_cache=v1 >/dev/null 2>&1 || echo "mount failed" + +_mkfs_v2 +echo "Mounting existing free space tree" +_scratch_mount +_check_fst_compat +_scratch_unmount +_scratch_mount -o space_cache=v2 +_check_fst_compat +_scratch_unmount + +_mkfs_v2 +echo "Recreating free space tree" +_scratch_mount -o clear_cache,space_cache=v2 +_check_fst_compat +_scratch_unmount +_mkfs_v2 +_scratch_mount -o clear_cache +_check_fst_compat +_scratch_unmount + +_mkfs_v2 +echo "Disabling free space tree" +_scratch_mount -o clear_cache,nospace_cache +_check_fst_compat +_scratch_unmount + +_mkfs_v2 +echo "Reverting to free space cache" +_scratch_mount -o clear_cache,space_cache=v1 +_check_fst_compat +_scratch_unmount + +# success, all done +status=0 +exit diff --git a/tests/btrfs/131.out b/tests/btrfs/131.out new file mode 100644 index 0000000..aaa4a70 --- /dev/null +++ b/tests/btrfs/131.out @@ -0,0 +1,20 @@ +QA output created by 131 +Using free space cache +free space tree is disabled +Enabling free space tree +free space tree is enabled +Disabling free space cache and enabling free space tree +free space tree is enabled +Trying to mount without free space tree +mount failed +mount failed +Mounting existing free space tree +free space tree is enabled +free space tree is enabled +Recreating free space tree +free space tree is enabled +free space tree is enabled +Disabling free space tree +free space tree is disabled +Reverting to free space cache +free space tree is disabled diff --git a/tests/btrfs/group b/tests/btrfs/group index f3a7a4f..c090604 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -133,3 +133,4 @@ 128 auto quick send 129 auto quick send 130 auto clone send +131 auto quick