@@ -352,6 +352,18 @@ static int mark_stripe_buckets(struct btree_trans *trans,
352352 return 0 ;
353353}
354354
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+
355367int bch2_trigger_stripe (struct btree_trans * trans ,
356368 enum btree_id btree , unsigned level ,
357369 struct bkey_s_c old , struct bkey_s _new ,
@@ -468,14 +480,7 @@ int bch2_trigger_stripe(struct btree_trans *trans,
468480
469481 memset (m , 0 , sizeof (* m ));
470482 } 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 );
479484
480485 if (!old_s )
481486 bch2_stripes_heap_insert (c , m , idx );
@@ -2198,17 +2203,9 @@ int bch2_stripes_read(struct bch_fs *c)
21982203 if (ret )
21992204 break ;
22002205
2201- const struct bch_stripe * s = bkey_s_c_to_stripe (k ).v ;
2202-
22032206 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 );
22122209
22132210 bch2_stripes_heap_insert (c , m , k .k -> p .offset );
22142211 0 ;
0 commit comments