Re: Dying SD memory? handle_workitem_freefile: got error 5 while accessing filesystem

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Sun, 24 Sep 2017 19:01:23 +0300
On Sun, Sep 24, 2017 at 08:32:54AM -0700, Rodney W. Grimes wrote:
> Would it be possible to add some robustness to these checksum
> failed errors to indicate there source more accurately?  Ie
> either a /dev entry or a fstab entry, and the fact they are
> from the ffs layer?

Perhaps this. But untested and somewhat racy.

diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index b981b5e5794..bd78b760442 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
_at__at_ -2584,6 +2584,15 _at__at_ ffs_mapsearch(fs, cgp, bpref, allocsiz)
 	return (-1);
 }
 
+static const struct statfs *
+ffs_getmntstat(struct vnode *devvp)
+{
+
+	if (devvp->v_type == VCHR)
+		return (&devvp->v_rdev->si_mountpt->mnt_stat);
+	return (ffs_getmntstat(VFSTOUFS(devvp->v_mount)->um_devvp));
+}
+
 /*
  * Fetch and verify a cylinder group.
  */
_at__at_ -2597,6 +2606,7 _at__at_ ffs_getcg(fs, devvp, cg, bpp, cgpp)
 {
 	struct buf *bp;
 	struct cg *cgp;
+	const struct statfs *sfs;
 	int flags, error;
 
 	*bpp = NULL;
_at__at_ -2615,7 +2625,11 _at__at_ ffs_getcg(fs, devvp, cg, bpp, cgpp)
 	    (bp->b_flags & B_CKHASH) != 0 &&
 	    cgp->cg_ckhash != bp->b_ckhash) ||
 	    !cg_chkmagic(cgp) || cgp->cg_cgx != cg) {
-		printf("checksum failed: cg %u, cgp: 0x%x != bp: 0x%jx\n",
+		sfs = ffs_getmntstat(devvp);
+		printf("UFS %s%s (%s) cylinder checksum failed: cg %u, cgp: "
+		    "0x%x != bp: 0x%jx\n",
+		    devvp->v_type == VCHR ? "" : "snapshot of ",
+		    sfs->f_mntfromname, sfs->f_mntonname,
 		    cg, cgp->cg_ckhash, (uintmax_t)bp->b_ckhash);
 		bp->b_flags &= ~B_CKHASH;
 		bp->b_flags |= B_INVAL | B_NOCACHE;
Received on Sun Sep 24 2017 - 14:01:34 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:13 UTC