hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/fs/ext4/block_validity.c
....@@ -217,7 +217,6 @@
217217 struct ext4_system_blocks *system_blks;
218218 struct ext4_group_desc *gdp;
219219 ext4_group_t i;
220
- int flex_size = ext4_flex_bg_size(sbi);
221220 int ret;
222221
223222 system_blks = kzalloc(sizeof(*system_blks), GFP_KERNEL);
....@@ -225,12 +224,13 @@
225224 return -ENOMEM;
226225
227226 for (i=0; i < ngroups; i++) {
227
+ unsigned int meta_blks = ext4_num_base_meta_blocks(sb, i);
228
+
228229 cond_resched();
229
- if (ext4_bg_has_super(sb, i) &&
230
- ((i < 5) || ((i % flex_size) == 0))) {
230
+ if (meta_blks != 0) {
231231 ret = add_system_zone(system_blks,
232232 ext4_group_first_block_no(sb, i),
233
- ext4_bg_num_gdb(sb, i) + 1, 0);
233
+ meta_blks, 0);
234234 if (ret)
235235 goto err;
236236 }
....@@ -294,15 +294,10 @@
294294 call_rcu(&system_blks->rcu, ext4_destroy_system_zone);
295295 }
296296
297
-/*
298
- * Returns 1 if the passed-in block region (start_blk,
299
- * start_blk+count) is valid; 0 if some part of the block region
300
- * overlaps with some other filesystem metadata blocks.
301
- */
302
-int ext4_inode_block_valid(struct inode *inode, ext4_fsblk_t start_blk,
303
- unsigned int count)
297
+int ext4_sb_block_valid(struct super_block *sb, struct inode *inode,
298
+ ext4_fsblk_t start_blk, unsigned int count)
304299 {
305
- struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
300
+ struct ext4_sb_info *sbi = EXT4_SB(sb);
306301 struct ext4_system_blocks *system_blks;
307302 struct ext4_system_zone *entry;
308303 struct rb_node *n;
....@@ -331,7 +326,9 @@
331326 else if (start_blk >= (entry->start_blk + entry->count))
332327 n = n->rb_right;
333328 else {
334
- ret = (entry->ino == inode->i_ino);
329
+ ret = 0;
330
+ if (inode)
331
+ ret = (entry->ino == inode->i_ino);
335332 break;
336333 }
337334 }
....@@ -340,6 +337,17 @@
340337 return ret;
341338 }
342339
340
+/*
341
+ * Returns 1 if the passed-in block region (start_blk,
342
+ * start_blk+count) is valid; 0 if some part of the block region
343
+ * overlaps with some other filesystem metadata blocks.
344
+ */
345
+int ext4_inode_block_valid(struct inode *inode, ext4_fsblk_t start_blk,
346
+ unsigned int count)
347
+{
348
+ return ext4_sb_block_valid(inode->i_sb, inode, start_blk, count);
349
+}
350
+
343351 int ext4_check_blockref(const char *function, unsigned int line,
344352 struct inode *inode, __le32 *p, unsigned int max)
345353 {