diff options
| -rw-r--r-- | fs/ext4/ext4.h | 29 | ||||
| -rw-r--r-- | fs/ext4/super.c | 1 |
2 files changed, 14 insertions, 16 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index e20dc38858d4..b79d613091d0 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
| @@ -463,25 +463,22 @@ enum { | |||
| 463 | EXT4_INODE_RESERVED = 31, /* reserved for ext4 lib */ | 463 | EXT4_INODE_RESERVED = 31, /* reserved for ext4 lib */ |
| 464 | }; | 464 | }; |
| 465 | 465 | ||
| 466 | #define TEST_FLAG_VALUE(FLAG) (EXT4_##FLAG##_FL == (1 << EXT4_INODE_##FLAG)) | 466 | /* |
| 467 | #define CHECK_FLAG_VALUE(FLAG) if (!TEST_FLAG_VALUE(FLAG)) { \ | 467 | * Since it's pretty easy to mix up bit numbers and hex values, we use a |
| 468 | printk(KERN_EMERG "EXT4 flag fail: " #FLAG ": %d %d\n", \ | 468 | * build-time check to make sure that EXT4_XXX_FL is consistent with respect to |
| 469 | EXT4_##FLAG##_FL, EXT4_INODE_##FLAG); BUG_ON(1); } | 469 | * EXT4_INODE_XXX. If all is well, the macros will be dropped, so, it won't cost |
| 470 | 470 | * any extra space in the compiled kernel image, otherwise, the build will fail. | |
| 471 | /* | 471 | * It's important that these values are the same, since we are using |
| 472 | * Since it's pretty easy to mix up bit numbers and hex values, and we | 472 | * EXT4_INODE_XXX to test for flag values, but EXT4_XXX_FL must be consistent |
| 473 | * can't do a compile-time test for ENUM values, we use a run-time | 473 | * with the values of FS_XXX_FL defined in include/linux/fs.h and the on-disk |
| 474 | * test to make sure that EXT4_XXX_FL is consistent with respect to | 474 | * values found in ext2, ext3 and ext4 filesystems, and of course the values |
| 475 | * EXT4_INODE_XXX. If all is well the printk and BUG_ON will all drop | 475 | * defined in e2fsprogs. |
| 476 | * out so it won't cost any extra space in the compiled kernel image. | ||
| 477 | * But it's important that these values are the same, since we are | ||
| 478 | * using EXT4_INODE_XXX to test for the flag values, but EXT4_XX_FL | ||
| 479 | * must be consistent with the values of FS_XXX_FL defined in | ||
| 480 | * include/linux/fs.h and the on-disk values found in ext2, ext3, and | ||
| 481 | * ext4 filesystems, and of course the values defined in e2fsprogs. | ||
| 482 | * | 476 | * |
| 483 | * It's not paranoia if the Murphy's Law really *is* out to get you. :-) | 477 | * It's not paranoia if the Murphy's Law really *is* out to get you. :-) |
| 484 | */ | 478 | */ |
| 479 | #define TEST_FLAG_VALUE(FLAG) (EXT4_##FLAG##_FL == (1 << EXT4_INODE_##FLAG)) | ||
| 480 | #define CHECK_FLAG_VALUE(FLAG) BUILD_BUG_ON(!TEST_FLAG_VALUE(FLAG)) | ||
| 481 | |||
| 485 | static inline void ext4_check_flag_values(void) | 482 | static inline void ext4_check_flag_values(void) |
| 486 | { | 483 | { |
| 487 | CHECK_FLAG_VALUE(SECRM); | 484 | CHECK_FLAG_VALUE(SECRM); |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 7d53adff8bd3..3cdb0a2fc648 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
| @@ -5278,6 +5278,7 @@ static int __init ext4_init_fs(void) | |||
| 5278 | ext4_li_info = NULL; | 5278 | ext4_li_info = NULL; |
| 5279 | mutex_init(&ext4_li_mtx); | 5279 | mutex_init(&ext4_li_mtx); |
| 5280 | 5280 | ||
| 5281 | /* Build-time check for flags consistency */ | ||
| 5281 | ext4_check_flag_values(); | 5282 | ext4_check_flag_values(); |
| 5282 | 5283 | ||
| 5283 | for (i = 0; i < EXT4_WQ_HASH_SZ; i++) { | 5284 | for (i = 0; i < EXT4_WQ_HASH_SZ; i++) { |
