@@ -352,6 +352,18 @@ static int mark_stripe_buckets(struct btree_trans *trans,
352
352
return 0 ;
353
353
}
354
354
355
+ static inline void stripe_to_mem (struct stripe * m , const struct bch_stripe * s )
356
+ {
357
+ m -> sectors = le16_to_cpu (s -> sectors );
358
+ m -> algorithm = s -> algorithm ;
359
+ m -> nr_blocks = s -> nr_blocks ;
360
+ m -> nr_redundant = s -> nr_redundant ;
361
+ m -> blocks_nonempty = 0 ;
362
+
363
+ for (unsigned i = 0 ; i < s -> nr_blocks ; i ++ )
364
+ m -> blocks_nonempty += !!stripe_blockcount_get (s , i );
365
+ }
366
+
355
367
int bch2_trigger_stripe (struct btree_trans * trans ,
356
368
enum btree_id btree , unsigned level ,
357
369
struct bkey_s_c old , struct bkey_s _new ,
@@ -468,14 +480,7 @@ int bch2_trigger_stripe(struct btree_trans *trans,
468
480
469
481
memset (m , 0 , sizeof (* m ));
470
482
} else {
471
- m -> sectors = le16_to_cpu (new_s -> sectors );
472
- m -> algorithm = new_s -> algorithm ;
473
- m -> nr_blocks = new_s -> nr_blocks ;
474
- m -> nr_redundant = new_s -> nr_redundant ;
475
- m -> blocks_nonempty = 0 ;
476
-
477
- for (unsigned i = 0 ; i < new_s -> nr_blocks ; i ++ )
478
- m -> blocks_nonempty += !!stripe_blockcount_get (new_s , i );
483
+ stripe_to_mem (m , new_s );
479
484
480
485
if (!old_s )
481
486
bch2_stripes_heap_insert (c , m , idx );
@@ -2198,17 +2203,9 @@ int bch2_stripes_read(struct bch_fs *c)
2198
2203
if (ret )
2199
2204
break ;
2200
2205
2201
- const struct bch_stripe * s = bkey_s_c_to_stripe (k ).v ;
2202
-
2203
2206
struct stripe * m = genradix_ptr (& c -> stripes , k .k -> p .offset );
2204
- m -> sectors = le16_to_cpu (s -> sectors );
2205
- m -> algorithm = s -> algorithm ;
2206
- m -> nr_blocks = s -> nr_blocks ;
2207
- m -> nr_redundant = s -> nr_redundant ;
2208
- m -> blocks_nonempty = 0 ;
2209
-
2210
- for (unsigned i = 0 ; i < s -> nr_blocks ; i ++ )
2211
- m -> blocks_nonempty += !!stripe_blockcount_get (s , i );
2207
+
2208
+ stripe_to_mem (m , bkey_s_c_to_stripe (k ).v );
2212
2209
2213
2210
bch2_stripes_heap_insert (c , m , k .k -> p .offset );
2214
2211
0 ;
0 commit comments