From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: Re: [PATCH 05/11] quota: make per-sb hash array Date: Wed, 6 Oct 2010 12:38:18 +0200 Message-ID: <20101006103818.GF3676@quack.suse.cz> References: <1286302827-31043-1-git-send-email-dmonakhov@gmail.com> <1286302827-31043-6-git-send-email-dmonakhov@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, jack@suse.cz, hch@infradead.org, Dmitry Monakhov To: Dmitry Monakhov Return-path: Received: from cantor.suse.de ([195.135.220.2]:51933 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752384Ab0JFKjO (ORCPT ); Wed, 6 Oct 2010 06:39:14 -0400 Content-Disposition: inline In-Reply-To: <1286302827-31043-6-git-send-email-dmonakhov@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue 05-10-10 22:20:21, Dmitry Monakhov wrote: > @@ -1925,6 +1927,47 @@ int dquot_file_open(struct inode *inode, struct file *file) > } > EXPORT_SYMBOL(dquot_file_open); > > +int dquot_hash_alloc(struct super_block *sb, int order) > +{ > + unsigned long nr_hash, i; > + struct hlist_head *hash_array; > + struct dquot_hash *dq_hash = &sb_dqopt(sb)->dq_hash; > + > + hash_array = (struct hlist_head *)__get_free_pages(GFP_KERNEL, order); > + if (!hash_array) > + return -ENOMEM; > + > + /* Find power-of-two hlist_heads which can fit into allocation */ > + nr_hash = (1UL << order) * PAGE_SIZE / sizeof(struct hlist_head); > + dq_hash->bits = 0; > + do { > + dq_hash->bits++; > + } while (nr_hash >> dq_hash->bits); > + dq_hash->bits--; We have ilog2() function for this these days... > +void dquot_hash_destroy(struct super_block *sb) > +{ > + > + struct dquot_hash * dq_hash = &sb_dqopt(sb)->dq_hash; > + unsigned long i, nr_hash = 1UL << dq_hash->bits; > + unsigned long addr = (unsigned long )dq_hash->head; ^ superfluous space > + > + for (i = 0; i < nr_hash; i++) > + BUG_ON(!hlist_empty(dq_hash->head + i)); Just WARN_ON + return would be better. It's probably better to leak a page of kernel memory than crash the whole kernel... Honza -- Jan Kara SUSE Labs, CR