diff mbox series

[2/6] xfs/529: Fix test to execute in multi-block directory config

Message ID 20210325140857.7145-2-chandanrlinux@gmail.com (mailing list archive)
State New
Headers show
Series [1/6] xfs/529: Execute chown on an existing directory entry | expand

Commit Message

Chandan Babu R March 25, 2021, 2:08 p.m. UTC
xfs/529 attempts to create $testfile after reduce_max_iextents error tag is
injected. Creation of $testfile fails when using a multi-block directory test
configuration because,
1. A directory can have a pseudo maximum extent count of 10.
2. In the worst case a directory entry creation operation can consume
   (XFS_DA_NODE_MAXDEPTH + 1 + 1) * (Nr fs blocks in a single directory block)
   extents.
   With 1k fs block size and 4k directory block size, this evaluates to,
   (5 + 1 + 1) * 4
   = 7 * 4
   = 28
   > 10 (Pseudo maximum inode extent count).

This commit fixes the issue by creating $testfile before injecting
reduce_max_iextents error tag.

Reported-by: Darrick J. Wong <djwong@kernel.org>
Suggested-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
---
 tests/xfs/529     | 24 +++++++++++++++++++++---
 tests/xfs/529.out |  6 +++++-
 2 files changed, 26 insertions(+), 4 deletions(-)

Comments

Eryu Guan March 28, 2021, 4:49 p.m. UTC | #1
On Thu, Mar 25, 2021 at 07:38:53PM +0530, Chandan Babu R wrote:
> xfs/529 attempts to create $testfile after reduce_max_iextents error tag is
> injected. Creation of $testfile fails when using a multi-block directory test
> configuration because,
> 1. A directory can have a pseudo maximum extent count of 10.
> 2. In the worst case a directory entry creation operation can consume
>    (XFS_DA_NODE_MAXDEPTH + 1 + 1) * (Nr fs blocks in a single directory block)
>    extents.
>    With 1k fs block size and 4k directory block size, this evaluates to,
>    (5 + 1 + 1) * 4
>    = 7 * 4
>    = 28
>    > 10 (Pseudo maximum inode extent count).
> 
> This commit fixes the issue by creating $testfile before injecting
> reduce_max_iextents error tag.
> 
> Reported-by: Darrick J. Wong <djwong@kernel.org>
> Suggested-by: Darrick J. Wong <djwong@kernel.org>
> Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>

Seems patch 2 to 6 fix the same bug in different tests, I think we could
put the fixes in one patch.

Thanks,
Eryu
> ---
>  tests/xfs/529     | 24 +++++++++++++++++++++---
>  tests/xfs/529.out |  6 +++++-
>  2 files changed, 26 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/xfs/529 b/tests/xfs/529
> index abe5b1e0..b4533eba 100755
> --- a/tests/xfs/529
> +++ b/tests/xfs/529
> @@ -54,6 +54,8 @@ echo "* Delalloc to written extent conversion"
>  
>  testfile=$SCRATCH_MNT/testfile
>  
> +touch $testfile
> +
>  echo "Inject reduce_max_iextents error tag"
>  _scratch_inject_error reduce_max_iextents 1
>  
> @@ -74,10 +76,18 @@ if (( $nextents > 10 )); then
>  	exit 1
>  fi
>  
> +echo "Disable reduce_max_iextents error tag"
> +_scratch_inject_error reduce_max_iextents 0
> +
>  rm $testfile
>  
>  echo "* Fallocate unwritten extents"
>  
> +touch $testfile
> +
> +echo "Inject reduce_max_iextents error tag"
> +_scratch_inject_error reduce_max_iextents 1
> +
>  echo "Fallocate fragmented file"
>  for i in $(seq 0 2 $((nr_blks - 1))); do
>  	$XFS_IO_PROG -f -c "falloc $((i * bsize)) $bsize" $testfile \
> @@ -93,10 +103,18 @@ if (( $nextents > 10 )); then
>  	exit 1
>  fi
>  
> +echo "Disable reduce_max_iextents error tag"
> +_scratch_inject_error reduce_max_iextents 0
> +
>  rm $testfile
>  
>  echo "* Directio write"
>  
> +touch $testfile
> +
> +echo "Inject reduce_max_iextents error tag"
> +_scratch_inject_error reduce_max_iextents 1
> +
>  echo "Create fragmented file via directio writes"
>  for i in $(seq 0 2 $((nr_blks - 1))); do
>  	$XFS_IO_PROG -d -s -f -c "pwrite $((i * bsize)) $bsize" $testfile \
> @@ -112,15 +130,15 @@ if (( $nextents > 10 )); then
>  	exit 1
>  fi
>  
> +echo "Disable reduce_max_iextents error tag"
> +_scratch_inject_error reduce_max_iextents 0
> +
>  rm $testfile
>  
>  # Check if XFS gracefully returns with an error code when we try to increase
>  # extent count of user quota inode beyond the pseudo max extent count limit.
>  echo "* Extend quota inodes"
>  
> -echo "Disable reduce_max_iextents error tag"
> -_scratch_inject_error reduce_max_iextents 0
> -
>  echo "Consume free space"
>  fillerdir=$SCRATCH_MNT/fillerdir
>  nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT)
> diff --git a/tests/xfs/529.out b/tests/xfs/529.out
> index b2ae3f42..13489d34 100644
> --- a/tests/xfs/529.out
> +++ b/tests/xfs/529.out
> @@ -4,14 +4,18 @@ Format and mount fs
>  Inject reduce_max_iextents error tag
>  Create fragmented file
>  Verify $testfile's extent count
> +Disable reduce_max_iextents error tag
>  * Fallocate unwritten extents
> +Inject reduce_max_iextents error tag
>  Fallocate fragmented file
>  Verify $testfile's extent count
> +Disable reduce_max_iextents error tag
>  * Directio write
> +Inject reduce_max_iextents error tag
>  Create fragmented file via directio writes
>  Verify $testfile's extent count
> -* Extend quota inodes
>  Disable reduce_max_iextents error tag
> +* Extend quota inodes
>  Consume free space
>  Create fragmented filesystem
>  Inject reduce_max_iextents error tag
> -- 
> 2.29.2
Darrick J. Wong March 29, 2021, 4:20 p.m. UTC | #2
On Thu, Mar 25, 2021 at 07:38:53PM +0530, Chandan Babu R wrote:
> xfs/529 attempts to create $testfile after reduce_max_iextents error tag is
> injected. Creation of $testfile fails when using a multi-block directory test
> configuration because,
> 1. A directory can have a pseudo maximum extent count of 10.
> 2. In the worst case a directory entry creation operation can consume
>    (XFS_DA_NODE_MAXDEPTH + 1 + 1) * (Nr fs blocks in a single directory block)
>    extents.
>    With 1k fs block size and 4k directory block size, this evaluates to,
>    (5 + 1 + 1) * 4
>    = 7 * 4
>    = 28
>    > 10 (Pseudo maximum inode extent count).
> 
> This commit fixes the issue by creating $testfile before injecting
> reduce_max_iextents error tag.
> 
> Reported-by: Darrick J. Wong <djwong@kernel.org>
> Suggested-by: Darrick J. Wong <djwong@kernel.org>
> Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>

Looks good to me,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  tests/xfs/529     | 24 +++++++++++++++++++++---
>  tests/xfs/529.out |  6 +++++-
>  2 files changed, 26 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/xfs/529 b/tests/xfs/529
> index abe5b1e0..b4533eba 100755
> --- a/tests/xfs/529
> +++ b/tests/xfs/529
> @@ -54,6 +54,8 @@ echo "* Delalloc to written extent conversion"
>  
>  testfile=$SCRATCH_MNT/testfile
>  
> +touch $testfile
> +
>  echo "Inject reduce_max_iextents error tag"
>  _scratch_inject_error reduce_max_iextents 1
>  
> @@ -74,10 +76,18 @@ if (( $nextents > 10 )); then
>  	exit 1
>  fi
>  
> +echo "Disable reduce_max_iextents error tag"
> +_scratch_inject_error reduce_max_iextents 0
> +
>  rm $testfile
>  
>  echo "* Fallocate unwritten extents"
>  
> +touch $testfile
> +
> +echo "Inject reduce_max_iextents error tag"
> +_scratch_inject_error reduce_max_iextents 1
> +
>  echo "Fallocate fragmented file"
>  for i in $(seq 0 2 $((nr_blks - 1))); do
>  	$XFS_IO_PROG -f -c "falloc $((i * bsize)) $bsize" $testfile \
> @@ -93,10 +103,18 @@ if (( $nextents > 10 )); then
>  	exit 1
>  fi
>  
> +echo "Disable reduce_max_iextents error tag"
> +_scratch_inject_error reduce_max_iextents 0
> +
>  rm $testfile
>  
>  echo "* Directio write"
>  
> +touch $testfile
> +
> +echo "Inject reduce_max_iextents error tag"
> +_scratch_inject_error reduce_max_iextents 1
> +
>  echo "Create fragmented file via directio writes"
>  for i in $(seq 0 2 $((nr_blks - 1))); do
>  	$XFS_IO_PROG -d -s -f -c "pwrite $((i * bsize)) $bsize" $testfile \
> @@ -112,15 +130,15 @@ if (( $nextents > 10 )); then
>  	exit 1
>  fi
>  
> +echo "Disable reduce_max_iextents error tag"
> +_scratch_inject_error reduce_max_iextents 0
> +
>  rm $testfile
>  
>  # Check if XFS gracefully returns with an error code when we try to increase
>  # extent count of user quota inode beyond the pseudo max extent count limit.
>  echo "* Extend quota inodes"
>  
> -echo "Disable reduce_max_iextents error tag"
> -_scratch_inject_error reduce_max_iextents 0
> -
>  echo "Consume free space"
>  fillerdir=$SCRATCH_MNT/fillerdir
>  nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT)
> diff --git a/tests/xfs/529.out b/tests/xfs/529.out
> index b2ae3f42..13489d34 100644
> --- a/tests/xfs/529.out
> +++ b/tests/xfs/529.out
> @@ -4,14 +4,18 @@ Format and mount fs
>  Inject reduce_max_iextents error tag
>  Create fragmented file
>  Verify $testfile's extent count
> +Disable reduce_max_iextents error tag
>  * Fallocate unwritten extents
> +Inject reduce_max_iextents error tag
>  Fallocate fragmented file
>  Verify $testfile's extent count
> +Disable reduce_max_iextents error tag
>  * Directio write
> +Inject reduce_max_iextents error tag
>  Create fragmented file via directio writes
>  Verify $testfile's extent count
> -* Extend quota inodes
>  Disable reduce_max_iextents error tag
> +* Extend quota inodes
>  Consume free space
>  Create fragmented filesystem
>  Inject reduce_max_iextents error tag
> -- 
> 2.29.2
>
diff mbox series

Patch

diff --git a/tests/xfs/529 b/tests/xfs/529
index abe5b1e0..b4533eba 100755
--- a/tests/xfs/529
+++ b/tests/xfs/529
@@ -54,6 +54,8 @@  echo "* Delalloc to written extent conversion"
 
 testfile=$SCRATCH_MNT/testfile
 
+touch $testfile
+
 echo "Inject reduce_max_iextents error tag"
 _scratch_inject_error reduce_max_iextents 1
 
@@ -74,10 +76,18 @@  if (( $nextents > 10 )); then
 	exit 1
 fi
 
+echo "Disable reduce_max_iextents error tag"
+_scratch_inject_error reduce_max_iextents 0
+
 rm $testfile
 
 echo "* Fallocate unwritten extents"
 
+touch $testfile
+
+echo "Inject reduce_max_iextents error tag"
+_scratch_inject_error reduce_max_iextents 1
+
 echo "Fallocate fragmented file"
 for i in $(seq 0 2 $((nr_blks - 1))); do
 	$XFS_IO_PROG -f -c "falloc $((i * bsize)) $bsize" $testfile \
@@ -93,10 +103,18 @@  if (( $nextents > 10 )); then
 	exit 1
 fi
 
+echo "Disable reduce_max_iextents error tag"
+_scratch_inject_error reduce_max_iextents 0
+
 rm $testfile
 
 echo "* Directio write"
 
+touch $testfile
+
+echo "Inject reduce_max_iextents error tag"
+_scratch_inject_error reduce_max_iextents 1
+
 echo "Create fragmented file via directio writes"
 for i in $(seq 0 2 $((nr_blks - 1))); do
 	$XFS_IO_PROG -d -s -f -c "pwrite $((i * bsize)) $bsize" $testfile \
@@ -112,15 +130,15 @@  if (( $nextents > 10 )); then
 	exit 1
 fi
 
+echo "Disable reduce_max_iextents error tag"
+_scratch_inject_error reduce_max_iextents 0
+
 rm $testfile
 
 # Check if XFS gracefully returns with an error code when we try to increase
 # extent count of user quota inode beyond the pseudo max extent count limit.
 echo "* Extend quota inodes"
 
-echo "Disable reduce_max_iextents error tag"
-_scratch_inject_error reduce_max_iextents 0
-
 echo "Consume free space"
 fillerdir=$SCRATCH_MNT/fillerdir
 nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT)
diff --git a/tests/xfs/529.out b/tests/xfs/529.out
index b2ae3f42..13489d34 100644
--- a/tests/xfs/529.out
+++ b/tests/xfs/529.out
@@ -4,14 +4,18 @@  Format and mount fs
 Inject reduce_max_iextents error tag
 Create fragmented file
 Verify $testfile's extent count
+Disable reduce_max_iextents error tag
 * Fallocate unwritten extents
+Inject reduce_max_iextents error tag
 Fallocate fragmented file
 Verify $testfile's extent count
+Disable reduce_max_iextents error tag
 * Directio write
+Inject reduce_max_iextents error tag
 Create fragmented file via directio writes
 Verify $testfile's extent count
-* Extend quota inodes
 Disable reduce_max_iextents error tag
+* Extend quota inodes
 Consume free space
 Create fragmented filesystem
 Inject reduce_max_iextents error tag