From owner-freebsd-arch@FreeBSD.ORG Fri Jan 27 09:36:05 2006 Return-Path: X-Original-To: arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 13E7916A422; Fri, 27 Jan 2006 09:36:05 +0000 (GMT) (envelope-from glebius@FreeBSD.org) Received: from cell.sick.ru (cell.sick.ru [217.72.144.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4A3DB43D46; Fri, 27 Jan 2006 09:36:04 +0000 (GMT) (envelope-from glebius@FreeBSD.org) Received: from cell.sick.ru (glebius@localhost [127.0.0.1]) by cell.sick.ru (8.13.3/8.13.3) with ESMTP id k0R9a2CW049685 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 27 Jan 2006 12:36:03 +0300 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.sick.ru (8.13.3/8.13.1/Submit) id k0R9a2DS049684; Fri, 27 Jan 2006 12:36:02 +0300 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.sick.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Fri, 27 Jan 2006 12:36:02 +0300 From: Gleb Smirnoff To: arch@FreeBSD.org Message-ID: <20060127093602.GO83922@cell.sick.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="O8/n5iBOhiUtMkxf" Content-Disposition: inline User-Agent: Mutt/1.5.6i Cc: alfred@FreeBSD.org Subject: fix return code for pipe(2) syscall X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jan 2006 09:36:05 -0000 --O8/n5iBOhiUtMkxf Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Colleagues, sometimes pipe(2) can return ENFILE, which has nothing to do with number of open files. It happens when we run out of kva. However, pipe(2) can also return correct ENFILE, when falloc() fails. The only way to distinguish between latter error and the former one is looking into the 'dmesg' output, right after failure. If your dmesg is later overwritten with some other logging, then you will loose this information, and you won't be able to tell why pipe(2) syscall yesterday returned ENFILE - did it hit descriptor limit or kva? Recently I've got some communication with people, who have problems with mpd port. They have experienced ENFILE from pipe(2). They have spent some time tuning descriptor limits and I spent some time trying to help them, until we looked into dmesg, and then into source, to discover alternative meaning of ENFILES. Any objection for the attached change? It should make return ENOMEM in case of kva outage? Yes, according to SUSv3 the only errors from pipe(2) are ENFILE and EMFILE. I think that blindly following standard in this case will lead to confusion (see above). And we already return EFAULT from pipe(2), which is not described in standard. -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE --O8/n5iBOhiUtMkxf Content-Type: text/plain; charset=koi8-r Content-Disposition: attachment; filename="sys_pipe.c.diff" Index: sys_pipe.c =================================================================== RCS file: /home/ncvs/src/sys/kern/sys_pipe.c,v retrieving revision 1.185 diff -u -r1.185 sys_pipe.c --- sys_pipe.c 16 Dec 2005 18:32:39 -0000 1.185 +++ sys_pipe.c 27 Jan 2006 09:15:56 -0000 @@ -357,10 +357,11 @@ NULL); /* Only the forward direction pipe is backed by default */ - if (pipe_create(rpipe, 1) || pipe_create(wpipe, 0)) { + if ((error = pipe_create(rpipe, 1)) != 0 || + (error = pipe_create(wpipe, 0)) != 0) { pipeclose(rpipe); pipeclose(wpipe); - return (ENFILE); + return (error); } rpipe->pipe_state |= PIPE_DIRECTOK; --O8/n5iBOhiUtMkxf--