From patchwork Fri Apr 18 03:39:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4012981 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 E4E249F2CC for ; Fri, 18 Apr 2014 02:40:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6B1A20328 for ; Fri, 18 Apr 2014 02:40:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E142D202EC for ; Fri, 18 Apr 2014 02:40:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbaDRCj7 (ORCPT ); Thu, 17 Apr 2014 22:39:59 -0400 Received: from mail-we0-f171.google.com ([74.125.82.171]:34799 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbaDRCj5 (ORCPT ); Thu, 17 Apr 2014 22:39:57 -0400 Received: by mail-we0-f171.google.com with SMTP id t61so1150264wes.30 for ; Thu, 17 Apr 2014 19:39:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=CpF0TNmYOSzbU0vanyp9OQyIllrczCNK7tdHi/NtpZY=; b=TFTI/HuosDHYyWoh/CoiA2Trx0PBH+DHZ6vfuHk9Xm0EX7BbRAJd3xIWq3WeThrjPp C8pznhRWhfS3RXBZrUsa49PtL44wHLz+ClV9HVL5ncKDrX824CckCg1Ce7hdrJ/i67oe GogN38U8wUYBzbEUOb3HuvfGGjyGXduNd4yCBkKsRWXIyzHWJhpdhqRGIuqZcQfMGJrt 3Ck1ubjbj8fa0Pd5HYn0jZof9Q6JwH3ezCuoyIREFfmfY8MS/3xMrbrDV4w5Cw6SmU9s cNMFyN7tE06Q1mbNaxq6BMmfEDe6m/lpRFQ+tnLtCkqlTHiA1XznE9azP2RYZVb75mXA BzIw== X-Received: by 10.194.109.227 with SMTP id hv3mr14685050wjb.10.1397788796648; Thu, 17 Apr 2014 19:39:56 -0700 (PDT) Received: from debian-vm3.lan (bl10-198-83.dsl.telepac.pt. [85.243.198.83]) by mx.google.com with ESMTPSA id b2sm487827wiz.15.2014.04.17.19.39.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Apr 2014 19:39:55 -0700 (PDT) From: Filipe David Borba Manana To: xfs@oss.sgi.com Cc: linux-btrfs@vger.kernel.org, jbacik@fb.com, Filipe David Borba Manana Subject: [PATCH] xfstests: btrfs/004, fix failure with inlined file extents Date: Fri, 18 Apr 2014 04:39:46 +0100 Message-Id: <1397792386-18316-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 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, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 Files that consist of an inline extent, have the corresponding data in the filesystem btree and not on a dedicated extent. For such extents filefrag (fiemap) will report a physical location of 0 for that extent and set the 'inline' flag. The btrfs inspect-internal logical-resolve command will cause a lookup in the extent tree for the extent address we give it as an argument, which fails with errno ENOENT if it is 0. This error didn't happen always, as the test uses fsstress to generate a random filesystem, which needed to generate at least one file that could be inlined (content less than 4018 bytes). Example, taken from results/btrfs/004.full: # filefrag -v /home/fdmanana/btrfs-tests/scratch_1/snap1/p0/de/d1b/dcb/fb1 Filesystem type is: 9123683e File size of /home/fdmanana/btrfs-tests/scratch_1/snap1/p0/de/d1b/dcb/fb1 is 3860 (1 block of 4096 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 4095: 0.. 4095: 4096: not_aligned,inline,eof 1: 280.. 344: 35190.. 35254: 65: 1: eof /home/fdmanana/btrfs-tests/scratch_1/snap1/p0/de/d1b/dcb/fb1: 2 extents found after filter: 0#0#0 0#0#0 # stat -c %i /home/fdmanana/btrfs-tests/scratch_1/snap1/p0/de/d1b/dcb/fb1 403 # /home/fdmanana/git/hub/btrfs-progs/btrfs inspect-internal logical-resolve -P 0 /home/fdmanana/btrfs-tests/scratch_1 ioctl ret=-1, error: No such file or directory Signed-off-by: Filipe David Borba Manana --- tests/btrfs/004 | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/btrfs/004 b/tests/btrfs/004 index 670e1c2..1d5b816 100755 --- a/tests/btrfs/004 +++ b/tests/btrfs/004 @@ -65,9 +65,11 @@ FILEFRAG_FILTER=' ($ext, $logical, $physical, $length) = (/^\s*(\d+):\s+(\d+)..\s+\d+:\s+(\d+)..\s+\d+:\s+(\d+):/) or next; + ($flags) = /.*:\s*(\S*)$/; print $physical * $blocksize, "#", $length * $blocksize, "#", - $logical * $blocksize, " "' + $logical * $blocksize, "#", + $flags, " "' # this makes filefrag output script readable by using a perl helper. # output is one extent per line, with three numbers separated by '#' @@ -230,16 +232,26 @@ workout() continue; fi for i in $extents; do - physical=$i - length=$i - logical=$i - physical=`echo $physical | sed -e 's/#.*//'` - length=`echo $length | sed -e 's/[^#]+#//'` - length=`echo $length | sed -e 's/#.*//'` - logical=`echo $logical | sed -e 's/.*#//'` - _btrfs_inspect_check $file $physical $length $logical \ - $snap_name - ret=$? + physical=`echo $i | cut -d '#' -f 1` + length=`echo $i | cut -d '#' -f 2` + logical=`echo $i | cut -d '#' -f 3` + flags=`echo $i | cut -d '#' -f 4` + # Skip inline extents, otherwise btrfs inspect-internal + # logical-resolve will fail (with errno ENOENT), as it + # can't find an extent with a start address of 0 in the + # extent tree. + if [ $physical -eq 0 ]; then + echo "$flags" | grep -E '(^|,)inline(,|$)' \ + > /dev/null + ret=$? + if [ $ret -ne 0 ]; then + echo "Unexpected physical address 0 for non-inline extent, file $file, flags $flags" + fi + else + _btrfs_inspect_check $file $physical $length \ + $logical $snap_name + ret=$? + fi if [ $ret -ne 0 ]; then errcnt=`expr $errcnt + 1` fi