]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: clean up duplicate min_heap_callbacks declarations
authorKuan-Wei Chiu <visitorckw@gmail.com>
Sun, 20 Oct 2024 04:01:58 +0000 (12:01 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 6 Nov 2024 01:12:36 +0000 (17:12 -0800)
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/20241017095520.GV16066@noisy.programming.kicks-ass.net
Link: https://lkml.kernel.org/r/20241020040200.939973-9-visitorckw@gmail.com
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ching-Chun (Jim) Huang <jserv@ccns.ncku.edu.tw>
Cc: Coly Li <colyli@suse.de>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: "Liang, Kan" <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Matthew Sakai <msakai@redhat.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/bcachefs/clock.c
fs/bcachefs/ec.c

index 1d6b691e8da6e174e55fea67ae81c4a00d22c464..1fcfcb5fd44f28398ed4644e7dfddb2d1b1751f4 100644 (file)
@@ -22,13 +22,13 @@ static inline void io_timer_swp(void *l, void *r, void __always_unused *args)
        swap(*_l, *_r);
 }
 
+static const struct min_heap_callbacks callbacks = {
+       .less = io_timer_cmp,
+       .swp = io_timer_swp,
+};
+
 void bch2_io_timer_add(struct io_clock *clock, struct io_timer *timer)
 {
-       const struct min_heap_callbacks callbacks = {
-               .less = io_timer_cmp,
-               .swp = io_timer_swp,
-       };
-
        spin_lock(&clock->timer_lock);
 
        if (time_after_eq64((u64) atomic64_read(&clock->now), timer->expire)) {
@@ -48,11 +48,6 @@ out:
 
 void bch2_io_timer_del(struct io_clock *clock, struct io_timer *timer)
 {
-       const struct min_heap_callbacks callbacks = {
-               .less = io_timer_cmp,
-               .swp = io_timer_swp,
-       };
-
        spin_lock(&clock->timer_lock);
 
        for (size_t i = 0; i < clock->timers.nr; i++)
@@ -142,10 +137,6 @@ void bch2_kthread_io_clock_wait(struct io_clock *clock,
 static struct io_timer *get_expired_timer(struct io_clock *clock, u64 now)
 {
        struct io_timer *ret = NULL;
-       const struct min_heap_callbacks callbacks = {
-               .less = io_timer_cmp,
-               .swp = io_timer_swp,
-       };
 
        if (clock->timers.nr &&
            time_after_eq64(now, clock->timers.data[0]->expire)) {
index 749dcf368841d729ad5573b7b9959e962cf68d7f..6094afb0c6be7a89935ed378a28f56bc289c9e40 100644 (file)
@@ -1057,6 +1057,11 @@ static inline void ec_stripes_heap_swap(void *l, void *r, void *h)
        ec_stripes_heap_set_backpointer(_h, j);
 }
 
+static const struct min_heap_callbacks callbacks = {
+       .less = ec_stripes_heap_cmp,
+       .swp = ec_stripes_heap_swap,
+};
+
 static void heap_verify_backpointer(struct bch_fs *c, size_t idx)
 {
        ec_stripes_heap *h = &c->ec_stripes_heap;
@@ -1069,11 +1074,6 @@ static void heap_verify_backpointer(struct bch_fs *c, size_t idx)
 void bch2_stripes_heap_del(struct bch_fs *c,
                           struct stripe *m, size_t idx)
 {
-       const struct min_heap_callbacks callbacks = {
-               .less = ec_stripes_heap_cmp,
-               .swp = ec_stripes_heap_swap,
-       };
-
        mutex_lock(&c->ec_stripes_heap_lock);
        heap_verify_backpointer(c, idx);
 
@@ -1084,11 +1084,6 @@ void bch2_stripes_heap_del(struct bch_fs *c,
 void bch2_stripes_heap_insert(struct bch_fs *c,
                              struct stripe *m, size_t idx)
 {
-       const struct min_heap_callbacks callbacks = {
-               .less = ec_stripes_heap_cmp,
-               .swp = ec_stripes_heap_swap,
-       };
-
        mutex_lock(&c->ec_stripes_heap_lock);
        BUG_ON(min_heap_full(&c->ec_stripes_heap));
 
@@ -1107,10 +1102,6 @@ void bch2_stripes_heap_insert(struct bch_fs *c,
 void bch2_stripes_heap_update(struct bch_fs *c,
                              struct stripe *m, size_t idx)
 {
-       const struct min_heap_callbacks callbacks = {
-               .less = ec_stripes_heap_cmp,
-               .swp = ec_stripes_heap_swap,
-       };
        ec_stripes_heap *h = &c->ec_stripes_heap;
        bool do_deletes;
        size_t i;