Browse Source

Refactor FEATURE_RO to FRO

pull/11/head
gkostka 9 years ago
parent
commit
c3ad783203
  1. 2
      lwext4/ext4_balloc.c
  2. 6
      lwext4/ext4_dir.c
  3. 22
      lwext4/ext4_dir_idx.c
  4. 4
      lwext4/ext4_extent_full.c
  5. 30
      lwext4/ext4_fs.c
  6. 2
      lwext4/ext4_ialloc.c
  7. 4
      lwext4/ext4_inode.c
  8. 2
      lwext4/ext4_mkfs.c
  9. 6
      lwext4/ext4_super.c
  10. 46
      lwext4/ext4_types.h
  11. 4
      lwext4/ext4_xattr.c

2
lwext4/ext4_balloc.c

@ -83,7 +83,7 @@ static uint32_t ext4_balloc_bitmap_csum(struct ext4_sblock *sb,
{
uint32_t checksum = 0;
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
uint32_t blocks_per_group =
ext4_get32(sb, blocks_per_group);

6
lwext4/ext4_dir.c

@ -100,7 +100,7 @@ ext4_dir_checksum_verify(struct ext4_inode_ref *inode_ref,
/* Compute the checksum only if the filesystem supports it */
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
t = ext4_dir_get_tail(inode_ref, dirent);
if (!t) {
/* There is no space to hold the checksum */
@ -131,7 +131,7 @@ void ext4_dir_set_checksum(struct ext4_inode_ref *inode_ref,
/* Compute the checksum only if the filesystem supports it */
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
t = ext4_dir_get_tail(inode_ref, dirent);
if (!t) {
/* There is no space to hold the checksum */
@ -413,7 +413,7 @@ int ext4_dir_add_entry(struct ext4_inode_ref *parent, const char *name,
/* Save new block */
if (ext4_sb_has_feature_read_only(&fs->sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
ext4_dir_write_entry(&fs->sb, block_entry,
block_size - sizeof(struct ext4_directory_entry_tail),
child,

22
lwext4/ext4_dir_idx.c

@ -215,7 +215,7 @@ ext4_dir_dx_checksum(struct ext4_inode_ref *inode_ref,
/* Compute the checksum only if the filesystem supports it */
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
uint32_t ino_index = to_le32(inode_ref->index);
uint32_t ino_gen =
to_le32(ext4_inode_get_generation(inode_ref->inode));
@ -285,7 +285,7 @@ ext4_dir_dx_checksum_verify(struct ext4_inode_ref *inode_ref,
int count_offset, limit, count;
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
struct ext4_directory_dx_countlimit *countlimit =
ext4_dir_dx_get_countlimit(inode_ref, dirent, &count_offset);
if (!countlimit) {
@ -321,7 +321,7 @@ ext4_dir_set_dx_checksum(struct ext4_inode_ref *inode_ref,
struct ext4_sblock *sb = &inode_ref->fs->sb;
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
struct ext4_directory_dx_countlimit *countlimit =
ext4_dir_dx_get_countlimit(inode_ref, dirent, &count_offset);
if (!countlimit) {
@ -399,7 +399,7 @@ int ext4_dir_dx_init(struct ext4_inode_ref *dir, struct ext4_inode_ref *parent)
2 * sizeof(struct ext4_directory_dx_dot_entry) -
sizeof(struct ext4_directory_dx_root_info);
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
EXT4_FRO_COM_METADATA_CSUM))
entry_space -= sizeof(struct ext4_directory_dx_tail);
uint16_t root_limit =
@ -426,7 +426,7 @@ int ext4_dir_dx_init(struct ext4_inode_ref *dir, struct ext4_inode_ref *parent)
struct ext4_directory_entry_ll *block_entry = (void *)new_block.data;
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
ext4_dir_entry_ll_set_entry_length(block_entry,
block_size -
sizeof(struct ext4_directory_entry_tail));
@ -500,7 +500,7 @@ static int ext4_dir_hinfo_init(struct ext4_hash_info *hinfo,
entry_space -= 2 * sizeof(struct ext4_directory_dx_dot_entry);
entry_space -= sizeof(struct ext4_directory_dx_root_info);
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
EXT4_FRO_COM_METADATA_CSUM))
entry_space -= sizeof(struct ext4_directory_dx_tail);
entry_space = entry_space / sizeof(struct ext4_directory_dx_entry);
@ -619,7 +619,7 @@ static int ext4_dir_dx_get_leaf(struct ext4_hash_info *hinfo,
sizeof(struct ext4_fake_directory_entry);
if (ext4_sb_has_feature_read_only(&inode_ref->fs->sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
EXT4_FRO_COM_METADATA_CSUM))
entry_space -= sizeof(struct ext4_directory_dx_tail);
entry_space =
@ -1041,7 +1041,7 @@ static int ext4_dir_dx_split_data(struct ext4_inode_ref *inode_ref,
void *ptr;
if (ext4_sb_has_feature_read_only(&inode_ref->fs->sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
EXT4_FRO_COM_METADATA_CSUM))
block_size -= sizeof(struct ext4_directory_entry_tail);
/* First part - to the old block */
@ -1081,7 +1081,7 @@ static int ext4_dir_dx_split_data(struct ext4_inode_ref *inode_ref,
/* Do some steps to finish operation */
if (ext4_sb_has_feature_read_only(&inode_ref->fs->sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
initialize_dir_tail(EXT4_DIRENT_TAIL(old_data_block->data,
block_size));
initialize_dir_tail(EXT4_DIRENT_TAIL(new_data_block_tmp.data,
@ -1210,7 +1210,7 @@ ext4_dir_dx_split_index(struct ext4_inode_ref *inode_ref,
block_size -
sizeof(struct ext4_fake_directory_entry);
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
EXT4_FRO_COM_METADATA_CSUM))
entry_space -= sizeof(struct ext4_directory_dx_tail);
uint32_t node_limit =
entry_space /
@ -1273,7 +1273,7 @@ ext4_dir_dx_split_index(struct ext4_inode_ref *inode_ref,
block_size -
sizeof(struct ext4_fake_directory_entry);
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
EXT4_FRO_COM_METADATA_CSUM))
entry_space -= sizeof(struct ext4_directory_dx_tail);
uint32_t node_limit =
entry_space /

4
lwext4/ext4_extent_full.c

@ -316,7 +316,7 @@ static uint32_t ext4_ext_block_csum(struct ext4_inode_ref *inode_ref,
struct ext4_sblock *sb = &inode_ref->fs->sb;
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
uint32_t ino_index = to_le32(inode_ref->index);
uint32_t ino_gen =
to_le32(ext4_inode_get_generation(inode_ref->inode));
@ -410,7 +410,7 @@ static int ext4_ext_check(struct ext4_inode_ref *inode_ref,
tail = find_ext4_extent_tail(eh);
if (ext4_sb_has_feature_read_only(&inode_ref->fs->sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
if (tail->et_checksum != to_le32(ext4_ext_block_csum(inode_ref, eh))) {
/* FIXME: Warning: extent checksum damaged? */
}

30
lwext4/ext4_fs.c

@ -175,25 +175,25 @@ static void ext4_fs_debug_features_comp(uint32_t features_compatible)
static void ext4_fs_debug_features_ro(uint32_t features_ro)
{
if (features_ro & EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER)
if (features_ro & EXT4_FRO_COM_SPARSE_SUPER)
ext4_dbg(DEBUG_FS, DBG_NONE "sparse_super\n");
if (features_ro & EXT4_FEATURE_RO_COMPAT_LARGE_FILE)
if (features_ro & EXT4_FRO_COM_LARGE_FILE)
ext4_dbg(DEBUG_FS, DBG_NONE "large_file\n");
if (features_ro & EXT4_FEATURE_RO_COMPAT_BTREE_DIR)
if (features_ro & EXT4_FRO_COM_BTREE_DIR)
ext4_dbg(DEBUG_FS, DBG_NONE "btree_dir\n");
if (features_ro & EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
if (features_ro & EXT4_FRO_COM_HUGE_FILE)
ext4_dbg(DEBUG_FS, DBG_NONE "huge_file\n");
if (features_ro & EXT4_FEATURE_RO_COMPAT_GDT_CSUM)
if (features_ro & EXT4_FRO_COM_GDT_CSUM)
ext4_dbg(DEBUG_FS, DBG_NONE "gtd_csum\n");
if (features_ro & EXT4_FEATURE_RO_COMPAT_DIR_NLINK)
if (features_ro & EXT4_FRO_COM_DIR_NLINK)
ext4_dbg(DEBUG_FS, DBG_NONE "dir_nlink\n");
if (features_ro & EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)
if (features_ro & EXT4_FRO_COM_EXTRA_ISIZE)
ext4_dbg(DEBUG_FS, DBG_NONE "extra_isize\n");
if (features_ro & EXT4_FEATURE_RO_COMPAT_QUOTA)
if (features_ro & EXT4_FRO_COM_QUOTA)
ext4_dbg(DEBUG_FS, DBG_NONE "quota\n");
if (features_ro & EXT4_FEATURE_RO_COMPAT_BIGALLOC)
if (features_ro & EXT4_FRO_COM_BIGALLOC)
ext4_dbg(DEBUG_FS, DBG_NONE "bigalloc\n");
if (features_ro & EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)
if (features_ro & EXT4_FRO_COM_METADATA_CSUM)
ext4_dbg(DEBUG_FS, DBG_NONE "metadata_csum\n");
}
@ -576,7 +576,7 @@ static uint16_t ext4_fs_bg_checksum(struct ext4_sblock *sb, uint32_t bgid,
/* Compute the checksum only if the filesystem supports it */
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
/* Use metadata_csum algorithm instead */
uint32_t le32_bgid = to_le32(bgid);
uint32_t orig_checksum, checksum;
@ -597,7 +597,7 @@ static uint16_t ext4_fs_bg_checksum(struct ext4_sblock *sb, uint32_t bgid,
crc = checksum & 0xFFFF;
} else if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
EXT4_FRO_COM_GDT_CSUM)) {
uint8_t *base = (uint8_t *)bg;
uint8_t *checksum = (uint8_t *)&bg->checksum;
@ -656,7 +656,7 @@ static uint32_t ext4_fs_inode_checksum(struct ext4_inode_ref *inode_ref)
uint16_t inode_size = ext4_get16(sb, inode_size);
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
uint32_t orig_checksum;
uint32_t ino_index = to_le32(inode_ref->index);
@ -689,7 +689,7 @@ static void ext4_fs_set_inode_checksum(struct ext4_inode_ref *inode_ref)
{
struct ext4_sblock *sb = &inode_ref->fs->sb;
if (!ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
EXT4_FRO_COM_METADATA_CSUM))
return;
ext4_inode_set_checksum(sb, inode_ref->inode,
@ -1686,7 +1686,7 @@ void ext4_fs_inode_links_count_inc(struct ext4_inode_ref *inode_ref)
uint32_t v =
ext4_get32(&inode_ref->fs->sb, features_read_only);
v |= EXT4_FEATURE_RO_COMPAT_DIR_NLINK;
v |= EXT4_FRO_COM_DIR_NLINK;
ext4_set32(&inode_ref->fs->sb, features_read_only, v);
}
}

2
lwext4/ext4_ialloc.c

@ -91,7 +91,7 @@ static uint32_t ext4_ialloc_bitmap_csum(struct ext4_sblock *sb,
{
uint32_t checksum = 0;
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
uint32_t inodes_per_group =
ext4_get32(sb, inodes_per_group);

4
lwext4/ext4_inode.c

@ -195,7 +195,7 @@ uint64_t ext4_inode_get_blocks_count(struct ext4_sblock *sb,
uint64_t count = to_le32(inode->blocks_count_lo);
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) {
EXT4_FRO_COM_HUGE_FILE)) {
/* 48-bit field */
count |= ((uint64_t)to_le16(inode->osd2.linux2.blocks_high))
@ -229,7 +229,7 @@ int ext4_inode_set_blocks_count(struct ext4_sblock *sb,
/* Check if there can be used huge files (many blocks) */
if (!ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_HUGE_FILE))
EXT4_FRO_COM_HUGE_FILE))
return EINVAL;
/* 48-bit maximum */

2
lwext4/ext4_mkfs.c

@ -145,7 +145,7 @@ static uint32_t compute_journal_blocks(struct ext4_mkfs_info *info)
static bool has_superblock(struct ext4_mkfs_info *info, uint32_t bgid)
{
if (!(info->feat_ro_compat & EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER))
if (!(info->feat_ro_compat & EXT4_FRO_COM_SPARSE_SUPER))
return true;
return ext4_sb_sparse(bgid);

6
lwext4/ext4_super.c

@ -89,7 +89,7 @@ static uint32_t ext4_sb_csum(struct ext4_sblock *s)
static bool ext4_sb_verify_csum(struct ext4_sblock *s)
{
if (!ext4_sb_has_feature_read_only(s,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
EXT4_FRO_COM_METADATA_CSUM))
return true;
if (s->checksum_type != to_le32(EXT4_CHECKSUM_CRC32C))
@ -101,7 +101,7 @@ static bool ext4_sb_verify_csum(struct ext4_sblock *s)
static void ext4_sb_set_csum(struct ext4_sblock *s)
{
if (!ext4_sb_has_feature_read_only(s,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
EXT4_FRO_COM_METADATA_CSUM))
return;
s->checksum = to_le32(ext4_sb_csum(s));
@ -183,7 +183,7 @@ bool ext4_sb_sparse(uint32_t group)
bool ext4_sb_is_super_in_bg(struct ext4_sblock *s, uint32_t group)
{
if (ext4_sb_has_feature_read_only(
s, EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
s, EXT4_FRO_COM_SPARSE_SUPER) &&
!ext4_sb_sparse(group))
return false;
return true;

46
lwext4/ext4_types.h

@ -203,16 +203,16 @@ struct ext4_sblock {
/*
* Read-only compatible features
*/
#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
#define EXT4_FEATURE_RO_COMPAT_QUOTA 0x0100
#define EXT4_FEATURE_RO_COMPAT_BIGALLOC 0x0200
#define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
#define EXT4_FRO_COM_SPARSE_SUPER 0x0001
#define EXT4_FRO_COM_LARGE_FILE 0x0002
#define EXT4_FRO_COM_BTREE_DIR 0x0004
#define EXT4_FRO_COM_HUGE_FILE 0x0008
#define EXT4_FRO_COM_GDT_CSUM 0x0010
#define EXT4_FRO_COM_DIR_NLINK 0x0020
#define EXT4_FRO_COM_EXTRA_ISIZE 0x0040
#define EXT4_FRO_COM_QUOTA 0x0100
#define EXT4_FRO_COM_BIGALLOC 0x0200
#define EXT4_FRO_COM_METADATA_CSUM 0x0400
/*
* Incompatible features
@ -241,8 +241,8 @@ struct ext4_sblock {
(EXT4_FEATURE_INCOMPAT_FILETYPE | EXT4_FEATURE_INCOMPAT_META_BG)
#define EXT2_FEATURE_RO_COMPAT_SUPP \
(EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER | \
EXT4_FEATURE_RO_COMPAT_LARGE_FILE | EXT4_FEATURE_RO_COMPAT_BTREE_DIR)
(EXT4_FRO_COM_SPARSE_SUPER | \
EXT4_FRO_COM_LARGE_FILE | EXT4_FRO_COM_BTREE_DIR)
/*
* EXT3 supported feature set
@ -253,8 +253,8 @@ struct ext4_sblock {
(EXT4_FEATURE_INCOMPAT_FILETYPE | EXT4_FEATURE_INCOMPAT_META_BG)
#define EXT3_FEATURE_RO_COMPAT_SUPP \
(EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER | \
EXT4_FEATURE_RO_COMPAT_LARGE_FILE | EXT4_FEATURE_RO_COMPAT_BTREE_DIR)
(EXT4_FRO_COM_SPARSE_SUPER | \
EXT4_FRO_COM_LARGE_FILE | EXT4_FRO_COM_BTREE_DIR)
/*
* EXT4 supported feature set
@ -267,12 +267,12 @@ struct ext4_sblock {
EXT4_FEATURE_INCOMPAT_64BIT)
#define EXT4_FEATURE_RO_COMPAT_SUPP \
(EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER | \
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM | \
EXT4_FEATURE_RO_COMPAT_LARGE_FILE | EXT4_FEATURE_RO_COMPAT_GDT_CSUM | \
EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \
EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \
EXT4_FEATURE_RO_COMPAT_BTREE_DIR | EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
(EXT4_FRO_COM_SPARSE_SUPER | \
EXT4_FRO_COM_METADATA_CSUM | \
EXT4_FRO_COM_LARGE_FILE | EXT4_FRO_COM_GDT_CSUM | \
EXT4_FRO_COM_DIR_NLINK | \
EXT4_FRO_COM_EXTRA_ISIZE | \
EXT4_FRO_COM_BTREE_DIR | EXT4_FRO_COM_HUGE_FILE)
/*Ignored features:
* RECOVER - journaling in lwext4 is not supported
@ -289,9 +289,9 @@ struct ext4_sblock {
/*TODO: Features read only to implement*/
#define EXT4_FEATURE_RO_COMPAT_SUPP
EXT4_FEATURE_RO_COMPAT_BIGALLOC |\
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM|\
EXT4_FEATURE_RO_COMPAT_QUOTA)
EXT4_FRO_COM_BIGALLOC |\
EXT4_FRO_COM_METADATA_CSUM|\
EXT4_FRO_COM_QUOTA)
#endif
struct ext4_fs {

4
lwext4/ext4_xattr.c

@ -122,7 +122,7 @@ ext4_xattr_block_checksum(struct ext4_inode_ref *inode_ref,
struct ext4_sblock *sb = &inode_ref->fs->sb;
if (ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
EXT4_FRO_COM_METADATA_CSUM)) {
uint32_t orig_checksum;
/* Preparation: temporarily set bg checksum to 0 */
@ -149,7 +149,7 @@ ext4_xattr_set_block_checksum(struct ext4_inode_ref *inode_ref,
{
struct ext4_sblock *sb = &inode_ref->fs->sb;
if (!ext4_sb_has_feature_read_only(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
EXT4_FRO_COM_METADATA_CSUM))
return;
header->h_checksum =

Loading…
Cancel
Save