Browse Source

Some minor cosmetic fixes

1. Move EXT_MAX_BLOCKS to ext4_types.h
2. Use EXT_MAX_BLOCKS instead of (ext4_lblk_t) (-1)
3. Change return value of ext4_ext_more_to_rm to bool
4. Move assignment ex = path[depth].extent outside if statement
pull/11/head
gkostka 9 years ago
parent
commit
5bf5ef05f8
  1. 2
      lwext4/ext4_extent.c
  2. 29
      lwext4/ext4_extent_full.c
  3. 2
      lwext4/ext4_fs.c
  4. 9
      lwext4/ext4_types.h

2
lwext4/ext4_extent.c

@ -359,7 +359,7 @@ static int ext4_extent_release_branch(struct ext4_inode_ref *inode_ref,
int ext4_extent_remove_space(struct ext4_inode_ref *inode_ref, ext4_lblk_t from,
ext4_lblk_t to)
{
if (to != (ext4_lblk_t)-1)
if (to != EXT_MAX_BLOCKS)
return ENOTSUP;
/* Find the first extent to modify */

29
lwext4/ext4_extent_full.c

@ -1370,18 +1370,18 @@ static int ext4_ext_remove_leaf(struct ext4_inode_ref *inode_ref,
return err;
}
static int ext4_ext_more_to_rm(struct ext4_extent_path *path, ext4_lblk_t to)
static bool ext4_ext_more_to_rm(struct ext4_extent_path *path, ext4_lblk_t to)
{
if (!to_le16(path->header->entries_count))
return 0;
return false;
if (path->index > EXT_LAST_INDEX(path->header))
return 0;
return false;
if (to_le32(path->index->first_block) > to)
return 0;
return false;
return 1;
return true;
}
int ext4_extent_remove_space(struct ext4_inode_ref *inode_ref, ext4_lblk_t from,
@ -1396,9 +1396,10 @@ int ext4_extent_remove_space(struct ext4_inode_ref *inode_ref, ext4_lblk_t from,
if (ret)
goto out;
if (!path[depth].extent ||
!IN_RANGE(from, to_le32(path[depth].extent->first_block),
ext4_ext_get_actual_len(path[depth].extent))) {
bool in_range = IN_RANGE(from, to_le32(path[depth].extent->first_block),
ext4_ext_get_actual_len(path[depth].extent));
if (!path[depth].extent || !in_range) {
ret = EOK;
goto out;
}
@ -1579,15 +1580,6 @@ static int ext4_ext_convert_to_initialized(struct ext4_inode_ref *inode_ref,
return err;
}
/*
* ext4_ext_next_allocated_block:
* returns allocated block in subsequent extent or EXT_MAX_BLOCKS.
* NOTE: it considers block number from index entry as
* allocated block. Thus, index entries have to be consistent
* with leaves.
*/
#define EXT_MAX_BLOCKS (ext4_lblk_t) - 1
static ext4_lblk_t ext4_ext_next_allocated_block(struct ext4_extent_path *path)
{
int32_t depth;
@ -1672,7 +1664,8 @@ int ext4_extent_get_blocks(struct ext4_inode_ref *inode_ref, ext4_fsblk_t iblock
* this situations is possible, though, _during_ tree modification
* this is why assert can't be put in ext4_ext_find_extent()
*/
if ((ex = path[depth].extent)) {
ex = path[depth].extent;
if (ex) {
ext4_lblk_t ee_block = to_le32(ex->first_block);
ext4_fsblk_t ee_start = ext4_ext_pblock(ex);
uint16_t ee_len = ext4_ext_get_actual_len(ex);

2
lwext4/ext4_fs.c

@ -974,7 +974,7 @@ int ext4_fs_truncate_inode(struct ext4_inode_ref *inode_ref, uint64_t new_size)
/* Extents require special operation */
if (diff_blocks_count) {
int rc = ext4_extent_remove_space(inode_ref,
new_blocks_count, (ext4_lblk_t)-1);
new_blocks_count, EXT_MAX_BLOCKS);
if (rc != EOK)
return rc;

9
lwext4/ext4_types.h

@ -711,11 +711,18 @@ struct ext4_extent_path {
(sizeof(struct ext4_extent_header) + \
(sizeof(struct ext4_extent) * (hdr)->max_entries_count))
/*
* ext4_ext_next_allocated_block:
* returns allocated block in subsequent extent or EXT_MAX_BLOCKS.
* NOTE: it considers block number from index entry as
* allocated block. Thus, index entries have to be consistent
* with leaves.
*/
#define EXT_MAX_BLOCKS (ext4_lblk_t) (-1)
#define IN_RANGE(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1)
/******************************************************************************/
/* EXT3 HTree directory indexing */

Loading…
Cancel
Save