From owner-svn-src-head@FreeBSD.ORG Tue Jun 12 08:26:35 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B4F0C1065673; Tue, 12 Jun 2012 08:26:35 +0000 (UTC) (envelope-from listlog2011@gmail.com) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 855EF8FC08; Tue, 12 Jun 2012 08:26:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q5C8QXUn088231; Tue, 12 Jun 2012 08:26:34 GMT (envelope-from listlog2011@gmail.com) Message-ID: <4FD6FD39.5090800@gmail.com> Date: Tue, 12 Jun 2012 16:26:33 +0800 From: David Xu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Pawel Jakub Dawidek References: <201206112205.q5BM5QIv013266@svn.freebsd.org> In-Reply-To: <201206112205.q5BM5QIv013266@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r236935 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: davidxu@FreeBSD.org List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2012 08:26:35 -0000 On 2012/6/12 6:05, Pawel Jakub Dawidek wrote: > Author: pjd > Date: Mon Jun 11 22:05:26 2012 > New Revision: 236935 > URL: http://svn.freebsd.org/changeset/base/236935 > > Log: > fdgrowtable() no longer drops the filedesc lock so it is enough to > retry finding free file descriptor only once after fdgrowtable(). > > Spotted by: pluknet > MFC after: 1 month > > Modified: > head/sys/kern/kern_descrip.c > > Modified: head/sys/kern/kern_descrip.c > ============================================================================== > --- head/sys/kern/kern_descrip.c Mon Jun 11 21:56:37 2012 (r236934) > +++ head/sys/kern/kern_descrip.c Mon Jun 11 22:05:26 2012 (r236935) > @@ -1478,29 +1478,33 @@ fdalloc(struct thread *td, int minfd, in > /* > * Search the bitmap for a free descriptor. If none is found, try > * to grow the file table. Keep at it until we either get a file > - * descriptor or run into process or system limits; fdgrowtable() > - * may drop the filedesc lock, so we're in a race. > + * descriptor or run into process or system limits. > */ > - for (;;) { > - fd = fd_first_free(fdp, minfd, fdp->fd_nfiles); > - if (fd>= maxfd) > - return (EMFILE); > - if (fd< fdp->fd_nfiles) > - break; > + fd = fd_first_free(fdp, minfd, fdp->fd_nfiles); > + if (fd>= maxfd) > + return (EMFILE); > + if (fd>= fdp->fd_nfiles) { > #ifdef RACCT > PROC_LOCK(p); > - error = racct_set(p, RACCT_NOFILE, min(fdp->fd_nfiles * 2, maxfd)); > + error = racct_set(p, RACCT_NOFILE, > + min(fdp->fd_nfiles * 2, maxfd)); > PROC_UNLOCK(p); > if (error != 0) > return (EMFILE); > #endif > fdgrowtable(fdp, min(fdp->fd_nfiles * 2, maxfd)); > + /* Retry... */ > + fd = fd_first_free(fdp, minfd, fdp->fd_nfiles); > + if (fd>= maxfd) > + return (EMFILE); > } > > /* > * Perform some sanity checks, then mark the file descriptor as > * used and return it to the caller. > */ > + KASSERT((unsigned int)fd< min(maxfd, fdp->fd_nfiles), > + ("invalid descriptor %d", fd)); > KASSERT(!fdisused(fdp, fd), > ("fd_first_free() returned non-free descriptor")); > KASSERT(fdp->fd_ofiles[fd] == NULL, ("file descriptor isn't free")); > My machine crashed with this change. http://people.freebsd.org/~davidxu/fdcrash.jpg Regards,