xfs
[Top] [All Lists]

[PATCH] xfstests: btrfs/004, fix failure with inlined file extents

To: xfs@xxxxxxxxxxx
Subject: [PATCH] xfstests: btrfs/004, fix failure with inlined file extents
From: Filipe David Borba Manana <fdmanana@xxxxxxxxx>
Date: Fri, 18 Apr 2014 04:39:46 +0100
Cc: linux-btrfs@xxxxxxxxxxxxxxx, jbacik@xxxxxx, Filipe David Borba Manana <fdmanana@xxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
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==
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 <fdmanana@xxxxxxxxx>
---
 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
-- 
1.9.1

<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH] xfstests: btrfs/004, fix failure with inlined file extents, Filipe David Borba Manana <=