super.c (725d26d3f09ccb5bac4b4293096b985a312a0d67) super.c (fd2d42912f9f09e5250cb3b024ee0625704e9cb7)
1/*
2 * linux/fs/ext4/super.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *

--- 1350 unchanged lines hidden (view full) ---

1359 ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
1360 ext4_fsblk_t last_block;
1361 ext4_fsblk_t block_bitmap;
1362 ext4_fsblk_t inode_bitmap;
1363 ext4_fsblk_t inode_table;
1364 struct ext4_group_desc * gdp = NULL;
1365 int desc_block = 0;
1366 int flexbg_flag = 0;
1/*
2 * linux/fs/ext4/super.c
3 *
4 * Copyright (C) 1992, 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 *

--- 1350 unchanged lines hidden (view full) ---

1359 ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
1360 ext4_fsblk_t last_block;
1361 ext4_fsblk_t block_bitmap;
1362 ext4_fsblk_t inode_bitmap;
1363 ext4_fsblk_t inode_table;
1364 struct ext4_group_desc * gdp = NULL;
1365 int desc_block = 0;
1366 int flexbg_flag = 0;
1367 int i;
1367 ext4_group_t i;
1368
1369 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG))
1370 flexbg_flag = 1;
1371
1372 ext4_debug ("Checking group descriptors");
1373
1374 for (i = 0; i < sbi->s_groups_count; i++)
1375 {

--- 5 unchanged lines hidden (view full) ---

1381
1382 if ((i % EXT4_DESC_PER_BLOCK(sb)) == 0)
1383 gdp = (struct ext4_group_desc *)
1384 sbi->s_group_desc[desc_block++]->b_data;
1385 block_bitmap = ext4_block_bitmap(sb, gdp);
1386 if (block_bitmap < first_block || block_bitmap > last_block)
1387 {
1388 ext4_error (sb, "ext4_check_descriptors",
1368
1369 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG))
1370 flexbg_flag = 1;
1371
1372 ext4_debug ("Checking group descriptors");
1373
1374 for (i = 0; i < sbi->s_groups_count; i++)
1375 {

--- 5 unchanged lines hidden (view full) ---

1381
1382 if ((i % EXT4_DESC_PER_BLOCK(sb)) == 0)
1383 gdp = (struct ext4_group_desc *)
1384 sbi->s_group_desc[desc_block++]->b_data;
1385 block_bitmap = ext4_block_bitmap(sb, gdp);
1386 if (block_bitmap < first_block || block_bitmap > last_block)
1387 {
1388 ext4_error (sb, "ext4_check_descriptors",
1389 "Block bitmap for group %d"
1389 "Block bitmap for group %lu"
1390 " not in group (block %llu)!",
1391 i, block_bitmap);
1392 return 0;
1393 }
1394 inode_bitmap = ext4_inode_bitmap(sb, gdp);
1395 if (inode_bitmap < first_block || inode_bitmap > last_block)
1396 {
1397 ext4_error (sb, "ext4_check_descriptors",
1390 " not in group (block %llu)!",
1391 i, block_bitmap);
1392 return 0;
1393 }
1394 inode_bitmap = ext4_inode_bitmap(sb, gdp);
1395 if (inode_bitmap < first_block || inode_bitmap > last_block)
1396 {
1397 ext4_error (sb, "ext4_check_descriptors",
1398 "Inode bitmap for group %d"
1398 "Inode bitmap for group %lu"
1399 " not in group (block %llu)!",
1400 i, inode_bitmap);
1401 return 0;
1402 }
1403 inode_table = ext4_inode_table(sb, gdp);
1404 if (inode_table < first_block ||
1405 inode_table + sbi->s_itb_per_group - 1 > last_block)
1406 {
1407 ext4_error (sb, "ext4_check_descriptors",
1399 " not in group (block %llu)!",
1400 i, inode_bitmap);
1401 return 0;
1402 }
1403 inode_table = ext4_inode_table(sb, gdp);
1404 if (inode_table < first_block ||
1405 inode_table + sbi->s_itb_per_group - 1 > last_block)
1406 {
1407 ext4_error (sb, "ext4_check_descriptors",
1408 "Inode table for group %d"
1408 "Inode table for group %lu"
1409 " not in group (block %llu)!",
1410 i, inode_table);
1411 return 0;
1412 }
1413 if (!ext4_group_desc_csum_verify(sbi, i, gdp)) {
1414 ext4_error(sb, __FUNCTION__,
1409 " not in group (block %llu)!",
1410 i, inode_table);
1411 return 0;
1412 }
1413 if (!ext4_group_desc_csum_verify(sbi, i, gdp)) {
1414 ext4_error(sb, __FUNCTION__,
1415 "Checksum for group %d failed (%u!=%u)\n", i,
1416 le16_to_cpu(ext4_group_desc_csum(sbi, i,
1417 gdp)),
1418 le16_to_cpu(gdp->bg_checksum));
1415 "Checksum for group %lu failed (%u!=%u)\n",
1416 i, le16_to_cpu(ext4_group_desc_csum(sbi, i,
1417 gdp)), le16_to_cpu(gdp->bg_checksum));
1419 return 0;
1420 }
1421 if (!flexbg_flag)
1422 first_block += EXT4_BLOCKS_PER_GROUP(sb);
1423 gdp = (struct ext4_group_desc *)
1424 ((__u8 *)gdp + EXT4_DESC_SIZE(sb));
1425 }
1426
1427 ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb));
1428 sbi->s_es->s_free_inodes_count=cpu_to_le32(ext4_count_free_inodes(sb));
1429 return 1;
1430}
1431
1418 return 0;
1419 }
1420 if (!flexbg_flag)
1421 first_block += EXT4_BLOCKS_PER_GROUP(sb);
1422 gdp = (struct ext4_group_desc *)
1423 ((__u8 *)gdp + EXT4_DESC_SIZE(sb));
1424 }
1425
1426 ext4_free_blocks_count_set(sbi->s_es, ext4_count_free_blocks(sb));
1427 sbi->s_es->s_free_inodes_count=cpu_to_le32(ext4_count_free_inodes(sb));
1428 return 1;
1429}
1430
1432
1433/* ext4_orphan_cleanup() walks a singly-linked list of inodes (starting at
1434 * the superblock) which were deleted from all directories, but held open by
1435 * a process at the time of a crash. We walk the list and try to delete these
1436 * inodes at recovery time (only with a read-write filesystem).
1437 *
1438 * In order to keep the orphan inode chain consistent during traversal (in
1439 * case of crash during recovery), we link each inode into the superblock
1440 * orphan list_head and handle it the same way as an inode deletion during

--- 124 unchanged lines hidden (view full) ---

1565 res = upper_limit;
1566 return res;
1567}
1568
1569static ext4_fsblk_t descriptor_loc(struct super_block *sb,
1570 ext4_fsblk_t logical_sb_block, int nr)
1571{
1572 struct ext4_sb_info *sbi = EXT4_SB(sb);
1431/* ext4_orphan_cleanup() walks a singly-linked list of inodes (starting at
1432 * the superblock) which were deleted from all directories, but held open by
1433 * a process at the time of a crash. We walk the list and try to delete these
1434 * inodes at recovery time (only with a read-write filesystem).
1435 *
1436 * In order to keep the orphan inode chain consistent during traversal (in
1437 * case of crash during recovery), we link each inode into the superblock
1438 * orphan list_head and handle it the same way as an inode deletion during

--- 124 unchanged lines hidden (view full) ---

1563 res = upper_limit;
1564 return res;
1565}
1566
1567static ext4_fsblk_t descriptor_loc(struct super_block *sb,
1568 ext4_fsblk_t logical_sb_block, int nr)
1569{
1570 struct ext4_sb_info *sbi = EXT4_SB(sb);
1573 unsigned long bg, first_meta_bg;
1571 ext4_group_t bg, first_meta_bg;
1574 int has_super = 0;
1575
1576 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
1577
1578 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG) ||
1579 nr < first_meta_bg)
1580 return logical_sb_block + nr + 1;
1581 bg = sbi->s_desc_per_block * nr;

--- 1091 unchanged lines hidden (view full) ---

2673 struct super_block *sb = dentry->d_sb;
2674 struct ext4_sb_info *sbi = EXT4_SB(sb);
2675 struct ext4_super_block *es = sbi->s_es;
2676 u64 fsid;
2677
2678 if (test_opt(sb, MINIX_DF)) {
2679 sbi->s_overhead_last = 0;
2680 } else if (sbi->s_blocks_last != ext4_blocks_count(es)) {
1572 int has_super = 0;
1573
1574 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
1575
1576 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_META_BG) ||
1577 nr < first_meta_bg)
1578 return logical_sb_block + nr + 1;
1579 bg = sbi->s_desc_per_block * nr;

--- 1091 unchanged lines hidden (view full) ---

2671 struct super_block *sb = dentry->d_sb;
2672 struct ext4_sb_info *sbi = EXT4_SB(sb);
2673 struct ext4_super_block *es = sbi->s_es;
2674 u64 fsid;
2675
2676 if (test_opt(sb, MINIX_DF)) {
2677 sbi->s_overhead_last = 0;
2678 } else if (sbi->s_blocks_last != ext4_blocks_count(es)) {
2681 unsigned long ngroups = sbi->s_groups_count, i;
2679 ext4_group_t ngroups = sbi->s_groups_count, i;
2682 ext4_fsblk_t overhead = 0;
2683 smp_rmb();
2684
2685 /*
2686 * Compute the overhead (FS structures). This is constant
2687 * for a given filesystem unless the number of block groups
2688 * changes so we cache the previous value until it does.
2689 */

--- 374 unchanged lines hidden ---
2680 ext4_fsblk_t overhead = 0;
2681 smp_rmb();
2682
2683 /*
2684 * Compute the overhead (FS structures). This is constant
2685 * for a given filesystem unless the number of block groups
2686 * changes so we cache the previous value until it does.
2687 */

--- 374 unchanged lines hidden ---