Re: [PATCH V6 2/2] common/populate: Ensure that S_IFDIR.FMT_BTREE is in btree format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




on 2022/12/12 13:56, Ziyang Zhang wrote:

> Sometimes "$((128 * dblksz / 40))" dirents cannot make sure that
> S_IFDIR.FMT_BTREE could become btree format for its DATA fork.
> 
> Actually we just observed it can fail after apply our inode
> extent-to-btree workaround. The root cause is that the kernel may be
> too good at allocating consecutive blocks so that the data fork is
> still in extents format.
> 
> Therefore instead of using a fixed number, let's make sure the number
> of extents is large enough than (inode size - inode core size) /
> sizeof(xfs_bmbt_rec_t).

After this patch, xfs/083 and xfs/155 failed on my envrionment(6.1.0+ 
kernel).

the 083 fail as below:
1 fuzzing xfs with FUZZ_ARGS=-3 -n 32 and FSCK_PASSES=10
   2 + create scratch fs
   3 meta-data=/dev/sdb9              isize=512    agcount=4, 
agsize=529878 blks
   4          =                       sectsz=512   attr=2, projid32bit=1
   5          =                       crc=1        finobt=1, sparse=1, 
rmapbt=0
   6          =                       reflink=0    bigtime=1 
inobtcount=1 nrext64=0
   7 data     =                       bsize=4096   blocks=2119510, 
imaxpct=25
   8          =                       sunit=0      swidth=0 blks
   9 naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
  10 log      =internal log           bsize=4096   blocks=16384, version=2
  11          =                       sectsz=512   sunit=0 blks, 
lazy-count=1
  12 realtime =none                   extsz=4096   blocks=0, rtextents=0
  13 + populate fs image
  14 MOUNT_OPTIONS =  -o usrquota,grpquota,prjquota
  15 + fill root ino chunk
  16 + extents file
  17 wrote 4096/4096 bytes at offset 0
  18 4 KiB, 1 ops; 0.0187 sec (212.891 KiB/sec and 53.2226 ops/sec)
  19 + btree extents file
  20 wrote 2097152/2097152 bytes at offset 0
  21 2 MiB, 2 ops; 0.0637 sec (31.370 MiB/sec and 31.3701 ops/sec)
  22 + inline dir
  23 + block dir
  24 + leaf dir
  25 + leafn dir
  26 + node dir
  27 + btree dir
  28 + inline symlink
  29 + extents symlink
  30 + special
  31 + local attr
  32 + leaf attr
  33 + node attr
  34 + btree attr
  35 + attr extents with a remote less-than-a-block value
  36 + attr extents with a remote one-block value
  37 + empty file
  38 + freesp btree
  39 wrote 4194304/4194304 bytes at offset 0
  40 4 MiB, 4 ops; 0.0941 sec (42.470 MiB/sec and 42.4696 ops/sec)
  41 + inobt btree
  42 + real files
  43 FILL FS
  44 src_sz 2052 fs_sz 8342940 nr 203
  45 failed to create ino 8578 dformat expected btree saw extents
  46 failed to create ino 8578 dformat expected btree saw extents
  47 (see /var/lib/xfstests/results//xfs/083.full for details)


It seems this logic can't ensure to creat a btree format dir and it
is a  extent format dir. Or I miss something?


Best Regards
Yang Xu


> 
> Reviewed-by: Zorro Lang <zlang@xxxxxxxxxx>
> Reviewed-by: Allison Henderson <allison.henderson@xxxxxxxxxx>
> Suggested-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
> Signed-off-by: Gao Xiang <hsiangkao@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Ziyang Zhang <ZiyangZhang@xxxxxxxxxxxxxxxxx>
> ---
>   common/populate | 34 +++++++++++++++++++++++++++++++++-
>   common/xfs      |  9 +++++++++
>   2 files changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/common/populate b/common/populate
> index 6e004997..8f7f2113 100644
> --- a/common/populate
> +++ b/common/populate
> @@ -71,6 +71,37 @@ __populate_create_dir() {
>   	done
>   }
>   
> +# Create a large directory and ensure that it's a btree format
> +__populate_xfs_create_btree_dir() {
> +	local name="$1"
> +	local isize="$2"
> +	local missing="$3"
> +	local icore_size="$(_xfs_get_inode_core_bytes $SCRATCH_MNT)"
> +	# We need enough extents to guarantee that the data fork is in
> +	# btree format.  Cycling the mount to use xfs_db is too slow, so
> +	# watch for when the extent count exceeds the space after the
> +	# inode core.
> +	local max_nextents="$(((isize - icore_size) / 16))"
> +	local nr=0
> +
> +	mkdir -p "${name}"
> +	while true; do
> +		local creat=mkdir
> +		test "$((nr % 20))" -eq 0 && creat=touch
> +		$creat "${name}/$(printf "%.08d" "$nr")"
> +		if [ "$((nr % 40))" -eq 0 ]; then
> +			local nextents="$(_xfs_get_fsxattr nextents $name)"
> +			[ $nextents -gt $max_nextents ] && break
> +		fi
> +		nr=$((nr+1))
> +	done
> +
> +	test -z "${missing}" && return
> +	seq 1 2 "${nr}" | while read d; do
> +		rm -rf "${name}/$(printf "%.08d" "$d")"
> +	done
> +}
> +
>   # Add a bunch of attrs to a file
>   __populate_create_attr() {
>   	name="$1"
> @@ -176,6 +207,7 @@ _scratch_xfs_populate() {
>   
>   	blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")"
>   	dblksz="$(_xfs_get_dir_blocksize "$SCRATCH_MNT")"
> +	isize="$(_xfs_get_inode_size "$SCRATCH_MNT")"
>   	crc="$(_xfs_has_feature "$SCRATCH_MNT" crc -v)"
>   	if [ $crc -eq 1 ]; then
>   		leaf_hdr_size=64
> @@ -226,7 +258,7 @@ _scratch_xfs_populate() {
>   
>   	# - BTREE
>   	echo "+ btree dir"
> -	__populate_create_dir "${SCRATCH_MNT}/S_IFDIR.FMT_BTREE" "$((128 * dblksz / 40))" true
> +	__populate_xfs_create_btree_dir "${SCRATCH_MNT}/S_IFDIR.FMT_BTREE" "$isize" true
>   
>   	# Symlinks
>   	# - FMT_LOCAL
> diff --git a/common/xfs b/common/xfs
> index 674384a9..7aaa63c7 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -1487,6 +1487,15 @@ _require_xfsrestore_xflag()
>   			_notrun 'xfsrestore does not support -x flag.'
>   }
>   
> +# Number of bytes reserved for a full inode record, which includes the
> +# immediate fork areas.
> +_xfs_get_inode_size()
> +{
> +	local mntpoint="$1"
> +
> +	$XFS_INFO_PROG "$mntpoint" | sed -n '/meta-data=.*isize/s/^.*isize=\([0-9]*\).*$/\1/p'
> +}
> +
>   # Number of bytes reserved for only the inode record, excluding the
>   # immediate fork areas.
>   _xfs_get_inode_core_bytes()




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux