File tree Expand file tree Collapse file tree 4 files changed +6
-37
lines changed Expand file tree Collapse file tree 4 files changed +6
-37
lines changed Original file line number Diff line number Diff line change @@ -542,7 +542,7 @@ struct bch_dev {
542
542
* gc_gens_lock, for device resize - holding any is sufficient for
543
543
* access: Or rcu_read_lock(), but only for dev_ptr_stale():
544
544
*/
545
- struct bucket_array __rcu * buckets_gc ;
545
+ GENRADIX ( struct bucket ) buckets_gc ;
546
546
struct bucket_gens __rcu * bucket_gens ;
547
547
u8 * oldest_gen ;
548
548
unsigned long * buckets_nouse ;
Original file line number Diff line number Diff line change @@ -753,10 +753,8 @@ static void bch2_gc_free(struct bch_fs *c)
753
753
genradix_free (& c -> reflink_gc_table );
754
754
genradix_free (& c -> gc_stripes );
755
755
756
- for_each_member_device (c , ca ) {
757
- kvfree (rcu_dereference_protected (ca -> buckets_gc , 1 ));
758
- ca -> buckets_gc = NULL ;
759
- }
756
+ for_each_member_device (c , ca )
757
+ genradix_free (& ca -> buckets_gc );
760
758
}
761
759
762
760
static int bch2_gc_start (struct bch_fs * c )
@@ -910,20 +908,12 @@ static int bch2_gc_alloc_start(struct bch_fs *c)
910
908
int ret = 0 ;
911
909
912
910
for_each_member_device (c , ca ) {
913
- struct bucket_array * buckets = kvmalloc (sizeof (struct bucket_array ) +
914
- ca -> mi .nbuckets * sizeof (struct bucket ),
915
- GFP_KERNEL |__GFP_ZERO );
916
- if (!buckets ) {
911
+ ret = genradix_prealloc (& ca -> buckets_gc , ca -> mi .nbuckets , GFP_KERNEL );
912
+ if (ret ) {
917
913
bch2_dev_put (ca );
918
914
ret = - BCH_ERR_ENOMEM_gc_alloc_start ;
919
915
break ;
920
916
}
921
-
922
- buckets -> first_bucket = ca -> mi .first_bucket ;
923
- buckets -> nbuckets = ca -> mi .nbuckets ;
924
- buckets -> nbuckets_minus_first =
925
- buckets -> nbuckets - buckets -> first_bucket ;
926
- rcu_assign_pointer (ca -> buckets_gc , buckets );
927
917
}
928
918
929
919
bch_err_fn (c , ret );
Original file line number Diff line number Diff line change @@ -80,22 +80,9 @@ static inline void bucket_lock(struct bucket *b)
80
80
TASK_UNINTERRUPTIBLE );
81
81
}
82
82
83
- static inline struct bucket_array * gc_bucket_array (struct bch_dev * ca )
84
- {
85
- return rcu_dereference_check (ca -> buckets_gc ,
86
- !ca -> fs ||
87
- percpu_rwsem_is_held (& ca -> fs -> mark_lock ) ||
88
- lockdep_is_held (& ca -> fs -> state_lock ) ||
89
- lockdep_is_held (& ca -> bucket_lock ));
90
- }
91
-
92
83
static inline struct bucket * gc_bucket (struct bch_dev * ca , size_t b )
93
84
{
94
- struct bucket_array * buckets = gc_bucket_array (ca );
95
-
96
- if (b - buckets -> first_bucket >= buckets -> nbuckets_minus_first )
97
- return NULL ;
98
- return buckets -> b + b ;
85
+ return genradix_ptr (& ca -> buckets_gc , b );
99
86
}
100
87
101
88
static inline struct bucket_gens * bucket_gens (struct bch_dev * ca )
Original file line number Diff line number Diff line change @@ -19,14 +19,6 @@ struct bucket {
19
19
u32 stripe_sectors ;
20
20
} __aligned (sizeof (long ));
21
21
22
- struct bucket_array {
23
- struct rcu_head rcu ;
24
- u16 first_bucket ;
25
- size_t nbuckets ;
26
- size_t nbuckets_minus_first ;
27
- struct bucket b [] __counted_by (nbuckets );
28
- };
29
-
30
22
struct bucket_gens {
31
23
struct rcu_head rcu ;
32
24
u16 first_bucket ;
You can’t perform that action at this time.
0 commit comments