Skip to contentSkip to conversation

xfstests: introduce 279 for SEEK_DATA/SEEK_HOLE sanity check

PATCH In review Jeff Liu 2 participants 8 messages Feb 6, 2012 – Feb 10, 2012

lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH v2 1/2 xfstests: introduce 279 for SEEK_DATA/SEEK_HOLE sanity check

Introduce 279 for SEEK_DATA/SEEK_HOLE sanity check.

---
 279                      |   63 +++++
 279.out                  |  116 ++++++++
 group                    |    1 +
 src/Makefile             |    2 +-
 src/seek_sanity_tester.c |  683 ++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 864 insertions(+), 1 deletions(-)
 create mode 100755 279
 create mode 100644 279.out
 create mode 100644 src/seek_sanity_tester.c
279 new file +63 -0
new file mode 100755
index 0000000..afdf864
@@ -0,0 +1,63 @@
+#! /bin/bash
+# FS QA Test No. 279
+#
+# SEEK_DATA/SEEK_HOLE sanity checker.
+#
+# Improved by [email protected]
+# Creater: [email protected]
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2011 Oracle Inc.  All Rights Reserved.
+# Copyright (c) 2011 Red Hat.  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
+#-----------------------------------------------------------------------
+#
+# creator
[email protected]
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+here=`pwd`
+status=0	# success is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+# real QA test starts here
+
+# Modify as appropriate.
+# FIXME: _supported_os should include Solaris too.
+_supported_fs generic
+_supported_os Linux Solaris
+
+base_test_path=$TEST_DIR/seek_sanity_testfile
+
+[ -x $here/src/seek_sanity_tester ] || _notrun "seek_sanitfy_tester not built"
+
+_cleanup()
+{
+	rm -f $base_test_path.*
+}
+
+rm -rf $seq.out
+echo "QA output created by $seq" > $seq.out
+$here/src/seek_sanity_tester $base_test_path 2>&1 | tee -a $seq.out
+
+# success, all done
+status=0
+exit
279.out new file +116 -0

116 lines not on this page · raw message

group +1 -0
index 08d999a..02c6743 100644
@@ -389,3 +389,4 @@ deprecated
 273 auto rw
 274 auto rw
 275 auto rw
+279 auto rw
src/Makefile +1 -1
index 67250ee..6797064 100644
@@ -17,7 +17,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	preallo_rw_pattern_writer ftrunc trunc fs_perms testx looptest \
 	locktest unwritten_mmap bulkstat_unlink_test t_stripealign \
 	bulkstat_unlink_test_modified t_dir_offset t_futimens t_immutable \
-	stale_handle pwrite_mmap_blocked fstrim t_dir_offset2
+	stale_handle pwrite_mmap_blocked fstrim t_dir_offset2 seek_sanity_tester
 
 SUBDIRS =
 
src/seek_sanity_tester.c new file +683 -0

683 lines not on this page · raw message

Signature · 6 lines
1.7.9

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw
Quoted 1 line · Jeff Liu

Introduce 279 for SEEK_DATA/SEEK_HOLE sanity check.

.....

279 line 34

Quoted 4 lines
279 new file +4 -0
+echo "QA output created by $seq"
+
+here=`pwd`
+status=0	# success is the default!

Why? failure should be the default, and it is in the new test template...

$ grep failure new
status=1        # failure is the default!
Quoted 1 line

+trap "_cleanup; exit \$status" 0 1 2 3 15

Indeed, we want the test to fail if it is interrupted.

279 line 46

Quoted 11 lines
279 new file +11 -0
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+# real QA test starts here
+
+# Modify as appropriate.
+# FIXME: _supported_os should include Solaris too.
+_supported_fs generic
+_supported_os Linux Solaris

What is the FIXME for?

279 line 58

Quoted 11 lines
279 new file +11 -0
+base_test_path=$TEST_DIR/seek_sanity_testfile
+
+[ -x $here/src/seek_sanity_tester ] || _notrun "seek_sanitfy_tester not built"
+
+_cleanup()
+{
+	rm -f $base_test_path.*
+}
+
+rm -rf $seq.out
+echo "QA output created by $seq" > $seq.out

Anything output on stdout automatically gets put into $seq.out by the test harness. The $seq.out file is truncated before the test, so this is not necessary. Indeed, doing this is probably why the tee command below only results in a single copy of the output in $seq.out.

Quoted 1 line

+$here/src/seek_sanity_tester $base_test_path 2>&1 | tee -a $seq.out

This only needs to be:

$here/src/seek_sanity_tester $base_test_path 2>&1

to redirect both stdout and stderr to $seq.out.

279.out line 3

Quoted 6 lines
279.out new file +3 -0
@@ -0,0 +1,116 @@
+QA output created by 279
+File system supports the default behavior.
+File system magic#: 0x58465342

You can't put the filesystem magic number in the output. It is different for XFS, ext4, ext3, etc. Either it needs to be removed or filtered.

279.out line 4

Quoted 1 line
279.out new file +1 -0
+Allocation size: 4096

That's no good, either, as filesystems can easily return return something other than 4k there as well.

Quoted 13 lines
279.out new file +13 -0
+01. Test empty file
+01.01 SEEK_DATA expected -1 with errno -6, got -6.                succ
+01.02 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+01.03 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+
+02. Test a tiny full file
+02.01 SEEK_HOLE expected 8 or 8, got 8.                           succ
+02.02 SEEK_DATA expected 0 or 0, got 0.                           succ
+02.03 SEEK_DATA expected 1 or 1, got 1.                           succ
+02.04 SEEK_HOLE expected 8 or 8, got 8.                           succ
+02.05 SEEK_DATA expected 7 or 7, got 7.                           succ
+02.06 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+02.07 SEEK_DATA expected -1 with errno -6, got -6.                succ

279.out line 28

Quoted 10 lines
279.out new file +10 -0
+02.08 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+02.09 SEEK_DATA expected -1 with errno -6, got -6.                succ
+
+03. Test a larger full file
+03.01 SEEK_HOLE expected 8292 or 8292, got 8292.                  succ
+03.02 SEEK_HOLE expected 8292 or 8292, got 8292.                  succ
+03.03 SEEK_DATA expected 0 or 0, got 0.                           succ
+03.04 SEEK_DATA expected 1 or 1, got 1.                           succ
+03.05 SEEK_HOLE expected 8292 or 8292, got 8292.                  succ
+03.06 SEEK_DATA expected 8291 or 8291, got 8291.                  succ

Hmmm, these are all numbers that are based on an allocation size of 4k. So this test is guaranteed to fail on configurations that don't report a 4k block size from fstat().

I'd suggest that what you need to do here is have the test exit with a 1 or 0 to indicate success, and test for that in the 279 script, and pipe all this output to $seq.full so it can be used for debugging when a failure occurs.

Basically, if numbers can change between different test configs, then they either need to be filtered out of the golden output or directed to the $seq.full and the test does something like:

status=1 # failure is the default
rm -f $seq.full
....
run_test >> $seq.full 2>&1 || _fail "run_test failed!" status=0
exit

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#2 lore raw

Hi Dave,

Sorry! I missed your response for this patch.

Quoted 10 lines · Dave Chinner
Quoted 1 line · Jeff Liu

Introduce 279 for SEEK_DATA/SEEK_HOLE sanity check.

.....

279 line 34

Quoted 4 lines
279 new file +4 -0
+echo "QA output created by $seq"
+
+here=`pwd`
+status=0	# success is the default!

Why? failure should be the default, and it is in the new test template...

That's my mistake, I manually changed this default setting at that time somehow. :(

Quoted 10 lines
$ grep failure new
status=1        # failure is the default!
Quoted 1 line

+trap "_cleanup; exit \$status" 0 1 2 3 15

Indeed, we want the test to fail if it is interrupted.

Quoted 13 lines

279 line 46

Quoted 11 lines
279 new file +11 -0
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+# real QA test starts here
+
+# Modify as appropriate.
+# FIXME: _supported_os should include Solaris too.
+_supported_fs generic
+_supported_os Linux Solaris

What is the FIXME for?

At first, I was consider to let it also support Solaris lseek(2) tests, but xfstests only works on IRIX && Linux, so "FIXME" should be removed.

Quoted 19 lines

279 line 58

Quoted 12 lines
279 new file +11 -0
+base_test_path=$TEST_DIR/seek_sanity_testfile
+
+[ -x $here/src/seek_sanity_tester ] || _notrun "seek_sanitfy_tester not built"
+
+_cleanup()
+{
+	rm -f $base_test_path.*
+}
+
+rm -rf $seq.out
+echo "QA output created by $seq" > $seq.out

Anything output on stdout automatically gets put into $seq.out by the test harness. The $seq.out file is truncated before the test, so this is not necessary. Indeed, doing this is probably why the tee command below only results in a single copy of the output in $seq.out.

Quoted 7 lines
Quoted 1 line

+$here/src/seek_sanity_tester $base_test_path 2>&1 | tee -a $seq.out

This only needs to be:

$here/src/seek_sanity_tester $base_test_path 2>&1

to redirect both stdout and stderr to $seq.out.

Ok.

Quoted 11 lines

279.out line 3

Quoted 7 lines
279.out new file +3 -0
@@ -0,0 +1,116 @@
+QA output created by 279
+File system supports the default behavior.
+File system magic#: 0x58465342

You can't put the filesystem magic number in the output. It is different for XFS, ext4, ext3, etc. Either it needs to be removed or filtered.

I'll remove it. :)

Quoted 25 lines

279.out line 4

Quoted 2 lines
279.out new file +1 -0
+Allocation size: 4096

That's no good, either, as filesystems can easily return return something other than 4k there as well.

Quoted 19 lines
279.out new file +19 -0
+01. Test empty file
+01.01 SEEK_DATA expected -1 with errno -6, got -6.                succ
+01.02 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+01.03 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+
+02. Test a tiny full file
+02.01 SEEK_HOLE expected 8 or 8, got 8.                           succ
+02.02 SEEK_DATA expected 0 or 0, got 0.                           succ
+02.03 SEEK_DATA expected 1 or 1, got 1.                           succ
+02.04 SEEK_HOLE expected 8 or 8, got 8.                           succ
+02.05 SEEK_DATA expected 7 or 7, got 7.                           succ
+02.06 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+02.07 SEEK_DATA expected -1 with errno -6, got -6.                succ
+02.08 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+02.09 SEEK_DATA expected -1 with errno -6, got -6.                succ
+
+03. Test a larger full file
+03.01 SEEK_HOLE expected 8292 or 8292, got 8292.                  succ
+03.02 SEEK_HOLE expected 8292 or 8292, got 8292.                  succ
Quoted 8 lines

279.out line 28

Quoted 4 lines
279.out new file +4 -0
+03.03 SEEK_DATA expected 0 or 0, got 0.                           succ
+03.04 SEEK_DATA expected 1 or 1, got 1.                           succ
+03.05 SEEK_HOLE expected 8292 or 8292, got 8292.                  succ
+03.06 SEEK_DATA expected 8291 or 8291, got 8291.                  succ

Hmmm, these are all numbers that are based on an allocation size of 4k. So this test is guaranteed to fail on configurations that don't report a 4k block size from fstat().

Hmm, although the numbers(like 8292, 8291) are based on an allocation size(4k in this case). But they will adjusted to other numbers depending on the detected allocation size on the fly.

For example, if a file system blksize is 8k, then the old result:
03.01 SEEK_HOLE expected 8292 or 8292, got 8292.
will show as:
03.01 SEEK_HOLE expected 16484 or 16484, got 16484.

Frankly speaking, I have not yet tried it on other allocation size, that is just the desired behavior per current implementation. I'll fix it up as you suggested if it run failed. :)

Thanks,
-Jeff

Quoted 18 lines

I'd suggest that what you need to do here is have the test exit with a 1 or 0 to indicate success, and test for that in the 279 script, and pipe all this output to $seq.full so it can be used for debugging when a failure occurs.

Basically, if numbers can change between different test configs, then they either need to be filtered out of the golden output or directed to the $seq.full and the test does something like:

status=1 # failure is the default
rm -f $seq.full
....
run_test >> $seq.full 2>&1 || _fail "run_test failed!" status=0
exit

Quoted 3 lines

Cheers,

Dave.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

author
#3 lore raw
Quoted 134 lines · Jeff Liu

Hi Dave,

Sorry! I missed your response for this patch.

Quoted 10 lines · Dave Chinner
Quoted 1 line · Jeff Liu

Introduce 279 for SEEK_DATA/SEEK_HOLE sanity check.

.....

279 line 34

Quoted 4 lines
279 new file +4 -0
+echo "QA output created by $seq"
+
+here=`pwd`
+status=0	# success is the default!

Why? failure should be the default, and it is in the new test template...

That's my mistake, I manually changed this default setting at that time somehow. :(

Quoted 10 lines
$ grep failure new
status=1        # failure is the default!
Quoted 1 line

+trap "_cleanup; exit \$status" 0 1 2 3 15

Indeed, we want the test to fail if it is interrupted.

Quoted 13 lines

279 line 46

Quoted 11 lines
279 new file +11 -0
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+# real QA test starts here
+
+# Modify as appropriate.
+# FIXME: _supported_os should include Solaris too.
+_supported_fs generic
+_supported_os Linux Solaris

What is the FIXME for?

At first, I was consider to let it also support Solaris lseek(2) tests, but xfstests only works on IRIX && Linux, so "FIXME" should be removed.

Quoted 19 lines

279 line 58

Quoted 12 lines
279 new file +11 -0
+base_test_path=$TEST_DIR/seek_sanity_testfile
+
+[ -x $here/src/seek_sanity_tester ] || _notrun "seek_sanitfy_tester not built"
+
+_cleanup()
+{
+	rm -f $base_test_path.*
+}
+
+rm -rf $seq.out
+echo "QA output created by $seq" > $seq.out

Anything output on stdout automatically gets put into $seq.out by the test harness. The $seq.out file is truncated before the test, so this is not necessary. Indeed, doing this is probably why the tee command below only results in a single copy of the output in $seq.out.

Quoted 7 lines
Quoted 1 line

+$here/src/seek_sanity_tester $base_test_path 2>&1 | tee -a $seq.out

This only needs to be:

$here/src/seek_sanity_tester $base_test_path 2>&1

to redirect both stdout and stderr to $seq.out.

Ok.

Quoted 11 lines

279.out line 3

Quoted 7 lines
279.out new file +3 -0
@@ -0,0 +1,116 @@
+QA output created by 279
+File system supports the default behavior.
+File system magic#: 0x58465342

You can't put the filesystem magic number in the output. It is different for XFS, ext4, ext3, etc. Either it needs to be removed or filtered.

I'll remove it. :)

Quoted 25 lines

279.out line 4

Quoted 2 lines
279.out new file +1 -0
+Allocation size: 4096

That's no good, either, as filesystems can easily return return something other than 4k there as well.

Quoted 19 lines
279.out new file +19 -0
+01. Test empty file
+01.01 SEEK_DATA expected -1 with errno -6, got -6.                succ
+01.02 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+01.03 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+
+02. Test a tiny full file
+02.01 SEEK_HOLE expected 8 or 8, got 8.                           succ
+02.02 SEEK_DATA expected 0 or 0, got 0.                           succ
+02.03 SEEK_DATA expected 1 or 1, got 1.                           succ
+02.04 SEEK_HOLE expected 8 or 8, got 8.                           succ
+02.05 SEEK_DATA expected 7 or 7, got 7.                           succ
+02.06 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+02.07 SEEK_DATA expected -1 with errno -6, got -6.                succ
+02.08 SEEK_HOLE expected -1 with errno -6, got -6.                succ
+02.09 SEEK_DATA expected -1 with errno -6, got -6.                succ
+
+03. Test a larger full file
+03.01 SEEK_HOLE expected 8292 or 8292, got 8292.                  succ
+03.02 SEEK_HOLE expected 8292 or 8292, got 8292.                  succ
Quoted 8 lines

279.out line 28

Quoted 4 lines
279.out new file +4 -0
+03.03 SEEK_DATA expected 0 or 0, got 0.                           succ
+03.04 SEEK_DATA expected 1 or 1, got 1.                           succ
+03.05 SEEK_HOLE expected 8292 or 8292, got 8292.                  succ
+03.06 SEEK_DATA expected 8291 or 8291, got 8291.                  succ

Hmmm, these are all numbers that are based on an allocation size of 4k. So this test is guaranteed to fail on configurations that don't report a 4k block size from fstat().

Hmm, although the numbers(like 8292, 8291) are based on an allocation size(4k in this case). But they will adjusted to other numbers depending on the detected allocation size on the fly.

For example, if a file system blksize is 8k, then the old result:
03.01 SEEK_HOLE expected 8292 or 8292, got 8292.
will show as:
03.01 SEEK_HOLE expected 16484 or 16484, got 16484.

Quoted 3 lines

Frankly speaking, I have not yet tried it on other allocation size, that is just the desired behavior per current implementation. I'll fix it up as you suggested if it run failed. :)

Ok, I just tried on an ext4 file system with 2k blksize, looks fine, the number of expected size were shown as following:

$ ./seek_test
File system magic#: 0xef53
Allocation unit: 2048 bytes
File system supports the default behavior.

03. Test a larger full file

03.01 SEEK_HOLE expected 4196 or 4196, got 4196.                  succ
03.02 SEEK_HOLE expected 4196 or 4196, got 4196.                  succ
03.03 SEEK_DATA expected 0 or 0, got 0.                           succ
03.04 SEEK_DATA expected 1 or 1, got 1.                           succ
03.05 SEEK_HOLE expected 4196 or 4196, got 4196.                  succ
03.06 SEEK_DATA expected 4195 or 4195, got 4195.                  succ

Strange, I also tried to build XFS with 2k which shown as following:

$ sudo mkfs.xfs -b size=2k -n size=2k -f /dev/sda7
$ xfs_info /dev/sda7
meta-data=/dev/sda7              isize=256    agcount=4, agsize=1418736 blks
         =                       sectsz=512   attr=2
data     =                       bsize=2048   blocks=5674944, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=2048   ascii-ci=0
log      =internal               bsize=2048   blocks=5120, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

But the blksize still shown as 4k, I think I must have missed something, will try it tomorrow.

Have a nice day!
-Jeff

Quoted 27 lines

Thanks,
-Jeff

Quoted 21 lines

I'd suggest that what you need to do here is have the test exit with a 1 or 0 to indicate success, and test for that in the 279 script, and pipe all this output to $seq.full so it can be used for debugging when a failure occurs.

Basically, if numbers can change between different test configs, then they either need to be filtered out of the golden output or directed to the $seq.full and the test does something like:

status=1 # failure is the default
rm -f $seq.full
....
run_test >> $seq.full 2>&1 || _fail "run_test failed!" status=0
exit

Cheers,

Dave.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw
Quoted 8 lines · Jeff Liu

Strange, I also tried to build XFS with 2k which shown as following:

$ sudo mkfs.xfs -b size=2k -n size=2k -f /dev/sda7
$ xfs_info /dev/sda7
meta-data=/dev/sda7              isize=256    agcount=4, agsize=1418736 blks
         =                       sectsz=512   attr=2
data     =                       bsize=2048   blocks=5674944, imaxpct=25
                                   ^^^^^^^^^^
Quoted 2 lines
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=2048   ascii-ci=0
                                   ^^^^^^^^^^
Quoted 1 line

log =internal bsize=2048 blocks=5120, version=2

                                   ^^^^^^^^^^

The block size for data, metadata, directories and the log is 2k, just like you asked.

Quoted 2 lines
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

For the non-existent realtime device, the default is an extent size of 4k. However, extent size for the real time device is separate from the data/log device block size - it's more like the bigalloc ext4 functionality in that it defines the default extent allocation size and alignment for the RT device.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#5 lore raw
Quoted 11 lines · Dave Chinner
Quoted 8 lines · Jeff Liu

Strange, I also tried to build XFS with 2k which shown as following:

$ sudo mkfs.xfs -b size=2k -n size=2k -f /dev/sda7
$ xfs_info /dev/sda7
meta-data=/dev/sda7              isize=256    agcount=4, agsize=1418736 blks
         =                       sectsz=512   attr=2
data     =                       bsize=2048   blocks=5674944, imaxpct=25
                                   ^^^^^^^^^^
Quoted 8 lines
Quoted 2 lines
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=2048   ascii-ci=0
                                   ^^^^^^^^^^
Quoted 1 line

log =internal bsize=2048 blocks=5120, version=2

                                   ^^^^^^^^^^

The block size for data, metadata, directories and the log is 2k, just like you asked.

Sorry, I mislead you.

Yes, the block size for data and metadata, etc are ok for me, but the allocate unit at "struct stat.st_blksize" is 4k, It should match data->bsize=2k IMHO.

File system magic#: 0x58465342
Allocation unit: 4096 bytes
File system supports the default behavior.

$ stat --print "%o\n" /xfs/seek_test
4096
Quoted 9 lines
Quoted 3 lines
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

For the non-existent realtime device, the default is an extent size of 4k. However, extent size for the real time device is separate from the data/log device block size - it's more like the bigalloc ext4 functionality in that it defines the default extent allocation size and alignment for the RT device.

Thanks for those patiently explaining!

Cheers,
-Jeff

Quoted 4 lines

Cheers,

Dave.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#6 lore raw
Quoted 22 lines · Jeff Liu
Quoted 11 lines · Dave Chinner
Quoted 8 lines · Jeff Liu

Strange, I also tried to build XFS with 2k which shown as following:

$ sudo mkfs.xfs -b size=2k -n size=2k -f /dev/sda7
$ xfs_info /dev/sda7
meta-data=/dev/sda7              isize=256    agcount=4, agsize=1418736 blks
         =                       sectsz=512   attr=2
data     =                       bsize=2048   blocks=5674944, imaxpct=25
                                   ^^^^^^^^^^
Quoted 8 lines
Quoted 2 lines
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=2048   ascii-ci=0
                                   ^^^^^^^^^^
Quoted 1 line

log =internal bsize=2048 blocks=5120, version=2

                                   ^^^^^^^^^^

The block size for data, metadata, directories and the log is 2k, just like you asked.

Quoted 5 lines

Sorry, I mislead you.

Yes, the block size for data and metadata, etc are ok for me, but the allocate unit at "struct stat.st_blksize" is 4k, It should match data->bsize=2k IMHO.

That field has nothing to do with the filesystem block size. According to the stat(2) man page:

'The st_blksize field gives the "preferred" blocksize for efficient file system I/O.'

Giving a value of less than PAGE_SIZE for this field leads to inefficient IO because it forces the page cache to do read-modify-write cycles for single filesystem block writes. Hence on a 4k page size machine, it needs to report 4k as a minimum to avoid this. On a 64k page size machine, you'll find that value is 64k.

Indeed, XFS gives you some control over what is actually reported here. If your file lies on a real-time device, then XFS will export the extent allocation size (either the mkfs default of the per inode hint if it is set) in this field. For files on the data device, if you mount with the "largeio" mount option, XFS will export the stripe width if it is set, the biosize if that mount option is used or the PAGE_SIZE if neither are set. These are all different but valid definitions of "preferred blocksize for efficient IO".

If you want to know the real block size of the filesystem, use statfs(2).

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#7 lore raw
Quoted 35 lines · Dave Chinner
Quoted 22 lines · Jeff Liu
Quoted 11 lines · Dave Chinner
Quoted 8 lines · Jeff Liu

Strange, I also tried to build XFS with 2k which shown as following:

$ sudo mkfs.xfs -b size=2k -n size=2k -f /dev/sda7
$ xfs_info /dev/sda7
meta-data=/dev/sda7              isize=256    agcount=4, agsize=1418736 blks
         =                       sectsz=512   attr=2
data     =                       bsize=2048   blocks=5674944, imaxpct=25
                                   ^^^^^^^^^^
Quoted 8 lines
Quoted 2 lines
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=2048   ascii-ci=0
                                   ^^^^^^^^^^
Quoted 1 line

log =internal bsize=2048 blocks=5120, version=2

                                   ^^^^^^^^^^

The block size for data, metadata, directories and the log is 2k, just like you asked.

Quoted 5 lines

Sorry, I mislead you.

Yes, the block size for data and metadata, etc are ok for me, but the allocate unit at "struct stat.st_blksize" is 4k, It should match data->bsize=2k IMHO.

That field has nothing to do with the filesystem block size. According to the stat(2) man page:

'The st_blksize field gives the "preferred" blocksize for efficient file system I/O.'

Quoted 6 lines

Giving a value of less than PAGE_SIZE for this field leads to inefficient IO because it forces the page cache to do read-modify-write cycles for single filesystem block writes. Hence on a 4k page size machine, it needs to report 4k as a minimum to avoid this. On a 64k page size machine, you'll find that value is 64k.

Sigh, I was misled by EXT4's output for stat(2), since its st_blksize is 2k which is equal to the mkfs formating value even on a 4k page size machine. :(

Quoted 10 lines

Indeed, XFS gives you some control over what is actually reported here. If your file lies on a real-time device, then XFS will export the extent allocation size (either the mkfs default of the per inode hint if it is set) in this field. For files on the data device, if you mount with the "largeio" mount option, XFS will export the stripe width if it is set, the biosize if that mount option is used or the PAGE_SIZE if neither are set. These are all different but valid definitions of "preferred blocksize for efficient IO".

Quoted 2 lines

If you want to know the real block size of the filesystem, use statfs(2).

Definitely, thanks a lot!!

-Jeff

Quoted 4 lines

Cheers,

Dave.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs