Lines Matching refs:pctx
73 static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
103 struct problem_context *pctx; member
272 struct problem_context *pctx) in check_extents_inlinedata() argument
274 if (!(pctx->inode->i_flags & BAD_SPECIAL_FLAGS)) in check_extents_inlinedata()
277 if (!fix_problem(ctx, PR_1_SPECIAL_EXTENTS_IDATA, pctx)) in check_extents_inlinedata()
280 pctx->inode->i_flags &= ~BAD_SPECIAL_FLAGS; in check_extents_inlinedata()
281 e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1"); in check_extents_inlinedata()
290 static void check_immutable(e2fsck_t ctx, struct problem_context *pctx) in check_immutable() argument
292 if (!(pctx->inode->i_flags & BAD_SPECIAL_FLAGS)) in check_immutable()
295 if (!fix_problem(ctx, PR_1_SET_IMMUTABLE, pctx)) in check_immutable()
298 pctx->inode->i_flags &= ~BAD_SPECIAL_FLAGS; in check_immutable()
299 e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1"); in check_immutable()
306 static void check_size(e2fsck_t ctx, struct problem_context *pctx) in check_size() argument
308 struct ext2_inode *inode = pctx->inode; in check_size()
313 if (!fix_problem(ctx, PR_1_SET_NONZSIZE, pctx)) in check_size()
317 e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1"); in check_size()
337 struct problem_context *pctx, in check_large_ea_inode() argument
347 pctx->num = entry->e_value_inum; in check_large_ea_inode()
366 if (inode.i_mtime == pctx->ino && in check_large_ea_inode()
367 inode.i_generation == pctx->inode->i_generation) { in check_large_ea_inode()
374 pctx->num = entry->e_value_inum; in check_large_ea_inode()
377 pctx->num = entry->e_hash; in check_large_ea_inode()
384 pctx->num = entry->e_value_inum; in check_large_ea_inode()
385 if (fix_problem(ctx, PR_1_ATTR_SET_EA_INODE_FL, pctx)) { in check_large_ea_inode()
396 static void inc_ea_inode_refs(e2fsck_t ctx, struct problem_context *pctx, in inc_ea_inode_refs() argument
407 pctx->errcode = ea_refcount_create(0, in inc_ea_inode_refs()
409 if (pctx->errcode) { in inc_ea_inode_refs()
410 pctx->num = 4; in inc_ea_inode_refs()
411 fix_problem(ctx, PR_1_ALLOCATE_REFCOUNT, pctx); in inc_ea_inode_refs()
421 static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx, in check_ea_in_inode() argument
435 inode = (struct ext2_inode_large *) pctx->inode; in check_ea_in_inode()
451 fix_problem(ctx, PR_1_EA_ALLOC_REGION_ABORT, pctx); in check_ea_in_inode()
476 pctx->num = entry->e_name_len; in check_ea_in_inode()
487 pctx->num = entry->e_value_size; in check_ea_in_inode()
506 pctx->num = entry->e_hash; in check_ea_in_inode()
513 problem = check_large_ea_inode(ctx, entry, pctx, in check_ea_in_inode()
542 if (problem == 0 || !fix_problem(ctx, problem, pctx)) { in check_ea_in_inode()
543 inc_ea_inode_refs(ctx, pctx, in check_ea_in_inode()
550 e2fsck_write_inode_full(ctx, pctx->ino, pctx->inode, in check_ea_in_inode()
571 static void check_inode_extra_space(e2fsck_t ctx, struct problem_context *pctx, in check_inode_extra_space() argument
582 inode = (struct ext2_inode_large *) pctx->inode; in check_inode_extra_space()
589 printf("inode #%u, i_extra_size %d\n", pctx->ino, in check_inode_extra_space()
602 if (!fix_problem(ctx, PR_1_EXTRA_ISIZE, pctx)) in check_inode_extra_space()
608 e2fsck_write_inode_full(ctx, pctx->ino, pctx->inode, in check_inode_extra_space()
620 check_ea_in_inode(ctx, pctx, ea_ibody_quota); in check_inode_extra_space()
635 if (!fix_problem(ctx, PR_1_EA_TIME_OUT_OF_RANGE, pctx)) in check_inode_extra_space()
646 e2fsck_write_inode_full(ctx, pctx->ino, pctx->inode, in check_inode_extra_space()
660 static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx, in check_is_really_dir() argument
663 struct ext2_inode *inode = pctx->inode; in check_is_really_dir()
710 if (ext2fs_inline_data_size(ctx->fs, pctx->ino, &size)) in check_is_really_dir()
742 if (ext2fs_bmap2(ctx->fs, pctx->ino, inode, 0, 0, 0, 0, in check_is_really_dir()
775 retval = ext2fs_read_dir_block4(ctx->fs, blk, buf, 0, pctx->ino); in check_is_really_dir()
786 (dirent->inode != pctx->ino) || in check_is_really_dir()
804 if (fix_problem(ctx, PR_1_TREAT_AS_DIRECTORY, pctx)) { in check_is_really_dir()
806 e2fsck_write_inode_full(ctx, pctx->ino, inode, in check_is_really_dir()
854 struct problem_context *pctx) in recheck_bad_inode_checksum() argument
876 if (!fix_problem(ctx, PR_1_INODE_ONLY_CSUM_INVALID, pctx)) in recheck_bad_inode_checksum()
945 struct problem_context *pctx, in finish_processing_inode() argument
956 pctx->errcode = recheck_bad_inode_checksum(ctx->fs, ino, ctx, pctx); in finish_processing_inode()
957 if (pctx->errcode) in finish_processing_inode()
960 #define FINISH_INODE_LOOP(ctx, ino, pctx, failed_csum) \ argument
962 finish_processing_inode((ctx), (ino), (pctx), (failed_csum)); \
992 struct problem_context *pctx) in fix_inline_data_extents_file() argument
1008 check_extents_inlinedata(ctx, pctx); in fix_inline_data_extents_file()
1015 fix_problem(ctx, PR_1_CLEAR_INLINE_DATA_FOR_EXTENT, pctx)) { in fix_inline_data_extents_file()
1030 fix_problem(ctx, PR_1_CLEAR_EXTENT_FOR_INLINE_DATA, pctx)) { in fix_inline_data_extents_file()
1041 fix_problem(ctx, PR_1_CLEAR_EXTENT_INLINE_DATA_FLAGS, pctx)) { in fix_inline_data_extents_file()
1055 if (fix_problem(ctx, PR_1_CLEAR_EXTENT_INLINE_DATA_INODE, pctx)) { in fix_inline_data_extents_file()
1169 struct problem_context pctx; in e2fsck_pass1() local
1183 clear_problem_context(&pctx); in e2fsck_pass1()
1193 fix_problem(ctx, PR_1_PASS_HEADER, &pctx); in e2fsck_pass1()
1223 pctx.errcode = e2fsck_allocate_inode_bitmap(fs, _("in-use inode map"), in e2fsck_pass1()
1227 if (pctx.errcode) { in e2fsck_pass1()
1228 pctx.num = 1; in e2fsck_pass1()
1229 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx); in e2fsck_pass1()
1233 pctx.errcode = e2fsck_allocate_inode_bitmap(fs, in e2fsck_pass1()
1237 if (pctx.errcode) { in e2fsck_pass1()
1238 pctx.num = 2; in e2fsck_pass1()
1239 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx); in e2fsck_pass1()
1243 pctx.errcode = e2fsck_allocate_inode_bitmap(fs, in e2fsck_pass1()
1246 if (pctx.errcode) { in e2fsck_pass1()
1247 pctx.num = 6; in e2fsck_pass1()
1248 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx); in e2fsck_pass1()
1252 pctx.errcode = e2fsck_allocate_subcluster_bitmap(fs, in e2fsck_pass1()
1255 if (pctx.errcode) { in e2fsck_pass1()
1256 pctx.num = 1; in e2fsck_pass1()
1257 fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, &pctx); in e2fsck_pass1()
1261 pctx.errcode = e2fsck_allocate_block_bitmap(fs, in e2fsck_pass1()
1264 if (pctx.errcode) { in e2fsck_pass1()
1265 pctx.num = 1; in e2fsck_pass1()
1266 fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, &pctx); in e2fsck_pass1()
1270 pctx.errcode = e2fsck_setup_icount(ctx, "inode_link_info", 0, NULL, in e2fsck_pass1()
1272 if (pctx.errcode) { in e2fsck_pass1()
1273 fix_problem(ctx, PR_1_ALLOCATE_ICOUNT, &pctx); in e2fsck_pass1()
1290 pctx.errcode = ext2fs_init_dblist(fs, 0); in e2fsck_pass1()
1291 if (pctx.errcode) { in e2fsck_pass1()
1292 fix_problem(ctx, PR_1_ALLOCATE_DBCOUNT, &pctx); in e2fsck_pass1()
1312 pctx.errcode = ext2fs_convert_subcluster_bitmap(fs, in e2fsck_pass1()
1314 if (pctx.errcode) { in e2fsck_pass1()
1315 fix_problem(ctx, PR_1_CONVERT_SUBCLUSTER, &pctx); in e2fsck_pass1()
1325 pctx.errcode = ext2fs_open_inode_scan(fs, ctx->inode_buffer_blocks, in e2fsck_pass1()
1328 if (pctx.errcode) { in e2fsck_pass1()
1329 fix_problem(ctx, PR_1_ISCAN_ERROR, &pctx); in e2fsck_pass1()
1363 pctx.errcode = ext2fs_get_next_inode_full(scan, &ino, in e2fsck_pass1()
1370 if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE) { in e2fsck_pass1()
1378 &pctx)) { in e2fsck_pass1()
1388 &pctx); in e2fsck_pass1()
1396 &pctx); in e2fsck_pass1()
1408 if (pctx.errcode && in e2fsck_pass1()
1409 pctx.errcode != EXT2_ET_INODE_CSUM_INVALID && in e2fsck_pass1()
1410 pctx.errcode != EXT2_ET_INODE_IS_GARBAGE) { in e2fsck_pass1()
1411 fix_problem(ctx, PR_1_ISCAN_ERROR, &pctx); in e2fsck_pass1()
1417 pctx.ino = ino; in e2fsck_pass1()
1418 pctx.inode = inode; in e2fsck_pass1()
1422 if (pctx.errcode == EXT2_ET_INODE_IS_GARBAGE && in e2fsck_pass1()
1424 fix_problem(ctx, PR_1_INODE_IS_GARBAGE, &pctx)) { in e2fsck_pass1()
1425 pctx.errcode = 0; in e2fsck_pass1()
1428 failed_csum = pctx.errcode != 0; in e2fsck_pass1()
1449 if (fix_problem(ctx, PR_1_LOW_DTIME, &pctx)) { in e2fsck_pass1()
1459 pctx.errcode = ext2fs_icount_store(ctx->inode_link_info, in e2fsck_pass1()
1461 if (pctx.errcode) { in e2fsck_pass1()
1462 pctx.num = inode->i_links_count; in e2fsck_pass1()
1463 fix_problem(ctx, PR_1_ICOUNT_STORE, &pctx); in e2fsck_pass1()
1471 PR_1_ZERO_DTIME, &pctx)) { in e2fsck_pass1()
1478 FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum); in e2fsck_pass1()
1487 &pctx); in e2fsck_pass1()
1499 pctx.errcode = ext2fs_inline_data_size(fs, ino, &size); in e2fsck_pass1()
1500 if (!pctx.errcode && size && in e2fsck_pass1()
1501 fix_problem(ctx, PR_1_INLINE_DATA_FEATURE, &pctx)) { in e2fsck_pass1()
1505 } else if (fix_problem(ctx, PR_1_INLINE_DATA_SET, &pctx)) { in e2fsck_pass1()
1547 &pctx)) { in e2fsck_pass1()
1550 pctx.errcode = err; in e2fsck_pass1()
1564 pctx.errcode = err; in e2fsck_pass1()
1590 fix_problem(ctx, PR_1_EXTENT_FEATURE, &pctx)) { in e2fsck_pass1()
1594 } else if (fix_problem(ctx, PR_1_EXTENTS_SET, &pctx)) { in e2fsck_pass1()
1630 (fix_problem(ctx, PR_1_UNSET_EXTENT_FL, &pctx))) { in e2fsck_pass1()
1648 fix_problem(ctx, PR_1_INVALID_BAD_INODE, &pctx)) { in e2fsck_pass1()
1655 pctx.errcode = ext2fs_copy_bitmap(ctx->block_found_map, in e2fsck_pass1()
1657 if (pctx.errcode) { in e2fsck_pass1()
1658 pctx.num = 4; in e2fsck_pass1()
1659 fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, &pctx); in e2fsck_pass1()
1670 pb.pctx = &pctx; in e2fsck_pass1()
1672 pctx.errcode = ext2fs_block_iterate3(fs, ino, 0, in e2fsck_pass1()
1675 if (pctx.errcode) { in e2fsck_pass1()
1676 fix_problem(ctx, PR_1_BLOCK_ITERATE, &pctx); in e2fsck_pass1()
1681 if (!fix_problem(ctx, PR_1_BBINODE_BAD_METABLOCK_PROMPT, &pctx)) { in e2fsck_pass1()
1686 clear_problem_context(&pctx); in e2fsck_pass1()
1687 FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum); in e2fsck_pass1()
1696 if (fix_problem(ctx, PR_1_ROOT_NO_DIR, &pctx)) in e2fsck_pass1()
1709 if (fix_problem(ctx, PR_1_ROOT_DTIME, &pctx)) { in e2fsck_pass1()
1721 &pctx)) { in e2fsck_pass1()
1727 check_blocks(ctx, &pctx, block_buf, NULL); in e2fsck_pass1()
1728 FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum); in e2fsck_pass1()
1734 &pctx)) { in e2fsck_pass1()
1748 &pctx)) { in e2fsck_pass1()
1754 check_blocks(ctx, &pctx, block_buf, NULL); in e2fsck_pass1()
1755 FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum); in e2fsck_pass1()
1761 &pctx)) { in e2fsck_pass1()
1785 if (fix_problem(ctx, problem, &pctx)) { in e2fsck_pass1()
1792 check_blocks(ctx, &pctx, block_buf, NULL); in e2fsck_pass1()
1793 FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum); in e2fsck_pass1()
1798 FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum); in e2fsck_pass1()
1812 if (fix_problem(ctx, PR_1_SET_DTIME, &pctx)) { in e2fsck_pass1()
1848 if (fix_problem(ctx, PR_1_SET_IMAGIC, &pctx)) { in e2fsck_pass1()
1857 check_inode_extra_space(ctx, &pctx, &ea_ibody_quota); in e2fsck_pass1()
1858 check_is_really_dir(ctx, &pctx, block_buf); in e2fsck_pass1()
1867 fix_problem(ctx, PR_1_FAST_SYMLINK_EXTENT_FL, &pctx)) { in e2fsck_pass1()
1884 check_extents_inlinedata(ctx, &pctx); in e2fsck_pass1()
1885 check_immutable(ctx, &pctx); in e2fsck_pass1()
1886 check_size(ctx, &pctx); in e2fsck_pass1()
1890 check_extents_inlinedata(ctx, &pctx); in e2fsck_pass1()
1891 check_immutable(ctx, &pctx); in e2fsck_pass1()
1892 check_size(ctx, &pctx); in e2fsck_pass1()
1897 check_immutable(ctx, &pctx); in e2fsck_pass1()
1900 FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum); in e2fsck_pass1()
1904 check_blocks(ctx, &pctx, block_buf, in e2fsck_pass1()
1906 FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum); in e2fsck_pass1()
1912 check_extents_inlinedata(ctx, &pctx); in e2fsck_pass1()
1913 check_immutable(ctx, &pctx); in e2fsck_pass1()
1914 check_size(ctx, &pctx); in e2fsck_pass1()
1918 check_extents_inlinedata(ctx, &pctx); in e2fsck_pass1()
1919 check_immutable(ctx, &pctx); in e2fsck_pass1()
1920 check_size(ctx, &pctx); in e2fsck_pass1()
1950 check_blocks(ctx, &pctx, block_buf, &ea_ibody_quota); in e2fsck_pass1()
1952 FINISH_INODE_LOOP(ctx, ino, &pctx, failed_csum); in e2fsck_pass1()
2008 clear_problem_context(&pctx); in e2fsck_pass1()
2009 pctx.errcode = ext2fs_create_resize_inode(fs); in e2fsck_pass1()
2010 if (pctx.errcode) { in e2fsck_pass1()
2012 &pctx)) { in e2fsck_pass1()
2016 pctx.errcode = 0; in e2fsck_pass1()
2018 if (!pctx.errcode) { in e2fsck_pass1()
2042 clear_problem_context(&pctx); in e2fsck_pass1()
2043 fix_problem(ctx, PR_1_DUP_BLOCKS_PREENSTOP, &pctx); in e2fsck_pass1()
2106 struct problem_context pctx; in process_inodes() local
2118 clear_problem_context(&pctx); in process_inodes()
2120 pctx.inode = ctx->stashed_inode = in process_inodes()
2122 pctx.ino = ctx->stashed_ino = inodes_to_process[i].ino; in process_inodes()
2125 printf("%u ", pctx.ino); in process_inodes()
2128 pctx.ino); in process_inodes()
2130 check_blocks(ctx, &pctx, block_buf, in process_inodes()
2172 struct problem_context pctx; in mark_inode_bad() local
2175 clear_problem_context(&pctx); in mark_inode_bad()
2177 pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs, in mark_inode_bad()
2180 if (pctx.errcode) { in mark_inode_bad()
2181 pctx.num = 3; in mark_inode_bad()
2182 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx); in mark_inode_bad()
2193 struct problem_context pctx; in add_encrypted_dir() local
2196 pctx.errcode = ext2fs_u32_list_create(&ctx->encrypted_dirs, 0); in add_encrypted_dir()
2197 if (pctx.errcode) in add_encrypted_dir()
2200 pctx.errcode = ext2fs_u32_list_add(ctx->encrypted_dirs, ino); in add_encrypted_dir()
2201 if (pctx.errcode == 0) in add_encrypted_dir()
2204 fix_problem(ctx, PR_1_ALLOCATE_ENCRYPTED_DIRLIST, &pctx); in add_encrypted_dir()
2214 struct problem_context pctx; in alloc_bb_map() local
2216 clear_problem_context(&pctx); in alloc_bb_map()
2217 pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs, in alloc_bb_map()
2220 if (pctx.errcode) { in alloc_bb_map()
2221 pctx.num = 4; in alloc_bb_map()
2222 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx); in alloc_bb_map()
2234 struct problem_context pctx; in alloc_imagic_map() local
2236 clear_problem_context(&pctx); in alloc_imagic_map()
2237 pctx.errcode = e2fsck_allocate_inode_bitmap(ctx->fs, in alloc_imagic_map()
2240 if (pctx.errcode) { in alloc_imagic_map()
2241 pctx.num = 5; in alloc_imagic_map()
2242 fix_problem(ctx, PR_1_ALLOCATE_IBITMAP_ERROR, &pctx); in alloc_imagic_map()
2258 struct problem_context pctx; in mark_block_used() local
2260 clear_problem_context(&pctx); in mark_block_used()
2268 pctx.errcode = e2fsck_allocate_block_bitmap(ctx->fs, in mark_block_used()
2272 if (pctx.errcode) { in mark_block_used()
2273 pctx.num = 3; in mark_block_used()
2275 &pctx); in mark_block_used()
2315 struct problem_context pctx; in adjust_extattr_refcount() local
2321 clear_problem_context(&pctx); in adjust_extattr_refcount()
2327 pctx.blk = blk; in adjust_extattr_refcount()
2328 pctx.errcode = ext2fs_read_ext_attr3(fs, blk, block_buf, in adjust_extattr_refcount()
2329 pctx.ino); in adjust_extattr_refcount()
2330 if (pctx.errcode) { in adjust_extattr_refcount()
2331 fix_problem(ctx, PR_1_EXTATTR_READ_ABORT, &pctx); in adjust_extattr_refcount()
2335 pctx.blkcount = header->h_refcount; in adjust_extattr_refcount()
2337 pctx.num = should_be; in adjust_extattr_refcount()
2338 if (fix_problem(ctx, PR_1_EXTATTR_REFCOUNT, &pctx)) { in adjust_extattr_refcount()
2340 pctx.errcode = ext2fs_write_ext_attr3(fs, blk, in adjust_extattr_refcount()
2342 pctx.ino); in adjust_extattr_refcount()
2343 if (pctx.errcode) { in adjust_extattr_refcount()
2345 &pctx); in adjust_extattr_refcount()
2355 static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx, in check_ext_attr() argument
2359 ext2_ino_t ino = pctx->ino; in check_ext_attr()
2360 struct ext2_inode *inode = pctx->inode; in check_ext_attr()
2393 pctx->errcode = e2fsck_allocate_block_bitmap(fs, in check_ext_attr()
2397 if (pctx->errcode) { in check_ext_attr()
2398 pctx->num = 2; in check_ext_attr()
2399 fix_problem(ctx, PR_1_ALLOCATE_BBITMAP_ERROR, pctx); in check_ext_attr()
2407 pctx->errcode = ea_refcount_create(0, &ctx->refcount); in check_ext_attr()
2408 if (pctx->errcode) { in check_ext_attr()
2409 pctx->num = 1; in check_ext_attr()
2410 fix_problem(ctx, PR_1_ALLOCATE_REFCOUNT, pctx); in check_ext_attr()
2441 pctx->errcode = ea_refcount_create(0, in check_ext_attr()
2443 if (pctx->errcode) { in check_ext_attr()
2444 pctx->num = 2; in check_ext_attr()
2445 fix_problem(ctx, PR_1_ALLOCATE_REFCOUNT, pctx); in check_ext_attr()
2458 pctx->blk = blk; in check_ext_attr()
2459 pctx->errcode = ext2fs_read_ext_attr3(fs, blk, block_buf, pctx->ino); in check_ext_attr()
2460 if (pctx->errcode == EXT2_ET_EXT_ATTR_CSUM_INVALID) { in check_ext_attr()
2461 pctx->errcode = 0; in check_ext_attr()
2463 } else if (pctx->errcode == EXT2_ET_BAD_EA_HEADER) in check_ext_attr()
2464 pctx->errcode = 0; in check_ext_attr()
2466 if (pctx->errcode && in check_ext_attr()
2467 fix_problem(ctx, PR_1_READ_EA_BLOCK, pctx)) { in check_ext_attr()
2468 pctx->errcode = 0; in check_ext_attr()
2472 pctx->blk = ext2fs_file_acl_block(fs, inode); in check_ext_attr()
2477 if (fix_problem(ctx, PR_1_BAD_EA_BLOCK, pctx)) in check_ext_attr()
2482 if (fix_problem(ctx, PR_1_EA_MULTI_BLOCK, pctx)) in check_ext_attr()
2486 if (pctx->errcode && fix_problem(ctx, PR_1_READ_EA_BLOCK, pctx)) in check_ext_attr()
2491 fix_problem(ctx, PR_1_EA_ALLOC_REGION_ABORT, pctx); in check_ext_attr()
2496 if (fix_problem(ctx, PR_1_EA_ALLOC_COLLISION, pctx)) in check_ext_attr()
2508 if (fix_problem(ctx, PR_1_EA_ALLOC_COLLISION, pctx)) in check_ext_attr()
2516 if (fix_problem(ctx, PR_1_EA_BAD_NAME, pctx)) in check_ext_attr()
2523 if (fix_problem(ctx, PR_1_EA_BAD_VALUE, pctx)) in check_ext_attr()
2531 pctx)) in check_ext_attr()
2539 pctx->num = entry->e_hash; in check_ext_attr()
2540 if (fix_problem(ctx, PR_1_ATTR_HASH, pctx)) in check_ext_attr()
2548 problem = check_large_ea_inode(ctx, entry, pctx, in check_ext_attr()
2550 if (problem && fix_problem(ctx, problem, pctx)) in check_ext_attr()
2560 if (fix_problem(ctx, PR_1_EA_ALLOC_COLLISION, pctx)) in check_ext_attr()
2570 fix_problem(ctx, PR_1_EA_BLOCK_ONLY_CSUM_INVALID, pctx)) { in check_ext_attr()
2571 pctx->errcode = ext2fs_write_ext_attr3(fs, blk, block_buf, in check_ext_attr()
2572 pctx->ino); in check_ext_attr()
2573 if (pctx->errcode) in check_ext_attr()
2579 pctx->errcode = ea_refcount_create(0, in check_ext_attr()
2581 if (pctx->errcode) { in check_ext_attr()
2582 pctx->num = 3; in check_ext_attr()
2592 pctx->errcode = ea_refcount_create(0, in check_ext_attr()
2594 if (pctx->errcode) { in check_ext_attr()
2595 pctx->num = 4; in check_ext_attr()
2597 fix_problem(ctx, PR_1_ALLOCATE_REFCOUNT, pctx); in check_ext_attr()
2609 inc_ea_inode_refs(ctx, pctx, first, end); in check_ext_attr()
2624 static int handle_htree(e2fsck_t ctx, struct problem_context *pctx, in handle_htree() argument
2634 fix_problem(ctx, PR_1_HTREE_NODIR, pctx)) || in handle_htree()
2636 fix_problem(ctx, PR_1_HTREE_SET, pctx))) in handle_htree()
2639 pctx->errcode = ext2fs_bmap2(fs, ino, inode, 0, 0, 0, 0, &blk); in handle_htree()
2641 if ((pctx->errcode) || in handle_htree()
2645 if (fix_problem(ctx, PR_1_HTREE_BADROOT, pctx)) in handle_htree()
2652 if (retval && fix_problem(ctx, PR_1_HTREE_BADROOT, pctx)) in handle_htree()
2659 fix_problem(ctx, PR_1_HTREE_BADROOT, pctx)) in handle_htree()
2662 pctx->num = root->hash_version; in handle_htree()
2666 fix_problem(ctx, PR_1_HTREE_HASHV, pctx)) in handle_htree()
2670 fix_problem(ctx, PR_1_HTREE_INCOMPAT, pctx)) in handle_htree()
2673 pctx->num = root->indirect_levels; in handle_htree()
2675 fix_problem(ctx, PR_1_HTREE_DEPTH, pctx)) in handle_htree()
2753 static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx, in scan_extent_node() argument
2768 if (pctx->errcode == EXT2_ET_EXTENT_CSUM_INVALID) in scan_extent_node()
2771 pctx->errcode = ext2fs_extent_get_info(ehandle, &info); in scan_extent_node()
2772 if (pctx->errcode) in scan_extent_node()
2792 pctx->errcode = ext2fs_extent_get(ehandle, EXT2_EXTENT_FIRST_SIB, in scan_extent_node()
2794 while ((pctx->errcode == 0 || in scan_extent_node()
2795 pctx->errcode == EXT2_ET_EXTENT_CSUM_INVALID) && in scan_extent_node()
2798 is_dir = LINUX_S_ISDIR(pctx->inode->i_mode); in scan_extent_node()
2802 pctx->blk = extent.e_pblk; in scan_extent_node()
2803 pctx->blk2 = extent.e_lblk; in scan_extent_node()
2804 pctx->num = extent.e_len; in scan_extent_node()
2805 pctx->blkcount = extent.e_lblk + extent.e_len; in scan_extent_node()
2847 fix_problem(ctx, PR_1_UNINIT_DBLOCK, pctx)) { in scan_extent_node()
2850 pctx->errcode = ext2fs_extent_replace(ehandle, 0, in scan_extent_node()
2852 if (pctx->errcode) in scan_extent_node()
2859 if (fix_problem(ctx, problem, pctx)) { in scan_extent_node()
2868 pctx->errcode = ext2fs_extent_get( in scan_extent_node()
2873 if (pctx->errcode == in scan_extent_node()
2875 pctx->errcode = 0; in scan_extent_node()
2882 pctx->errcode = in scan_extent_node()
2884 if (pctx->errcode) { in scan_extent_node()
2885 pctx->str = "ext2fs_extent_delete"; in scan_extent_node()
2888 pctx->errcode = ext2fs_extent_fix_parents(ehandle); in scan_extent_node()
2889 if (pctx->errcode && in scan_extent_node()
2890 pctx->errcode != EXT2_ET_NO_CURRENT_NODE) { in scan_extent_node()
2891 pctx->str = "ext2fs_extent_fix_parents"; in scan_extent_node()
2894 pctx->errcode = ext2fs_extent_get(ehandle, in scan_extent_node()
2897 if (pctx->errcode == EXT2_ET_NO_CURRENT_NODE) { in scan_extent_node()
2898 pctx->errcode = 0; in scan_extent_node()
2923 pctx->blk = blk; in scan_extent_node()
2926 pctx); in scan_extent_node()
2930 pctx->errcode = ext2fs_extent_get(ehandle, in scan_extent_node()
2932 if (pctx->errcode && in scan_extent_node()
2933 pctx->errcode != EXT2_ET_EXTENT_CSUM_INVALID) { in scan_extent_node()
2934 pctx->str = "EXT2_EXTENT_DOWN"; in scan_extent_node()
2938 if (pctx->errcode == EXT2_ET_EXTENT_HEADER_BAD) in scan_extent_node()
2947 pctx->blk = lblk; in scan_extent_node()
2948 pctx->blk2 = extent.e_lblk; in scan_extent_node()
2949 pctx->num = e_info.curr_level - 1; in scan_extent_node()
2951 if (fix_problem(ctx, problem, pctx)) { in scan_extent_node()
2953 pctx->errcode = in scan_extent_node()
2955 if (pctx->errcode) { in scan_extent_node()
2956 pctx->str = "ext2fs_extent_fix_parents"; in scan_extent_node()
2961 scan_extent_node(ctx, pctx, pb, extent.e_lblk, in scan_extent_node()
2964 if (pctx->errcode) in scan_extent_node()
2966 pctx->errcode = ext2fs_extent_get(ehandle, in scan_extent_node()
2968 if (pctx->errcode) { in scan_extent_node()
2969 pctx->str = "EXT2_EXTENT_UP"; in scan_extent_node()
2990 (unsigned long) pctx->ino, type, in scan_extent_node()
3015 pctx->blk = extent.e_lblk; in scan_extent_node()
3016 pctx->blk2 = new_lblk; in scan_extent_node()
3017 if (fix_problem(ctx, PR_1_COLLAPSE_DBLOCK, pctx)) { in scan_extent_node()
3020 pctx->errcode = ext2fs_extent_replace(ehandle, in scan_extent_node()
3022 if (pctx->errcode) { in scan_extent_node()
3023 pctx->errcode = 0; in scan_extent_node()
3026 pctx->errcode = ext2fs_extent_fix_parents(ehandle); in scan_extent_node()
3027 if (pctx->errcode) in scan_extent_node()
3029 pctx->errcode = ext2fs_extent_goto(ehandle, in scan_extent_node()
3031 if (pctx->errcode) in scan_extent_node()
3041 pctx->errcode = ext2fs_add_dir_block2( in scan_extent_node()
3045 if (pctx->errcode) { in scan_extent_node()
3046 pctx->blk = 0; in scan_extent_node()
3047 pctx->num = pb->last_db_block; in scan_extent_node()
3053 pctx->errcode = ext2fs_add_dir_block2( in scan_extent_node()
3055 pctx->ino, in scan_extent_node()
3058 if (pctx->errcode) { in scan_extent_node()
3059 pctx->blk = extent.e_pblk + i; in scan_extent_node()
3060 pctx->num = extent.e_lblk + i; in scan_extent_node()
3062 fix_problem(ctx, PR_1_ADD_DBLOCK, pctx); in scan_extent_node()
3076 pctx->blk = extent.e_lblk + i; in scan_extent_node()
3077 pctx->blk2 = extent.e_pblk + i; in scan_extent_node()
3078 fix_problem(ctx, PR_1_MISALIGNED_CLUSTER, pctx); in scan_extent_node()
3114 pctx->errcode = ext2fs_extent_get(ehandle, in scan_extent_node()
3121 fix_problem(ctx, PR_1_EXTENT_ONLY_CSUM_INVALID, pctx)) { in scan_extent_node()
3123 pctx->errcode = ext2fs_extent_replace(ehandle, 0, &extent); in scan_extent_node()
3124 if (pctx->errcode) in scan_extent_node()
3128 if (pctx->errcode == EXT2_ET_EXTENT_NO_NEXT) in scan_extent_node()
3129 pctx->errcode = 0; in scan_extent_node()
3132 static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx, in check_blocks_extents() argument
3136 struct ext2_inode *inode = pctx->inode; in check_blocks_extents()
3139 ext2_ino_t ino = pctx->ino; in check_blocks_extents()
3148 if (fix_problem(ctx, PR_1_MISSING_EXTENT_HEADER, pctx)) in check_blocks_extents()
3151 pctx->errcode = 0; in check_blocks_extents()
3156 pctx->errcode = ext2fs_extent_open2(fs, ino, inode, &ehandle); in check_blocks_extents()
3157 if (pctx->errcode) { in check_blocks_extents()
3158 if (fix_problem(ctx, PR_1_READ_EXTENT, pctx)) in check_blocks_extents()
3161 pctx->errcode = 0; in check_blocks_extents()
3175 pctx->blk = info.max_depth; in check_blocks_extents()
3176 pctx->blk2 = ext2fs_max_extent_depth(ehandle); in check_blocks_extents()
3177 if (pctx->blk2 < pctx->blk && in check_blocks_extents()
3178 fix_problem(ctx, PR_1_EXTENT_BAD_MAX_DEPTH, pctx)) in check_blocks_extents()
3182 pctx->blk = MAX_EXTENT_DEPTH_COUNT; in check_blocks_extents()
3183 if (pctx->blk2 > pctx->blk) in check_blocks_extents()
3184 fix_problem(ctx, PR_1E_MAX_EXTENT_TREE_DEPTH, pctx); in check_blocks_extents()
3192 scan_extent_node(ctx, pctx, pb, 0, 0, eof_lblk, ehandle, 1); in check_blocks_extents()
3193 if (pctx->errcode && in check_blocks_extents()
3194 fix_problem(ctx, PR_1_EXTENT_ITERATE_FAILURE, pctx)) { in check_blocks_extents()
3199 pctx->errcode = 0; in check_blocks_extents()
3211 e2fsck_should_rebuild_extents(ctx, pctx, &pb->eti, &info); in check_blocks_extents()
3219 static void check_blocks_inline_data(e2fsck_t ctx, struct problem_context *pctx, in check_blocks_inline_data() argument
3226 pctx->errcode = 0; in check_blocks_inline_data()
3231 pctx->errcode = ext2fs_add_dir_block2(ctx->fs->dblist, pb->ino, 0, 0); in check_blocks_inline_data()
3232 if (pctx->errcode) in check_blocks_inline_data()
3238 pctx->errcode = ext2fs_inline_data_size(ctx->fs, pb->ino, in check_blocks_inline_data()
3242 if (pctx->errcode) { in check_blocks_inline_data()
3243 pctx->errcode = 0; in check_blocks_inline_data()
3250 pctx->errcode = ext2fs_add_dir_block2(ctx->fs->dblist, pb->ino, 0, 1); in check_blocks_inline_data()
3251 if (pctx->errcode) in check_blocks_inline_data()
3256 pctx->blk = 0; in check_blocks_inline_data()
3257 pctx->num = 0; in check_blocks_inline_data()
3258 fix_problem(ctx, PR_1_ADD_DBLOCK, pctx); in check_blocks_inline_data()
3266 static void check_blocks(e2fsck_t ctx, struct problem_context *pctx, in check_blocks() argument
3271 ext2_ino_t ino = pctx->ino; in check_blocks()
3272 struct ext2_inode *inode = pctx->inode; in check_blocks()
3295 pb.pctx = pctx; in check_blocks()
3299 pctx->ino = ino; in check_blocks()
3300 pctx->errcode = 0; in check_blocks()
3305 if (check_ext_attr(ctx, pctx, block_buf, &ea_block_quota)) { in check_blocks()
3312 check_blocks_inline_data(ctx, pctx, &pb); in check_blocks()
3315 check_blocks_extents(ctx, pctx, &pb); in check_blocks()
3329 pctx->errcode = ext2fs_block_iterate3(fs, ino, in check_blocks()
3363 if (pctx->errcode) in check_blocks()
3364 fix_problem(ctx, PR_1_BLOCK_ITERATE, pctx); in check_blocks()
3380 if (handle_htree(ctx, pctx, ino, inode, block_buf)) { in check_blocks()
3390 if (fix_problem(ctx, PR_1_ZERO_LENGTH_DIR, pctx)) { in check_blocks()
3427 err = ext2fs_inline_data_size(ctx->fs, pctx->ino, in check_blocks()
3435 pctx->num = sz; in check_blocks()
3467 pctx->num = (pb.last_block + 1) * fs->blocksize; in check_blocks()
3468 pctx->group = bad_size; in check_blocks()
3469 if (fix_problem(ctx, PR_1_BAD_I_SIZE, pctx)) { in check_blocks()
3471 pctx->num &= 0xFFFFFFFFULL; in check_blocks()
3472 ext2fs_inode_size_set(fs, inode, pctx->num); in check_blocks()
3481 pctx->num = 0; in check_blocks()
3491 pctx->num = pb.num_blocks; in check_blocks()
3492 if (fix_problem(ctx, PR_1_BAD_I_BLOCKS, pctx)) { in check_blocks()
3497 pctx->num = 0; in check_blocks()
3510 fix_problem(ctx, PR_1_NO_BIGALLOC_BLOCKMAP_FILES, pctx)) { in check_blocks()
3511 pctx->errcode = e2fsck_rebuild_extents_later(ctx, ino); in check_blocks()
3512 if (pctx->errcode) in check_blocks()
3590 struct problem_context *pctx; in process_block() local
3597 pctx = p->pctx; in process_block()
3606 pctx->errcode = ext2fs_add_dir_block2(fs->dblist, p->ino, 0, 0); in process_block()
3607 if (pctx->errcode) { in process_block()
3608 pctx->blk = blk; in process_block()
3609 pctx->num = blockcnt; in process_block()
3640 (unsigned long) pctx->ino, type, in process_block()
3670 pctx->blk = blk; in process_block()
3671 fix_problem(ctx, PR_1_CRITICAL_METADATA_COLLISION, pctx); in process_block()
3701 if (fix_problem(ctx, PR_1_TOO_MANY_BAD_BLOCKS, pctx)) { in process_block()
3705 if (fix_problem(ctx, PR_1_SUPPRESS_MESSAGES, pctx)) { in process_block()
3711 pctx->blk = blk; in process_block()
3712 pctx->blkcount = blockcnt; in process_block()
3713 if (fix_problem(ctx, problem, pctx)) { in process_block()
3754 pctx->blk = blockcnt; in process_block()
3755 pctx->blk2 = blk; in process_block()
3756 fix_problem(ctx, PR_1_MISALIGNED_CLUSTER, pctx); in process_block()
3766 pctx->errcode = ext2fs_add_dir_block2(fs->dblist, in process_block()
3769 if (pctx->errcode) { in process_block()
3770 pctx->blk = 0; in process_block()
3771 pctx->num = p->last_db_block; in process_block()
3775 pctx->errcode = ext2fs_add_dir_block2(fs->dblist, p->ino, in process_block()
3777 if (pctx->errcode) { in process_block()
3778 pctx->blk = blk; in process_block()
3779 pctx->num = blockcnt; in process_block()
3781 fix_problem(ctx, PR_1_ADD_DBLOCK, pctx); in process_block()
3801 struct problem_context *pctx; in process_bad_block() local
3809 pctx = p->pctx; in process_bad_block()
3811 pctx->ino = EXT2_BAD_INO; in process_bad_block()
3812 pctx->blk = blk; in process_bad_block()
3813 pctx->blkcount = blockcnt; in process_bad_block()
3817 if (fix_problem(ctx, PR_1_BB_ILLEGAL_BLOCK_NUM, pctx)) { in process_bad_block()
3827 if (fix_problem(ctx, PR_1_BB_FS_BLOCK, pctx)) { in process_bad_block()
3835 pctx)) { in process_bad_block()
3865 pctx->group = i; in process_bad_block()
3866 pctx->blk = blk; in process_bad_block()
3873 pctx)) { in process_bad_block()
3879 fix_problem(ctx, PR_1_BAD_SUPERBLOCK, pctx); in process_bad_block()
3885 pctx->blk = *block_nr; in process_bad_block()
3887 PR_1_BAD_PRIMARY_GROUP_DESCRIPTOR, pctx)) { in process_bad_block()
3893 fix_problem(ctx, PR_1_BAD_GROUP_DESCRIPTORS, pctx); in process_bad_block()
3898 if (fix_problem(ctx, PR_1_BB_BAD_BLOCK, pctx)) { in process_bad_block()
3905 if (fix_problem(ctx, PR_1_IB_BAD_BLOCK, pctx)) { in process_bad_block()
3932 if (fix_problem(ctx, PR_1_BBINODE_BAD_METABLOCK, pctx)) { in process_bad_block()
3941 pctx->group = -1; in process_bad_block()
3944 fix_problem(ctx, PR_1_PROGERR_CLAIMED_BLOCK, pctx); in process_bad_block()
3960 struct problem_context pctx; in new_table_block() local
3962 clear_problem_context(&pctx); in new_table_block()
3964 pctx.group = group; in new_table_block()
3965 pctx.blk = old_block; in new_table_block()
3966 pctx.str = name; in new_table_block()
3985 pctx.errcode = ext2fs_get_free_blocks2(fs, first_block, last_block, in new_table_block()
3988 if (is_flexbg && (pctx.errcode == EXT2_ET_BLOCK_ALLOC_FAIL)) in new_table_block()
3989 pctx.errcode = ext2fs_get_free_blocks2(fs, in new_table_block()
3993 if (pctx.errcode) { in new_table_block()
3994 pctx.num = num; in new_table_block()
3995 fix_problem(ctx, PR_1_RELOC_BLOCK_ALLOCATE, &pctx); in new_table_block()
4000 pctx.errcode = ext2fs_get_mem(fs->blocksize, &buf); in new_table_block()
4001 if (pctx.errcode) { in new_table_block()
4002 fix_problem(ctx, PR_1_RELOC_MEMORY_ALLOCATE, &pctx); in new_table_block()
4009 pctx.blk2 = *new_block; in new_table_block()
4011 PR_1_RELOC_TO), &pctx); in new_table_block()
4012 pctx.blk2 = 0; in new_table_block()
4014 pctx.blk = i; in new_table_block()
4017 pctx.errcode = io_channel_read_blk64(fs->io, in new_table_block()
4019 if (pctx.errcode) in new_table_block()
4020 fix_problem(ctx, PR_1_RELOC_READ_ERR, &pctx); in new_table_block()
4021 pctx.blk = (*new_block) + i; in new_table_block()
4022 pctx.errcode = io_channel_write_blk64(fs->io, pctx.blk, in new_table_block()
4025 pctx.blk = (*new_block) + i; in new_table_block()
4026 pctx.errcode = ext2fs_zero_blocks2(fs, pctx.blk, 1, in new_table_block()
4030 if (pctx.errcode) in new_table_block()
4031 fix_problem(ctx, PR_1_RELOC_WRITE_ERR, &pctx); in new_table_block()
4087 struct problem_context pctx; in mark_table_blocks() local
4089 clear_problem_context(&pctx); in mark_table_blocks()
4092 pctx.group = i; in mark_table_blocks()
4106 pctx.blk = b; in mark_table_blocks()
4109 PR_1_ITABLE_CONFLICT, &pctx)) { in mark_table_blocks()
4128 pctx.blk = ext2fs_block_bitmap_loc(fs, i); in mark_table_blocks()
4129 if (fix_problem(ctx, PR_1_BB_CONFLICT, &pctx)) { in mark_table_blocks()
4146 pctx.blk = ext2fs_inode_bitmap_loc(fs, i); in mark_table_blocks()
4147 if (fix_problem(ctx, PR_1_IB_CONFLICT, &pctx)) { in mark_table_blocks()