Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Aug 2023 06:26:13 GMT
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 44e4279e565f - stable/13 - Add diagnostics to fsck_ffs(8) for journaled soft-updates debugging.
Message-ID:  <202308050626.3756QDEw027998@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=44e4279e565fbd00804bb8e9ad03df03ab6ac5ee

commit 44e4279e565fbd00804bb8e9ad03df03ab6ac5ee
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2023-07-26 21:49:07 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2023-08-05 06:22:19 +0000

    Add diagnostics to fsck_ffs(8) for journaled soft-updates debugging.
    
    Sponsored-by: The FreeBSD Foundation
    (cherry picked from commit 6f0ca273a393bad293cc3ae12b3816ab1582bbc2)
---
 sbin/fsck_ffs/suj.c | 32 +++++++++++++++++---------------
 sys/ufs/ffs/fs.h    | 14 +++++++++++++-
 2 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c
index 0b1202866fe5..1ae9d4d4b675 100644
--- a/sbin/fsck_ffs/suj.c
+++ b/sbin/fsck_ffs/suj.c
@@ -113,6 +113,7 @@ static TAILQ_HEAD(seghd, suj_seg) allsegs;
 static uint64_t oldseq;
 static struct fs *fs = NULL;
 static ino_t sujino;
+static char *joptype[JOP_NUMJOPTYPES] = JOP_NAMES;
 
 /*
  * Summary statistics.
@@ -1444,9 +1445,9 @@ ino_check(struct suj_ino *sino)
 			err_suj("Inode mode/directory type mismatch %o != %o\n",
 			    mode, rrec->jr_mode);
 		if (debug)
-			printf("jrefrec: op %d ino %ju, nlink %ju, parent %ju, "
+			printf("jrefrec: op %s ino %ju, nlink %ju, parent %ju, "
 			    "diroff %jd, mode %o, isat %d, isdot %d\n",
-			    rrec->jr_op, (uintmax_t)rrec->jr_ino,
+			    JOP_OPTYPE(rrec->jr_op), (uintmax_t)rrec->jr_ino,
 			    (uintmax_t)rrec->jr_nlink,
 			    (uintmax_t)rrec->jr_parent,
 			    (uintmax_t)rrec->jr_diroff,
@@ -1510,9 +1511,10 @@ blk_check(struct suj_blk *sblk)
 			sino->si_blkadj = 1;
 		}
 		if (debug)
-			printf("op %d blk %jd ino %ju lbn %jd frags %d isat %d "
-			    "(%d)\n", brec->jb_op, blk, (uintmax_t)brec->jb_ino,
-			    brec->jb_lbn, brec->jb_frags, isat, frags);
+			printf("op %s blk %jd ino %ju lbn %jd frags %d isat %d "
+			    "(%d)\n", JOP_OPTYPE(brec->jb_op), blk,
+			    (uintmax_t)brec->jb_ino, brec->jb_lbn,
+			    brec->jb_frags, isat, frags);
 		/*
 		 * If we found the block at this address we still have to
 		 * determine if we need to free the tail end that was
@@ -1694,9 +1696,9 @@ ino_append(union jrec *rec)
 		    (uintmax_t)mvrec->jm_newoff, (uintmax_t)mvrec->jm_oldoff);
 	else if (debug &&
 	    (refrec->jr_op == JOP_ADDREF || refrec->jr_op == JOP_REMREF))
-		printf("ino ref: op %d, ino %ju, nlink %ju, "
+		printf("ino ref: op %s, ino %ju, nlink %ju, "
 		    "parent %ju, diroff %jd\n",
-		    refrec->jr_op, (uintmax_t)refrec->jr_ino,
+		    JOP_OPTYPE(refrec->jr_op), (uintmax_t)refrec->jr_ino,
 		    (uintmax_t)refrec->jr_nlink,
 		    (uintmax_t)refrec->jr_parent, (uintmax_t)refrec->jr_diroff);
 	sino = ino_lookup(((struct jrefrec *)rec)->jr_ino, 1);
@@ -1856,8 +1858,8 @@ ino_build_ref(struct suj_ino *sino, struct suj_rec *srec)
 			TAILQ_REMOVE(&sino->si_newrecs, srn, sr_next);
 			break;
 		default:
-			err_suj("ino_build_ref: Unknown op %d\n",
-			    srn->sr_rec->rec_jrefrec.jr_op);
+			err_suj("ino_build_ref: Unknown op %s\n",
+			    JOP_OPTYPE(srn->sr_rec->rec_jrefrec.jr_op));
 		}
 	}
 	ino_add_ref(sino, srec);
@@ -1886,8 +1888,8 @@ ino_build(struct suj_ino *sino)
 			TAILQ_INSERT_TAIL(&sino->si_movs, srec, sr_next);
 			break;
 		default:
-			err_suj("ino_build: Unknown op %d\n",
-			    srec->sr_rec->rec_jrefrec.jr_op);
+			err_suj("ino_build: Unknown op %s\n",
+			    JOP_OPTYPE(srec->sr_rec->rec_jrefrec.jr_op));
 		}
 	}
 	if (TAILQ_EMPTY(&sino->si_recs))
@@ -1909,9 +1911,9 @@ blk_build(struct jblkrec *blkrec)
 	int frag;
 
 	if (debug)
-		printf("blk_build: op %d blkno %jd frags %d oldfrags %d "
+		printf("blk_build: op %s blkno %jd frags %d oldfrags %d "
 		    "ino %ju lbn %jd\n",
-		    blkrec->jb_op, (uintmax_t)blkrec->jb_blkno,
+		    JOP_OPTYPE(blkrec->jb_op), (uintmax_t)blkrec->jb_blkno,
 		    blkrec->jb_frags, blkrec->jb_oldfrags,
 		    (uintmax_t)blkrec->jb_ino, (uintmax_t)blkrec->jb_lbn);
 
@@ -2016,8 +2018,8 @@ suj_build(void)
 				ino_build_trunc((struct jtrncrec *)rec);
 				break;
 			default:
-				err_suj("Unknown journal operation %d (%d)\n",
-				    rec->rec_jrefrec.jr_op, off);
+				err_suj("Unknown journal operation %s at %d\n",
+				    JOP_OPTYPE(rec->rec_jrefrec.jr_op), off);
 			}
 			i++;
 		}
diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h
index 70e24242b01b..9b1181250669 100644
--- a/sys/ufs/ffs/fs.h
+++ b/sys/ufs/ffs/fs.h
@@ -755,7 +755,7 @@ lbn_offset(struct fs *fs, int level)
 /*
  * Softdep journal record format.
  */
-
+#define	JOP_UNKNOWN	0	/* JOP operation is unknown */
 #define	JOP_ADDREF	1	/* Add a reference to an inode. */
 #define	JOP_REMREF	2	/* Remove a reference from an inode. */
 #define	JOP_NEWBLK	3	/* Allocate a block. */
@@ -763,6 +763,18 @@ lbn_offset(struct fs *fs, int level)
 #define	JOP_MVREF	5	/* Move a reference from one off to another. */
 #define	JOP_TRUNC	6	/* Partial truncation record. */
 #define	JOP_SYNC	7	/* fsync() complete record. */
+#define	JOP_NUMJOPTYPES	8
+#define JOP_NAMES {	\
+        "unknown",	\
+	"JOP_ADDREF",	\
+	"JOP_REMREF",	\
+	"JOP_NEWBLK",	\
+	"JOP_FREEBLK",	\
+	"JOP_MVREF",	\
+	"JOP_TRUNC",	\
+	"JOP_SYNC" }
+#define JOP_OPTYPE(op) \
+	(op) < JOP_NUMJOPTYPES ? joptype[op] : joptype[JOP_UNKNOWN]
 
 #define	JREC_SIZE	32	/* Record and segment header size. */
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308050626.3756QDEw027998>