Why does ufs choose panic instead of EIO when processing illegal directory data?

Raymond Yuan number201724 at me.com
Tue Apr 6 12:22:13 UTC 2021


Why does ufs choose panic instead of EIO when processing illegal directory data?

I have a virtual machine. When my database directory is damaged, every time I start the system, once I start the mysql system, it will panic and keep panic.

Many times when this kind of problem occurs, it is caused by accidental power failure or panic.


The problem is that the file system has been damaged, but after panic, the last panic crash information will be written to the file system every time it is started. Is this a bit too dangerous?

void
ufs_dirbad(ip, offset, how)
	struct inode *ip;
	doff_t offset;
	char *how;
{
	struct mount *mp;

	mp = ITOV(ip)->v_mount;
	if ((mp->mnt_flag & MNT_RDONLY) == 0)
		panic("ufs_dirbad: %s: bad dir ino %ju at offset %ld: %s",
		    mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number,
		    (long)offset, how);
	else
		(void)printf("%s: bad dir ino %ju at offset %ld: %s\n",
		    mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number,
		    (long)offset, how);
}


		ep = (struct direct *)((char *)bp->b_data + entryoffsetinblock);
		if (ep->d_reclen == 0 || ep->d_reclen >
		    DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1)) ||
		    (dirchk && ufs_dirbadentry(vdp, ep, entryoffsetinblock))) {
			int i;

			ufs_dirbad(dp, i_offset, "mangled entry");
			i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1));
			i_offset += i;
			entryoffsetinblock += i;
			continue;
		}





More information about the freebsd-fs mailing list