From patchwork Sat Feb 8 08:30:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koen De Wit X-Patchwork-Id: 3609771 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D30DC9F2D6 for ; Sat, 8 Feb 2014 08:31:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E096B201BB for ; Sat, 8 Feb 2014 08:31:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C3AF32017E for ; Sat, 8 Feb 2014 08:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751438AbaBHIa7 (ORCPT ); Sat, 8 Feb 2014 03:30:59 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:30812 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751414AbaBHIar (ORCPT ); Sat, 8 Feb 2014 03:30:47 -0500 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s188Ui3k022941 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 8 Feb 2014 08:30:45 GMT Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s188UixP011778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 8 Feb 2014 08:30:44 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s188UiKp011772; Sat, 8 Feb 2014 08:30:44 GMT Received: from koen-obi.localdomain (/178.116.134.76) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 08 Feb 2014 00:30:43 -0800 From: Koen De Wit To: xfs@oss.sgi.com Cc: linux-btrfs@vger.kernel.org, Koen De Wit Subject: [PATCH v2] xfstests: Btrfs: add test for large metadata blocks Date: Sat, 8 Feb 2014 09:30:30 +0100 Message-Id: <1391848230-26761-1-git-send-email-koen.de.wit@oracle.com> X-Mailer: git-send-email 1.7.1 X-Source-IP: acsinet21.oracle.com [141.146.126.237] 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.4 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 Tests Btrfs filesystems with all possible metadata block sizes, by setting large extended attributes on files. Signed-off-by: Koen De Wit --- v1->v2: - Fix indentation: 8 spaces instead of 4 - Move _scratch_unmount to end of loop, add _check_scratch_fs - Sending failure messages of mkfs.btrfs to output instead of $seqres.full diff --git a/tests/btrfs/036 b/tests/btrfs/036 new file mode 100644 index 0000000..b14697d --- /dev/null +++ b/tests/btrfs/036 @@ -0,0 +1,137 @@ +#! /bin/bash +# FS QA Test No. 036 +# +# Tests large metadata blocks in btrfs, which allows large extended +# attributes. +# +#----------------------------------------------------------------------- +# Copyright (c) 2014, Oracle and/or its affiliates. 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` +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here + +_supported_fs btrfs +_supported_os Linux +_require_scratch +_need_to_be_root + +rm -f $seqres.full + +pagesize=`$here/src/feature -s` +pagesize_kb=`expr $pagesize / 1024` + +# Test all valid leafsizes +for leafsize in `seq $pagesize_kb $pagesize_kb 64`; do + _scratch_mkfs -l ${leafsize}K >/dev/null + _scratch_mount + # Calculate the size of the extended attribute value, leaving + # 512 bytes for other metadata. + xattr_size=`expr $leafsize \* 1024 - 512` + + touch $SCRATCH_MNT/emptyfile + # smallfile will be inlined, bigfile not. + $XFS_IO_PROG -f -c "pwrite 0 100" $SCRATCH_MNT/smallfile \ + >/dev/null + $XFS_IO_PROG -f -c "pwrite 0 9000" $SCRATCH_MNT/bigfile \ + >/dev/null + ln -s $SCRATCH_MNT/bigfile $SCRATCH_MNT/bigfile_softlink + + files=(emptyfile smallfile bigfile bigfile_softlink) + chars=(a b c d) + for i in `seq 0 1 3`; do + char=${chars[$i]} + file=$SCRATCH_MNT/${files[$i]} + lnkfile=${file}_hardlink + ln $file $lnkfile + xattr_value=`head -c $xattr_size < /dev/zero \ + | tr '\0' $char` + + set_md5=`echo -n "$xattr_value" | md5sum` + ${ATTR_PROG} -Lq -s attr_$char -V $xattr_value $file + get_md5=`${ATTR_PROG} -Lq -g attr_$char $file | md5sum` + get_ln_md5=`${ATTR_PROG} -Lq -g attr_$char $lnkfile \ + | md5sum` + + # Using md5sums for comparison instead of the values + # themselves because bash command lines cannot be larger + # than 64K chars. + if [ "$set_md5" != "$get_md5" ]; then + echo -n "Got unexpected xattr value for " + echo -n "attr_$char from file ${file}. " + echo "(leafsize is ${leafsize}K)" + fi + if [ "$set_md5" != "$get_ln_md5" ]; then + echo -n "Value for attr_$char differs for " + echo -n "$file and ${lnkfile}. " + echo "(leafsize is ${leafsize}K)" + fi + done + + # Test attributes with a size larger than the leafsize. + # Should result in an error. + if [ "$leafsize" -lt "64" ]; then + # Bash command lines cannot be larger than 64K + # characters, so we do not test attribute values + # with a size >64KB. + xattr_size=`expr $leafsize \* 1024 + 512` + xattr_value=`head -c $xattr_size < /dev/zero | tr '\0' x` + ${ATTR_PROG} -q -s attr_toobig -V $xattr_value \ + $SCRATCH_MNT/emptyfile >> $seqres.full 2>&1 + if [ "$?" -eq "0" ]; then + echo -n "Expected error, xattr_size is bigger " + echo "than ${leafsize}K" + fi + fi + + _scratch_unmount >/dev/null 2>&1 + _check_scratch_fs +done + +_scratch_mount + +# Illegal attribute name (more than 256 characters) +attr_name=`head -c 260 < /dev/zero | tr '\0' n` +${ATTR_PROG} -s $attr_name -V attribute_name_too_big \ + $SCRATCH_MNT/emptyfile 2>&1 | head -n 1 + +_scratch_unmount + +_filter_size_numbers() { + sed "s/$pagesize/PAGESIZE/g" | sed "s/$1/LEAFSIZE/g" +} + +# Some illegal leafsizes +_scratch_mkfs -l 0 2>&1 | _filter_size_numbers 0 +_scratch_mkfs -l 5678 2>&1 | _filter_size_numbers 5678 +lsize=`expr $pagesize / 2 + $pagesize` +_scratch_mkfs -l $lsize 2>&1 | _filter_size_numbers $lsize +_scratch_mkfs -l 128K 2>&1 | _filter_size_numbers 131072 +_scratch_mkfs -l K + +# success, all done +status=0 +exit diff --git a/tests/btrfs/036.out b/tests/btrfs/036.out new file mode 100644 index 0000000..7e88d54 --- /dev/null +++ b/tests/btrfs/036.out @@ -0,0 +1,7 @@ +QA output created by 036 +attr_set: Invalid argument +Illegal leafsize (or nodesize) LEAFSIZE (smaller than PAGESIZE) +Illegal leafsize (or nodesize) LEAFSIZE (not align to PAGESIZE) +Illegal leafsize (or nodesize) LEAFSIZE (not align to PAGESIZE) +Illegal leafsize (or nodesize) LEAFSIZE (larger than 65536) +ERROR: size value is empty diff --git a/tests/btrfs/group b/tests/btrfs/group index f9f062f..2ca2225 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -37,3 +37,4 @@ 032 auto quick 033 auto quick 034 auto quick +036 auto quick