From: Andrew Morton Subject: Re: [patch]anon_inodes.c: fix error check in anon_inode_getfd Date: Thu, 27 Sep 2007 10:40:44 -0700 Message-ID: <20070927104044.b12c1072.akpm@linux-foundation.org> References: <3d0408630709261930l730f5081n2391b236dd0efb71@mail.gmail.com> <20070926205957.54f49465.akpm@linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Yan Zheng , linux-fsdevel@vger.kernel.org To: Davide Libenzi Return-path: Received: from smtp2.linux-foundation.org ([207.189.120.14]:38883 "EHLO smtp2.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751829AbXI0Rkx (ORCPT ); Thu, 27 Sep 2007 13:40:53 -0400 In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Thu, 27 Sep 2007 09:54:47 -0700 (PDT) Davide Libenzi wrote: > On Thu, 27 Sep 2007, Davide Libenzi wrote: > > > On Wed, 26 Sep 2007, Andrew Morton wrote: > > > > > On Thu, 27 Sep 2007 10:30:50 +0800 "Yan Zheng" wrote: > > > > > > > Hello, > > > > > > > > igrab return NULL on error. > > > > > > > > Signed-off-by: Yan Zheng > > > > --- > > > > diff -ur linux-2.6.23-rc8/fs/anon_inodes.c linux/fs/anon_inodes.c > > > > --- linux-2.6.23-rc8/fs/anon_inodes.c 2007-09-27 10:05:07.000000000 +0800 > > > > +++ linux/fs/anon_inodes.c 2007-09-27 10:18:26.000000000 +0800 > > > > @@ -87,8 +87,8 @@ > > > > return -ENFILE; > > > > > > > > inode = igrab(anon_inode_inode); > > > > - if (IS_ERR(inode)) { > > > > - error = PTR_ERR(inode); > > > > + if (!inode) { > > > > + error = -ENOENT; > > > > goto err_put_filp; > > > > } > > > > > > hm, does that code actually need to exist? igrab() is pretty expensive and > > > that fs is permanently mounted anyway... > > > > yes. The inode gets attached the the file*, and on its way out an iput() > > is done. > > Wait. You mean "is it worth checking the igrab() return code at all"? Well I was more thinking "can we just leave that inode's refcount alone all the time". I guess that would be tricky, but I think we can at least use the much less expensive __iget(), or an open-coded atomic_inc. inode_lock is a heavily-used singleton. I remain surprised that it hasn't bitten us in the ass yet.