From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH v2] fs/minix: Verify bitmap block counts before mounting Date: Fri, 19 Aug 2011 19:10:54 +0100 Message-ID: <20110819181054.GA2203@ZenIV.linux.org.uk> References: <20110819180159.GB2270@zod.bos.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Josh Boyer Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:48398 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753630Ab1HSSK4 (ORCPT ); Fri, 19 Aug 2011 14:10:56 -0400 Content-Disposition: inline In-Reply-To: <20110819180159.GB2270@zod.bos.redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Aug 19, 2011 at 02:02:00PM -0400, Josh Boyer wrote: > -unsigned long minix_count_free_blocks(struct minix_sb_info *sbi) > +unsigned long minix_count_free_blocks(struct super_block *sb) > { > - return (count_free(sbi->s_zmap, sbi->s_zmap_blocks, > - sbi->s_nzones - sbi->s_firstdatazone + 1) > + struct minix_sb_info *sbi = minix_sb(sb); > + u32 bits = sbi->s_nzones - (sbi->s_firstdatazone + 1); > + unsigned blocks = minix_blocks_needed(bits, sb->s_blocksize); > + > + return (count_free(sbi->s_zmap, blocks, bits) > << sbi->s_log_zone_size); > } > + unsigned blocks = minix_blocks_needed(bits, sb->s_blocksize); > + > + return count_free(sbi->s_imap, blocks, bits); I'd pass sb->s_blocksize to that sucker instead of blocks; less redundancy and we have good uses for it there anyway. > +static inline unsigned minix_blocks_needed(unsigned bits, unsigned blocksize) > +{ > + unsigned blocks = bits / (blocksize * 8); > + > + if (bits % (blocksize * 8)) > + blocks++; > + return blocks; > +} Yecchh... The usual idiom for that is DIV_ROUND_UP(bits, blocksize * 8) (see linux/kernel.h for details).