From patchwork Tue Jul 25 18:06:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tahsin Erdogan X-Patchwork-Id: 9862637 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 41ED2601A1 for ; Tue, 25 Jul 2017 18:06:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 381CC26E76 for ; Tue, 25 Jul 2017 18:06:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D04E286F5; Tue, 25 Jul 2017 18:06:23 +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_ADSP_CUSTOM_MED, 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 8C0E526E76 for ; Tue, 25 Jul 2017 18:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751632AbdGYSGV (ORCPT ); Tue, 25 Jul 2017 14:06:21 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:33254 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751682AbdGYSGU (ORCPT ); Tue, 25 Jul 2017 14:06:20 -0400 Received: by mail-pf0-f175.google.com with SMTP id s70so61271808pfs.0 for ; Tue, 25 Jul 2017 11:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fxoVgwrTZ6VC4miChM9fWDpQU/7KK7MoaUUMu16Lea4=; b=c67nxUhuZDGov+QEVRc7Q437UIZsDGlJ3uNjwb5aDkMpPrz2Hbg0DZ+i55FvRbhI3h vqCzOyjlZWhM97UoUMFJJxGVsCeqlbfRgLIXg8GGz2ObKuzsa8gLDZCOeLn1SP1oYqgB HmOJDWatiVOcfAWZ8ROkC25NOCyjsUXVhWtsWZmULq0nWhcYotNBqxmZVLln7xTnYO6E yphdxxlz05j1Rx6027gv+/sq54mil2OKqAiwHqT9bM43FbsJBTgHaYdLLlyamDqEWxt7 hwONFsbLTVlfqW7etlsgXMkPQbIBPUlvUpB4HUK72k0/ukqeXLDk5hFIaWg15m5le5A9 m7Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fxoVgwrTZ6VC4miChM9fWDpQU/7KK7MoaUUMu16Lea4=; b=bAhIYMJyzPJxFnJV5tj7fSklxBLUiqu0kAoBvzIBOsa47cORnZuj1j32luOTJMQhhS CJcyzh+TibIgb8+6CM4eNPHM31OleIsNFxeYJ996garovC/cTm5PArUpHES+SLQftlNo V2hhC/yKnv6yjWK69W3Juz1fLWS6zCC1y9dNuv15821T2TlzubtOU2rQNgL8K4aa66vR 64MZdgwRsA33KfOC/KUPtXu54z23Is/vWsaon8dRQWGgQotnu1uFaDNderxcDDZykyja sqSKKwGFwdOEH9lE3ElsSZoLOaHMj0Zelx0772lG9RcHoiTMho3ROe3U+0EdWD/Wakrd ypLA== X-Gm-Message-State: AIVw112GGNAMFNL6xIes7QQRBtmbk5L8x7W+ABAsFtCQ6VT3T4qgA0zP 0zsjoINvRUgTM1ik X-Received: by 10.84.131.163 with SMTP id d32mr21998756pld.16.1501005978962; Tue, 25 Jul 2017 11:06:18 -0700 (PDT) Received: from tahsin1.svl.corp.google.com ([100.123.230.167]) by smtp.gmail.com with ESMTPSA id j1sm25034400pgs.77.2017.07.25.11.06.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 11:06:18 -0700 (PDT) From: Tahsin Erdogan To: Eryu Guan , Theodore Ts'o , Andreas Dilger , fstests@vger.kernel.org Cc: Tahsin Erdogan Subject: [PATCH v2] ext4: add a test for ea_inode feature Date: Tue, 25 Jul 2017 11:06:15 -0700 Message-Id: <20170725180615.8091-1-tahsin@google.com> X-Mailer: git-send-email 2.14.0.rc0.284.gd933b75aa4-goog In-Reply-To: <20170725180528.7829-1-tahsin@google.com> References: <20170725180528.7829-1-tahsin@google.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ea_inode feature supports creating extended attributes with values greater than the fs block size. This test exercises some common scenarios: - Extended attibute being placed in inode vs xattr block - Removing extended attribute - Removing a file that has an extended attribute - Multiple files having identical large attribute values - Repeatedly setting an extended attribute with various sizes Signed-off-by: Tahsin Erdogan --- v2: - Expanded test description in the script - Added comments for inode and block size selection - replaced getfattr/setfattr with GETFATTR_PROG/SETFATTR_PROG - fixed unquoted variable comparison tests/ext4/026 | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/026.out | 29 +++++++++++ tests/ext4/group | 1 + 3 files changed, 172 insertions(+) create mode 100755 tests/ext4/026 create mode 100644 tests/ext4/026.out diff --git a/tests/ext4/026 b/tests/ext4/026 new file mode 100755 index 000000000000..c41bb6fa6b88 --- /dev/null +++ b/tests/ext4/026 @@ -0,0 +1,142 @@ +#! /bin/bash +# FS QA Test 026 +# +# Test for ea_inode feature in ext4. Without ea_inode feature, an extended +# attribute in ext4 cannot be larger than the fs block size. ea_inode feature +# allows storing xattr values in external inodes and so raises xattr value +# size limit to 64k. +# +#----------------------------------------------------------------------- +# Copyright (c) 2017 Google, Inc. 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" + +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs ext4 +_supported_os Linux +_require_scratch +_require_attrs +_require_ext4_mkfs_feature ea_inode + +# Set inode size to 256 so that there is room for storing some extended +# attributes in the inode body. +# The block size is explicitly set 4k so that xattr value sizes can be hardcoded +# throughout the test. Otherwise, the selection of block size is not that +# important for the purposes of this test. +_scratch_mkfs_ext4 -O ea_inode -I 256 -b 4096 >/dev/null 2>&1 +_scratch_mount + +# Sets an extended attribute on a file. +attr_set() +{ + local file=$1 name=$2 value=$3 tmp + + if [[ "$value" != "" ]]; then + $SETFATTR_PROG -n $name -v "$value" $file + else + $SETFATTR_PROG -n $name $file + fi + + tmp=$($GETFATTR_PROG --absolute-names --only-values -n $name $file) + [[ "$tmp" == "$value" ]] || echo "unexpected value returned: $tmp" +} + +# List attributes on a file. +attr_list() +{ + $GETFATTR_PROG --absolute-names $1 | grep -v '^#' +} + +# Removes an extended attribute from a file. +attr_remove() +{ + local file=$1 name=$2 + + $SETFATTR_PROG -x $name $file +} + +# Test files. +x=$SCRATCH_MNT/x +y=$SCRATCH_MNT/y +z=$SCRATCH_MNT/z + +# Attribute with short name that goes into inode body. +name_in_ibody=user.i + +# Attribute with long name that goes into xattr block. +name_in_block=user.$(perl -e 'print "b" x 100;') + +# Set large xattr values on multiple files. +touch $x $y $z +for file in $x $y $z; do + for name in $name_in_ibody $name_in_block; do + for size in 4096 8000 $((64*1024)); do + attr_set $file $name-$size \ + $(perl -e "print 'v' x $size;") + done + done + attr_list $file +done +rm $x $y $z + +# Set/remove. +touch $x +attr_set $x $name_in_ibody $(perl -e "print 'i' x 25000;") +attr_set $x $name_in_block $(perl -e "print 'b' x 25000;") +attr_list $x +attr_remove $x $name_in_ibody +attr_remove $x $name_in_block +rm $x + +# Set with same value twice. +touch $x +attr_set $x $name_in_ibody $(perl -e "print 'i' x 60000;") +attr_set $x $name_in_ibody $(perl -e "print 'i' x 60000;") +attr_list $x +rm $x + +# Repeatedly set an extended attribute with various value sizes. +touch $x +for size in 0 10 40 80 3000 9000 60 10000 9000 0 8000 3000 10 0 20 10000 5; do + attr_set $x user.1 $(perl -e "print 'v' x $size;") +done +attr_list $x +rm $x + +# success, all done +status=0 +exit diff --git a/tests/ext4/026.out b/tests/ext4/026.out new file mode 100644 index 000000000000..5b94f3e2e4ea --- /dev/null +++ b/tests/ext4/026.out @@ -0,0 +1,29 @@ +QA output created by 026 +user.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-4096 +user.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-65536 +user.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-8000 +user.i-4096 +user.i-65536 +user.i-8000 + +user.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-4096 +user.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-65536 +user.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-8000 +user.i-4096 +user.i-65536 +user.i-8000 + +user.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-4096 +user.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-65536 +user.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb-8000 +user.i-4096 +user.i-65536 +user.i-8000 + +user.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +user.i + +user.i + +user.1 + diff --git a/tests/ext4/group b/tests/ext4/group index 664c0591e345..9aed07e271fe 100644 --- a/tests/ext4/group +++ b/tests/ext4/group @@ -28,6 +28,7 @@ 023 auto quick scrub 024 auto quick encrypt dangerous 025 auto quick fuzzers dangerous +026 auto quick attr 271 auto rw quick 301 aio auto ioctl rw stress defrag 302 aio auto ioctl rw stress defrag