Lines Matching refs:fs
58 static int release_inode_block(ext2_filsys fs, in release_inode_block() argument
81 if ((blk < fs->super->s_first_data_block) || in release_inode_block()
82 (blk >= ext2fs_blocks_count(fs->super))) { in release_inode_block()
89 if (!ext2fs_test_block_bitmap2(fs->block_map, blk)) { in release_inode_block()
108 pb->errcode = io_channel_read_blk64(fs->io, blk, 1, in release_inode_block()
113 limit = fs->blocksize >> 2; in release_inode_block()
130 pb->errcode = io_channel_read_blk64(fs->io, blk, 1, in release_inode_block()
135 fs->blocksize - pb->truncate_offset); in release_inode_block()
136 pb->errcode = io_channel_write_blk64(fs->io, blk, 1, in release_inode_block()
146 ext2fs_block_alloc_stats2(fs, blk, -1); in release_inode_block()
161 ext2_filsys fs = ctx->fs; in release_inode_blocks() local
165 if (!ext2fs_inode_has_valid_blocks2(fs, inode)) in release_inode_blocks()
168 pb.buf = block_buf + 3 * ctx->fs->blocksize; in release_inode_blocks()
176 ((EXT2_I_SIZE(inode) + fs->blocksize - 1) / in release_inode_blocks()
177 fs->blocksize); in release_inode_blocks()
178 pb.truncate_offset = inode->i_size % fs->blocksize; in release_inode_blocks()
185 retval = ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE, in release_inode_blocks()
200 ext2fs_iblk_sub_blocks(fs, inode, pb.truncated_blocks); in release_inode_blocks()
202 if (ext2fs_file_acl_block(fs, inode)) { in release_inode_blocks()
203 retval = ext2fs_adjust_ea_refcount2(fs, in release_inode_blocks()
204 ext2fs_file_acl_block(fs, inode), in release_inode_blocks()
217 ext2fs_block_alloc_stats2(fs, in release_inode_blocks()
218 ext2fs_file_acl_block(fs, inode), -1); in release_inode_blocks()
221 ext2fs_file_acl_block_set(fs, inode, 0); in release_inode_blocks()
232 ext2_filsys fs = ctx->fs; in release_orphan_inodes() local
238 if ((ino = fs->super->s_last_orphan) == 0) in release_orphan_inodes()
245 fs->super->s_last_orphan = 0; in release_orphan_inodes()
246 ext2fs_mark_super_dirty(fs); in release_orphan_inodes()
253 if (fs->super->s_state & EXT2_ERROR_FS) in release_orphan_inodes()
256 if ((ino < EXT2_FIRST_INODE(fs->super)) || in release_orphan_inodes()
257 (ino > fs->super->s_inodes_count)) { in release_orphan_inodes()
264 block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 4, in release_orphan_inodes()
280 ((next_ino < EXT2_FIRST_INODE(fs->super)) || in release_orphan_inodes()
281 (next_ino > fs->super->s_inodes_count))) { in release_orphan_inodes()
291 ext2fs_inode_alloc_stats2(fs, ino, -1, in release_orphan_inodes()
316 ext2_filsys fs = ctx->fs; in check_resize_inode() local
332 if (!(fs->super->s_feature_compat & in check_resize_inode()
334 if (fs->super->s_reserved_gdt_blocks) { in check_resize_inode()
335 pctx.num = fs->super->s_reserved_gdt_blocks; in check_resize_inode()
338 fs->super->s_reserved_gdt_blocks = 0; in check_resize_inode()
339 ext2fs_mark_super_dirty(fs); in check_resize_inode()
346 retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode); in check_resize_inode()
348 if (fs->super->s_feature_compat & in check_resize_inode()
358 if (!(fs->super->s_feature_compat & in check_resize_inode()
384 (blk < fs->super->s_first_data_block || in check_resize_inode()
385 blk >= ext2fs_blocks_count(fs->super))) { in check_resize_inode()
394 fs->super->s_state &= ~EXT2_VALID_FS; in check_resize_inode()
395 ext2fs_mark_super_dirty(fs); in check_resize_inode()
399 dind_buf = (__u32 *) e2fsck_allocate_memory(ctx, fs->blocksize * 2, in check_resize_inode()
401 ind_buf = (__u32 *) ((char *) dind_buf + fs->blocksize); in check_resize_inode()
403 retval = ext2fs_read_ind_block(fs, blk, dind_buf); in check_resize_inode()
407 gdt_off = fs->desc_blocks; in check_resize_inode()
408 pblk = fs->super->s_first_data_block + 1 + fs->desc_blocks; in check_resize_inode()
409 if (fs->blocksize == 1024 && fs->super->s_first_data_block == 0) in check_resize_inode()
411 for (i = 0; i < fs->super->s_reserved_gdt_blocks / 4; in check_resize_inode()
413 gdt_off %= fs->blocksize/4; in check_resize_inode()
416 retval = ext2fs_read_ind_block(fs, pblk, ind_buf); in check_resize_inode()
420 for (j = 1; j < fs->group_desc_count; j++) { in check_resize_inode()
421 if (!ext2fs_bg_has_super(fs, j)) in check_resize_inode()
423 expect = pblk + (j * fs->super->s_blocks_per_group); in check_resize_inode()
441 struct ext2_super_block *sb = ctx->fs->super; in e2fsck_fix_dirhash_hint()
459 ext2fs_mark_super_dirty(ctx->fs); in e2fsck_fix_dirhash_hint()
466 ext2_filsys fs = ctx->fs; in check_super_block() local
468 struct ext2_super_block *sb = fs->super; in check_super_block()
471 blk64_t blocks_per_group = fs->super->s_blocks_per_group; in check_super_block()
484 inodes_per_block = EXT2_INODES_PER_BLOCK(fs->super); in check_super_block()
491 bpg_max = 8 * EXT2_BLOCK_SIZE(sb) * EXT2FS_CLUSTER_RATIO(fs); in check_super_block()
496 sizeof(int) * fs->group_desc_count, "invalid_inode_bitmap"); in check_super_block()
498 sizeof(int) * fs->group_desc_count, "invalid_block_bitmap"); in check_super_block()
500 sizeof(int) * fs->group_desc_count, "invalid_inode_table"); in check_super_block()
531 fs->blocksize / sizeof(__u32)); in check_super_block()
542 EXT2_GOOD_OLD_INODE_SIZE, fs->blocksize); in check_super_block()
544 EXT2FS_CLUSTER_RATIO(fs))) { in check_super_block()
545 pctx.num = sb->s_clusters_per_group * EXT2FS_CLUSTER_RATIO(fs); in check_super_block()
563 EXT2FS_CLUSTER_RATIO(fs) == 1) ? 1 : 0; in check_super_block()
572 should_be = sb->s_inodes_per_group * fs->group_desc_count; in check_super_block()
578 ext2fs_mark_super_dirty(fs); in check_super_block()
583 if (EXT2_HAS_INCOMPAT_FEATURE(fs->super, in check_super_block()
585 !EXT2_HAS_INCOMPAT_FEATURE(fs->super, in check_super_block()
588 fs->super->s_feature_incompat |= in check_super_block()
590 ext2fs_mark_super_dirty(fs); in check_super_block()
599 csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super, in check_super_block()
601 for (i = 0; i < fs->group_desc_count; i++) { in check_super_block()
604 if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super, in check_super_block()
606 first_block = ext2fs_group_first_block2(fs, i); in check_super_block()
607 last_block = ext2fs_group_last_block2(fs, i); in check_super_block()
610 if ((ext2fs_block_bitmap_loc(fs, i) < first_block) || in check_super_block()
611 (ext2fs_block_bitmap_loc(fs, i) > last_block)) { in check_super_block()
612 pctx.blk = ext2fs_block_bitmap_loc(fs, i); in check_super_block()
614 ext2fs_block_bitmap_loc_set(fs, i, 0); in check_super_block()
616 if (ext2fs_block_bitmap_loc(fs, i) == 0) { in check_super_block()
620 if ((ext2fs_inode_bitmap_loc(fs, i) < first_block) || in check_super_block()
621 (ext2fs_inode_bitmap_loc(fs, i) > last_block)) { in check_super_block()
622 pctx.blk = ext2fs_inode_bitmap_loc(fs, i); in check_super_block()
624 ext2fs_inode_bitmap_loc_set(fs, i, 0); in check_super_block()
626 if (ext2fs_inode_bitmap_loc(fs, i) == 0) { in check_super_block()
630 if ((ext2fs_inode_table_loc(fs, i) < first_block) || in check_super_block()
631 ((ext2fs_inode_table_loc(fs, i) + in check_super_block()
632 fs->inode_blocks_per_group - 1) > last_block)) { in check_super_block()
633 pctx.blk = ext2fs_inode_table_loc(fs, i); in check_super_block()
635 ext2fs_inode_table_loc_set(fs, i, 0); in check_super_block()
637 if (ext2fs_inode_table_loc(fs, i) == 0) { in check_super_block()
641 free_blocks += ext2fs_bg_free_blocks_count(fs, i); in check_super_block()
642 free_inodes += ext2fs_bg_free_inodes_count(fs, i); in check_super_block()
644 if ((ext2fs_bg_free_blocks_count(fs, i) > sb->s_blocks_per_group) || in check_super_block()
645 (ext2fs_bg_free_inodes_count(fs, i) > sb->s_inodes_per_group) || in check_super_block()
646 (ext2fs_bg_used_dirs_count(fs, i) > sb->s_inodes_per_group)) in check_super_block()
647 ext2fs_unmark_valid(fs); in check_super_block()
650 if (!ext2fs_group_desc_csum_verify(fs, i)) { in check_super_block()
651 pctx.csum1 = ext2fs_bg_checksum(fs, i); in check_super_block()
652 pctx.csum2 = ext2fs_group_desc_csum(fs, i); in check_super_block()
654 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
655 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT); in check_super_block()
656 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
659 ext2fs_unmark_valid(fs); in check_super_block()
663 (ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) || in check_super_block()
664 ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) || in check_super_block()
665 ext2fs_bg_itable_unused(fs, i) != 0)) { in check_super_block()
667 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
668 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT); in check_super_block()
669 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
672 ext2fs_unmark_valid(fs); in check_super_block()
675 if (i == fs->group_desc_count - 1 && in check_super_block()
676 ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT)) { in check_super_block()
678 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
681 ext2fs_unmark_valid(fs); in check_super_block()
685 (ext2fs_bg_itable_unused(fs, i) > ext2fs_bg_free_inodes_count(fs, i) || in check_super_block()
686 ext2fs_bg_itable_unused(fs, i) > sb->s_inodes_per_group)) { in check_super_block()
687 pctx.blk = ext2fs_bg_itable_unused(fs, i); in check_super_block()
689 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
692 ext2fs_unmark_valid(fs); in check_super_block()
696 ext2fs_group_desc_csum_set(fs, i); in check_super_block()
702 ctx->free_blocks = EXT2FS_C2B(fs, free_blocks); in check_super_block()
707 ext2fs_unmark_valid(fs); in check_super_block()
716 ext2fs_mark_super_dirty(fs); in check_super_block()
728 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
729 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
742 (fs->super->s_flags & EXT2_FLAGS_TEST_FILESYS) && in check_super_block()
745 fs->super->s_flags &= ~EXT2_FLAGS_TEST_FILESYS; in check_super_block()
746 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
747 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
756 fs->super->s_creator_os == EXT2_OS_HURD && in check_super_block()
757 (fs->super->s_feature_incompat & in check_super_block()
760 fs->super->s_feature_incompat &= in check_super_block()
762 ext2fs_mark_super_dirty(fs); in check_super_block()
763 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
774 fs->super->s_rev_level == EXT2_GOOD_OLD_REV && in check_super_block()
775 (fs->super->s_feature_compat || in check_super_block()
776 fs->super->s_feature_ro_compat || in check_super_block()
777 fs->super->s_feature_incompat) && in check_super_block()
779 ext2fs_update_dynamic_rev(fs); in check_super_block()
780 ext2fs_mark_super_dirty(fs); in check_super_block()
781 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
788 fs->super->s_state &= ~EXT2_VALID_FS; in check_super_block()
789 ext2fs_mark_super_dirty(fs); in check_super_block()
828 fs->super->s_mtime > (__u32) ctx->now) { in check_super_block()
829 pctx.num = fs->super->s_mtime; in check_super_block()
831 if (fs->super->s_mtime <= (__u32) ctx->now + ctx->time_fudge) in check_super_block()
834 fs->super->s_mtime = ctx->now; in check_super_block()
835 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
840 fs->super->s_wtime > (__u32) ctx->now) { in check_super_block()
841 pctx.num = fs->super->s_wtime; in check_super_block()
843 if (fs->super->s_wtime <= (__u32) ctx->now + ctx->time_fudge) in check_super_block()
846 fs->super->s_wtime = ctx->now; in check_super_block()
847 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
900 ext2_filsys fs = ctx->fs; in check_backup_super_block() local
915 if (((fs->flags & EXT2_FLAG_MASTER_SB_ONLY) == 0) || in check_backup_super_block()
916 !ext2fs_test_valid(fs) || in check_backup_super_block()
917 (fs->super->s_state & EXT2_ERROR_FS) || in check_backup_super_block()
922 for (g = 1; g < fs->group_desc_count; g++) { in check_backup_super_block()
923 if (!ext2fs_bg_has_super(fs, g)) in check_backup_super_block()
926 sb = ext2fs_group_first_block2(fs, g); in check_backup_super_block()
928 retval = io_channel_read_blk(fs->io, sb, -SUPERBLOCK_SIZE, in check_backup_super_block()
944 ((fs->super->x & ~FEATURE_INCOMPAT_IGNORE) != \ in check_backup_super_block()
947 ((fs->super->x & ~FEATURE_RO_COMPAT_IGNORE) != \ in check_backup_super_block()
950 (fs->super->x != backup_sb->x) in check_backup_super_block()
958 memcmp(fs->super->s_uuid, backup_sb->s_uuid, in check_backup_super_block()
959 sizeof(fs->super->s_uuid))) in check_backup_super_block()