All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Slusarz <marcin.slusarz@gmail.com>
To: Bob Copeland <me@bobcopeland.com>
Cc: akpm@linux-foundation.org, hch@infradead.org,
	alan@lxorguk.ukuu.org.uk, miklos@szeredi.hu,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 3/8] omfs: add inode routines
Date: Sat, 19 Apr 2008 23:28:49 +0200	[thread overview]
Message-ID: <20080419212842.GA7888@joi> (raw)
In-Reply-To: <1208637457-24969-4-git-send-email-me@bobcopeland.com>

On Sat, Apr 19, 2008 at 04:37:32PM -0400, Bob Copeland wrote:
> +static int omfs_get_imap(struct super_block *sb)
> +{
> +	int bitmap_size;
> +	int array_size;
> +	int count;
> +	struct omfs_sb_info *sbi = OMFS_SB(sb);
> +	struct buffer_head *bh;
> +	unsigned long **ptr;
> +	sector_t block;
> +
> +	bitmap_size = (sbi->s_num_blocks + 7) / 8;
> +	array_size = (bitmap_size + sb->s_blocksize - 1) / sb->s_blocksize;
these are DIV_ROUND_UP

> +
> +	if (sbi->s_bitmap_ino == ~0ULL)
> +		goto out;
> +
> +	sbi->s_imap_size = array_size;
> +	sbi->s_imap = kzalloc(array_size * sizeof(unsigned long *), GFP_KERNEL);
> +	if (!sbi->s_imap)
> +		goto nomem;
> +
> +	block = clus_to_blk(sbi, sbi->s_bitmap_ino);
> +	ptr = sbi->s_imap;
> +	for (count = bitmap_size; count > 0; count -= sb->s_blocksize) {
> +		bh = sb_bread(sb, block++);
> +		if (!bh)
> +			goto nomem_free;
> +		*ptr = kmalloc(sb->s_blocksize, GFP_KERNEL);
> +		if (!*ptr) {
> +			brelse(bh);
> +			goto nomem_free;
> +		}
> +		memcpy(*ptr, bh->b_data, sb->s_blocksize);
> +		if (count < sb->s_blocksize)
> +			memset((void *)*ptr + count, 0xff,
> +				sb->s_blocksize - count);
> +		brelse(bh);
> +		ptr++;
> +	}
> +out:
> +	return 0;
> +
> +nomem_free:
> +	for (count = 0; count < array_size; count++)
> +		kfree(sbi->s_imap[count]);
> +
> +	kfree(sbi->s_imap);
> +nomem:
> +	sbi->s_imap = NULL;
> +	sbi->s_imap_size = 0;
> +	return -ENOMEM;
> +}
> +
> +static void set_block_shift(struct omfs_sb_info *sbi)
> +{
> +	unsigned int scale = sbi->s_blocksize / sbi->s_sys_blocksize;
> +	sbi->s_block_shift = 0;
> +	for (scale >>= 1; scale; scale >>= 1)
> +		sbi->s_block_shift++;
> +}
isn't it get_bitmask_order(scale - 1)?

Marcin

  reply	other threads:[~2008-04-19 21:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-19 20:37 [PATCH 3/8] omfs: add inode routines Bob Copeland
2008-04-19 21:28 ` Marcin Slusarz [this message]
2008-04-20  9:57   ` Marcin Slusarz
2008-04-21  0:41     ` Bob Copeland
2008-04-21 15:13 ` Miklos Szeredi
2008-04-22  2:11   ` Bob Copeland
  -- strict thread matches above, loose matches on Subject: below --
2008-04-26 21:26 Bob Copeland

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=20080419212842.GA7888@joi \
    --to=marcin.slusarz@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@bobcopeland.com \
    --cc=miklos@szeredi.hu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.