Lines Matching refs: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()
299 if (!ext2fs_has_feature_quota(ctx->fs->super)) in e2fsck_write_all_quotas()
322 ext2_filsys fs = ctx->fs; in release_orphan_inodes() local
328 if ((ino = fs->super->s_last_orphan) == 0) in release_orphan_inodes()
342 fs->super->s_last_orphan = 0; in release_orphan_inodes()
343 ext2fs_mark_super_dirty(fs); in release_orphan_inodes()
350 if (fs->super->s_state & EXT2_ERROR_FS) { in release_orphan_inodes()
356 if ((ino < EXT2_FIRST_INODE(fs->super)) || in release_orphan_inodes()
357 (ino > fs->super->s_inodes_count)) { in release_orphan_inodes()
364 block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 4, in release_orphan_inodes()
381 ((next_ino < EXT2_FIRST_INODE(fs->super)) || in release_orphan_inodes()
382 (next_ino > fs->super->s_inodes_count))) { in release_orphan_inodes()
394 ext2fs_inode_alloc_stats2(fs, ino, -1, in release_orphan_inodes()
427 ext2_filsys fs = ctx->fs; in check_resize_inode() local
439 if (ext2fs_has_feature_resize_inode(fs->super) && in check_resize_inode()
440 ext2fs_has_feature_meta_bg(fs->super) && in check_resize_inode()
442 ext2fs_clear_feature_resize_inode(fs->super); in check_resize_inode()
443 fs->super->s_reserved_gdt_blocks = 0; in check_resize_inode()
444 ext2fs_mark_super_dirty(fs); in check_resize_inode()
451 if (!ext2fs_has_feature_resize_inode(fs->super)) { in check_resize_inode()
452 if (fs->super->s_reserved_gdt_blocks) { in check_resize_inode()
453 pctx.num = fs->super->s_reserved_gdt_blocks; in check_resize_inode()
456 fs->super->s_reserved_gdt_blocks = 0; in check_resize_inode()
457 ext2fs_mark_super_dirty(fs); in check_resize_inode()
464 retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode); in check_resize_inode()
466 if (ext2fs_has_feature_resize_inode(fs->super)) in check_resize_inode()
475 if (!ext2fs_has_feature_resize_inode(fs->super)) { in check_resize_inode()
500 (blk < fs->super->s_first_data_block || in check_resize_inode()
501 blk >= ext2fs_blocks_count(fs->super))) { in check_resize_inode()
510 fs->super->s_state &= ~EXT2_VALID_FS; in check_resize_inode()
511 ext2fs_mark_super_dirty(fs); in check_resize_inode()
515 dind_buf = (__u32 *) e2fsck_allocate_memory(ctx, fs->blocksize * 2, in check_resize_inode()
517 ind_buf = (__u32 *) ((char *) dind_buf + fs->blocksize); in check_resize_inode()
519 retval = ext2fs_read_ind_block(fs, blk, dind_buf); in check_resize_inode()
523 gdt_off = fs->desc_blocks; in check_resize_inode()
524 pblk = fs->super->s_first_data_block + 1 + fs->desc_blocks; in check_resize_inode()
525 if (fs->blocksize == 1024 && fs->super->s_first_data_block == 0) in check_resize_inode()
527 for (i = 0; i < fs->super->s_reserved_gdt_blocks / 4; in check_resize_inode()
529 gdt_off %= fs->blocksize/4; in check_resize_inode()
532 retval = ext2fs_read_ind_block(fs, pblk, ind_buf); in check_resize_inode()
536 for (j = 1; j < fs->group_desc_count; j++) { in check_resize_inode()
537 if (!ext2fs_bg_has_super(fs, j)) in check_resize_inode()
539 expect = pblk + EXT2_GROUPS_TO_BLOCKS(fs->super, j); in check_resize_inode()
557 struct ext2_super_block *sb = ctx->fs->super; in e2fsck_fix_dirhash_hint()
575 ext2fs_mark_super_dirty(ctx->fs); in e2fsck_fix_dirhash_hint()
582 ext2_filsys fs = ctx->fs; in check_super_block() local
584 struct ext2_super_block *sb = fs->super; in check_super_block()
587 blk64_t blocks_per_group = fs->super->s_blocks_per_group; in check_super_block()
601 inodes_per_block = EXT2_INODES_PER_BLOCK(fs->super); in check_super_block()
608 bpg_max = 8 * EXT2_BLOCK_SIZE(sb) * EXT2FS_CLUSTER_RATIO(fs); in check_super_block()
613 sizeof(int) * fs->group_desc_count, "invalid_inode_bitmap"); in check_super_block()
615 sizeof(int) * fs->group_desc_count, "invalid_block_bitmap"); in check_super_block()
617 sizeof(int) * fs->group_desc_count, "invalid_inode_table"); in check_super_block()
619 blks_max = (1ULL << 32) * EXT2_MAX_BLOCKS_PER_GROUP(fs->super); in check_super_block()
620 if (ext2fs_has_feature_64bit(fs->super)) { in check_super_block()
667 fs->blocksize / sizeof(__u32))) in check_super_block()
674 should_be = (__u64)sb->s_inodes_per_group * fs->group_desc_count; in check_super_block()
686 ext2fs_mark_super_dirty(fs); in check_super_block()
703 EXT2_GOOD_OLD_INODE_SIZE, fs->blocksize)) in check_super_block()
706 EXT2FS_CLUSTER_RATIO(fs))) { in check_super_block()
707 pctx.num = sb->s_clusters_per_group * EXT2FS_CLUSTER_RATIO(fs); in check_super_block()
725 EXT2FS_CLUSTER_RATIO(fs) == 1) ? 1 : 0; in check_super_block()
748 ext2fs_mark_super_dirty(fs); in check_super_block()
759 ext2fs_mark_super_dirty(fs); in check_super_block()
764 if (ext2fs_has_feature_metadata_csum(fs->super) && in check_super_block()
765 ext2fs_has_feature_gdt_csum(fs->super) && in check_super_block()
767 ext2fs_clear_feature_gdt_csum(fs->super); in check_super_block()
768 ext2fs_mark_super_dirty(fs); in check_super_block()
769 for (i = 0; i < fs->group_desc_count; i++) in check_super_block()
770 ext2fs_group_desc_csum_set(fs, i); in check_super_block()
774 if (!ext2fs_has_feature_metadata_csum(fs->super) && in check_super_block()
775 ext2fs_has_feature_csum_seed(fs->super) && in check_super_block()
777 ext2fs_clear_feature_csum_seed(fs->super); in check_super_block()
778 fs->super->s_checksum_seed = 0; in check_super_block()
779 ext2fs_mark_super_dirty(fs); in check_super_block()
783 if (ext2fs_has_feature_64bit(fs->super) && in check_super_block()
784 !ext2fs_has_feature_extents(fs->super) && in check_super_block()
786 ext2fs_set_feature_extents(fs->super); in check_super_block()
787 ext2fs_mark_super_dirty(fs); in check_super_block()
792 ext2fs_set_feature_extents(fs->super); in check_super_block()
793 ext2fs_mark_super_dirty(fs); in check_super_block()
796 if (ext2fs_has_feature_meta_bg(fs->super) && in check_super_block()
797 (fs->super->s_first_meta_bg > fs->desc_blocks)) { in check_super_block()
798 pctx.group = fs->desc_blocks; in check_super_block()
799 pctx.num = fs->super->s_first_meta_bg; in check_super_block()
801 ext2fs_clear_feature_meta_bg(fs->super); in check_super_block()
802 fs->super->s_first_meta_bg = 0; in check_super_block()
803 ext2fs_mark_super_dirty(fs); in check_super_block()
813 csum_flag = ext2fs_has_group_desc_csum(fs); in check_super_block()
814 for (i = 0; i < fs->group_desc_count; i++) { in check_super_block()
817 if (!ext2fs_has_feature_flex_bg(fs->super)) { in check_super_block()
818 first_block = ext2fs_group_first_block2(fs, i); in check_super_block()
819 last_block = ext2fs_group_last_block2(fs, i); in check_super_block()
822 if ((ext2fs_block_bitmap_loc(fs, i) < first_block) || in check_super_block()
823 (ext2fs_block_bitmap_loc(fs, i) > last_block)) { in check_super_block()
824 pctx.blk = ext2fs_block_bitmap_loc(fs, i); in check_super_block()
826 ext2fs_block_bitmap_loc_set(fs, i, 0); in check_super_block()
828 if (ext2fs_block_bitmap_loc(fs, i) == 0) { in check_super_block()
832 if ((ext2fs_inode_bitmap_loc(fs, i) < first_block) || in check_super_block()
833 (ext2fs_inode_bitmap_loc(fs, i) > last_block)) { in check_super_block()
834 pctx.blk = ext2fs_inode_bitmap_loc(fs, i); in check_super_block()
836 ext2fs_inode_bitmap_loc_set(fs, i, 0); in check_super_block()
838 if (ext2fs_inode_bitmap_loc(fs, i) == 0) { in check_super_block()
842 if ((ext2fs_inode_table_loc(fs, i) < first_block) || in check_super_block()
843 ((ext2fs_inode_table_loc(fs, i) + in check_super_block()
844 fs->inode_blocks_per_group - 1) > last_block)) { in check_super_block()
845 pctx.blk = ext2fs_inode_table_loc(fs, i); in check_super_block()
847 ext2fs_inode_table_loc_set(fs, i, 0); in check_super_block()
849 if (ext2fs_inode_table_loc(fs, i) == 0) { in check_super_block()
853 free_blocks += ext2fs_bg_free_blocks_count(fs, i); in check_super_block()
854 free_inodes += ext2fs_bg_free_inodes_count(fs, i); in check_super_block()
856 if ((ext2fs_bg_free_blocks_count(fs, i) > sb->s_blocks_per_group) || in check_super_block()
857 (ext2fs_bg_free_inodes_count(fs, i) > sb->s_inodes_per_group) || in check_super_block()
858 (ext2fs_bg_used_dirs_count(fs, i) > sb->s_inodes_per_group)) in check_super_block()
859 ext2fs_unmark_valid(fs); in check_super_block()
862 if (!ext2fs_group_desc_csum_verify(fs, i)) { in check_super_block()
863 pctx.csum1 = ext2fs_bg_checksum(fs, i); in check_super_block()
864 pctx.csum2 = ext2fs_group_desc_csum(fs, i); in check_super_block()
866 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
867 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT); in check_super_block()
868 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
871 ext2fs_unmark_valid(fs); in check_super_block()
875 (ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) || in check_super_block()
876 ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) || in check_super_block()
877 ext2fs_bg_itable_unused(fs, i) != 0)) { in check_super_block()
879 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
880 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT); in check_super_block()
881 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
884 ext2fs_unmark_valid(fs); in check_super_block()
887 if (i == fs->group_desc_count - 1 && in check_super_block()
888 ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT)) { in check_super_block()
890 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT); in check_super_block()
893 ext2fs_unmark_valid(fs); in check_super_block()
897 (ext2fs_bg_itable_unused(fs, i) > ext2fs_bg_free_inodes_count(fs, i) || in check_super_block()
898 ext2fs_bg_itable_unused(fs, i) > sb->s_inodes_per_group)) { in check_super_block()
899 pctx.blk = ext2fs_bg_itable_unused(fs, i); in check_super_block()
901 ext2fs_bg_itable_unused_set(fs, i, 0); in check_super_block()
904 ext2fs_unmark_valid(fs); in check_super_block()
908 ext2fs_group_desc_csum_set(fs, i); in check_super_block()
914 ctx->free_blocks = EXT2FS_C2B(fs, free_blocks); in check_super_block()
919 ext2fs_unmark_valid(fs); in check_super_block()
928 ext2fs_mark_super_dirty(fs); in check_super_block()
940 !ext2fs_has_feature_metadata_csum(ctx->fs->super) && in check_super_block()
944 ext2fs_init_csum_seed(fs); in check_super_block()
945 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
946 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
959 (fs->super->s_flags & EXT2_FLAGS_TEST_FILESYS) && in check_super_block()
962 fs->super->s_flags &= ~EXT2_FLAGS_TEST_FILESYS; in check_super_block()
963 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
964 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
973 fs->super->s_creator_os == EXT2_OS_HURD && in check_super_block()
974 ext2fs_has_feature_filetype(fs->super)) { in check_super_block()
976 ext2fs_clear_feature_filetype(fs->super); in check_super_block()
977 ext2fs_mark_super_dirty(fs); in check_super_block()
978 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
989 fs->super->s_rev_level == EXT2_GOOD_OLD_REV && in check_super_block()
990 (fs->super->s_feature_compat || in check_super_block()
991 fs->super->s_feature_ro_compat || in check_super_block()
992 fs->super->s_feature_incompat) && in check_super_block()
994 ext2fs_update_dynamic_rev(fs); in check_super_block()
995 ext2fs_mark_super_dirty(fs); in check_super_block()
996 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY; in check_super_block()
1003 fs->super->s_state &= ~EXT2_VALID_FS; in check_super_block()
1004 ext2fs_mark_super_dirty(fs); in check_super_block()
1043 fs->super->s_mtime > (__u32) ctx->now) { in check_super_block()
1044 pctx.num = fs->super->s_mtime; in check_super_block()
1046 if (fs->super->s_mtime <= (__u32) ctx->now + ctx->time_fudge) in check_super_block()
1049 fs->super->s_mtime = ctx->now; in check_super_block()
1050 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
1055 fs->super->s_wtime > (__u32) ctx->now) { in check_super_block()
1056 pctx.num = fs->super->s_wtime; in check_super_block()
1058 if (fs->super->s_wtime <= (__u32) ctx->now + ctx->time_fudge) in check_super_block()
1061 fs->super->s_wtime = ctx->now; in check_super_block()
1062 fs->flags |= EXT2_FLAG_DIRTY; in check_super_block()
1117 ext2_filsys fs = ctx->fs; in check_backup_super_block() local
1132 if (((fs->flags & EXT2_FLAG_MASTER_SB_ONLY) == 0) || in check_backup_super_block()
1133 !ext2fs_test_valid(fs) || in check_backup_super_block()
1134 (fs->super->s_state & EXT2_ERROR_FS) || in check_backup_super_block()
1139 for (g = 1; g < fs->group_desc_count; g++) { in check_backup_super_block()
1140 if (!ext2fs_bg_has_super(fs, g)) in check_backup_super_block()
1143 sb = ext2fs_group_first_block2(fs, g); in check_backup_super_block()
1145 retval = io_channel_read_blk(fs->io, sb, -SUPERBLOCK_SIZE, in check_backup_super_block()
1161 ((fs->super->x & ~FEATURE_INCOMPAT_IGNORE) != \ in check_backup_super_block()
1164 ((fs->super->x & ~FEATURE_RO_COMPAT_IGNORE) != \ in check_backup_super_block()
1167 (fs->super->x != backup_sb->x) in check_backup_super_block()
1175 memcmp(fs->super->s_uuid, backup_sb->s_uuid, in check_backup_super_block()
1176 sizeof(fs->super->s_uuid))) in check_backup_super_block()