From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [PATCH 1/4] hugetlbfs: move free_inodes accounting Date: Wed, 21 Sep 2005 12:10:36 -0700 Message-ID: <20050921121036.416bdbfb.akpm@osdl.org> References: <20050921092156.GA22544@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: viro@ftp.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, William Lee Irwin III Return-path: Received: from smtp.osdl.org ([65.172.181.4]:51626 "EHLO smtp.osdl.org") by vger.kernel.org with ESMTP id S1751377AbVIUTOi (ORCPT ); Wed, 21 Sep 2005 15:14:38 -0400 To: Christoph Hellwig In-Reply-To: <20050921092156.GA22544@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Christoph Hellwig wrote: > > +static inline int hugetlbfs_inc_free_inodes(struct hugetlbfs_sb_info *sbinfo) > +{ > + if (sbinfo->free_inodes >= 0) { > + spin_lock(&sbinfo->stat_lock); > + if (unlikely(!sbinfo->free_inodes)) { > + spin_unlock(&sbinfo->stat_lock); > + return 0; > + } > + sbinfo->free_inodes--; > + spin_unlock(&sbinfo->stat_lock); > + } > + > + return 1; > +} > + > +static void hugetlbfs_dec_free_inodes(struct hugetlbfs_sb_info *sbinfo) > +{ > + if (sbinfo->free_inodes >= 0) { > + spin_lock(&sbinfo->stat_lock); > + sbinfo->free_inodes++; > + spin_unlock(&sbinfo->stat_lock); > + } > +} > + These functions seem to be called from the right places, but the naming is most confusing. The test for the current value of sbinfo->free_inodes in hugetlbfs_dec_free_inodes() looks racy and the logic simply escapes me. Does anyone remember why we have special-case handling in there for (sbinfo->free_inodes < 0)?