lkml.org 
[lkml]   [2008]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 5/8] omfs: add file routines
From
Date
> +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;
> +}


\
 
 \ /
  Last update: 2008-04-21 17:31    [W:0.055 / U:2.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site