diff mbox

[2/2] xfstests,btrfs/004: use FILEFRAG_PROG macro

Message ID 1412764522-15754-2-git-send-email-wangshilong1991@gmail.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Wang Shilong Oct. 8, 2014, 10:35 a.m. UTC
Signed-off-by: Wang Shilong <wangshilong1991@gmail.com>
---
i didn't find a way to remove filefrag here, but let us
use macro firstly...
---
 tests/btrfs/004 | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Dave Chinner Oct. 8, 2014, 4:20 a.m. UTC | #1
On Wed, Oct 08, 2014 at 06:35:22AM -0400, Wang Shilong wrote:
> Signed-off-by: Wang Shilong <wangshilong1991@gmail.com>
> ---
> i didn't find a way to remove filefrag here, but let us
> use macro firstly...

YOu shoul dbe able to use fiemap to calculate the same output.
i.e. _check_file_extents() outputs a strings of the format 
#physical#length#logical#flags and this is then cut up later
later by the test. fiemap outputs the same information,
it just requires slightly different processing via the
_filter_extents function to munge it into the same format...

Cheers,

Dave.
Wang Shilong Oct. 8, 2014, 5:31 a.m. UTC | #2
Cc list

> On Wed, Oct 08, 2014 at 06:35:22AM -0400, Wang Shilong wrote:
>>> Signed-off-by: Wang Shilong <wangshilong1991@gmail.com>
>>> ---
>>> i didn't find a way to remove filefrag here, but let us
>>> use macro firstly...
>> 
>> YOu shoul dbe able to use fiemap to calculate the same output.
>> i.e. _check_file_extents() outputs a strings of the format 
>> #physical#length#logical#flags and this is then cut up later
>> later by the test. fiemap outputs the same information,
>> it just requires slightly different processing via the
>> _filter_extents function to munge it into the same format…
> 
> I supposed there are some differences between fiemap and filefrag:
> 
> [root@vm01 mnt]# filefrag -v data 
> Filesystem type is: 9123683e
> File size of data is 1024 (1 block of 4096 bytes)
> ext:     logical_offset:        physical_offset: length:   expected: flags:
>   0:        0..    4095:          0..      4095:   4096:             not_aligned,inline,eof
> data: 1 extent found
> 
> [root@vm01 mnt]# xfs_io -c fiemap data 
> data:
> 	0: [0..7]: 0..7
> 
> Hm….
> 
> 
>> 
>> Cheers,
>> 
>> Dave.
>> -- 
>> Dave Chinner
>> david@fromorbit.com
> 
> Best Regards,
> Wang Shilong
> 

Best Regards,
Wang Shilong

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dave Chinner Oct. 8, 2014, 5:54 a.m. UTC | #3
On Wed, Oct 08, 2014 at 01:31:24PM +0800, Wang Shilong wrote:
> Cc list
> 
> > On Wed, Oct 08, 2014 at 06:35:22AM -0400, Wang Shilong wrote:
> >>> Signed-off-by: Wang Shilong <wangshilong1991@gmail.com>
> >>> ---
> >>> i didn't find a way to remove filefrag here, but let us
> >>> use macro firstly...
> >> 
> >> YOu shoul dbe able to use fiemap to calculate the same output.
> >> i.e. _check_file_extents() outputs a strings of the format 
> >> #physical#length#logical#flags and this is then cut up later
> >> later by the test. fiemap outputs the same information,
> >> it just requires slightly different processing via the
> >> _filter_extents function to munge it into the same format…
> > 
> > I supposed there are some differences between fiemap and filefrag:
> > 
> > [root@vm01 mnt]# filefrag -v data 
> > Filesystem type is: 9123683e
> > File size of data is 1024 (1 block of 4096 bytes)
> > ext:     logical_offset:        physical_offset: length:   expected: flags:
> >   0:        0..    4095:          0..      4095:   4096:             not_aligned,inline,eof
> > data: 1 extent found
> > 
> > [root@vm01 mnt]# xfs_io -c fiemap data 
> > data:
> > 	0: [0..7]: 0..7

Of course. Units, for one: the output of filefrag is in bytes, while
fiemap is in 512 byte blocks. And fiemap needs the  "-v" option to
output the flag state. Same information, different presentation.

Cheers,

Dave.
diff mbox

Patch

diff --git a/tests/btrfs/004 b/tests/btrfs/004
index 1d5b816..1f59963 100755
--- a/tests/btrfs/004
+++ b/tests/btrfs/004
@@ -53,7 +53,6 @@  _supported_os Linux
 _require_scratch
 _require_no_large_scratch_dev
 _require_btrfs inspect-internal
-_require_command "/usr/sbin/filefrag"
 
 rm -f $seqres.full
 
@@ -82,7 +81,7 @@  _filter_extents()
 
 _check_file_extents()
 {
-	cmd="filefrag -v $1"
+	cmd="$FILEFRAG_PROG -v $1"
 	echo "# $cmd" >> $seqres.full
 	out=`$cmd | _filter_extents`
 	if [ -z "$out" ]; then