Commit 26452d1d authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Add missing call to bch2_replicas_entry_sort()

This fixes a bug introduced by "bcachefs: Improve diagnostics when
journal entries are missing" - devices in a replicas entry are supposed
to be sorted.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent a28bd48a
...@@ -937,6 +937,8 @@ int bch2_journal_read(struct bch_fs *c, struct list_head *list, ...@@ -937,6 +937,8 @@ int bch2_journal_read(struct bch_fs *c, struct list_head *list,
for (ptr = 0; ptr < i->nr_ptrs; ptr++) for (ptr = 0; ptr < i->nr_ptrs; ptr++)
replicas.e.devs[replicas.e.nr_devs++] = i->ptrs[ptr].dev; replicas.e.devs[replicas.e.nr_devs++] = i->ptrs[ptr].dev;
bch2_replicas_entry_sort(&replicas.e);
/* /*
* If we're mounting in degraded mode - if we didn't read all * If we're mounting in degraded mode - if we didn't read all
* the devices - this is wrong: * the devices - this is wrong:
......
...@@ -26,7 +26,7 @@ static void verify_replicas_entry(struct bch_replicas_entry *e) ...@@ -26,7 +26,7 @@ static void verify_replicas_entry(struct bch_replicas_entry *e)
#endif #endif
} }
static void replicas_entry_sort(struct bch_replicas_entry *e) void bch2_replicas_entry_sort(struct bch_replicas_entry *e)
{ {
bubble_sort(e->devs, e->nr_devs, u8_cmp); bubble_sort(e->devs, e->nr_devs, u8_cmp);
} }
...@@ -122,7 +122,7 @@ void bch2_bkey_to_replicas(struct bch_replicas_entry *e, ...@@ -122,7 +122,7 @@ void bch2_bkey_to_replicas(struct bch_replicas_entry *e,
break; break;
} }
replicas_entry_sort(e); bch2_replicas_entry_sort(e);
} }
void bch2_devlist_to_replicas(struct bch_replicas_entry *e, void bch2_devlist_to_replicas(struct bch_replicas_entry *e,
...@@ -142,7 +142,7 @@ void bch2_devlist_to_replicas(struct bch_replicas_entry *e, ...@@ -142,7 +142,7 @@ void bch2_devlist_to_replicas(struct bch_replicas_entry *e,
for (i = 0; i < devs.nr; i++) for (i = 0; i < devs.nr; i++)
e->devs[e->nr_devs++] = devs.devs[i]; e->devs[e->nr_devs++] = devs.devs[i];
replicas_entry_sort(e); bch2_replicas_entry_sort(e);
} }
static struct bch_replicas_cpu static struct bch_replicas_cpu
...@@ -197,7 +197,7 @@ static inline int __replicas_entry_idx(struct bch_replicas_cpu *r, ...@@ -197,7 +197,7 @@ static inline int __replicas_entry_idx(struct bch_replicas_cpu *r,
int bch2_replicas_entry_idx(struct bch_fs *c, int bch2_replicas_entry_idx(struct bch_fs *c,
struct bch_replicas_entry *search) struct bch_replicas_entry *search)
{ {
replicas_entry_sort(search); bch2_replicas_entry_sort(search);
return __replicas_entry_idx(&c->replicas, search); return __replicas_entry_idx(&c->replicas, search);
} }
...@@ -690,7 +690,7 @@ __bch2_sb_replicas_to_cpu_replicas(struct bch_sb_field_replicas *sb_r, ...@@ -690,7 +690,7 @@ __bch2_sb_replicas_to_cpu_replicas(struct bch_sb_field_replicas *sb_r,
for_each_replicas_entry(sb_r, e) { for_each_replicas_entry(sb_r, e) {
dst = cpu_replicas_entry(cpu_r, idx++); dst = cpu_replicas_entry(cpu_r, idx++);
memcpy(dst, e, replicas_entry_bytes(e)); memcpy(dst, e, replicas_entry_bytes(e));
replicas_entry_sort(dst); bch2_replicas_entry_sort(dst);
} }
return 0; return 0;
...@@ -727,7 +727,7 @@ __bch2_sb_replicas_v0_to_cpu_replicas(struct bch_sb_field_replicas_v0 *sb_r, ...@@ -727,7 +727,7 @@ __bch2_sb_replicas_v0_to_cpu_replicas(struct bch_sb_field_replicas_v0 *sb_r,
dst->nr_devs = e->nr_devs; dst->nr_devs = e->nr_devs;
dst->nr_required = 1; dst->nr_required = 1;
memcpy(dst->devs, e->devs, e->nr_devs); memcpy(dst->devs, e->devs, e->nr_devs);
replicas_entry_sort(dst); bch2_replicas_entry_sort(dst);
} }
return 0; return 0;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "eytzinger.h" #include "eytzinger.h"
#include "replicas_types.h" #include "replicas_types.h"
void bch2_replicas_entry_sort(struct bch_replicas_entry *);
void bch2_replicas_entry_to_text(struct printbuf *, void bch2_replicas_entry_to_text(struct printbuf *,
struct bch_replicas_entry *); struct bch_replicas_entry *);
void bch2_cpu_replicas_to_text(struct printbuf *, struct bch_replicas_cpu *); void bch2_cpu_replicas_to_text(struct printbuf *, struct bch_replicas_cpu *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment