From owner-dev-commits-src-all@freebsd.org Wed Feb 24 07:56:59 2021 Return-Path: Delivered-To: dev-commits-src-all@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 824875533F9; Wed, 24 Feb 2021 07:56:59 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DlpCv3B9Vz4Ybt; Wed, 24 Feb 2021 07:56:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5E8C228E0F; Wed, 24 Feb 2021 07:56:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11O7uxQ1045754; Wed, 24 Feb 2021 07:56:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11O7uxKk045753; Wed, 24 Feb 2021 07:56:59 GMT (envelope-from git) Date: Wed, 24 Feb 2021 07:56:59 GMT Message-Id: <202102240756.11O7uxKk045753@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 498314627946 - main - ffs: do not call softdep_prealloc() from UFS_BALLOC() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 49831462794690155ce8dbe02679e6d9390f3d7d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Feb 2021 07:56:59 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=49831462794690155ce8dbe02679e6d9390f3d7d commit 49831462794690155ce8dbe02679e6d9390f3d7d Author: Konstantin Belousov AuthorDate: 2021-02-18 14:51:50 +0000 Commit: Konstantin Belousov CommitDate: 2021-02-24 07:54:50 +0000 ffs: do not call softdep_prealloc() from UFS_BALLOC() Do it in ffs_write(), where we can gracefuly handle relock and its consequences. In particular, recheck the v_data to see if the vnode reclamation ended, and return EBADF when we cannot proceed with the write. Reviewed by: mckusick Reported by: pho MFC after: 1 week Sponsored by: The FreeBSD Foundation --- sys/ufs/ffs/ffs_balloc.c | 5 ----- sys/ufs/ffs/ffs_vnops.c | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index daa897dfe032..1b53a90a48c4 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -128,8 +128,6 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size, return (EFBIG); gbflags = (flags & BA_UNMAPPED) != 0 ? GB_UNMAPPED : 0; - if (DOINGSOFTDEP(vp)) - softdep_prealloc(vp, MNT_WAIT); /* * If the next write will extend the file into a new block, * and the file is currently composed of a fragment @@ -621,9 +619,6 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size, return (EFBIG); gbflags = (flags & BA_UNMAPPED) != 0 ? GB_UNMAPPED : 0; - if (DOINGSOFTDEP(vp)) - softdep_prealloc(vp, MNT_WAIT); - /* * Check for allocating external data. */ diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 686bfddcb0ea..db14d2099be9 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -834,6 +834,11 @@ ffs_write(ap) int blkoffset, error, flags, ioflag, size, xfersize; vp = ap->a_vp; + if (DOINGSUJ(vp)) + softdep_prealloc(vp, MNT_WAIT); + if (vp->v_data == NULL) + return (EBADF); + uio = ap->a_uio; ioflag = ap->a_ioflag; if (ap->a_ioflag & IO_EXT)