From nobody Mon Sep 22 08:44:50 2025 X-Original-To: dev-commits-src-main@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 4cVc9t4RM2z68pLk; Mon, 22 Sep 2025 08:44:50 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cVc9t2FwKz3ts0; Mon, 22 Sep 2025 08:44:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758530690; 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=rqWsx3Z71xkHVw0xcZtIJux+QqjmHx3vLwSaA5rfJAQ=; b=rgf1dWX/9ZUZ7Vw1klxwj1UW5WPfZt37XAJk/7OqOLrWSYVrtm3AwgnAWhGyd1ZKTOchX5 8f+kfZ2wtIQvFjE4zt31BbrEiya2AC18Oae0Q5FDW1pSABECLSRaWxmIdXVUJDfStoHteO +Zz0iBAbc+MEW/yM9eLEOVwvH2kEVo2jzvDlcMhVrPzMGQIndDz1ER0iMRxYZrA/icHTzc XPxxFU9A2HIodHHnnXf2zqWBhSBONyM12xn1bhDA/XqnO840rls8SeH6tKhDK88FUbb5dD CzT6f4QEFTyVztP+9a/DzpBpNaNPxsDGgwi3pGiHG3Vzxm6H1gz3FCSNwhn+ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758530690; 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=rqWsx3Z71xkHVw0xcZtIJux+QqjmHx3vLwSaA5rfJAQ=; b=oz20IyY/Y0AR6Qb4LtREE+JCtHvQYQn/OmrcaBmc8/q3LXUd2cACWWlULNiORM+G983ZeM Y9dud6ryMdV8Ocz0eGCfUuUl0wNlqpa8p4Vjv8geyZA4wLtVVeZM1kVbnkBiMP0NqcbqLs feFEJVsmXCufj4vIvZbIRcD3DgCvKAj85j9qJyeA0UlkNvYd9E/oqIWIuAdx1NWcDqQiGN W6aABUnhXBv5hYzOXO2S2k+z9u5r+7X8aIO2WoOGfSa+jDHCUqRl9m2FEBMLSSYoy5L0tX m1gCW2geLFhkpQCKZH2AShCRbQaYarfqFo8tDuyJ/g5+VvoZXaB8x58KPD2Faw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758530690; a=rsa-sha256; cv=none; b=FUb/VLmjnu0KqjWbHwvzQBBIyp/0oG0ns3jex+ETgP53Q1P6kJglIWjXks3dJBv1a/CraY 9K4P9cm5CFEsf9bFjZphxQ1MNIc2BchRbUgBoVTnxA+GZA82+R680Rh/8awE+Qv+LIjcVt bzYAGqDbbjGomqzfIKbUi8GWZAM1VlPfVj01XU6evtc9z1+sg0v1JTUCRpS3FBx0WDv6pH vQGjhEV9Rehf7ZuYyZxaurTZSgWhrswBTZRB43NSdFJqB3eizgZ5It4hDhFIMTb6bn+axe 21kfEGYkO0mVFmDvd1lF4in7ZA5vz6TFu2Q8HeEBS6a1qnjEbJVF6mvqbUNDqA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cVc9t1Yzrzt3W; Mon, 22 Sep 2025 08:44:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58M8iotB024096; Mon, 22 Sep 2025 08:44:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58M8ioci024093; Mon, 22 Sep 2025 08:44:50 GMT (envelope-from git) Date: Mon, 22 Sep 2025 08:44:50 GMT Message-Id: <202509220844.58M8ioci024093@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: ff6abfec807e - main - pipe: sort out ino commentary on failed pipe creation List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org 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: ff6abfec807e31301e3bf9c0df14a22bb6bc3443 Auto-Submitted: auto-generated The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=ff6abfec807e31301e3bf9c0df14a22bb6bc3443 commit ff6abfec807e31301e3bf9c0df14a22bb6bc3443 Author: Mateusz Guzik AuthorDate: 2025-09-22 08:37:50 +0000 Commit: Mateusz Guzik CommitDate: 2025-09-22 08:44:46 +0000 pipe: sort out ino commentary on failed pipe creation Implements pipe_destroy as a counterpart to pipe_create, no functional changes. Arguably code could be refactored so that ino allocation only happens after bufs are allocated. --- sys/kern/sys_pipe.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index ed651da96b14..30527fdd4fd0 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -234,6 +234,7 @@ static void pipeinit(void *dummy __unused); static void pipeclose(struct pipe *cpipe); static void pipe_free_kmem(struct pipe *cpipe); static int pipe_create(struct pipe *pipe, bool backing); +static void pipe_destroy(struct pipe *pipe); static int pipe_paircreate(struct thread *td, struct pipepair **p_pp); static __inline int pipelock(struct pipe *cpipe, bool catch); static __inline void pipeunlock(struct pipe *cpipe); @@ -399,16 +400,7 @@ pipe_paircreate(struct thread *td, struct pipepair **p_pp) goto fail; error = pipe_create(wpipe, false); if (error != 0) { - /* - * This cleanup leaves the pipe inode number for rpipe - * still allocated, but never used. We do not free - * inode numbers for opened pipes, which is required - * for correctness because numbers must be unique. - * But also it avoids any memory use by the unr - * allocator, so stashing away the transient inode - * number is reasonable. - */ - pipe_free_kmem(rpipe); + pipe_destroy(rpipe); goto fail; } @@ -743,6 +735,16 @@ pipe_create(struct pipe *pipe, bool large_backing) return (error); } +static void +pipe_destroy(struct pipe *pipe) +{ + pipe_free_kmem(pipe); + /* + * Note: we "leak" pipe_ino -- by design the alloc_unr64 mechanism does + * not undo allocations. + */ +} + /* ARGSUSED */ static int pipe_read(struct file *fp, struct uio *uio, struct ucred *active_cred,