From nobody Thu Aug 04 13:55:44 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Lz9H528Nkz4Xv34; Thu, 4 Aug 2022 13:55:45 +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 4Lz9H51V8Kz4MRr; Thu, 4 Aug 2022 13:55:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659621345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gckp46doDGtnbddHNTtwgNuyrWJPKaGmOXN/JqlXBoU=; b=QlrO99hiLzHzvNalbQkzZl0yBjOadkBdWN6m08sIHTA8h0KE7GECQyyPK/ug5h5a5b549+ 94AKosJ1/rG0aT4yYW+eqMP8UxvC7fYRp1+nx3Rdsa9Hp6IqJ1y2k5R8ylBu5aapWZ45oN cc1DfgEyAoU8DYyXd5A6ERzyzkxIMfwV1mZIb1mSdRtbf5y6K7JakRNMWfZw3NZODxb3lf EcZB3o43LqFwt+FAV9pqo7wCnjCtYFmZfcGCCvxBMVZO5NakADj/oNiGgmgD5LEWQ0JcEE 6ZSc7mOgB17dhvS0t+Xwmdg6ASlPQhUs7V6OAIpwECdhO6hAqoJqJV6Zyr75qA== 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 4Lz9H50WGNzH59; Thu, 4 Aug 2022 13:55:45 +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 274DtivW056213; Thu, 4 Aug 2022 13:55:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 274Dti97056212; Thu, 4 Aug 2022 13:55:44 GMT (envelope-from git) Date: Thu, 4 Aug 2022 13:55:44 GMT Message-Id: <202208041355.274Dti97056212@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: d07675a9352e - main - file: Move code to share fdtol structs into kern_descrip.c List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d07675a9352efce5e997e987080b3f98bbfdac96 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659621345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gckp46doDGtnbddHNTtwgNuyrWJPKaGmOXN/JqlXBoU=; b=PXEFRURC6yY7TqvsTMbNbMR0NEZ2jRvIJ5zc17nFONYSGK22ISmEfj95Us8vyAx02SVsTc MF9NORL/1Jk696aQWd/L93B1AP75pZyhv9yP/e6UtGfLGOGLV2RfHcfa8muW2wvxFkeoGK uKILlLz74WrBHWDAmou1WBcnPaSLzDP/fKtxqtn5cLXLwXBcROs/zNOgGgLGZKn7y7hEqp vRyyP4twgJJwQfAFCOcezTtITrKEvqTMD5XZt9lzjqYjFFjS4YOKbEhysprWXbWxrleIQU bJn04DBfX3Rtf56KPOH7bdWHNUDEyqSnV/l3XeuIkI7IhYRsxQ+mX4JD5GTtRg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659621345; a=rsa-sha256; cv=none; b=ZtoR2xkg6CD+kXHsgEaWB1KneWeUfn/CdlJHo/CmS3fogfSG50Wmbdi8uHyylxfkYRefUp x8zgG++f7ppub69Rvulgz14UuMxmkvbELSCZQL98+ieH7SVQmHfoU4bGO1aaYuy7h4yv3z x78+X3TyK+js6qWkTQlW8nwSqh6wnf+BnGfK39/WkdzJeZD+qZr77XFPwfU5vaeZyLjwEv h/eXvPVzlk0gQxL0niV7mAHIQ1HmkOUWHWcXQVww4l3bpeknjy6NCaKStbtnXLEBZd9tj6 dLjRiFt0Pg3BXQ8eOgXqwoqTHt1uA9DOakQtP+fJGZr00vTEknECLC9mwmcOXw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d07675a9352efce5e997e987080b3f98bbfdac96 commit d07675a9352efce5e997e987080b3f98bbfdac96 Author: Mark Johnston AuthorDate: 2022-08-04 13:39:25 +0000 Commit: Mark Johnston CommitDate: 2022-08-04 13:39:25 +0000 file: Move code to share fdtol structs into kern_descrip.c This ensures the filedesc-to-leader code is consistently encapsulated in kern_descrip.c. No functional change intended. Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35988 --- sys/kern/kern_descrip.c | 12 +++++++++++- sys/kern/kern_fork.c | 5 +---- sys/sys/filedesc.h | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 24ab81693e4c..63a7f8b2a6d7 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -4173,7 +4173,8 @@ mountcheckdirs(struct vnode *olddp, struct vnode *newdp) } struct filedesc_to_leader * -filedesc_to_leader_alloc(struct filedesc_to_leader *old, struct filedesc *fdp, struct proc *leader) +filedesc_to_leader_alloc(struct filedesc_to_leader *old, struct filedesc *fdp, + struct proc *leader) { struct filedesc_to_leader *fdtol; @@ -4197,6 +4198,15 @@ filedesc_to_leader_alloc(struct filedesc_to_leader *old, struct filedesc *fdp, s return (fdtol); } +struct filedesc_to_leader * +filedesc_to_leader_share(struct filedesc_to_leader *fdtol, struct filedesc *fdp) +{ + FILEDESC_XLOCK(fdp); + fdtol->fdl_refcount++; + FILEDESC_XUNLOCK(fdp); + return (fdtol); +} + static int sysctl_kern_proc_nfds(SYSCTL_HANDLER_ARGS) { diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 60bf8a7093c9..d7f737832824 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -451,10 +451,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct proc *p2, struct thread * * Shared file descriptor table, and shared * process leaders. */ - fdtol = p1->p_fdtol; - FILEDESC_XLOCK(p1->p_fd); - fdtol->fdl_refcount++; - FILEDESC_XUNLOCK(p1->p_fd); + fdtol = filedesc_to_leader_share(p1->p_fdtol, p1->p_fd); } else { /* * Shared file descriptor table, and different diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 8ecf7d8cb45e..52bd3c97a9ac 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -270,6 +270,9 @@ struct filedesc *fdshare(struct filedesc *fdp); struct filedesc_to_leader * filedesc_to_leader_alloc(struct filedesc_to_leader *old, struct filedesc *fdp, struct proc *leader); +struct filedesc_to_leader * + filedesc_to_leader_share(struct filedesc_to_leader *fdtol, + struct filedesc *fdp); int getvnode(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp); int getvnode_path(struct thread *td, int fd, cap_rights_t *rightsp,