@@ -1083,9 +1083,6 @@ static int extent_ptr_invalid(struct bch_fs *c,
1083
1083
struct printbuf * err )
1084
1084
{
1085
1085
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c (k );
1086
- u64 bucket ;
1087
- u32 bucket_offset ;
1088
- struct bch_dev * ca ;
1089
1086
int ret = 0 ;
1090
1087
1091
1088
if (!bch2_dev_exists (c , ptr -> dev )) {
@@ -1101,24 +1098,35 @@ static int extent_ptr_invalid(struct bch_fs *c,
1101
1098
"pointer to invalid device (%u)" , ptr -> dev );
1102
1099
}
1103
1100
1104
- ca = bch2_dev_bkey_exists (c , ptr -> dev );
1101
+ rcu_read_lock ();
1102
+ struct bch_dev * ca = bch2_dev_rcu (c , ptr -> dev );
1103
+ if (!ca ) {
1104
+ rcu_read_unlock ();
1105
+ return 0 ;
1106
+ }
1107
+ u32 bucket_offset ;
1108
+ u64 bucket = sector_to_bucket_and_offset (ca , ptr -> offset , & bucket_offset );
1109
+ unsigned first_bucket = ca -> mi .first_bucket ;
1110
+ u64 nbuckets = ca -> mi .nbuckets ;
1111
+ unsigned bucket_size = ca -> mi .bucket_size ;
1112
+ rcu_read_unlock ();
1113
+
1105
1114
bkey_for_each_ptr (ptrs , ptr2 )
1106
1115
bkey_fsck_err_on (ptr != ptr2 && ptr -> dev == ptr2 -> dev , c , err ,
1107
1116
ptr_to_duplicate_device ,
1108
1117
"multiple pointers to same device (%u)" , ptr -> dev );
1109
1118
1110
- bucket = sector_to_bucket_and_offset (ca , ptr -> offset , & bucket_offset );
1111
1119
1112
- bkey_fsck_err_on (bucket >= ca -> mi . nbuckets , c , err ,
1120
+ bkey_fsck_err_on (bucket >= nbuckets , c , err ,
1113
1121
ptr_after_last_bucket ,
1114
- "pointer past last bucket (%llu > %llu)" , bucket , ca -> mi . nbuckets );
1115
- bkey_fsck_err_on (ptr -> offset < bucket_to_sector ( ca , ca -> mi . first_bucket ) , c , err ,
1122
+ "pointer past last bucket (%llu > %llu)" , bucket , nbuckets );
1123
+ bkey_fsck_err_on (bucket < first_bucket , c , err ,
1116
1124
ptr_before_first_bucket ,
1117
- "pointer before first bucket (%llu < %u)" , bucket , ca -> mi . first_bucket );
1118
- bkey_fsck_err_on (bucket_offset + size_ondisk > ca -> mi . bucket_size , c , err ,
1125
+ "pointer before first bucket (%llu < %u)" , bucket , first_bucket );
1126
+ bkey_fsck_err_on (bucket_offset + size_ondisk > bucket_size , c , err ,
1119
1127
ptr_spans_multiple_buckets ,
1120
1128
"pointer spans multiple buckets (%u + %u > %u)" ,
1121
- bucket_offset , size_ondisk , ca -> mi . bucket_size );
1129
+ bucket_offset , size_ondisk , bucket_size );
1122
1130
fsck_err :
1123
1131
return ret ;
1124
1132
}
0 commit comments