Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 108494
b: refs/heads/master
c: 9419fc1
h: refs/heads/master
v: v3
  • Loading branch information
Bob Copeland authored and Linus Torvalds committed Aug 15, 2008
1 parent 077a899 commit 81378ab
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c963343a1150106819773e828c9b237ed977615b
refs/heads/master: 9419fc1c957d600093baaea247fef23cca3b4e93
5 changes: 3 additions & 2 deletions trunk/fs/omfs/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int omfs_allocate_block(struct super_block *sb, u64 block)
struct buffer_head *bh;
struct omfs_sb_info *sbi = OMFS_SB(sb);
int bits_per_entry = 8 * sb->s_blocksize;
int map, bit;
unsigned int map, bit;
int ret = 0;
u64 tmp;

Expand Down Expand Up @@ -176,7 +176,8 @@ int omfs_clear_range(struct super_block *sb, u64 block, int count)
struct omfs_sb_info *sbi = OMFS_SB(sb);
int bits_per_entry = 8 * sb->s_blocksize;
u64 tmp;
int map, bit, ret;
unsigned int map, bit;
int ret;

tmp = block;
bit = do_div(tmp, bits_per_entry);
Expand Down
33 changes: 26 additions & 7 deletions trunk/fs/omfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ static int omfs_sync_file(struct file *file, struct dentry *dentry,
return err ? -EIO : 0;
}

static u32 omfs_max_extents(struct omfs_sb_info *sbi, int offset)
{
return (sbi->s_sys_blocksize - offset -
sizeof(struct omfs_extent)) /
sizeof(struct omfs_extent_entry) + 1;
}

void omfs_make_empty_table(struct buffer_head *bh, int offset)
{
struct omfs_extent *oe = (struct omfs_extent *) &bh->b_data[offset];
Expand All @@ -45,6 +52,7 @@ int omfs_shrink_inode(struct inode *inode)
struct buffer_head *bh;
u64 next, last;
u32 extent_count;
u32 max_extents;
int ret;

/* traverse extent table, freeing each entry that is greater
Expand All @@ -62,15 +70,18 @@ int omfs_shrink_inode(struct inode *inode)
goto out;

oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]);
max_extents = omfs_max_extents(sbi, OMFS_EXTENT_START);

for (;;) {

if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next)) {
brelse(bh);
goto out;
}
if (omfs_is_bad(sbi, (struct omfs_header *) bh->b_data, next))
goto out_brelse;

extent_count = be32_to_cpu(oe->e_extent_count);

if (extent_count > max_extents)
goto out_brelse;

last = next;
next = be64_to_cpu(oe->e_next);
entry = &oe->e_entry;
Expand Down Expand Up @@ -98,10 +109,14 @@ int omfs_shrink_inode(struct inode *inode)
if (!bh)
goto out;
oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]);
max_extents = omfs_max_extents(sbi, OMFS_EXTENT_CONT);
}
ret = 0;
out:
return ret;
out_brelse:
brelse(bh);
return ret;
}

static void omfs_truncate(struct inode *inode)
Expand Down Expand Up @@ -154,9 +169,7 @@ static int omfs_grow_extent(struct inode *inode, struct omfs_extent *oe,
goto out;
}
}
max_count = (sbi->s_sys_blocksize - OMFS_EXTENT_START -
sizeof(struct omfs_extent)) /
sizeof(struct omfs_extent_entry) + 1;
max_count = omfs_max_extents(sbi, OMFS_EXTENT_START);

/* TODO: add a continuation block here */
if (be32_to_cpu(oe->e_extent_count) > max_count-1)
Expand Down Expand Up @@ -225,6 +238,7 @@ static int omfs_get_block(struct inode *inode, sector_t block,
sector_t next, offset;
int ret;
u64 new_block;
u32 max_extents;
int extent_count;
struct omfs_extent *oe;
struct omfs_extent_entry *entry;
Expand All @@ -238,6 +252,7 @@ static int omfs_get_block(struct inode *inode, sector_t block,
goto out;

oe = (struct omfs_extent *)(&bh->b_data[OMFS_EXTENT_START]);
max_extents = omfs_max_extents(sbi, OMFS_EXTENT_START);
next = inode->i_ino;

for (;;) {
Expand All @@ -249,6 +264,9 @@ static int omfs_get_block(struct inode *inode, sector_t block,
next = be64_to_cpu(oe->e_next);
entry = &oe->e_entry;

if (extent_count > max_extents)
goto out_brelse;

offset = find_block(inode, entry, block, extent_count, &remain);
if (offset > 0) {
ret = 0;
Expand All @@ -266,6 +284,7 @@ static int omfs_get_block(struct inode *inode, sector_t block,
if (!bh)
goto out;
oe = (struct omfs_extent *) (&bh->b_data[OMFS_EXTENT_CONT]);
max_extents = omfs_max_extents(sbi, OMFS_EXTENT_CONT);
}
if (create) {
ret = omfs_grow_extent(inode, oe, &new_block);
Expand Down

0 comments on commit 81378ab

Please sign in to comment.