Lines Matching full:fs

82 static int release_inode_block(ext2_filsys fs,  in release_inode_block()  argument
93 blk64_t cluster = EXT2FS_B2C(fs, *block_nr); in release_inode_block()
111 if ((blk < fs->super->s_first_data_block) || in release_inode_block()
112 (blk >= ext2fs_blocks_count(fs->super))) { in release_inode_block()
119 if (!ext2fs_test_block_bitmap2(fs->block_map, blk)) { in release_inode_block()
138 pb->errcode = io_channel_read_blk64(fs->io, blk, 1, in release_inode_block()
143 limit = fs->blocksize >> 2; in release_inode_block()
160 pb->errcode = io_channel_read_blk64(fs->io, blk, 1, in release_inode_block()
165 fs->blocksize - pb->truncate_offset); in release_inode_block()
166 pb->errcode = io_channel_write_blk64(fs->io, blk, 1, in release_inode_block()
177 quota_data_sub(ctx->qctx, pb->inode, 0, ctx->fs->blocksize); in release_inode_block()
178 ext2fs_block_alloc_stats2(fs, blk, -1); in release_inode_block()
193 ext2_filsys fs = ctx->fs; in release_inode_blocks() local
198 if (!ext2fs_inode_has_valid_blocks2(fs, EXT2_INODE(inode))) in release_inode_blocks()
201 pb.buf = block_buf + 3 * ctx->fs->blocksize; in release_inode_blocks()
211 ((EXT2_I_SIZE(inode) + fs->blocksize - 1) / in release_inode_blocks()
212 fs->blocksize); in release_inode_blocks()
213 pb.truncate_offset = inode->i_size % fs->blocksize; in release_inode_blocks()
220 retval = ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE, in release_inode_blocks()
236 ext2fs_iblk_sub_blocks(fs, EXT2_INODE(inode), in release_inode_blocks()
239 blk = ext2fs_file_acl_block(fs, EXT2_INODE(inode)); in release_inode_blocks()
241 retval = ext2fs_adjust_ea_refcount3(fs, blk, block_buf, -1, in release_inode_blocks()
256 ctx->fs->blocksize); in release_inode_blocks()
257 ext2fs_block_alloc_stats2(fs, blk, -1); in release_inode_blocks()
260 ext2fs_file_acl_block_set(fs, EXT2_INODE(inode), 0); in release_inode_blocks()
272 if (!ext2fs_has_feature_quota(ctx->fs->super)) in e2fsck_read_all_quotas()
275 retval = quota_init_context(&ctx->qctx, ctx->fs, 0); in e2fsck_read_all_quotas()
280 qf_ino = *quota_sb_inump(ctx->fs->super, qtype); in e2fsck_read_all_quotas()
300 if (!ext2fs_has_feature_quota(ctx->fs->super)) in e2fsck_write_all_quotas()
323 ext2_filsys fs = ctx->fs; in release_orphan_inodes() local
329 if ((ino = fs->super->s_last_orphan) == 0) in release_orphan_inodes()
343 fs->super->s_last_orphan = 0; in release_orphan_inodes()
344 ext2fs_mark_super_dirty(fs); in release_orphan_inodes()
351 if (fs->super->s_state & EXT2_ERROR_FS) { in release_orphan_inodes()
357 if ((ino < EXT2_FIRST_INODE(fs->super)) || in release_orphan_inodes()
358 (ino > fs->super->s_inodes_count)) { in release_orphan_inodes()
365 block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 4, in release_orphan_inodes()
382 ((next_ino < EXT2_FIRST_INODE(fs->super)) || in release_orphan_inodes()
383 (next_ino > fs->super->s_inodes_count))) { in release_orphan_inodes()
395 ext2fs_inode_alloc_stats2(fs, ino, -1, in release_orphan_inodes()
428 ext2_filsys fs = ctx->fs; in check_resize_inode() local
440 if (ext2fs_has_feature_resize_inode(fs->super) && in check_resize_inode()
441 ext2fs_has_feature_meta_bg(fs->super) && in check_resize_inode()
443 ext2fs_clear_feature_resize_inode(fs->super); in check_resize_inode()
444 fs->super->s_reserved_gdt_blocks = 0; in check_resize_inode()
445 ext2fs_mark_super_dirty(fs); in check_resize_inode()
452 if (!ext2fs_has_feature_resize_inode(fs->super)) { in check_resize_inode()
453 if (fs->super->s_reserved_gdt_blocks) { in check_resize_inode()
454 pctx.num = fs->super->s_reserved_gdt_blocks; in check_resize_inode()
457 fs->super->s_reserved_gdt_blocks = 0; in check_resize_inode()
458 ext2fs_mark_super_dirty(fs); in check_resize_inode()
465 retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode); in check_resize_inode()
467 if (ext2fs_has_feature_resize_inode(fs->super)) in check_resize_inode()
476 if (!ext2fs_has_feature_resize_inode(fs->super)) { in check_resize_inode()
501 (blk < fs->super->s_first_data_block || in check_resize_inode()
502 blk >= ext2fs_blocks_count(fs->super))) { in check_resize_inode()
511 fs->super->s_state &= ~EXT2_VALID_FS; in check_resize_inode()
512 ext2fs_mark_super_dirty(fs); in check_resize_inode()
516 dind_buf = (__u32 *) e2fsck_allocate_memory(ctx, fs->blocksize * 2, in check_resize_inode()
518 ind_buf = (__u32 *) ((char *) dind_buf + fs->blocksize); in check_resize_inode()
520 retval = ext2fs_read_ind_block(fs, blk, dind_buf); in check_resize_inode()
524 gdt_off = fs->desc_blocks; in check_resize_inode()
525 pblk = fs->super->s_first_data_block + 1 + fs->desc_blocks; in check_resize_inode()
526 if (fs->blocksize == 1024 && fs->super->s_first_data_block == 0) in check_resize_inode()
527 pblk++; /* Deal with 1024 blocksize bigalloc fs */ in check_resize_inode()
528 for (i = 0; i < fs->super->s_reserved_gdt_blocks / 4; in check_resize_inode()
530 gdt_off %= fs->blocksize/4; in check_resize_inode()
533 retval = ext2fs_read_ind_block(fs, pblk, ind_buf); in check_resize_inode()
537 for (j = 1; j < fs->group_desc_count; j++) { in check_resize_inode()
538 if (!ext2fs_bg_has_super(fs, j)) in check_resize_inode()
540 expect = pblk + EXT2_GROUPS_TO_BLOCKS(fs->super, j); in check_resize_inode()
558 struct ext2_super_block *sb = ctx->fs->super; in e2fsck_fix_dirhash_hint()
576 ext2fs_mark_super_dirty(ctx->fs); in e2fsck_fix_dirhash_hint()
583 ext2_filsys fs = ctx->fs; in check_super_block() local
585 struct ext2_super_block *sb = fs->super; in check_super_block()
588 blk64_t blocks_per_group = fs->super->s_blocks_per_group; in check_super_block()
602 inodes_per_block = EXT2_INODES_PER_BLOCK(fs->super); in check_super_block()
609 bpg_max = 8 * EXT2_BLOCK_SIZE(sb) * EXT2FS_CLUSTER_RATIO(fs); in check_super_block()
614 sizeof(int) * fs->group_desc_count, "invalid_inode_bitmap"); in check_super_block()
616 sizeof(int) * fs->group_desc_count, "invalid_block_bitmap"); in check_super_block()
618 sizeof(int) * fs->group_desc_count, "invalid_inode_table"); in check_super_block()
620 blks_max = (1ULL << 32) * EXT2_MAX_BLOCKS_PER_GROUP(fs->super); in check_super_block()
621 if (ext2fs_has_feature_64bit(fs->super)) { in check_super_block()
668 fs->blocksize / sizeof(__u32))) in check_super_block()
675 should_be = (__u64)sb->s_inodes_per_group * fs->group_desc_count; in check_super_block()
687 ext2fs_mark_super_dirty(fs); in check_super_block()
704 EXT2_GOOD_OLD_INODE_SIZE, fs->blocksize)) in check_super_block()
707 EXT2FS_CLUSTER_RATIO(fs))) { in check_super_block()
708 pctx.num = sb->s_clusters_per_group * EXT2FS_CLUSTER_RATIO(fs); in check_super_block()
726 EXT2FS_CLUSTER_RATIO(fs) == 1) ? 1 : 0; in check_super_block()
749 ext2fs_mark_super_dirty(fs); in check_super_block()
760 ext2fs_mark_super_dirty(fs); in check_super_block()
765 if (ext2fs_has_feature_metadata_csum(fs->super) && in check_super_block()
766 ext2fs_has_feature_gdt_csum(fs->super) && in check_super_block()
768 ext2fs_clear_feature_gdt_csum(fs->super); in check_super_block()
769 ext2fs_mark_super_dirty(fs); in check_super_block()
770 for (i = 0; i < fs->group_desc_count; i++) in check_super_block()
771 ext2fs_group_desc_csum_set(fs, i); in check_super_block()
775 if (!ext2fs_has_feature_metadata_csum(fs->super) && in check_super_block()
776 ext2fs_has_feature_csum_seed(fs->super) && in check_super_block()
778 ext2fs_clear_feature_csum_seed(fs->super); in check_super_block()
779 fs->super->s_checksum_seed = 0; in check_super_block()
780 ext2fs_mark_super_dirty(fs); in check_super_block()
784 if (ext2fs_has_feature_64bit(fs->super) && in check_super_block()
785 !ext2fs_has_feature_extents(fs->super) && in check_super_block()
787 ext2fs_set_feature_extents(fs->super); in check_super_block()
788 ext2fs_mark_super_dirty(fs); in check_super_block()
793 ext2fs_set_feature_extents(fs->super); in check_super_block()
794 ext2fs_mark_super_dirty(fs); in check_super_block()
797 if (ext2fs_has_feature_meta_bg(fs->super) && in check_super_block()
798 (fs->super->s_first_meta_bg > fs->desc_blocks)) { in check_super_block()
799 pctx.group = fs->desc_blocks; in check_super_block()
800 pctx.num = fs->super->s_first_meta_bg; in check_super_block()
802 ext2fs_clear_feature_meta_bg(fs->super); in check_super_block()
803 fs->super->s_first_meta_bg = 0; in check_super_block()
804 ext2fs_mark_super_dirty(fs); in check_super_block()
814 csum_flag = ext2fs_has_group_desc_csum(fs); in check_super_block()
815 for (i = 0; i < fs->group_desc_count; i++) { in check_super_block()
818 if (!ext2fs_has_feature_flex_bg(fs->super)) { in check_super_block()
819 first_block = ext2fs_group_first_block2(fs, i); in check_super_block()
820 last_block = ext2fs_group_last_block2(fs, i); in check_super_block()
823 if ((ext2fs_block_bitmap_loc(fs, i) < first_block) || in check_super_block()
824 (ext2fs_block_bitmap_loc(fs, i) > last_block)) { in check_super_block()
825 pctx.blk = ext2fs_block_bitmap_loc(fs, i); in check_super_block()
827 ext2fs_block_bitmap_loc_set(fs, i, 0); in check_super_block()
829 if (ext2fs_block_bitmap_loc(fs, i) == 0) { in check_super_block()
833 if ((ext2fs_inode_bitmap_loc(fs, i) < first_block) || in check_super_block()
834 (ext2fs_inode_bitmap_loc(fs, i) > last_block)) { in check_super_block()
835 pctx.blk = ext2fs_inode_bitmap_loc(fs, i); in check_super_block()
837 ext2fs_inode_bitmap_loc_set(fs, i, 0); in check_super_block()
839 if (ext2fs_inode_bitmap_loc(fs, i) == 0) { in check_super_block()
843 if ((ext2fs_inode_table_loc(fs, i) < first_block) || in check_super_block()
844 ((ext2fs_inode_table_loc(fs, i) + in check_super_block()
845 fs->inode_blocks_per_group - 1) > last_block)) { in check_super_block()
846 pctx.blk = ext2fs_inode_table_loc(fs, i); in check_super_block()
848 ext2fs_inode_table_loc_set(fs, i, 0); in check_super_block()
850 if (ext2fs_inode_table_loc(fs, i) == 0) { in check_super_block()
854 free_blocks += ext2fs_bg_free_blocks_count(fs, i); in check_super_block()
855 free_inodes += ext2fs_bg_free_inodes_count(fs, i); in check_super_block()
857 if ((ext2fs_bg_free_blocks_count(fs, i) > sb->s_blocks_per_group) || in check_super_block()
858 (ext2fs_bg_free_inodes_count(fs, i) > sb->s_inodes_per_group) || in check_super_block()
859 (ext2fs_bg_used_dirs_count(fs, i) > sb->s_inodes_per_group)) in check_super_block()
860 ext2fs_unmark_valid(fs); in check_super_block()
863 if (!ext2fs_group_desc_csum_verify(fs, i)) { in check_super_block()
864 pctx.csum1 = ext2fs_bg_checksum(fs, i); in check_super_block()
865 pctx.csum2 = ext2fs_group_desc_csum(fs, i); in check_super_block()
867 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
868 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT); in check_super_block()
869 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
872 ext2fs_unmark_valid(fs); in check_super_block()
876 (ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) || in check_super_block()
877 ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) || in check_super_block()
878 ext2fs_bg_itable_unused(fs, i) != 0)) { in check_super_block()
880 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
881 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT); in check_super_block()
882 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
885 ext2fs_unmark_valid(fs); in check_super_block()
888 if (i == fs->group_desc_count - 1 && in check_super_block()
889 ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT)) { in check_super_block()
891 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
894 ext2fs_unmark_valid(fs); in check_super_block()
898 (ext2fs_bg_itable_unused(fs, i) > ext2fs_bg_free_inodes_count(fs, i) || in check_super_block()
899 ext2fs_bg_itable_unused(fs, i) > sb->s_inodes_per_group)) { in check_super_block()
900 pctx.blk = ext2fs_bg_itable_unused(fs, i); in check_super_block()
902 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
905 ext2fs_unmark_valid(fs); in check_super_block()
909 ext2fs_group_desc_csum_set(fs, i); in check_super_block()
915 ctx->free_blocks = EXT2FS_C2B(fs, free_blocks); in check_super_block()
920 ext2fs_unmark_valid(fs); in check_super_block()
929 ext2fs_mark_super_dirty(fs); in check_super_block()
941 !ext2fs_has_feature_metadata_csum(ctx->fs->super) && in check_super_block()
945 ext2fs_init_csum_seed(fs); in check_super_block()
946 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
947 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
960 (fs->super->s_flags & EXT2_FLAGS_TEST_FILESYS) && in check_super_block()
963 fs->super->s_flags &= ~EXT2_FLAGS_TEST_FILESYS; in check_super_block()
964 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
965 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
974 fs->super->s_creator_os == EXT2_OS_HURD && in check_super_block()
975 ext2fs_has_feature_filetype(fs->super)) { in check_super_block()
977 ext2fs_clear_feature_filetype(fs->super); in check_super_block()
978 ext2fs_mark_super_dirty(fs); in check_super_block()
979 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
990 fs->super->s_rev_level == EXT2_GOOD_OLD_REV && in check_super_block()
991 (fs->super->s_feature_compat || in check_super_block()
992 fs->super->s_feature_ro_compat || in check_super_block()
993 fs->super->s_feature_incompat) && in check_super_block()
995 ext2fs_update_dynamic_rev(fs); in check_super_block()
996 ext2fs_mark_super_dirty(fs); in check_super_block()
997 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
1004 fs->super->s_state &= ~EXT2_VALID_FS; in check_super_block()
1005 ext2fs_mark_super_dirty(fs); in check_super_block()
1042 if (((ctx->options & E2F_OPT_FORCE) || fs->super->s_checkinterval) && in check_super_block()
1044 (fs->super->s_mtime > (__u32) ctx->now)) { in check_super_block()
1045 pctx.num = fs->super->s_mtime; in check_super_block()
1047 if (fs->super->s_mtime <= (__u32) ctx->now + ctx->time_fudge) in check_super_block()
1050 fs->super->s_mtime = ctx->now; in check_super_block()
1051 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
1054 if (((ctx->options & E2F_OPT_FORCE) || fs->super->s_checkinterval) && in check_super_block()
1056 (fs->super->s_wtime > (__u32) ctx->now)) { in check_super_block()
1057 pctx.num = fs->super->s_wtime; in check_super_block()
1059 if (fs->super->s_wtime <= (__u32) ctx->now + ctx->time_fudge) in check_super_block()
1062 fs->super->s_wtime = ctx->now; in check_super_block()
1063 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
1118 ext2_filsys fs = ctx->fs; in check_backup_super_block() local
1133 if (((fs->flags & EXT2_FLAG_MASTER_SB_ONLY) == 0) || in check_backup_super_block()
1134 !ext2fs_test_valid(fs) || in check_backup_super_block()
1135 (fs->super->s_state & EXT2_ERROR_FS) || in check_backup_super_block()
1140 for (g = 1; g < fs->group_desc_count; g++) { in check_backup_super_block()
1141 if (!ext2fs_bg_has_super(fs, g)) in check_backup_super_block()
1144 sb = ext2fs_group_first_block2(fs, g); in check_backup_super_block()
1146 retval = io_channel_read_blk(fs->io, sb, -SUPERBLOCK_SIZE, in check_backup_super_block()
1162 ((fs->super->x & ~FEATURE_INCOMPAT_IGNORE) != \ in check_backup_super_block()
1165 ((fs->super->x & ~FEATURE_RO_COMPAT_IGNORE) != \ in check_backup_super_block()
1168 (fs->super->x != backup_sb->x) in check_backup_super_block()
1176 memcmp(fs->super->s_uuid, backup_sb->s_uuid, in check_backup_super_block()
1177 sizeof(fs->super->s_uuid))) in check_backup_super_block()