From: Josh Boyer <jwboyer@redhat.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2] fs/minix: Verify bitmap block counts before mounting
Date: Fri, 19 Aug 2011 14:17:13 -0400 [thread overview]
Message-ID: <20110819181713.GC2270@zod.bos.redhat.com> (raw)
In-Reply-To: <20110819181054.GA2203@ZenIV.linux.org.uk>
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
prev parent reply other threads:[~2011-08-19 18:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-19 18:02 [PATCH v2] fs/minix: Verify bitmap block counts before mounting Josh Boyer
2011-08-19 18:10 ` Al Viro
2011-08-19 18:17 ` Josh Boyer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110819181713.GC2270@zod.bos.redhat.com \
--to=jwboyer@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).