diff mbox series

[V2,12/12] xfs: Error tag to test if v5 bulkstat skips inodes with large extent count

Message ID 20210726114541.24898-13-chandanrlinux@gmail.com (mailing list archive)
State Deferred, archived
Headers show
Series xfs: Extend per-inode extent counters | expand

Commit Message

Chandan Babu R July 26, 2021, 11:45 a.m. UTC
This commit adds a new error tag to allow user space tests to check if V5
bulkstat ioctl skips reporting inodes with large extent count.

Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
---
 fs/xfs/libxfs/xfs_errortag.h | 4 +++-
 fs/xfs/xfs_error.c           | 3 +++
 fs/xfs/xfs_itable.c          | 9 ++++++++-
 3 files changed, 14 insertions(+), 2 deletions(-)

Comments

Darrick J. Wong July 27, 2021, 11:10 p.m. UTC | #1
On Mon, Jul 26, 2021 at 05:15:41PM +0530, Chandan Babu R wrote:
> This commit adds a new error tag to allow user space tests to check if V5
> bulkstat ioctl skips reporting inodes with large extent count.
> 
> Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>

Keep in mind that each of these injection knobs costs us 4 bytes per
mount.  No particular objections, but I don't know how urgently we need
to do that to test a corner case...

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/libxfs/xfs_errortag.h | 4 +++-
>  fs/xfs/xfs_error.c           | 3 +++
>  fs/xfs/xfs_itable.c          | 9 ++++++++-
>  3 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h
> index f5fa2151e05d..b2c533153737 100644
> --- a/fs/xfs/libxfs/xfs_errortag.h
> +++ b/fs/xfs/libxfs/xfs_errortag.h
> @@ -60,7 +60,8 @@
>  #define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT		37
>  #define XFS_ERRTAG_AG_RESV_FAIL				38
>  #define XFS_ERRTAG_SWAPEXT_FINISH_ONE			39
> -#define XFS_ERRTAG_MAX					40
> +#define XFS_ERRTAG_BULKSTAT_REDUCE_MAX_IEXTENTS		40
> +#define XFS_ERRTAG_MAX					41
>  
>  /*
>   * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
> @@ -105,5 +106,6 @@
>  #define XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT		1
>  #define XFS_RANDOM_AG_RESV_FAIL				1
>  #define XFS_RANDOM_SWAPEXT_FINISH_ONE			1
> +#define XFS_RANDOM_BULKSTAT_REDUCE_MAX_IEXTENTS		1
>  
>  #endif /* __XFS_ERRORTAG_H_ */
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index e25b440cbfd3..e2a9446fb025 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -58,6 +58,7 @@ static unsigned int xfs_errortag_random_default[] = {
>  	XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT,
>  	XFS_RANDOM_AG_RESV_FAIL,
>  	XFS_RANDOM_SWAPEXT_FINISH_ONE,
> +	XFS_RANDOM_BULKSTAT_REDUCE_MAX_IEXTENTS,
>  };
>  
>  struct xfs_errortag_attr {
> @@ -172,6 +173,7 @@ XFS_ERRORTAG_ATTR_RW(reduce_max_iextents,	XFS_ERRTAG_REDUCE_MAX_IEXTENTS);
>  XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent,	XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT);
>  XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL);
>  XFS_ERRORTAG_ATTR_RW(swapext_finish_one, XFS_RANDOM_SWAPEXT_FINISH_ONE);
> +XFS_ERRORTAG_ATTR_RW(bulkstat_reduce_max_iextents, XFS_ERRTAG_BULKSTAT_REDUCE_MAX_IEXTENTS);
>  
>  static struct attribute *xfs_errortag_attrs[] = {
>  	XFS_ERRORTAG_ATTR_LIST(noerror),
> @@ -214,6 +216,7 @@ static struct attribute *xfs_errortag_attrs[] = {
>  	XFS_ERRORTAG_ATTR_LIST(bmap_alloc_minlen_extent),
>  	XFS_ERRORTAG_ATTR_LIST(ag_resv_fail),
>  	XFS_ERRORTAG_ATTR_LIST(swapext_finish_one),
> +	XFS_ERRORTAG_ATTR_LIST(bulkstat_reduce_max_iextents),
>  	NULL,
>  };
>  
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 8493870a0a87..1b252d1cda9d 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -20,6 +20,7 @@
>  #include "xfs_icache.h"
>  #include "xfs_health.h"
>  #include "xfs_trans.h"
> +#include "xfs_errortag.h"
>  
>  /*
>   * Bulk Stat
> @@ -143,7 +144,13 @@ xfs_bulkstat_one_int(
>  
>  	nextents = xfs_ifork_nextents(&ip->i_df);
>  	if (bc->breq->version != XFS_BULKSTAT_VERSION_V6) {
> -		if (nextents > XFS_IFORK_EXTCNT_MAXS32) {
> +		xfs_extnum_t max_nextents = XFS_IFORK_EXTCNT_MAXS32;
> +
> +		if (unlikely(XFS_TEST_ERROR(false, mp,
> +				XFS_ERRTAG_BULKSTAT_REDUCE_MAX_IEXTENTS)))
> +			max_nextents = 10;
> +
> +		if (nextents > max_nextents) {
>  			xfs_iunlock(ip, XFS_ILOCK_SHARED);
>  			xfs_irele(ip);
>  			error = -EINVAL;
> -- 
> 2.30.2
>
Chandan Babu R July 28, 2021, 7:23 a.m. UTC | #2
On 28 Jul 2021 at 04:40, Darrick J. Wong wrote:
> On Mon, Jul 26, 2021 at 05:15:41PM +0530, Chandan Babu R wrote:
>> This commit adds a new error tag to allow user space tests to check if V5
>> bulkstat ioctl skips reporting inodes with large extent count.
>>
>> Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
>
> Keep in mind that each of these injection knobs costs us 4 bytes per
> mount.  No particular objections, but I don't know how urgently we need
> to do that to test a corner case...
>

How about using the existing error tag XFS_RANDOM_REDUCE_MAX_IEXTENTS instead
of creating a new one? XFS_RANDOM_REDUCE_MAX_IEXTENTS conveys the meaning that
we use a pseudo max data/attr fork extent count. IMHO this fits into the
bulkstat testing use case where we use a pseudo max data fork extent count.

--
chandan
Chandan Babu R July 28, 2021, 7:38 a.m. UTC | #3
On 28 Jul 2021 at 12:53, Chandan Babu R wrote:
> On 28 Jul 2021 at 04:40, Darrick J. Wong wrote:
>> On Mon, Jul 26, 2021 at 05:15:41PM +0530, Chandan Babu R wrote:
>>> This commit adds a new error tag to allow user space tests to check if V5
>>> bulkstat ioctl skips reporting inodes with large extent count.
>>>
>>> Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
>>
>> Keep in mind that each of these injection knobs costs us 4 bytes per
>> mount.  No particular objections, but I don't know how urgently we need
>> to do that to test a corner case...
>>
>
> How about using the existing error tag XFS_RANDOM_REDUCE_MAX_IEXTENTS instead
> of creating a new one? XFS_RANDOM_REDUCE_MAX_IEXTENTS conveys the meaning that
> we use a pseudo max data/attr fork extent count. IMHO this fits into the
> bulkstat testing use case where we use a pseudo max data fork extent count.

Sorry, I actually meant to refer to XFS_ERRTAG_REDUCE_MAX_IEXTENTS instead of
XFS_RANDOM_REDUCE_MAX_IEXTENTS.
Darrick J. Wong July 28, 2021, 7:06 p.m. UTC | #4
On Wed, Jul 28, 2021 at 01:08:35PM +0530, Chandan Babu R wrote:
> On 28 Jul 2021 at 12:53, Chandan Babu R wrote:
> > On 28 Jul 2021 at 04:40, Darrick J. Wong wrote:
> >> On Mon, Jul 26, 2021 at 05:15:41PM +0530, Chandan Babu R wrote:
> >>> This commit adds a new error tag to allow user space tests to check if V5
> >>> bulkstat ioctl skips reporting inodes with large extent count.
> >>>
> >>> Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
> >>
> >> Keep in mind that each of these injection knobs costs us 4 bytes per
> >> mount.  No particular objections, but I don't know how urgently we need
> >> to do that to test a corner case...
> >>
> >
> > How about using the existing error tag XFS_RANDOM_REDUCE_MAX_IEXTENTS instead
> > of creating a new one? XFS_RANDOM_REDUCE_MAX_IEXTENTS conveys the meaning that
> > we use a pseudo max data/attr fork extent count. IMHO this fits into the
> > bulkstat testing use case where we use a pseudo max data fork extent count.
> 
> Sorry, I actually meant to refer to XFS_ERRTAG_REDUCE_MAX_IEXTENTS instead of
> XFS_RANDOM_REDUCE_MAX_IEXTENTS.

Works for me!

--D

> 
> -- 
> chandan
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h
index f5fa2151e05d..b2c533153737 100644
--- a/fs/xfs/libxfs/xfs_errortag.h
+++ b/fs/xfs/libxfs/xfs_errortag.h
@@ -60,7 +60,8 @@ 
 #define XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT		37
 #define XFS_ERRTAG_AG_RESV_FAIL				38
 #define XFS_ERRTAG_SWAPEXT_FINISH_ONE			39
-#define XFS_ERRTAG_MAX					40
+#define XFS_ERRTAG_BULKSTAT_REDUCE_MAX_IEXTENTS		40
+#define XFS_ERRTAG_MAX					41
 
 /*
  * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
@@ -105,5 +106,6 @@ 
 #define XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT		1
 #define XFS_RANDOM_AG_RESV_FAIL				1
 #define XFS_RANDOM_SWAPEXT_FINISH_ONE			1
+#define XFS_RANDOM_BULKSTAT_REDUCE_MAX_IEXTENTS		1
 
 #endif /* __XFS_ERRORTAG_H_ */
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index e25b440cbfd3..e2a9446fb025 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -58,6 +58,7 @@  static unsigned int xfs_errortag_random_default[] = {
 	XFS_RANDOM_BMAP_ALLOC_MINLEN_EXTENT,
 	XFS_RANDOM_AG_RESV_FAIL,
 	XFS_RANDOM_SWAPEXT_FINISH_ONE,
+	XFS_RANDOM_BULKSTAT_REDUCE_MAX_IEXTENTS,
 };
 
 struct xfs_errortag_attr {
@@ -172,6 +173,7 @@  XFS_ERRORTAG_ATTR_RW(reduce_max_iextents,	XFS_ERRTAG_REDUCE_MAX_IEXTENTS);
 XFS_ERRORTAG_ATTR_RW(bmap_alloc_minlen_extent,	XFS_ERRTAG_BMAP_ALLOC_MINLEN_EXTENT);
 XFS_ERRORTAG_ATTR_RW(ag_resv_fail, XFS_ERRTAG_AG_RESV_FAIL);
 XFS_ERRORTAG_ATTR_RW(swapext_finish_one, XFS_RANDOM_SWAPEXT_FINISH_ONE);
+XFS_ERRORTAG_ATTR_RW(bulkstat_reduce_max_iextents, XFS_ERRTAG_BULKSTAT_REDUCE_MAX_IEXTENTS);
 
 static struct attribute *xfs_errortag_attrs[] = {
 	XFS_ERRORTAG_ATTR_LIST(noerror),
@@ -214,6 +216,7 @@  static struct attribute *xfs_errortag_attrs[] = {
 	XFS_ERRORTAG_ATTR_LIST(bmap_alloc_minlen_extent),
 	XFS_ERRORTAG_ATTR_LIST(ag_resv_fail),
 	XFS_ERRORTAG_ATTR_LIST(swapext_finish_one),
+	XFS_ERRORTAG_ATTR_LIST(bulkstat_reduce_max_iextents),
 	NULL,
 };
 
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 8493870a0a87..1b252d1cda9d 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -20,6 +20,7 @@ 
 #include "xfs_icache.h"
 #include "xfs_health.h"
 #include "xfs_trans.h"
+#include "xfs_errortag.h"
 
 /*
  * Bulk Stat
@@ -143,7 +144,13 @@  xfs_bulkstat_one_int(
 
 	nextents = xfs_ifork_nextents(&ip->i_df);
 	if (bc->breq->version != XFS_BULKSTAT_VERSION_V6) {
-		if (nextents > XFS_IFORK_EXTCNT_MAXS32) {
+		xfs_extnum_t max_nextents = XFS_IFORK_EXTCNT_MAXS32;
+
+		if (unlikely(XFS_TEST_ERROR(false, mp,
+				XFS_ERRTAG_BULKSTAT_REDUCE_MAX_IEXTENTS)))
+			max_nextents = 10;
+
+		if (nextents > max_nextents) {
 			xfs_iunlock(ip, XFS_ILOCK_SHARED);
 			xfs_irele(ip);
 			error = -EINVAL;