From owner-svn-src-head@freebsd.org Sat Feb 15 13:00:40 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1C76B23A29B; Sat, 15 Feb 2020 13:00:40 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48KVjM564wz4D2m; Sat, 15 Feb 2020 13:00:39 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A7254D239; Sat, 15 Feb 2020 13:00:39 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 01FD0dYP059585; Sat, 15 Feb 2020 13:00:39 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 01FD0dma059583; Sat, 15 Feb 2020 13:00:39 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202002151300.01FD0dma059583@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 15 Feb 2020 13:00:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357962 - in head/sys: fs/tmpfs kern X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: fs/tmpfs kern X-SVN-Commit-Revision: 357962 X-SVN-Commit-Repository: base 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.29 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: Sat, 15 Feb 2020 13:00:40 -0000 Author: mjg Date: Sat Feb 15 13:00:39 2020 New Revision: 357962 URL: https://svnweb.freebsd.org/changeset/base/357962 Log: vfs: make write suspension mandatory At the time opt-in was introduced adding yourself as a writer was esrializing across the mount point. Nowadays it is fully per-cpu, the only impact being a small single-threaded hit on top of what's there right now. Vast majority of the overhead stems from the call to VOP_GETWRITEMOUNT which has is done regardless. Should someone want to microoptimize this single-threaded they can coalesce looking the mount up with adding a write to it. Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c head/sys/kern/vfs_vnops.c Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_vfsops.c Sat Feb 15 12:05:11 2020 (r357961) +++ head/sys/fs/tmpfs/tmpfs_vfsops.c Sat Feb 15 13:00:39 2020 (r357962) @@ -88,7 +88,6 @@ static int tmpfs_root(struct mount *, int flags, struc static int tmpfs_fhtovp(struct mount *, struct fid *, int, struct vnode **); static int tmpfs_statfs(struct mount *, struct statfs *); -static void tmpfs_susp_clean(struct mount *); static const char *tmpfs_opts[] = { "from", "size", "maxfilesize", "inodes", "uid", "gid", "mode", "export", @@ -646,14 +645,6 @@ tmpfs_sync(struct mount *mp, int waitfor) return (0); } -/* - * The presence of a susp_clean method tells the VFS to track writes. - */ -static void -tmpfs_susp_clean(struct mount *mp __unused) -{ -} - static int tmpfs_init(struct vfsconf *conf) { @@ -679,7 +670,6 @@ struct vfsops tmpfs_vfsops = { .vfs_statfs = tmpfs_statfs, .vfs_fhtovp = tmpfs_fhtovp, .vfs_sync = tmpfs_sync, - .vfs_susp_clean = tmpfs_susp_clean, .vfs_init = tmpfs_init, .vfs_uninit = tmpfs_uninit, }; Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Sat Feb 15 12:05:11 2020 (r357961) +++ head/sys/kern/vfs_vnops.c Sat Feb 15 13:00:39 2020 (r357962) @@ -1643,13 +1643,6 @@ vn_closefile(struct file *fp, struct thread *td) return (error); } -static bool -vn_suspendable(struct mount *mp) -{ - - return (mp->mnt_op->vfs_susp_clean != NULL); -} - /* * Preparing to start a filesystem write operation. If the operation is * permitted, then we bump the count of operations in progress and @@ -1729,12 +1722,6 @@ vn_start_write(struct vnode *vp, struct mount **mpp, i if ((mp = *mpp) == NULL) return (0); - if (!vn_suspendable(mp)) { - if (vp != NULL || (flags & V_MNTREF) != 0) - vfs_rel(mp); - return (0); - } - /* * VOP_GETWRITEMOUNT() returns with the mp refcount held through * a vfs_ref(). @@ -1780,12 +1767,6 @@ vn_start_secondary_write(struct vnode *vp, struct moun if ((mp = *mpp) == NULL) return (0); - if (!vn_suspendable(mp)) { - if (vp != NULL || (flags & V_MNTREF) != 0) - vfs_rel(mp); - return (0); - } - /* * VOP_GETWRITEMOUNT() returns with the mp refcount held through * a vfs_ref(). @@ -1829,7 +1810,7 @@ vn_finished_write(struct mount *mp) { int c; - if (mp == NULL || !vn_suspendable(mp)) + if (mp == NULL) return; if (vfs_op_thread_enter(mp)) { @@ -1863,7 +1844,7 @@ vn_finished_write(struct mount *mp) void vn_finished_secondary_write(struct mount *mp) { - if (mp == NULL || !vn_suspendable(mp)) + if (mp == NULL) return; MNT_ILOCK(mp); MNT_REL(mp); @@ -1884,8 +1865,6 @@ vfs_write_suspend(struct mount *mp, int flags) { int error; - MPASS(vn_suspendable(mp)); - vfs_op_enter(mp); MNT_ILOCK(mp); @@ -1934,8 +1913,6 @@ void vfs_write_resume(struct mount *mp, int flags) { - MPASS(vn_suspendable(mp)); - MNT_ILOCK(mp); if ((mp->mnt_kern_flag & MNTK_SUSPEND) != 0) { KASSERT(mp->mnt_susp_owner == curthread, ("mnt_susp_owner")); @@ -1970,7 +1947,6 @@ vfs_write_suspend_umnt(struct mount *mp) { int error; - MPASS(vn_suspendable(mp)); KASSERT((curthread->td_pflags & TDP_IGNSUSP) == 0, ("vfs_write_suspend_umnt: recursed"));