Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Nov 2010 11:38:57 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r215114 - head/sys/ufs/ffs
Message-ID:  <201011111138.oABBcvqk066043@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Nov 11 11:38:57 2010
New Revision: 215114
URL: http://svn.freebsd.org/changeset/base/215114

Log:
  In journal_mount(), only set MNTK_SUJ flag after the jblocks are mapped.
  I believe there is a window otherwise where jblocks can be accessed
  without proper initialization.
  
  Reviewed by:	jeff
  Tested by:	pho

Modified:
  head/sys/ufs/ffs/ffs_softdep.c

Modified: head/sys/ufs/ffs/ffs_softdep.c
==============================================================================
--- head/sys/ufs/ffs/ffs_softdep.c	Thu Nov 11 11:35:42 2010	(r215113)
+++ head/sys/ufs/ffs/ffs_softdep.c	Thu Nov 11 11:38:57 2010	(r215114)
@@ -2270,7 +2270,6 @@ journal_mount(mp, fs, cred)
 	int error;
 	int i;
 
-	mp->mnt_kern_flag |= MNTK_SUJ;
 	error = softdep_journal_lookup(mp, &vp);
 	if (error != 0) {
 		printf("Failed to find journal.  Use tunefs to create one\n");
@@ -2295,20 +2294,26 @@ journal_mount(mp, fs, cred)
 	}
 	jblocks->jb_low = jblocks->jb_free / 3;	/* Reserve 33%. */
 	jblocks->jb_min = jblocks->jb_free / 10; /* Suspend at 10%. */
-	/*
-	 * Only validate the journal contents if the filesystem is clean,
-	 * otherwise we write the logs but they'll never be used.  If the
-	 * filesystem was still dirty when we mounted it the journal is
-	 * invalid and a new journal can only be valid if it starts from a
-	 * clean mount.
-	 */
-	if (fs->fs_clean) {
-		DIP_SET(ip, i_modrev, fs->fs_mtime);
-		ip->i_flags |= IN_MODIFIED;
-		ffs_update(vp, 1);
-	}
 	VFSTOUFS(mp)->softdep_jblocks = jblocks;
 out:
+	if (error == 0) {
+		MNT_ILOCK(mp);
+		mp->mnt_kern_flag |= MNTK_SUJ;
+		MNT_IUNLOCK(mp);
+		/*
+		 * Only validate the journal contents if the
+		 * filesystem is clean, otherwise we write the logs
+		 * but they'll never be used.  If the filesystem was
+		 * still dirty when we mounted it the journal is
+		 * invalid and a new journal can only be valid if it
+		 * starts from a clean mount.
+		 */
+		if (fs->fs_clean) {
+			DIP_SET(ip, i_modrev, fs->fs_mtime);
+			ip->i_flags |= IN_MODIFIED;
+			ffs_update(vp, 1);
+		}
+	}
 	vput(vp);
 	return (error);
 }



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