ref: 765eb290a7700d817076ea633b1ea88ca0a21713
parent: 521bf29b9959334675c3019b81b3efc3ae39358e
author: gkostka <kostka.grzegorz@gmail.com>
date: Tue Oct 27 17:28:47 EDT 2015
Introduce CONFIG_META_CSUM_ENABLE flag For ext2 & ext3 feature set metadata checksum could be disabled at compile time
--- a/lwext4/ext4_balloc.c
+++ b/lwext4/ext4_balloc.c
@@ -78,6 +78,7 @@
return baddr;
}
+#if CONFIG_META_CSUM_ENABLE
static uint32_t ext4_balloc_bitmap_csum(struct ext4_sblock *sb,
void *bitmap)
{
@@ -95,6 +96,9 @@
}
return checksum;
}
+#else
+#define ext4_balloc_bitmap_csum(...) 0
+#endif
/*
* BIG FAT NOTES:
@@ -103,7 +107,7 @@
void ext4_balloc_set_bitmap_csum(struct ext4_sblock *sb,
struct ext4_bgroup *bg,
- void *bitmap)
+ void *bitmap __unused)
{
int desc_size = ext4_sb_get_desc_size(sb);
uint32_t checksum = ext4_balloc_bitmap_csum(sb, bitmap);
--- a/lwext4/ext4_config.h
+++ b/lwext4/ext4_config.h
@@ -75,6 +75,7 @@
#define CONFIG_DIR_INDEX_ENABLE (CONFIG_SUPPORTED_FCOM & EXT4_FCOM_DIR_INDEX)
#define CONFIG_EXTENT_ENABLE (CONFIG_SUPPORTED_FINCOM & EXT4_FINCOM_EXTENTS)
+#define CONFIG_META_CSUM_ENABLE (CONFIG_SUPPORTED_FRO_COM & EXT4_FRO_COM_METADATA_CSUM)
/*****************************************************************************/
--- a/lwext4/ext4_dir.c
+++ b/lwext4/ext4_dir.c
@@ -69,6 +69,7 @@
return t;
}
+#if CONFIG_META_CSUM_ENABLE
static uint32_t ext4_dir_checksum(struct ext4_inode_ref *inode_ref,
struct ext4_directory_entry_ll *dirent, int size)
{
@@ -90,8 +91,11 @@
checksum = ext4_crc32c(checksum, dirent, size);
return checksum;
}
+#else
+#define ext4_dir_checksum(...) 0
+#endif
-__unused int
+__unused static bool
ext4_dir_checksum_verify(struct ext4_inode_ref *inode_ref,
struct ext4_directory_entry_ll *dirent)
{
@@ -103,15 +107,15 @@
t = ext4_dir_get_tail(inode_ref, dirent);
if (!t) {
/* There is no space to hold the checksum */
- return 0;
+ return false;
}
if (t->checksum != to_le32(ext4_dir_checksum(inode_ref, dirent,
(char *)t - (char *)dirent)))
- return 0;
+ return false;
}
- return 1;
+ return true;
}
/* checksumming functions */
--- a/lwext4/ext4_dir_idx.c
+++ b/lwext4/ext4_dir_idx.c
@@ -204,6 +204,7 @@
&hinfo->hash, &hinfo->minor_hash);
}
+#if CONFIG_META_CSUM_ENABLE
static uint32_t
ext4_dir_dx_checksum(struct ext4_inode_ref *inode_ref,
void *dirent,
@@ -277,7 +278,7 @@
* BIG FAT NOTES:
* Currently we do not verify the checksum of HTree node.
*/
-__unused static int
+__unused static bool
ext4_dir_dx_checksum_verify(struct ext4_inode_ref *inode_ref,
struct ext4_directory_entry_ll *dirent)
{
@@ -289,7 +290,7 @@
ext4_dir_dx_get_countlimit(inode_ref, dirent, &count_offset);
if (!countlimit) {
/* Directory seems corrupted. */
- return 1;
+ return true;
}
struct ext4_directory_dx_tail *t;
limit = ext4_dir_dx_countlimit_get_limit(countlimit);
@@ -298,7 +299,7 @@
ext4_sb_get_block_size(sb) -
sizeof(struct ext4_directory_dx_tail)) {
/* There is no space to hold the checksum */
- return 1;
+ return true;
}
t = (struct ext4_directory_dx_tail *)
(((struct ext4_directory_dx_entry *)countlimit) + limit);
@@ -307,11 +308,12 @@
dirent,
count_offset,
count, t)))
- return 0;
+ return false;
}
- return 1;
+ return true;
}
+
static void
ext4_dir_set_dx_checksum(struct ext4_inode_ref *inode_ref,
struct ext4_directory_entry_ll *dirent)
@@ -342,6 +344,9 @@
to_le32(ext4_dir_dx_checksum(inode_ref, dirent, count_offset, count, t));
}
}
+#else
+#define ext4_dir_set_dx_checksum(...)
+#endif
/****************************************************************************/
@@ -875,7 +880,7 @@
*
*/
static void
-ext4_dir_dx_insert_entry(struct ext4_inode_ref *inode_ref,
+ext4_dir_dx_insert_entry(struct ext4_inode_ref *inode_ref __unused,
struct ext4_directory_dx_block *index_block,
uint32_t hash, uint32_t iblock)
{
--- a/lwext4/ext4_extent_full.c
+++ b/lwext4/ext4_extent_full.c
@@ -309,6 +309,7 @@
return newblock;
}
+#if CONFIG_META_CSUM_ENABLE
static uint32_t ext4_ext_block_csum(struct ext4_inode_ref *inode_ref,
struct ext4_extent_header *eh)
{
@@ -335,8 +336,11 @@
}
return checksum;
}
+#else
+#define ext4_ext_block_csum(...) 0
+#endif
-static void ext4_extent_block_csum_set(struct ext4_inode_ref *inode_ref,
+static void ext4_extent_block_csum_set(struct ext4_inode_ref *inode_ref __unused,
struct ext4_extent_header *eh)
{
struct ext4_extent_tail *tail;
--- a/lwext4/ext4_fs.c
+++ b/lwext4/ext4_fs.c
@@ -570,7 +570,7 @@
{
/* If checksum not supported, 0 will be returned */
uint16_t crc = 0;
-
+#if CONFIG_META_CSUM_ENABLE
/* Compute the checksum only if the filesystem supports it */
if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM)) {
/* Use metadata_csum algorithm instead */
@@ -593,7 +593,10 @@
bg->checksum = orig_checksum;
crc = checksum & 0xFFFF;
- } else if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_GDT_CSUM)) {
+ return crc;
+ }
+#endif
+ if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_GDT_CSUM)) {
uint8_t *base = (uint8_t *)bg;
uint8_t *checksum = (uint8_t *)&bg->checksum;
@@ -644,6 +647,7 @@
return ext4_block_set(ref->fs->bdev, &ref->block);
}
+#if CONFIG_META_CSUM_ENABLE
static uint32_t ext4_fs_inode_checksum(struct ext4_inode_ref *inode_ref)
{
uint32_t checksum = 0;
@@ -679,6 +683,9 @@
}
return checksum;
}
+#else
+#define ext4_fs_inode_checksum(...) 0
+#endif
static void ext4_fs_set_inode_checksum(struct ext4_inode_ref *inode_ref)
{
--- a/lwext4/ext4_ialloc.c
+++ b/lwext4/ext4_ialloc.c
@@ -86,6 +86,7 @@
return (inode - 1) / inodes_per_group;
}
+#if CONFIG_META_CSUM_ENABLE
static uint32_t ext4_ialloc_bitmap_csum(struct ext4_sblock *sb,
void *bitmap)
{
@@ -103,6 +104,9 @@
}
return checksum;
}
+#else
+#define ext4_ialloc_bitmap_csum(...) 0
+#endif
/*
* BIG FAT NOTES:
@@ -111,7 +115,7 @@
void ext4_ialloc_set_bitmap_csum(struct ext4_sblock *sb,
struct ext4_bgroup *bg,
- void *bitmap)
+ void *bitmap __unused)
{
int desc_size = ext4_sb_get_desc_size(sb);
uint32_t checksum = ext4_ialloc_bitmap_csum(sb, bitmap);
--- a/lwext4/ext4_super.c
+++ b/lwext4/ext4_super.c
@@ -80,11 +80,16 @@
return (total_inodes - ((block_group_count - 1) * inodes_per_group));
}
+#if CONFIG_META_CSUM_ENABLE
static uint32_t ext4_sb_csum(struct ext4_sblock *s)
{
+
return ext4_crc32c(EXT4_CRC32_INIT, s,
offsetof(struct ext4_sblock, checksum));
}
+#else
+#define ext4_sb_csum(...) 0
+#endif
static bool ext4_sb_verify_csum(struct ext4_sblock *s)
{
--- a/lwext4/ext4_xattr.c
+++ b/lwext4/ext4_xattr.c
@@ -112,6 +112,7 @@
header->h_hash = to_le32(hash);
}
+#if CONFIG_META_CSUM_ENABLE
static uint32_t
ext4_xattr_block_checksum(struct ext4_inode_ref *inode_ref,
ext4_fsblk_t blocknr,
@@ -141,10 +142,13 @@
}
return checksum;
}
+#else
+#define ext4_xattr_block_checksum(...) 0
+#endif
static void
ext4_xattr_set_block_checksum(struct ext4_inode_ref *inode_ref,
- ext4_fsblk_t blocknr,
+ ext4_fsblk_t blocknr __unused,
struct ext4_xattr_header *header)
{
struct ext4_sblock *sb = &inode_ref->fs->sb;