Lines Matching refs:fs

99 static int addref(struct ext2_fs *fs, struct ext2_inode_relocator_state *state, ino_t inode, blk_t block, off_t offset)
128 static int doblock(struct ext2_fs *fs, struct ext2_inode_relocator_state *state, blk_t blockno)
133 bh = ext2_bread(fs, blockno);
145 if (!addref(fs, state, EXT2_DIRENT_INODE(*ptr), blockno,
151 } while (offset < fs->blocksize);
157 static int doindblock(struct ext2_fs *fs, struct ext2_inode_relocator_state *state, blk_t blockno)
163 bh = ext2_bread(fs, blockno);
165 for (i=0;i<(fs->blocksize>>2);i++)
167 if (!doblock(fs, state, blk))
174 static int dodindblock(struct ext2_fs *fs, struct ext2_inode_relocator_state *state, blk_t blockno)
180 bh = ext2_bread(fs, blockno);
184 for (i=0;i<(fs->blocksize>>2);i++)
186 if (!doindblock(fs, state, blk))
193 static int dotindblock(struct ext2_fs *fs, struct ext2_inode_relocator_state *state, blk_t blockno)
199 bh = ext2_bread(fs, blockno);
203 for (i=0;i<(fs->blocksize>>2);i++)
205 if (!dodindblock(fs, state, blk))
212 static int doinode(struct ext2_fs *fs, struct ext2_inode_relocator_state *state, ino_t inode)
217 if (!ext2_read_inode(fs, inode, &buf))
225 if (!doblock(fs, state, blk))
229 if (!doindblock(fs, state, blk))
233 if (!dodindblock(fs, state, blk))
237 if (!dotindblock(fs, state, blk))
244 static int doscangroup(struct ext2_fs *fs, struct ext2_inode_relocator_state *state, int group)
250 if (fs->opt_verbose)
253 bh = ext2_bread(fs, EXT2_GROUP_INODE_BITMAP(fs->gd[group]));
254 offset = group * EXT2_SUPER_INODES_PER_GROUP(fs->sb) + 1;
256 for (i=0;i<EXT2_SUPER_INODES_PER_GROUP(fs->sb);i++)
259 if (!doinode(fs, state, offset + i))
271 if (fs->opt_verbose)
285 static int doscan(struct ext2_fs *fs, struct ext2_inode_relocator_state *state)
294 if (fs->has_internal_journal)
295 addref(fs, state, EXT2_SUPER_JOURNAL_INUM(fs->sb),
298 if (!doscangroup(fs, state, 0))
302 for (i=fs->numgroups-1;i>0;i--)
304 if (!doscangroup(fs, state, i))
311 if (fs->opt_verbose)
323 static int ext2_inode_relocator_copy(struct ext2_fs *fs, struct ext2_inode_relocator_state *state)
334 if (fs->opt_debug)
335 if (!ext2_get_inode_state(fs, entry->num) ||
336 ext2_get_inode_state(fs, entry->dest))
339 if (!ext2_read_inode(fs, entry->num, &buf))
341 if (!ext2_write_inode(fs, entry->dest, &buf))
347 if (fs->opt_safe)
348 if (!ext2_sync(fs))
353 static int ext2_inode_relocator_finish(struct ext2_fs *fs, struct ext2_inode_relocator_state *state)
362 ext2_set_inode_state(fs, entry->dest, 1, 1);
363 ext2_set_inode_state(fs, entry->num, 0, 1);
364 ext2_zero_inode(fs, entry->num);
367 if (fs->opt_safe)
368 if (!ext2_sync(fs))
373 static int ext2_inode_relocator_ref(struct ext2_fs *fs, struct ext2_inode_relocator_state *state)
391 bh = ext2_bread(fs, entry->ref[j].block);
395 if (fs->opt_debug)
429 / EXT2_SUPER_INODES_PER_GROUP(fs->sb);
431 / EXT2_SUPER_INODES_PER_GROUP(fs->sb);
433 fs->gd[oldgroup].bg_used_dirs_count = PED_CPU_TO_LE16 (
434 EXT2_GROUP_USED_DIRS_COUNT(fs->gd[oldgroup])
436 fs->gd[newgroup].bg_used_dirs_count = PED_CPU_TO_LE16 (
437 EXT2_GROUP_USED_DIRS_COUNT(fs->gd[newgroup])
440 fs->metadirty = EXT2_META_GD;
444 if (fs->opt_safe)
445 if (!ext2_sync(fs))
451 static int ext2_inode_relocator_grab_inodes(struct ext2_fs *fs, struct ext2_inode_relocator_state *state)
458 for (i=0;i<fs->numgroups;i++)
459 if (EXT2_GROUP_FREE_INODES_COUNT(fs->gd[i]))
465 bh = ext2_bread(fs, EXT2_GROUP_INODE_BITMAP(fs->gd[i]));
468 offset = i * EXT2_SUPER_INODES_PER_GROUP(fs->sb) + 1;
471 for (;j<EXT2_SUPER_INODES_PER_GROUP(fs->sb);j++)
491 static int ext2_inode_relocator_flush(struct ext2_fs *fs, struct ext2_inode_relocator_state *state)
496 if (!doscan(fs, state))
499 if (!ext2_inode_relocator_grab_inodes(fs, state))
502 if (!ext2_inode_relocator_copy(fs, state))
505 if (!ext2_inode_relocator_ref(fs, state))
508 if (!ext2_inode_relocator_finish(fs, state))
513 state->last = (struct ext2_reference *)fs->relocator_pool_end;
515 if (fs->opt_safe)
516 if (!ext2_sync(fs))
522 static int ext2_inode_relocator_mark(struct ext2_fs *fs, struct ext2_inode_relocator_state *state, ino_t inode)
528 if (!ext2_read_inode(fs, inode, &buf))
539 ext2_inode_relocator_flush(fs, state);
562 int ext2_inode_relocate(struct ext2_fs *fs, int newgroups)
567 if (fs->opt_verbose)
572 state.inode = (struct ext2_inode_entry *)fs->relocator_pool;
573 state.last = (struct ext2_reference *)fs->relocator_pool_end;
575 for (i=newgroups;i<fs->numgroups;i++)
581 bh = ext2_bread(fs, EXT2_GROUP_INODE_BITMAP(fs->gd[i]));
584 offset = i * EXT2_SUPER_INODES_PER_GROUP(fs->sb) + 1;
586 for (j=0;j<EXT2_SUPER_INODES_PER_GROUP(fs->sb);j++)
588 ext2_inode_relocator_mark(fs, &state,
594 if (!ext2_inode_relocator_flush(fs, &state))