From owner-svn-src-head@FreeBSD.ORG Sun Oct 19 06:59:34 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A4CF4CCC; Sun, 19 Oct 2014 06:59:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8F5E8BA; Sun, 19 Oct 2014 06:59:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9J6xYlf034749; Sun, 19 Oct 2014 06:59:34 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9J6xXQE034746; Sun, 19 Oct 2014 06:59:33 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201410190659.s9J6xXQE034746@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 19 Oct 2014 06:59:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273271 - in head/sys: fs/tmpfs kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Oct 2014 06:59:34 -0000 Author: mjg Date: Sun Oct 19 06:59:33 2014 New Revision: 273271 URL: https://svnweb.freebsd.org/changeset/base/273271 Log: Provide vfs suspension support only for filesystems which need it. Need is expressed by providing vfs_susp_clean function in vfsops. Differential Revision: D952 Reviewed by: kib (previous version) MFC after: 2 weeks Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c head/sys/kern/vfs_vnops.c head/sys/sys/mount.h Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_vfsops.c Sun Oct 19 04:38:02 2014 (r273270) +++ head/sys/fs/tmpfs/tmpfs_vfsops.c Sun Oct 19 06:59:33 2014 (r273271) @@ -427,6 +427,14 @@ tmpfs_sync(struct mount *mp, int waitfor } /* + * A stub created so that vfs does vn_start_write for this filesystem + */ +static void +tmpfs_susp_clean(struct mount *mp) +{ +} + +/* * tmpfs vfs operations. */ @@ -437,5 +445,6 @@ struct vfsops tmpfs_vfsops = { .vfs_statfs = tmpfs_statfs, .vfs_fhtovp = tmpfs_fhtovp, .vfs_sync = tmpfs_sync, + .vfs_susp_clean = tmpfs_susp_clean, }; VFS_SET(tmpfs_vfsops, tmpfs, VFCF_JAIL); Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Sun Oct 19 04:38:02 2014 (r273270) +++ head/sys/kern/vfs_vnops.c Sun Oct 19 06:59:33 2014 (r273271) @@ -1572,6 +1572,25 @@ vn_closefile(fp, td) return (error); } +static bool +vn_suspendable_mp(struct mount *mp) +{ + + return (mp->mnt_op->vfs_susp_clean != NULL); +} + +static bool +vn_suspendable(struct vnode *vp, struct mount **mpp) +{ + + if (vp != NULL) + *mpp = vp->v_mount; + if (*mpp == NULL) + return (false); + + return (vn_suspendable_mp(*mpp)); +} + /* * Preparing to start a filesystem write operation. If the operation is * permitted, then we bump the count of operations in progress and @@ -1621,6 +1640,9 @@ vn_start_write(vp, mpp, flags) struct mount *mp; int error; + if (!vn_suspendable(vp, mpp)) + return (0); + error = 0; /* * If a vnode is provided, get and return the mount point that @@ -1667,6 +1689,9 @@ vn_start_secondary_write(vp, mpp, flags) struct mount *mp; int error; + if (!vn_suspendable(vp, mpp)) + return (0); + retry: if (vp != NULL) { if ((error = VOP_GETWRITEMOUNT(vp, mpp)) != 0) { @@ -1724,7 +1749,7 @@ void vn_finished_write(mp) struct mount *mp; { - if (mp == NULL) + if (mp == NULL || !vn_suspendable_mp(mp)) return; MNT_ILOCK(mp); MNT_REL(mp); @@ -1747,7 +1772,7 @@ void vn_finished_secondary_write(mp) struct mount *mp; { - if (mp == NULL) + if (mp == NULL || !vn_suspendable_mp(mp)) return; MNT_ILOCK(mp); MNT_REL(mp); @@ -1770,6 +1795,8 @@ vfs_write_suspend(struct mount *mp, int { int error; + MPASS(vn_suspendable_mp(mp)); + MNT_ILOCK(mp); if (mp->mnt_susp_owner == curthread) { MNT_IUNLOCK(mp); @@ -1811,6 +1838,8 @@ void vfs_write_resume(struct mount *mp, int flags) { + MPASS(vn_suspendable_mp(mp)); + MNT_ILOCK(mp); if ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) { KASSERT(mp->mnt_susp_owner == curthread, ("mnt_susp_owner")); @@ -1844,6 +1873,7 @@ vfs_write_suspend_umnt(struct mount *mp) { int error; + MPASS(vn_suspendable_mp(mp)); KASSERT((curthread->td_pflags & TDP_IGNSUSP) == 0, ("vfs_write_suspend_umnt: recursed")); Modified: head/sys/sys/mount.h ============================================================================== --- head/sys/sys/mount.h Sun Oct 19 04:38:02 2014 (r273270) +++ head/sys/sys/mount.h Sun Oct 19 06:59:33 2014 (r273271) @@ -754,11 +754,10 @@ vfs_statfs_t __vfs_statfs; _rc; }) #define VFS_SUSP_CLEAN(MP) do { \ - if (*(MP)->mnt_op->vfs_susp_clean != NULL) { \ - VFS_PROLOGUE(MP); \ - (*(MP)->mnt_op->vfs_susp_clean)(MP); \ - VFS_EPILOGUE(MP); \ - } \ + MPASS(*(MP)->mnt_op->vfs_susp_clean != NULL); \ + VFS_PROLOGUE(MP); \ + (*(MP)->mnt_op->vfs_susp_clean)(MP); \ + VFS_EPILOGUE(MP); \ } while (0) #define VFS_RECLAIM_LOWERVP(MP, VP) do { \