[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <E1JnxxA-0002z2-NY@pomaz-ex.szeredi.hu>
Date: Mon, 21 Apr 2008 17:29:12 +0200
From: Miklos Szeredi <miklos@...redi.hu>
To: me@...copeland.com
CC: akpm@...ux-foundation.org, hch@...radead.org,
alan@...rguk.ukuu.org.uk, miklos@...redi.hu,
marcin.slusarz@...il.com, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org, me@...copeland.com
Subject: Re: [PATCH 5/8] omfs: add file routines
> +static int omfs_get_block(struct inode *inode, sector_t block,
> + struct buffer_head *bh_result, int create)
> +{
> + struct buffer_head *bh;
> + sector_t next, offset;
> + int ret = 0;
> + u64 new_block;
> + int extent_count;
> + struct omfs_extent *oe;
> + struct omfs_extent_entry *entry;
> + struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
> + int max_blocks = bh_result->b_size >> inode->i_blkbits;
> + int remain;
> +
> + bh = sb_bread(inode->i_sb, clus_to_blk(sbi, inode->i_ino));
> + if (!bh)
> + goto err;
> +
> + oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]);
> + next = inode->i_ino;
> +
> + for (;;) {
> +
> + if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next)) {
> + brelse(bh);
> + goto err;
Please:
ret = -EIO;
if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next))
goto out_brelse;
> + }
> + extent_count = be32_to_cpu(oe->e_extent_count);
> + next = be64_to_cpu(oe->e_next);
> + entry = &oe->e_entry;
> +
> + offset = find_block(inode, entry, block, extent_count, &remain);
> + if (offset > 0) {
> + brelse(bh);
> +
> + map_bh(bh_result, inode->i_sb, offset);
> + if (remain > max_blocks)
> + remain = max_blocks;
> + bh_result->b_size = (remain << inode->i_blkbits);
> + return 0;
This instead?
if (offset > 0) {
ret = 0;
map_bh(bh_result, inode->i_sb, offset);
if (remain > max_blocks)
remain = max_blocks;
bh_result->b_size = (remain << inode->i_blkbits);
goto out_brelse;
}
Miklos
> + }
> + if (next == ~0)
> + break;
> +
> + brelse(bh);
> + bh = sb_bread(inode->i_sb, clus_to_blk(sbi, next));
> + if (!bh)
> + goto err;
> + oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]);
> + }
> + if (create) {
> + ret = omfs_grow_extent(inode, oe, &new_block);
> + if (ret == 0) {
> + mark_buffer_dirty(bh);
> + mark_inode_dirty(inode);
> + map_bh(bh_result, inode->i_sb,
> + clus_to_blk(sbi, new_block));
> + }
> + }
> + brelse(bh);
> + return ret;
> +err:
> + return -EIO;
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists