@@ -131,29 +131,33 @@ int bch2_stripe_invalid(struct bch_fs *c, struct bkey_s_c k,
131131void bch2_stripe_to_text (struct printbuf * out , struct bch_fs * c ,
132132 struct bkey_s_c k )
133133{
134- const struct bch_stripe * s = bkey_s_c_to_stripe (k ).v ;
135- unsigned i , nr_data = s -> nr_blocks - s -> nr_redundant ;
134+ const struct bch_stripe * sp = bkey_s_c_to_stripe (k ).v ;
135+ struct bch_stripe s = {};
136+
137+ memcpy (& s , sp , min (sizeof (s ), bkey_val_bytes (k .k )));
138+
139+ unsigned nr_data = s .nr_blocks - s .nr_redundant ;
136140
137141 prt_printf (out , "algo %u sectors %u blocks %u:%u csum %u gran %u" ,
138- s -> algorithm ,
139- le16_to_cpu (s -> sectors ),
140- nr_data ,
141- s -> nr_redundant ,
142- s -> csum_type ,
143- 1U << s -> csum_granularity_bits );
144-
145- for (i = 0 ; i < s -> nr_blocks ; i ++ ) {
146- const struct bch_extent_ptr * ptr = s -> ptrs + i ;
147- struct bch_dev * ca = bch_dev_bkey_exists ( c , ptr -> dev );
148- u32 offset ;
149- u64 b = sector_to_bucket_and_offset ( ca , ptr -> offset , & offset ) ;
150-
151- prt_printf (out , " %u:%llu:%u" , ptr -> dev , b , offset );
152- if ( i < nr_data )
153- prt_printf ( out , "#%u" , stripe_blockcount_get ( s , i ));
154- prt_printf ( out , " gen %u" , ptr -> gen );
155- if ( ptr_stale ( ca , ptr ))
156- prt_printf (out , " stale" );
142+ s . algorithm ,
143+ le16_to_cpu (s . sectors ),
144+ nr_data ,
145+ s . nr_redundant ,
146+ s . csum_type ,
147+ 1U << s . csum_granularity_bits );
148+
149+ for (unsigned i = 0 ; i < s . nr_blocks ; i ++ ) {
150+ const struct bch_extent_ptr * ptr = sp -> ptrs + i ;
151+
152+ if (( void * ) ptr >= bkey_val_end ( k ))
153+ break ;
154+
155+ bch2_extent_ptr_to_text (out , c , ptr );
156+
157+ if ( s . csum_type < BCH_CSUM_NR &&
158+ i < nr_data &&
159+ stripe_blockcount_offset ( & s , i ) < bkey_val_bytes ( k . k ))
160+ prt_printf (out , "#%u" , stripe_blockcount_get ( sp , i ) );
157161 }
158162}
159163
0 commit comments