svn commit: r231936 - in stable/9/sys: fs/ext2fs fs/nfsclient geom/journal kern nfsclient sys ufs/ufs

Konstantin Belousov kib at FreeBSD.org
Mon Feb 20 11:27:38 UTC 2012


Author: kib
Date: Mon Feb 20 11:27:37 2012
New Revision: 231936
URL: http://svn.freebsd.org/changeset/base/231936

Log:
  MFC r231075:
  Instead of removing MNTK_ASYNC from mnt_kern_flag, provide a local
  thread flag to disable async i/o for current thread only. Use the
  opportunity to move DOINGASYNC() macro into sys/vnode.h and
  consistently use it through places which tested for MNTK_ASYNC.
  
  MFC r231204:
  Unbreak detection of the async mode for clustered writes after r231075.

Modified:
  stable/9/sys/fs/ext2fs/inode.h
  stable/9/sys/fs/nfsclient/nfs_clvnops.c
  stable/9/sys/geom/journal/g_journal.c
  stable/9/sys/kern/vfs_cluster.c
  stable/9/sys/kern/vfs_subr.c
  stable/9/sys/kern/vfs_syscalls.c
  stable/9/sys/nfsclient/nfs_vnops.c
  stable/9/sys/sys/proc.h
  stable/9/sys/sys/vnode.h
  stable/9/sys/ufs/ufs/inode.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/fs/ext2fs/inode.h
==============================================================================
--- stable/9/sys/fs/ext2fs/inode.h	Mon Feb 20 10:15:20 2012	(r231935)
+++ stable/9/sys/fs/ext2fs/inode.h	Mon Feb 20 11:27:37 2012	(r231936)
@@ -160,9 +160,6 @@ struct indir {
 #define VTOI(vp)	((struct inode *)(vp)->v_data)
 #define ITOV(ip)	((ip)->i_vnode)
 
-/* Check whether the MNTK_ASYNC flag has been set for a mount point */
-#define DOINGASYNC(vp)		((vp)->v_mount->mnt_kern_flag & MNTK_ASYNC)
-
 /* This overlays the fid structure (see mount.h). */
 struct ufid {
 	uint16_t ufid_len;	/* Length of structure. */

Modified: stable/9/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- stable/9/sys/fs/nfsclient/nfs_clvnops.c	Mon Feb 20 10:15:20 2012	(r231935)
+++ stable/9/sys/fs/nfsclient/nfs_clvnops.c	Mon Feb 20 11:27:37 2012	(r231936)
@@ -1385,7 +1385,7 @@ ncl_writerpc(struct vnode *vp, struct ui
 		if (ret && !error)
 			error = ret;
 	}
-	if (vp->v_mount->mnt_kern_flag & MNTK_ASYNC)
+	if (DOINGASYNC(vp))
 		*iomode = NFSWRITE_FILESYNC;
 	if (error && NFS_ISV4(vp))
 		error = nfscl_maperr(uiop->uio_td, error, (uid_t)0, (gid_t)0);

Modified: stable/9/sys/geom/journal/g_journal.c
==============================================================================
--- stable/9/sys/geom/journal/g_journal.c	Mon Feb 20 10:15:20 2012	(r231935)
+++ stable/9/sys/geom/journal/g_journal.c	Mon Feb 20 11:27:37 2012	(r231936)
@@ -2869,7 +2869,7 @@ g_journal_do_switch(struct g_class *clas
 	struct mount *mp;
 	struct bintime bt;
 	char *mountpoint;
-	int error, vfslocked;
+	int error, save, vfslocked;
 
 	DROP_GIANT();
 	g_topology_lock();
@@ -2931,10 +2931,7 @@ g_journal_do_switch(struct g_class *clas
 			goto next;
 		}
 
-		MNT_ILOCK(mp);
-		mp->mnt_noasync++;
-		mp->mnt_kern_flag &= ~MNTK_ASYNC;
-		MNT_IUNLOCK(mp);
+		save = curthread_pflags_set(TDP_SYNCIO);
 
 		GJ_TIMER_START(1, &bt);
 		vfs_msync(mp, MNT_NOWAIT);
@@ -2949,11 +2946,7 @@ g_journal_do_switch(struct g_class *clas
 			    mountpoint, error);
 		}
 
-		MNT_ILOCK(mp);
-		mp->mnt_noasync--;
-		if ((mp->mnt_flag & MNT_ASYNC) != 0 && mp->mnt_noasync == 0)
-			mp->mnt_kern_flag |= MNTK_ASYNC;
-		MNT_IUNLOCK(mp);
+		curthread_pflags_restore(save);
 
 		vn_finished_write(mp);
 

Modified: stable/9/sys/kern/vfs_cluster.c
==============================================================================
--- stable/9/sys/kern/vfs_cluster.c	Mon Feb 20 10:15:20 2012	(r231935)
+++ stable/9/sys/kern/vfs_cluster.c	Mon Feb 20 11:27:37 2012	(r231936)
@@ -604,7 +604,7 @@ cluster_write(struct vnode *vp, struct b
 	int async;
 
 	if (vp->v_type == VREG) {
-		async = vp->v_mount->mnt_kern_flag & MNTK_ASYNC;
+		async = DOINGASYNC(vp);
 		lblocksize = vp->v_mount->mnt_stat.f_iosize;
 	} else {
 		async = 0;

Modified: stable/9/sys/kern/vfs_subr.c
==============================================================================
--- stable/9/sys/kern/vfs_subr.c	Mon Feb 20 10:15:20 2012	(r231935)
+++ stable/9/sys/kern/vfs_subr.c	Mon Feb 20 11:27:37 2012	(r231936)
@@ -3521,7 +3521,7 @@ sync_fsync(struct vop_fsync_args *ap)
 {
 	struct vnode *syncvp = ap->a_vp;
 	struct mount *mp = syncvp->v_mount;
-	int error;
+	int error, save;
 	struct bufobj *bo;
 
 	/*
@@ -3551,17 +3551,10 @@ sync_fsync(struct vop_fsync_args *ap)
 		vfs_unbusy(mp);
 		return (0);
 	}
-	MNT_ILOCK(mp);
-	mp->mnt_noasync++;
-	mp->mnt_kern_flag &= ~MNTK_ASYNC;
-	MNT_IUNLOCK(mp);
+	save = curthread_pflags_set(TDP_SYNCIO);
 	vfs_msync(mp, MNT_NOWAIT);
 	error = VFS_SYNC(mp, MNT_LAZY);
-	MNT_ILOCK(mp);
-	mp->mnt_noasync--;
-	if ((mp->mnt_flag & MNT_ASYNC) != 0 && mp->mnt_noasync == 0)
-		mp->mnt_kern_flag |= MNTK_ASYNC;
-	MNT_IUNLOCK(mp);
+	curthread_pflags_restore(save);
 	vn_finished_write(mp);
 	vfs_unbusy(mp);
 	return (error);

Modified: stable/9/sys/kern/vfs_syscalls.c
==============================================================================
--- stable/9/sys/kern/vfs_syscalls.c	Mon Feb 20 10:15:20 2012	(r231935)
+++ stable/9/sys/kern/vfs_syscalls.c	Mon Feb 20 11:27:37 2012	(r231936)
@@ -134,7 +134,7 @@ sys_sync(td, uap)
 	struct sync_args *uap;
 {
 	struct mount *mp, *nmp;
-	int vfslocked;
+	int save, vfslocked;
 
 	mtx_lock(&mountlist_mtx);
 	for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
@@ -145,18 +145,10 @@ sys_sync(td, uap)
 		vfslocked = VFS_LOCK_GIANT(mp);
 		if ((mp->mnt_flag & MNT_RDONLY) == 0 &&
 		    vn_start_write(NULL, &mp, V_NOWAIT) == 0) {
-			MNT_ILOCK(mp);
-			mp->mnt_noasync++;
-			mp->mnt_kern_flag &= ~MNTK_ASYNC;
-			MNT_IUNLOCK(mp);
+			save = curthread_pflags_set(TDP_SYNCIO);
 			vfs_msync(mp, MNT_NOWAIT);
 			VFS_SYNC(mp, MNT_NOWAIT);
-			MNT_ILOCK(mp);
-			mp->mnt_noasync--;
-			if ((mp->mnt_flag & MNT_ASYNC) != 0 &&
-			    mp->mnt_noasync == 0)
-				mp->mnt_kern_flag |= MNTK_ASYNC;
-			MNT_IUNLOCK(mp);
+			curthread_pflags_restore(save);
 			vn_finished_write(mp);
 		}
 		VFS_UNLOCK_GIANT(vfslocked);

Modified: stable/9/sys/nfsclient/nfs_vnops.c
==============================================================================
--- stable/9/sys/nfsclient/nfs_vnops.c	Mon Feb 20 10:15:20 2012	(r231935)
+++ stable/9/sys/nfsclient/nfs_vnops.c	Mon Feb 20 11:27:37 2012	(r231936)
@@ -1454,7 +1454,7 @@ nfs_writerpc(struct vnode *vp, struct ui
 		tsiz -= len;
 	}
 nfsmout:
-	if (vp->v_mount->mnt_kern_flag & MNTK_ASYNC)
+	if (DOINGASYNC(vp))
 		committed = NFSV3WRITE_FILESYNC;
 	*iomode = committed;
 	if (error)

Modified: stable/9/sys/sys/proc.h
==============================================================================
--- stable/9/sys/sys/proc.h	Mon Feb 20 10:15:20 2012	(r231935)
+++ stable/9/sys/sys/proc.h	Mon Feb 20 11:27:37 2012	(r231936)
@@ -400,7 +400,7 @@ do {									\
 #define	TDP_NOSLEEPING	0x00000100 /* Thread is not allowed to sleep on a sq. */
 #define	TDP_OWEUPC	0x00000200 /* Call addupc() at next AST. */
 #define	TDP_ITHREAD	0x00000400 /* Thread is an interrupt thread. */
-#define	TDP_UNUSED800	0x00000800 /* available. */
+#define	TDP_SYNCIO	0x00000800 /* Local override, disable async i/o. */
 #define	TDP_SCHED1	0x00001000 /* Reserved for scheduler private use */
 #define	TDP_SCHED2	0x00002000 /* Reserved for scheduler private use */
 #define	TDP_SCHED3	0x00004000 /* Reserved for scheduler private use */

Modified: stable/9/sys/sys/vnode.h
==============================================================================
--- stable/9/sys/sys/vnode.h	Mon Feb 20 10:15:20 2012	(r231935)
+++ stable/9/sys/sys/vnode.h	Mon Feb 20 11:27:37 2012	(r231936)
@@ -538,6 +538,10 @@ void	assert_vop_unlocked(struct vnode *v
  */
 #define VCALL(c) ((c)->a_desc->vdesc_call(c))
 
+#define DOINGASYNC(vp)	   					\
+	(((vp)->v_mount->mnt_kern_flag & MNTK_ASYNC) != 0 &&	\
+	 ((curthread->td_pflags & TDP_SYNCIO) == 0))
+
 /*
  * VMIO support inline
  */

Modified: stable/9/sys/ufs/ufs/inode.h
==============================================================================
--- stable/9/sys/ufs/ufs/inode.h	Mon Feb 20 10:15:20 2012	(r231935)
+++ stable/9/sys/ufs/ufs/inode.h	Mon Feb 20 11:27:37 2012	(r231936)
@@ -176,7 +176,6 @@ struct indir {
 /* Determine if soft dependencies are being done */
 #define DOINGSOFTDEP(vp)   ((vp)->v_mount->mnt_flag & (MNT_SOFTDEP | MNT_SUJ))
 #define MOUNTEDSOFTDEP(mp) ((mp)->mnt_flag & (MNT_SOFTDEP | MNT_SUJ))
-#define DOINGASYNC(vp)	   ((vp)->v_mount->mnt_kern_flag & MNTK_ASYNC)
 #define DOINGSUJ(vp)	   ((vp)->v_mount->mnt_flag & MNT_SUJ)
 #define MOUNTEDSUJ(mp)	   ((mp)->mnt_flag & MNT_SUJ)
 


More information about the svn-src-stable-9 mailing list