From owner-dev-commits-src-main@freebsd.org Sun Jan 3 21:22:43 2021 Return-Path: Delivered-To: dev-commits-src-main@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 85BAF4DFE1A; Sun, 3 Jan 2021 21:22:43 +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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4D8BYb3QpZz4n8c; Sun, 3 Jan 2021 21:22:43 +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 5C07569C7; Sun, 3 Jan 2021 21:22:43 +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 103LMhNn054230; Sun, 3 Jan 2021 21:22:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 103LMhBo054229; Sun, 3 Jan 2021 21:22:43 GMT (envelope-from git) Date: Sun, 3 Jan 2021 21:22:43 GMT Message-Id: <202101032122.103LMhBo054229@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 33a195baf324 - main - vfs: keep seqc unchanged as long as the vnode is accessible via SMR MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 33a195baf324f260dd0b81a5e292f26c41044bad Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jan 2021 21:22:43 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=33a195baf324f260dd0b81a5e292f26c41044bad commit 33a195baf324f260dd0b81a5e292f26c41044bad Author: Mateusz Guzik AuthorDate: 2021-01-03 07:34:08 +0000 Commit: Mateusz Guzik CommitDate: 2021-01-03 21:22:16 +0000 vfs: keep seqc unchanged as long as the vnode is accessible via SMR --- sys/kern/vfs_subr.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 680475c00d52..8461fd0d49b5 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -108,6 +108,8 @@ static int flushbuflist(struct bufv *bufv, int flags, struct bufobj *bo, static void syncer_shutdown(void *arg, int howto); static int vtryrecycle(struct vnode *vp); static void v_init_counters(struct vnode *); +static void vn_seqc_init(struct vnode *); +static void vn_seqc_write_end_free(struct vnode *vp); static void vgonel(struct vnode *); static bool vhold_recycle_free(struct vnode *); static void vfs_knllock(void *arg); @@ -1719,6 +1721,7 @@ getnewvnode(const char *tag, struct mount *mp, struct vop_vector *vops, vp->v_op = vops; vp->v_irflag = 0; v_init_counters(vp); + vn_seqc_init(vp); vp->v_bufobj.bo_ops = &buf_ops_bio; #ifdef DIAGNOSTIC if (mp == NULL && vops != &dead_vnodeops) @@ -1787,8 +1790,7 @@ freevnode(struct vnode *vp) /* * Paired with vgone. */ - vn_seqc_write_end_locked(vp); - VNPASS(vp->v_seqc_users == 0, vp); + vn_seqc_write_end_free(vp); bo = &vp->v_bufobj; VNASSERT(vp->v_data == NULL, vp, ("cleaned vnode isn't")); @@ -6799,6 +6801,28 @@ vn_seqc_write_end(struct vnode *vp) VI_UNLOCK(vp); } +/* + * Special case handling for allocating and freeing vnodes. + * + * The counter remains unchanged on free so that a doomed vnode will + * keep testing as in modify as long as it is accessible with SMR. + */ +static void +vn_seqc_init(struct vnode *vp) +{ + + vp->v_seqc = 0; + vp->v_seqc_users = 0; +} + +static void +vn_seqc_write_end_free(struct vnode *vp) +{ + + VNPASS(seqc_in_modify(vp->v_seqc), vp); + VNPASS(vp->v_seqc_users == 1, vp); +} + void vn_irflag_set_locked(struct vnode *vp, short toset) {