aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c68
1 files changed, 66 insertions, 2 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2415e2b09707..a3321bf22311 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -93,6 +93,38 @@ ext4_fsblk_t ext4_inode_table(struct super_block *sb,
93 (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_table_hi) << 32 : 0); 93 (ext4_fsblk_t)le32_to_cpu(bg->bg_inode_table_hi) << 32 : 0);
94} 94}
95 95
96__u32 ext4_free_blks_count(struct super_block *sb,
97 struct ext4_group_desc *bg)
98{
99 return le16_to_cpu(bg->bg_free_blocks_count_lo) |
100 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
101 (__u32)le16_to_cpu(bg->bg_free_blocks_count_hi) << 16 : 0);
102}
103
104__u32 ext4_free_inodes_count(struct super_block *sb,
105 struct ext4_group_desc *bg)
106{
107 return le16_to_cpu(bg->bg_free_inodes_count_lo) |
108 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
109 (__u32)le16_to_cpu(bg->bg_free_inodes_count_hi) << 16 : 0);
110}
111
112__u32 ext4_used_dirs_count(struct super_block *sb,
113 struct ext4_group_desc *bg)
114{
115 return le16_to_cpu(bg->bg_used_dirs_count_lo) |
116 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
117 (__u32)le16_to_cpu(bg->bg_used_dirs_count_hi) << 16 : 0);
118}
119
120__u32 ext4_itable_unused_count(struct super_block *sb,
121 struct ext4_group_desc *bg)
122{
123 return le16_to_cpu(bg->bg_itable_unused_lo) |
124 (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
125 (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0);
126}
127
96void ext4_block_bitmap_set(struct super_block *sb, 128void ext4_block_bitmap_set(struct super_block *sb,
97 struct ext4_group_desc *bg, ext4_fsblk_t blk) 129 struct ext4_group_desc *bg, ext4_fsblk_t blk)
98{ 130{
@@ -117,6 +149,38 @@ void ext4_inode_table_set(struct super_block *sb,
117 bg->bg_inode_table_hi = cpu_to_le32(blk >> 32); 149 bg->bg_inode_table_hi = cpu_to_le32(blk >> 32);
118} 150}
119 151
152void ext4_free_blks_set(struct super_block *sb,
153 struct ext4_group_desc *bg, __u32 count)
154{
155 bg->bg_free_blocks_count_lo = cpu_to_le16((__u16)count);
156 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT)
157 bg->bg_free_blocks_count_hi = cpu_to_le16(count >> 16);
158}
159
160void ext4_free_inodes_set(struct super_block *sb,
161 struct ext4_group_desc *bg, __u32 count)
162{
163 bg->bg_free_inodes_count_lo = cpu_to_le16((__u16)count);
164 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT)
165 bg->bg_free_inodes_count_hi = cpu_to_le16(count >> 16);
166}
167
168void ext4_used_dirs_set(struct super_block *sb,
169 struct ext4_group_desc *bg, __u32 count)
170{
171 bg->bg_used_dirs_count_lo = cpu_to_le16((__u16)count);
172 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT)
173 bg->bg_used_dirs_count_hi = cpu_to_le16(count >> 16);
174}
175
176void ext4_itable_unused_set(struct super_block *sb,
177 struct ext4_group_desc *bg, __u32 count)
178{
179 bg->bg_itable_unused_lo = cpu_to_le16((__u16)count);
180 if (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT)
181 bg->bg_itable_unused_hi = cpu_to_le16(count >> 16);
182}
183
120/* 184/*
121 * Wrappers for jbd2_journal_start/end. 185 * Wrappers for jbd2_journal_start/end.
122 * 186 *
@@ -1561,9 +1625,9 @@ static int ext4_fill_flex_info(struct super_block *sb)
1561 1625
1562 flex_group = ext4_flex_group(sbi, i); 1626 flex_group = ext4_flex_group(sbi, i);
1563 sbi->s_flex_groups[flex_group].free_inodes += 1627 sbi->s_flex_groups[flex_group].free_inodes +=
1564 le16_to_cpu(gdp->bg_free_inodes_count); 1628 ext4_free_inodes_count(sb, gdp);
1565 sbi->s_flex_groups[flex_group].free_blocks += 1629 sbi->s_flex_groups[flex_group].free_blocks +=
1566 le16_to_cpu(gdp->bg_free_blocks_count); 1630 ext4_free_blks_count(sb, gdp);
1567 } 1631 }
1568 1632
1569 return 1; 1633 return 1;