@@ -493,33 +493,6 @@ static int device_record_compare(const struct rb_node *node1, const struct rb_no
493493 return 0 ;
494494}
495495
496- static int add_mismatch_ram_bytes_record (struct inode_record * inode_rec ,
497- struct btrfs_key * key )
498- {
499- struct mismatch_ram_bytes_record * record ;
500-
501- record = malloc (sizeof (* record ));
502- if (!record ) {
503- error_msg (ERROR_MSG_MEMORY , "mismatch ram bytes record" );
504- return - ENOMEM ;
505- }
506- memcpy (& record -> key , key , sizeof (* key ));
507- list_add_tail (& record -> list , & inode_rec -> mismatch_ram_bytes );
508- return 0 ;
509- }
510-
511- static void free_mismatch_ram_bytes_records (struct inode_record * inode_rec )
512- {
513- if (!list_empty (& inode_rec -> mismatch_ram_bytes )) {
514- struct mismatch_ram_bytes_record * ram ;
515-
516- ram = list_entry (inode_rec -> mismatch_ram_bytes .next ,
517- struct mismatch_ram_bytes_record , list );
518- list_del (& ram -> list );
519- free (ram );
520- }
521- }
522-
523496static struct inode_record * clone_inode_rec (struct inode_record * orig_rec )
524497{
525498 struct inode_record * rec ;
@@ -528,7 +501,6 @@ static struct inode_record *clone_inode_rec(struct inode_record *orig_rec)
528501 struct inode_backref * tmp ;
529502 struct mismatch_dir_hash_record * hash_record ;
530503 struct mismatch_dir_hash_record * new_record ;
531- struct mismatch_ram_bytes_record * ram_record ;
532504 struct unaligned_extent_rec_t * src ;
533505 struct unaligned_extent_rec_t * dst ;
534506 struct rb_node * rb ;
@@ -542,7 +514,6 @@ static struct inode_record *clone_inode_rec(struct inode_record *orig_rec)
542514 rec -> refs = 1 ;
543515 INIT_LIST_HEAD (& rec -> backrefs );
544516 INIT_LIST_HEAD (& rec -> mismatch_dir_hash );
545- INIT_LIST_HEAD (& rec -> mismatch_ram_bytes );
546517 INIT_LIST_HEAD (& rec -> unaligned_extent_recs );
547518 rec -> holes = RB_ROOT ;
548519
@@ -566,11 +537,6 @@ static struct inode_record *clone_inode_rec(struct inode_record *orig_rec)
566537 memcpy (& new_record , hash_record , size );
567538 list_add_tail (& new_record -> list , & rec -> mismatch_dir_hash );
568539 }
569- list_for_each_entry (ram_record , & orig_rec -> mismatch_ram_bytes , list ) {
570- ret = add_mismatch_ram_bytes_record (rec , & ram_record -> key );
571- if (ret < 0 )
572- goto cleanup ;
573- }
574540 list_for_each_entry (src , & orig_rec -> unaligned_extent_recs , list ) {
575541 size = sizeof (* src );
576542 dst = malloc (size );
@@ -612,7 +578,6 @@ static struct inode_record *clone_inode_rec(struct inode_record *orig_rec)
612578 free (hash_record );
613579 }
614580 }
615- free_mismatch_ram_bytes_records (rec );
616581 if (!list_empty (& rec -> unaligned_extent_recs ))
617582 list_for_each_entry_safe (src , dst , & rec -> unaligned_extent_recs ,
618583 list ) {
@@ -654,8 +619,6 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec)
654619 fprintf (stderr , ", odd file extent" );
655620 if (errors & I_ERR_BAD_FILE_EXTENT )
656621 fprintf (stderr , ", bad file extent" );
657- if (errors & I_ERR_RAM_BYTES_MISMATCH )
658- fprintf (stderr , ", bad ram bytes for non-compressed extents" );
659622 if (errors & I_ERR_FILE_EXTENT_OVERLAP )
660623 fprintf (stderr , ", file extent overlap" );
661624 if (errors & I_ERR_FILE_EXTENT_TOO_LARGE )
@@ -674,6 +637,8 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec)
674637 fprintf (stderr , ", link count wrong" );
675638 if (errors & I_ERR_ODD_INODE_FLAGS )
676639 fprintf (stderr , ", odd inode flags" );
640+ if (errors & I_ERR_INLINE_RAM_BYTES_WRONG )
641+ fprintf (stderr , ", invalid inline ram bytes" );
677642 if (errors & I_ERR_INVALID_IMODE )
678643 fprintf (stderr , ", invalid inode mode bit 0%o" ,
679644 rec -> imode & ~07777 );
@@ -734,17 +699,6 @@ static void print_inode_error(struct btrfs_root *root, struct inode_record *rec)
734699 hash_record -> key .offset );
735700 }
736701 }
737- if (errors & I_ERR_RAM_BYTES_MISMATCH ) {
738- struct mismatch_ram_bytes_record * ram_record ;
739-
740- fprintf (stderr ,
741- "Non-compressed file extents with invalid ram_bytes (minor errors):\n" );
742- list_for_each_entry (ram_record , & rec -> mismatch_ram_bytes , list ) {
743- fprintf (stderr , "\tino=%llu offset=%llu\n" ,
744- ram_record -> key .objectid ,
745- ram_record -> key .offset );
746- }
747- }
748702}
749703
750704static void print_ref_error (int errors )
@@ -806,7 +760,6 @@ static struct inode_record *get_inode_rec(struct cache_tree *inode_cache,
806760 rec -> refs = 1 ;
807761 INIT_LIST_HEAD (& rec -> backrefs );
808762 INIT_LIST_HEAD (& rec -> mismatch_dir_hash );
809- INIT_LIST_HEAD (& rec -> mismatch_ram_bytes );
810763 INIT_LIST_HEAD (& rec -> unaligned_extent_recs );
811764 rec -> holes = RB_ROOT ;
812765
@@ -858,14 +811,6 @@ static void free_inode_rec(struct inode_record *rec)
858811 list_del (& backref -> list );
859812 free (backref );
860813 }
861- while (!list_empty (& rec -> mismatch_ram_bytes )) {
862- struct mismatch_ram_bytes_record * ram ;
863-
864- ram = list_entry (rec -> mismatch_ram_bytes .next ,
865- struct mismatch_ram_bytes_record , list );
866- list_del (& ram -> list );
867- free (ram );
868- }
869814 list_for_each_entry_safe (hash , next , & rec -> mismatch_dir_hash , list )
870815 free (hash );
871816 free_unaligned_extent_recs (& rec -> unaligned_extent_recs );
@@ -876,8 +821,7 @@ static void free_inode_rec(struct inode_record *rec)
876821static bool can_free_inode_rec (struct inode_record * rec )
877822{
878823 if (!rec -> errors && rec -> checked && rec -> found_inode_item &&
879- rec -> nlink == rec -> found_link && list_empty (& rec -> backrefs ) &&
880- list_empty (& rec -> mismatch_ram_bytes ))
824+ rec -> nlink == rec -> found_link && list_empty (& rec -> backrefs ))
881825 return true;
882826 return false;
883827}
@@ -1798,14 +1742,6 @@ static int process_file_extent(struct btrfs_root *root,
17981742 rec -> errors |= I_ERR_BAD_FILE_EXTENT ;
17991743 if (compression && rec -> nodatasum )
18001744 rec -> errors |= I_ERR_BAD_FILE_EXTENT ;
1801- if (disk_bytenr && !compression &&
1802- btrfs_file_extent_ram_bytes (eb , fi ) !=
1803- btrfs_file_extent_disk_num_bytes (eb , fi )) {
1804- rec -> errors |= I_ERR_RAM_BYTES_MISMATCH ;
1805- ret = add_mismatch_ram_bytes_record (rec , key );
1806- if (ret < 0 )
1807- return ret ;
1808- }
18091745 if (disk_bytenr > 0 )
18101746 rec -> found_size += num_bytes ;
18111747 } else {
@@ -3076,57 +3012,6 @@ static int repair_inode_gen_original(struct btrfs_trans_handle *trans,
30763012 return 0 ;
30773013}
30783014
3079- static int repair_ram_bytes (struct btrfs_trans_handle * trans ,
3080- struct btrfs_root * root ,
3081- struct btrfs_path * path ,
3082- struct inode_record * rec )
3083- {
3084- struct mismatch_ram_bytes_record * record ;
3085- struct mismatch_ram_bytes_record * tmp ;
3086- int ret = 0 ;
3087-
3088- btrfs_release_path (path );
3089- list_for_each_entry_safe (record , tmp , & rec -> mismatch_ram_bytes , list ) {
3090- struct btrfs_file_extent_item * fi ;
3091- struct extent_buffer * leaf ;
3092- int type ;
3093- int slot ;
3094- int search_ret ;
3095-
3096- search_ret = btrfs_search_slot (trans , root , & record -> key , path , 0 , 1 );
3097- if (search_ret > 0 )
3098- search_ret = - ENOENT ;
3099- if (search_ret < 0 ) {
3100- ret = search_ret ;
3101- btrfs_release_path (path );
3102- continue ;
3103- }
3104- leaf = path -> nodes [0 ];
3105- slot = path -> slots [0 ];
3106- fi = btrfs_item_ptr (leaf , slot , struct btrfs_file_extent_item );
3107- type = btrfs_file_extent_type (leaf , fi );
3108- if (type != BTRFS_FILE_EXTENT_REG &&
3109- type != BTRFS_FILE_EXTENT_PREALLOC ) {
3110- ret = - EUCLEAN ;
3111- btrfs_release_path (path );
3112- continue ;
3113- }
3114- if (btrfs_file_extent_disk_bytenr (path -> nodes [0 ], fi ) == 0 ||
3115- btrfs_file_extent_compression (path -> nodes [0 ], fi )) {
3116- ret = - EUCLEAN ;
3117- btrfs_release_path (path );
3118- continue ;
3119- }
3120- btrfs_set_file_extent_ram_bytes (leaf , fi ,
3121- btrfs_file_extent_disk_num_bytes (leaf , fi ));
3122- btrfs_mark_buffer_dirty (leaf );
3123- btrfs_release_path (path );
3124- }
3125- if (!ret )
3126- rec -> errors &= ~I_ERR_RAM_BYTES_MISMATCH ;
3127- return ret ;
3128- }
3129-
31303015static int try_repair_inode (struct btrfs_root * root , struct inode_record * rec )
31313016{
31323017 struct btrfs_trans_handle * trans ;
@@ -3149,8 +3034,7 @@ static int try_repair_inode(struct btrfs_root *root, struct inode_record *rec)
31493034 I_ERR_MISMATCH_DIR_HASH |
31503035 I_ERR_UNALIGNED_EXTENT_REC |
31513036 I_ERR_INVALID_IMODE |
3152- I_ERR_INVALID_GEN |
3153- I_ERR_RAM_BYTES_MISMATCH )))
3037+ I_ERR_INVALID_GEN )))
31543038 return rec -> errors ;
31553039
31563040 /*
@@ -3190,8 +3074,6 @@ static int try_repair_inode(struct btrfs_root *root, struct inode_record *rec)
31903074 ret = repair_unaligned_extent_recs (trans , root , & path , rec );
31913075 if (!ret && rec -> errors & I_ERR_INVALID_GEN )
31923076 ret = repair_inode_gen_original (trans , root , & path , rec );
3193- if (!ret && rec -> errors & I_ERR_RAM_BYTES_MISMATCH )
3194- ret = repair_ram_bytes (trans , root , & path , rec );
31953077 btrfs_commit_transaction (trans , root );
31963078 btrfs_release_path (& path );
31973079 return ret ;
0 commit comments