From mboxrd@z Thu Jan 1 00:00:00 1970 From: Josh Boyer Subject: Re: [PATCH v2] fs/minix: Verify bitmap block counts before mounting Date: Fri, 19 Aug 2011 14:17:13 -0400 Message-ID: <20110819181713.GC2270@zod.bos.redhat.com> References: <20110819180159.GB2270@zod.bos.redhat.com> <20110819181054.GA2203@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Al Viro Return-path: Received: from mx1.redhat.com ([209.132.183.28]:52640 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752187Ab1HSSRQ (ORCPT ); Fri, 19 Aug 2011 14:17:16 -0400 Content-Disposition: inline In-Reply-To: <20110819181054.GA2203@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, Aug 19, 2011 at 07:10:54PM +0100, Al Viro wrote: > 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. OK. So just move the blocks calculating into count_free itself. I'll rework. > > +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). Will fix. josh