fix for per-mount i/o counting in ffs

Konstantin Belousov kostikbel at gmail.com
Tue May 17 08:42:47 UTC 2016


On Tue, May 17, 2016 at 07:26:08AM +1000, Bruce Evans wrote:
> Counting of i/o's in g_vfs_strategy() requires the fs to initialize
> devvp->v_rdev->si_mountpt to non-null.  This seems to be done correctly
> in ext2fs and msdosfs, but in ffs it is not done for ro mounts, or for
> rw mounts that started as ro.  The bug is most obvious for the root
> file system since it always starts as ro.

I committed the comments updates.

For the accounting patch, don't we want to account for all io, including
the mount-time metadata reads and initial superblock update ?

diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 9776554..712fc21 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -780,6 +780,8 @@ ffs_mountfs(devvp, mp, td)
 		mp->mnt_iosize_max = MAXPHYS;
 
 	devvp->v_bufobj.bo_ops = &ffs_ops;
+	if (devvp->v_type == VCHR)
+		devvp->v_rdev->si_mountpt = mp;
 
 	fs = NULL;
 	sblockloc = 0;
@@ -1049,8 +1051,6 @@ ffs_mountfs(devvp, mp, td)
 			ffs_flushfiles(mp, FORCECLOSE, td);
 			goto out;
 		}
-		if (devvp->v_type == VCHR && devvp->v_rdev != NULL)
-			devvp->v_rdev->si_mountpt = mp;
 		if (fs->fs_snapinum[0] != 0)
 			ffs_snapshot_mount(mp);
 		fs->fs_fmod = 1;
@@ -1083,6 +1083,8 @@ ffs_mountfs(devvp, mp, td)
 out:
 	if (bp)
 		brelse(bp);
+	if (devvp->v_type == VCHR && devvp->v_rdev != NULL)
+		devvp->v_rdev->si_mountpt = NULL;
 	if (cp != NULL) {
 		DROP_GIANT();
 		g_topology_lock();


More information about the freebsd-fs mailing list