Skip to content

Commit f9fa871

Browse files
chandanrDarrick J. Wong
authored andcommitted
xfs: Introduce error injection to reduce maximum inode fork extent count
This commit adds XFS_ERRTAG_REDUCE_MAX_IEXTENTS error tag which enables userspace programs to test "Inode fork extent count overflow detection" by reducing maximum possible inode fork extent count to 10. Reviewed-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Allison Henderson <[email protected]> Signed-off-by: Chandan Babu R <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent bcc561f commit f9fa871

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

fs/xfs/libxfs/xfs_errortag.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
#define XFS_ERRTAG_FORCE_SUMMARY_RECALC 33
5757
#define XFS_ERRTAG_IUNLINK_FALLBACK 34
5858
#define XFS_ERRTAG_BUF_IOERROR 35
59-
#define XFS_ERRTAG_MAX 36
59+
#define XFS_ERRTAG_REDUCE_MAX_IEXTENTS 36
60+
#define XFS_ERRTAG_MAX 37
6061

6162
/*
6263
* Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
@@ -97,5 +98,6 @@
9798
#define XFS_RANDOM_FORCE_SUMMARY_RECALC 1
9899
#define XFS_RANDOM_IUNLINK_FALLBACK (XFS_RANDOM_DEFAULT/10)
99100
#define XFS_RANDOM_BUF_IOERROR XFS_RANDOM_DEFAULT
101+
#define XFS_RANDOM_REDUCE_MAX_IEXTENTS 1
100102

101103
#endif /* __XFS_ERRORTAG_H_ */

fs/xfs/libxfs/xfs_inode_fork.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "xfs_dir2_priv.h"
2525
#include "xfs_attr_leaf.h"
2626
#include "xfs_types.h"
27+
#include "xfs_errortag.h"
2728

2829
kmem_zone_t *xfs_ifork_zone;
2930

@@ -745,6 +746,9 @@ xfs_iext_count_may_overflow(
745746

746747
max_exts = (whichfork == XFS_ATTR_FORK) ? MAXAEXTNUM : MAXEXTNUM;
747748

749+
if (XFS_TEST_ERROR(false, ip->i_mount, XFS_ERRTAG_REDUCE_MAX_IEXTENTS))
750+
max_exts = 10;
751+
748752
nr_exts = ifp->if_nextents + nr_to_add;
749753
if (nr_exts < ifp->if_nextents || nr_exts > max_exts)
750754
return -EFBIG;

fs/xfs/xfs_error.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static unsigned int xfs_errortag_random_default[] = {
5454
XFS_RANDOM_FORCE_SUMMARY_RECALC,
5555
XFS_RANDOM_IUNLINK_FALLBACK,
5656
XFS_RANDOM_BUF_IOERROR,
57+
XFS_RANDOM_REDUCE_MAX_IEXTENTS,
5758
};
5859

5960
struct xfs_errortag_attr {
@@ -164,6 +165,7 @@ XFS_ERRORTAG_ATTR_RW(force_repair, XFS_ERRTAG_FORCE_SCRUB_REPAIR);
164165
XFS_ERRORTAG_ATTR_RW(bad_summary, XFS_ERRTAG_FORCE_SUMMARY_RECALC);
165166
XFS_ERRORTAG_ATTR_RW(iunlink_fallback, XFS_ERRTAG_IUNLINK_FALLBACK);
166167
XFS_ERRORTAG_ATTR_RW(buf_ioerror, XFS_ERRTAG_BUF_IOERROR);
168+
XFS_ERRORTAG_ATTR_RW(reduce_max_iextents, XFS_ERRTAG_REDUCE_MAX_IEXTENTS);
167169

168170
static struct attribute *xfs_errortag_attrs[] = {
169171
XFS_ERRORTAG_ATTR_LIST(noerror),
@@ -202,6 +204,7 @@ static struct attribute *xfs_errortag_attrs[] = {
202204
XFS_ERRORTAG_ATTR_LIST(bad_summary),
203205
XFS_ERRORTAG_ATTR_LIST(iunlink_fallback),
204206
XFS_ERRORTAG_ATTR_LIST(buf_ioerror),
207+
XFS_ERRORTAG_ATTR_LIST(reduce_max_iextents),
205208
NULL,
206209
};
207210

0 commit comments

Comments
 (0)