[PATCH 3/3] xfs: convert sparse inode alloc debug fallback to errortag

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

 



XFS includes DEBUG logic to randomly fall into sparse inode chunk
allocation. This is to facilitate code coverage testing as sparse
allocation is really only required once an AG has insufficiently
large free extents to allocate a full inode chunk.

Similar to for the extent allocation path, convert this into an
errortag that is enabled by default to maintain current DEBUG mode
behavior.

Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
---
 fs/xfs/libxfs/xfs_errortag.h |  4 +++-
 fs/xfs/libxfs/xfs_ialloc.c   | 14 +++++---------
 fs/xfs/xfs_error.c           |  3 +++
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_errortag.h b/fs/xfs/libxfs/xfs_errortag.h
index c57d26619817..3a1404a24584 100644
--- a/fs/xfs/libxfs/xfs_errortag.h
+++ b/fs/xfs/libxfs/xfs_errortag.h
@@ -66,7 +66,8 @@
 #define XFS_ERRTAG_EXCHMAPS_FINISH_ONE			44
 #define XFS_ERRTAG_METAFILE_RESV_CRITICAL		45
 #define XFS_ERRTAG_AG_ALLOC_SKIP			46
-#define XFS_ERRTAG_MAX					47
+#define XFS_ERRTAG_SPARSE_IALLOC			47
+#define XFS_ERRTAG_MAX					48
 
 /*
  * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
@@ -117,5 +118,6 @@
 #define XFS_RANDOM_EXCHMAPS_FINISH_ONE			1
 #define XFS_RANDOM_METAFILE_RESV_CRITICAL		4
 #define XFS_RANDOM_AG_ALLOC_SKIP			2
+#define XFS_RANDOM_SPARSE_IALLOC			2
 
 #endif /* __XFS_ERRORTAG_H_ */
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 0c47b5c6ca7d..9901e09e7a5d 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -707,7 +707,6 @@ xfs_ialloc_ag_alloc(
 	struct xfs_inobt_rec_incore rec;
 	struct xfs_ino_geometry	*igeo = M_IGEO(tp->t_mountp);
 	uint16_t		allocmask = (uint16_t) -1;
-	int			do_sparse = 0;
 
 	memset(&args, 0, sizeof(args));
 	args.tp = tp;
@@ -716,13 +715,6 @@ xfs_ialloc_ag_alloc(
 	args.oinfo = XFS_RMAP_OINFO_INODES;
 	args.pag = pag;
 
-#ifdef DEBUG
-	/* randomly do sparse inode allocations */
-	if (xfs_has_sparseinodes(tp->t_mountp) &&
-	    igeo->ialloc_min_blks < igeo->ialloc_blks)
-		do_sparse = get_random_u32_below(2);
-#endif
-
 	/*
 	 * Locking will ensure that we don't have two callers in here
 	 * at one time.
@@ -742,8 +734,12 @@ xfs_ialloc_ag_alloc(
 	newino = be32_to_cpu(agi->agi_newino);
 	args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) +
 		     igeo->ialloc_blks;
-	if (do_sparse)
+
+	if (xfs_has_sparseinodes(args.mp) &&
+	    igeo->ialloc_min_blks < igeo->ialloc_blks &&
+	    XFS_TEST_ERROR(false, args.mp, XFS_ERRTAG_SPARSE_IALLOC))
 		goto sparse_alloc;
+
 	if (likely(newino != NULLAGINO &&
 		  (args.agbno < be32_to_cpu(agi->agi_length)))) {
 		args.prod = 1;
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index f1222e4e8c5f..480fabfadf39 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -65,6 +65,7 @@ static unsigned int xfs_errortag_random_default[] = {
 	XFS_RANDOM_EXCHMAPS_FINISH_ONE,
 	XFS_RANDOM_METAFILE_RESV_CRITICAL,
 	XFS_RANDOM_AG_ALLOC_SKIP,
+	XFS_RANDOM_SPARSE_IALLOC,
 };
 
 struct xfs_errortag_attr {
@@ -189,6 +190,7 @@ XFS_ERRORTAG_ATTR_RW(write_delay_ms,	XFS_ERRTAG_WRITE_DELAY_MS);
 XFS_ERRORTAG_ATTR_RW(exchmaps_finish_one, XFS_ERRTAG_EXCHMAPS_FINISH_ONE);
 XFS_ERRORTAG_ATTR_RW(metafile_resv_crit, XFS_ERRTAG_METAFILE_RESV_CRITICAL);
 __XFS_ERRORTAG_ATTR_RW(ag_alloc_skip,	XFS_ERRTAG_AG_ALLOC_SKIP,	true);
+__XFS_ERRORTAG_ATTR_RW(sparse_ialloc,	XFS_ERRTAG_SPARSE_IALLOC,	true);
 
 static struct attribute *xfs_errortag_attrs[] = {
 	XFS_ERRORTAG_ATTR_LIST(noerror),
@@ -237,6 +239,7 @@ static struct attribute *xfs_errortag_attrs[] = {
 	XFS_ERRORTAG_ATTR_LIST(exchmaps_finish_one),
 	XFS_ERRORTAG_ATTR_LIST(metafile_resv_crit),
 	XFS_ERRORTAG_ATTR_LIST(ag_alloc_skip),
+	XFS_ERRORTAG_ATTR_LIST(sparse_ialloc),
 	NULL,
 };
 ATTRIBUTE_GROUPS(xfs_errortag);
-- 
2.49.0





[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