FreeBSD/sys/kern/vfs_vnops.c
/*
 * Request a filesystem to suspend write operations.
 */
Request a filesystem to suspend write operations.
Request a filesystem to suspend write operations .
int
vfs_write_suspend(struct mount *mp, int flags)
{
	int error;
	MPASS(vn_suspendable(mp));
	MNT_ILOCK(mp);
	if (mp->mnt_susp_owner == curthread) {
		MNT_IUNLOCK(mp);
		return (EALREADY);
	}
	while (mp->mnt_kern_flag & MNTK_SUSPEND)
		msleep(&mp->mnt_flag, MNT_MTX(mp), PUSER - 1, "wsuspfs", 0);
	if ((flags & VS_SKIP_UNMOUNT) != 0 &&
	    (mp->mnt_kern_flag & MNTK_UNMOUNT) != 0) {
		MNT_IUNLOCK(mp);
		return (EBUSY);
	}
	mp->mnt_kern_flag |= MNTK_SUSPEND;
	mp->mnt_susp_owner = curthread;
	if (mp->mnt_writeopcount > 0)
		(void) msleep(&mp->mnt_writeopcount, 
		    MNT_MTX(mp), (PUSER - 1)|PDROP, "suspwt", 0);
	else
		MNT_IUNLOCK(mp);
	if ((error = VFS_SYNC(mp, MNT_SUSPEND)) != 0)
		vfs_write_resume(mp, 0);
	return (error);
}
int vfs_write_suspend ( struct mount * mp , int flags ) { int error ; MPASS ( vn_suspendable ( mp ) ) ; MNT_ILOCK ( mp ) ; if ( mp -> mnt_susp_owner == curthread ) { MNT_IUNLOCK ( mp ) ; return ( EALREADY ) ; } while ( mp -> mnt_kern_flag & MNTK_SUSPEND ) msleep ( & mp -> mnt_flag , MNT_MTX ( mp ) , PUSER - 1 , " " , 0 ) ; if ( ( flags & VS_SKIP_UNMOUNT ) != 0 && ( mp -> mnt_kern_flag & MNTK_UNMOUNT ) != 0 ) { MNT_IUNLOCK ( mp ) ; return ( EBUSY ) ; } mp -> mnt_kern_flag |= MNTK_SUSPEND ; mp -> mnt_susp_owner = curthread ; if ( mp -> mnt_writeopcount > 0 ) ( void ) msleep ( & mp -> mnt_writeopcount , MNT_MTX ( mp ) , ( PUSER - 1 ) | PDROP , " " , 0 ) ; else MNT_IUNLOCK ( mp ) ; if ( ( error = VFS_SYNC ( mp , MNT_SUSPEND ) ) != 0 ) vfs_write_resume ( mp , 0 ) ; return ( error ) ; }
Request a filesystem to suspend write operations.
Request a filesystem to suspend write operations .
/*
	 * Unmount holds a write reference on the mount point.  If we
	 * own busy reference and drain for writers, we deadlock with
	 * the reference draining in the unmount path.  Callers of
	 * vfs_write_suspend() must specify VS_SKIP_UNMOUNT if
	 * vfs_busy() reference is owned and caller is not in the
	 * unmount context.
	 */