Skip to content

Commit 06ce251

Browse files
visitorckwakpm00
authored andcommitted
bcachefs: clean up duplicate min_heap_callbacks declarations
Refactor the bcachefs code to remove multiple redundant declarations of min_heap_callbacks, ensuring that each unique declaration appears only once. Link: https://lore.kernel.org/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kuan-Wei Chiu <[email protected]> Suggested-by: Peter Zijlstra <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Ching-Chun (Jim) Huang <[email protected]> Cc: Coly Li <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Kent Overstreet <[email protected]> Cc: "Liang, Kan" <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Matthew Sakai <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Namhyung Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 3d8a9a1 commit 06ce251

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

fs/bcachefs/clock.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ static inline void io_timer_swp(void *l, void *r, void __always_unused *args)
2222
swap(*_l, *_r);
2323
}
2424

25+
static const struct min_heap_callbacks callbacks = {
26+
.less = io_timer_cmp,
27+
.swp = io_timer_swp,
28+
};
29+
2530
void bch2_io_timer_add(struct io_clock *clock, struct io_timer *timer)
2631
{
27-
const struct min_heap_callbacks callbacks = {
28-
.less = io_timer_cmp,
29-
.swp = io_timer_swp,
30-
};
31-
3232
spin_lock(&clock->timer_lock);
3333

3434
if (time_after_eq64((u64) atomic64_read(&clock->now), timer->expire)) {
@@ -48,11 +48,6 @@ void bch2_io_timer_add(struct io_clock *clock, struct io_timer *timer)
4848

4949
void bch2_io_timer_del(struct io_clock *clock, struct io_timer *timer)
5050
{
51-
const struct min_heap_callbacks callbacks = {
52-
.less = io_timer_cmp,
53-
.swp = io_timer_swp,
54-
};
55-
5651
spin_lock(&clock->timer_lock);
5752

5853
for (size_t i = 0; i < clock->timers.nr; i++)
@@ -142,10 +137,6 @@ void bch2_kthread_io_clock_wait(struct io_clock *clock,
142137
static struct io_timer *get_expired_timer(struct io_clock *clock, u64 now)
143138
{
144139
struct io_timer *ret = NULL;
145-
const struct min_heap_callbacks callbacks = {
146-
.less = io_timer_cmp,
147-
.swp = io_timer_swp,
148-
};
149140

150141
if (clock->timers.nr &&
151142
time_after_eq64(now, clock->timers.data[0]->expire)) {

fs/bcachefs/ec.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,11 @@ static inline void ec_stripes_heap_swap(void *l, void *r, void *h)
10571057
ec_stripes_heap_set_backpointer(_h, j);
10581058
}
10591059

1060+
static const struct min_heap_callbacks callbacks = {
1061+
.less = ec_stripes_heap_cmp,
1062+
.swp = ec_stripes_heap_swap,
1063+
};
1064+
10601065
static void heap_verify_backpointer(struct bch_fs *c, size_t idx)
10611066
{
10621067
ec_stripes_heap *h = &c->ec_stripes_heap;
@@ -1069,11 +1074,6 @@ static void heap_verify_backpointer(struct bch_fs *c, size_t idx)
10691074
void bch2_stripes_heap_del(struct bch_fs *c,
10701075
struct stripe *m, size_t idx)
10711076
{
1072-
const struct min_heap_callbacks callbacks = {
1073-
.less = ec_stripes_heap_cmp,
1074-
.swp = ec_stripes_heap_swap,
1075-
};
1076-
10771077
mutex_lock(&c->ec_stripes_heap_lock);
10781078
heap_verify_backpointer(c, idx);
10791079

@@ -1084,11 +1084,6 @@ void bch2_stripes_heap_del(struct bch_fs *c,
10841084
void bch2_stripes_heap_insert(struct bch_fs *c,
10851085
struct stripe *m, size_t idx)
10861086
{
1087-
const struct min_heap_callbacks callbacks = {
1088-
.less = ec_stripes_heap_cmp,
1089-
.swp = ec_stripes_heap_swap,
1090-
};
1091-
10921087
mutex_lock(&c->ec_stripes_heap_lock);
10931088
BUG_ON(min_heap_full(&c->ec_stripes_heap));
10941089

@@ -1107,10 +1102,6 @@ void bch2_stripes_heap_insert(struct bch_fs *c,
11071102
void bch2_stripes_heap_update(struct bch_fs *c,
11081103
struct stripe *m, size_t idx)
11091104
{
1110-
const struct min_heap_callbacks callbacks = {
1111-
.less = ec_stripes_heap_cmp,
1112-
.swp = ec_stripes_heap_swap,
1113-
};
11141105
ec_stripes_heap *h = &c->ec_stripes_heap;
11151106
bool do_deletes;
11161107
size_t i;

0 commit comments

Comments
 (0)