2017-03-17 06:18:50 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
#include "bcachefs.h"
|
2019-02-11 00:34:47 +00:00
|
|
|
#include "buckets.h"
|
2019-01-24 22:12:00 +00:00
|
|
|
#include "journal.h"
|
2017-03-17 06:18:50 +00:00
|
|
|
#include "replicas.h"
|
|
|
|
#include "super-io.h"
|
|
|
|
|
2024-03-22 23:26:33 +00:00
|
|
|
#include <linux/sort.h>
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
static int bch2_cpu_replicas_to_sb_replicas(struct bch_fs *,
|
|
|
|
struct bch_replicas_cpu *);
|
|
|
|
|
2024-01-15 19:12:43 +00:00
|
|
|
/* Some (buggy!) compilers don't allow memcmp to be passed as a pointer */
|
2024-03-22 23:26:33 +00:00
|
|
|
static int bch2_memcmp(const void *l, const void *r, const void *priv)
|
2024-01-15 19:12:43 +00:00
|
|
|
{
|
2024-03-22 23:26:33 +00:00
|
|
|
size_t size = (size_t) priv;
|
2024-01-15 19:12:43 +00:00
|
|
|
return memcmp(l, r, size);
|
|
|
|
}
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
/* Replicas tracking - in memory: */
|
|
|
|
|
2023-11-09 18:52:35 +00:00
|
|
|
static void verify_replicas_entry(struct bch_replicas_entry_v1 *e)
|
2019-01-21 20:32:13 +00:00
|
|
|
{
|
2019-09-20 18:28:35 +00:00
|
|
|
#ifdef CONFIG_BCACHEFS_DEBUG
|
|
|
|
BUG_ON(e->data_type >= BCH_DATA_NR);
|
|
|
|
BUG_ON(!e->nr_devs);
|
|
|
|
BUG_ON(e->nr_required > 1 &&
|
|
|
|
e->nr_required >= e->nr_devs);
|
|
|
|
|
2024-05-20 04:58:04 +00:00
|
|
|
for (unsigned i = 0; i + 1 < e->nr_devs; i++)
|
2019-01-21 20:32:13 +00:00
|
|
|
BUG_ON(e->devs[i] >= e->devs[i + 1]);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2023-11-09 18:52:35 +00:00
|
|
|
void bch2_replicas_entry_sort(struct bch_replicas_entry_v1 *e)
|
2018-10-30 18:14:19 +00:00
|
|
|
{
|
|
|
|
bubble_sort(e->devs, e->nr_devs, u8_cmp);
|
|
|
|
}
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
static void bch2_cpu_replicas_sort(struct bch_replicas_cpu *r)
|
|
|
|
{
|
2024-03-22 23:26:33 +00:00
|
|
|
eytzinger0_sort_r(r->entries, r->nr, r->entry_size,
|
|
|
|
bch2_memcmp, NULL, (void *)(size_t)r->entry_size);
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2023-07-07 02:47:42 +00:00
|
|
|
static void bch2_replicas_entry_v0_to_text(struct printbuf *out,
|
|
|
|
struct bch_replicas_entry_v0 *e)
|
2022-02-20 10:00:45 +00:00
|
|
|
{
|
2024-01-07 01:57:43 +00:00
|
|
|
bch2_prt_data_type(out, e->data_type);
|
2022-02-20 10:00:45 +00:00
|
|
|
|
2023-02-04 02:01:40 +00:00
|
|
|
prt_printf(out, ": %u [", e->nr_devs);
|
2024-01-07 01:57:43 +00:00
|
|
|
for (unsigned i = 0; i < e->nr_devs; i++)
|
2023-02-04 02:01:40 +00:00
|
|
|
prt_printf(out, i ? " %u" : "%u", e->devs[i]);
|
|
|
|
prt_printf(out, "]");
|
2022-02-20 10:00:45 +00:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:32:13 +00:00
|
|
|
void bch2_replicas_entry_to_text(struct printbuf *out,
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *e)
|
2017-03-17 06:18:50 +00:00
|
|
|
{
|
2024-01-07 01:57:43 +00:00
|
|
|
bch2_prt_data_type(out, e->data_type);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2023-02-04 02:01:40 +00:00
|
|
|
prt_printf(out, ": %u/%u [", e->nr_required, e->nr_devs);
|
2024-01-07 01:57:43 +00:00
|
|
|
for (unsigned i = 0; i < e->nr_devs; i++)
|
2023-02-04 02:01:40 +00:00
|
|
|
prt_printf(out, i ? " %u" : "%u", e->devs[i]);
|
|
|
|
prt_printf(out, "]");
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2023-11-09 18:52:35 +00:00
|
|
|
int bch2_replicas_entry_validate(struct bch_replicas_entry_v1 *r,
|
2023-11-26 02:42:08 +00:00
|
|
|
struct bch_sb *sb,
|
|
|
|
struct printbuf *err)
|
|
|
|
{
|
|
|
|
if (!r->nr_devs) {
|
|
|
|
prt_printf(err, "no devices in entry ");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (r->nr_required > 1 &&
|
|
|
|
r->nr_required >= r->nr_devs) {
|
|
|
|
prt_printf(err, "bad nr_required in entry ");
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < r->nr_devs; i++)
|
2024-04-12 03:31:55 +00:00
|
|
|
if (!bch2_member_exists(sb, r->devs[i])) {
|
2023-11-26 02:42:08 +00:00
|
|
|
prt_printf(err, "invalid device %u in entry ", r->devs[i]);
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
bad:
|
|
|
|
bch2_replicas_entry_to_text(err, r);
|
|
|
|
return -BCH_ERR_invalid_replicas_entry;
|
|
|
|
}
|
|
|
|
|
2018-11-09 06:24:07 +00:00
|
|
|
void bch2_cpu_replicas_to_text(struct printbuf *out,
|
2022-01-04 04:38:50 +00:00
|
|
|
struct bch_replicas_cpu *r)
|
2017-03-17 06:18:50 +00:00
|
|
|
{
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *e;
|
2017-03-17 06:18:50 +00:00
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
for_each_cpu_replicas_entry(r, e) {
|
|
|
|
if (!first)
|
2023-02-04 02:01:40 +00:00
|
|
|
prt_printf(out, " ");
|
2017-03-17 06:18:50 +00:00
|
|
|
first = false;
|
|
|
|
|
2019-01-21 20:32:13 +00:00
|
|
|
bch2_replicas_entry_to_text(out, e);
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-30 18:32:21 +00:00
|
|
|
static void extent_to_replicas(struct bkey_s_c k,
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *r)
|
2018-10-30 18:32:21 +00:00
|
|
|
{
|
2018-11-01 19:10:01 +00:00
|
|
|
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
|
|
|
|
const union bch_extent_entry *entry;
|
|
|
|
struct extent_ptr_decoded p;
|
2018-10-30 18:32:21 +00:00
|
|
|
|
2018-11-01 19:10:01 +00:00
|
|
|
r->nr_required = 1;
|
2018-10-30 18:32:47 +00:00
|
|
|
|
2018-11-01 19:10:01 +00:00
|
|
|
bkey_for_each_ptr_decode(k.k, ptrs, p, entry) {
|
|
|
|
if (p.ptr.cached)
|
|
|
|
continue;
|
2018-11-01 19:13:19 +00:00
|
|
|
|
2020-01-04 21:33:32 +00:00
|
|
|
if (!p.has_ec)
|
|
|
|
r->devs[r->nr_devs++] = p.ptr.dev;
|
|
|
|
else
|
2019-08-22 17:20:38 +00:00
|
|
|
r->nr_required = 0;
|
2018-11-01 19:13:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void stripe_to_replicas(struct bkey_s_c k,
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *r)
|
2018-11-01 19:13:19 +00:00
|
|
|
{
|
2018-11-01 19:10:01 +00:00
|
|
|
struct bkey_s_c_stripe s = bkey_s_c_to_stripe(k);
|
|
|
|
const struct bch_extent_ptr *ptr;
|
2018-11-01 19:13:19 +00:00
|
|
|
|
2018-11-01 19:10:01 +00:00
|
|
|
r->nr_required = s.v->nr_blocks - s.v->nr_redundant;
|
2018-11-01 19:13:19 +00:00
|
|
|
|
2018-11-01 19:10:01 +00:00
|
|
|
for (ptr = s.v->ptrs;
|
|
|
|
ptr < s.v->ptrs + s.v->nr_blocks;
|
|
|
|
ptr++)
|
|
|
|
r->devs[r->nr_devs++] = ptr->dev;
|
2018-10-30 18:32:21 +00:00
|
|
|
}
|
|
|
|
|
2023-11-09 18:52:35 +00:00
|
|
|
void bch2_bkey_to_replicas(struct bch_replicas_entry_v1 *e,
|
2019-03-11 18:59:58 +00:00
|
|
|
struct bkey_s_c k)
|
2018-10-30 18:32:21 +00:00
|
|
|
{
|
|
|
|
e->nr_devs = 0;
|
|
|
|
|
2018-11-01 19:10:01 +00:00
|
|
|
switch (k.k->type) {
|
|
|
|
case KEY_TYPE_btree_ptr:
|
2020-02-07 18:38:02 +00:00
|
|
|
case KEY_TYPE_btree_ptr_v2:
|
2020-07-09 22:28:11 +00:00
|
|
|
e->data_type = BCH_DATA_btree;
|
2018-10-30 18:32:21 +00:00
|
|
|
extent_to_replicas(k, e);
|
|
|
|
break;
|
2018-11-01 19:10:01 +00:00
|
|
|
case KEY_TYPE_extent:
|
2019-08-16 13:59:56 +00:00
|
|
|
case KEY_TYPE_reflink_v:
|
2020-07-09 22:28:11 +00:00
|
|
|
e->data_type = BCH_DATA_user;
|
2018-10-30 18:32:21 +00:00
|
|
|
extent_to_replicas(k, e);
|
|
|
|
break;
|
2018-11-01 19:10:01 +00:00
|
|
|
case KEY_TYPE_stripe:
|
2020-07-09 22:31:51 +00:00
|
|
|
e->data_type = BCH_DATA_parity;
|
2018-11-01 19:13:19 +00:00
|
|
|
stripe_to_replicas(k, e);
|
|
|
|
break;
|
2018-10-30 18:32:21 +00:00
|
|
|
}
|
|
|
|
|
2021-02-02 20:56:44 +00:00
|
|
|
bch2_replicas_entry_sort(e);
|
2018-10-30 18:32:21 +00:00
|
|
|
}
|
|
|
|
|
2023-11-09 18:52:35 +00:00
|
|
|
void bch2_devlist_to_replicas(struct bch_replicas_entry_v1 *e,
|
2019-01-21 20:32:13 +00:00
|
|
|
enum bch_data_type data_type,
|
|
|
|
struct bch_devs_list devs)
|
2017-03-17 06:18:50 +00:00
|
|
|
{
|
|
|
|
BUG_ON(!data_type ||
|
2020-07-09 22:28:11 +00:00
|
|
|
data_type == BCH_DATA_sb ||
|
2017-03-17 06:18:50 +00:00
|
|
|
data_type >= BCH_DATA_NR);
|
|
|
|
|
2018-10-30 18:14:19 +00:00
|
|
|
e->data_type = data_type;
|
|
|
|
e->nr_devs = 0;
|
2018-10-30 18:32:47 +00:00
|
|
|
e->nr_required = 1;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2023-12-24 02:02:45 +00:00
|
|
|
darray_for_each(devs, i)
|
|
|
|
e->devs[e->nr_devs++] = *i;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2021-02-02 20:56:44 +00:00
|
|
|
bch2_replicas_entry_sort(e);
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
static struct bch_replicas_cpu
|
2023-11-26 02:42:08 +00:00
|
|
|
cpu_replicas_add_entry(struct bch_fs *c,
|
|
|
|
struct bch_replicas_cpu *old,
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *new_entry)
|
2017-03-17 06:18:50 +00:00
|
|
|
{
|
2018-12-01 15:32:48 +00:00
|
|
|
struct bch_replicas_cpu new = {
|
|
|
|
.nr = old->nr + 1,
|
|
|
|
.entry_size = max_t(unsigned, old->entry_size,
|
|
|
|
replicas_entry_bytes(new_entry)),
|
|
|
|
};
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2021-01-22 00:14:37 +00:00
|
|
|
new.entries = kcalloc(new.nr, new.entry_size, GFP_KERNEL);
|
2018-12-01 15:32:48 +00:00
|
|
|
if (!new.entries)
|
|
|
|
return new;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2024-05-20 04:58:04 +00:00
|
|
|
for (unsigned i = 0; i < old->nr; i++)
|
2018-12-01 15:32:48 +00:00
|
|
|
memcpy(cpu_replicas_entry(&new, i),
|
2017-03-17 06:18:50 +00:00
|
|
|
cpu_replicas_entry(old, i),
|
2018-10-30 18:14:19 +00:00
|
|
|
old->entry_size);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
memcpy(cpu_replicas_entry(&new, old->nr),
|
2018-10-30 18:14:19 +00:00
|
|
|
new_entry,
|
|
|
|
replicas_entry_bytes(new_entry));
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
bch2_cpu_replicas_sort(&new);
|
2017-03-17 06:18:50 +00:00
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
2019-01-21 20:32:13 +00:00
|
|
|
static inline int __replicas_entry_idx(struct bch_replicas_cpu *r,
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *search)
|
2019-01-21 20:32:13 +00:00
|
|
|
{
|
|
|
|
int idx, entry_size = replicas_entry_bytes(search);
|
|
|
|
|
|
|
|
if (unlikely(entry_size > r->entry_size))
|
|
|
|
return -1;
|
|
|
|
|
2024-03-22 23:26:33 +00:00
|
|
|
#define entry_cmp(_l, _r) memcmp(_l, _r, entry_size)
|
2019-01-21 20:32:13 +00:00
|
|
|
idx = eytzinger0_find(r->entries, r->nr, r->entry_size,
|
|
|
|
entry_cmp, search);
|
|
|
|
#undef entry_cmp
|
|
|
|
|
|
|
|
return idx < r->nr ? idx : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int bch2_replicas_entry_idx(struct bch_fs *c,
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *search)
|
2019-01-21 20:32:13 +00:00
|
|
|
{
|
2021-02-02 20:56:44 +00:00
|
|
|
bch2_replicas_entry_sort(search);
|
2019-01-21 20:32:13 +00:00
|
|
|
|
|
|
|
return __replicas_entry_idx(&c->replicas, search);
|
|
|
|
}
|
|
|
|
|
2018-11-07 22:48:32 +00:00
|
|
|
static bool __replicas_has_entry(struct bch_replicas_cpu *r,
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *search)
|
2017-03-17 06:18:50 +00:00
|
|
|
{
|
2019-01-21 20:32:13 +00:00
|
|
|
return __replicas_entry_idx(r, search) >= 0;
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 20:13:52 +00:00
|
|
|
bool bch2_replicas_marked(struct bch_fs *c,
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *search)
|
2018-11-07 22:48:32 +00:00
|
|
|
{
|
2020-07-10 20:13:52 +00:00
|
|
|
bool marked;
|
|
|
|
|
2019-01-21 20:32:13 +00:00
|
|
|
if (!search->nr_devs)
|
|
|
|
return true;
|
|
|
|
|
2019-09-20 18:28:35 +00:00
|
|
|
verify_replicas_entry(search);
|
2019-01-21 20:32:13 +00:00
|
|
|
|
2019-03-15 22:20:46 +00:00
|
|
|
percpu_down_read(&c->mark_lock);
|
2020-07-10 20:13:52 +00:00
|
|
|
marked = __replicas_has_entry(&c->replicas, search) &&
|
|
|
|
(likely((!c->replicas_gc.entries)) ||
|
|
|
|
__replicas_has_entry(&c->replicas_gc, search));
|
2018-12-01 15:32:48 +00:00
|
|
|
percpu_up_read(&c->mark_lock);
|
2018-11-07 22:48:32 +00:00
|
|
|
|
|
|
|
return marked;
|
|
|
|
}
|
|
|
|
|
2019-02-11 00:34:47 +00:00
|
|
|
static void __replicas_table_update(struct bch_fs_usage *dst,
|
2019-01-21 20:32:13 +00:00
|
|
|
struct bch_replicas_cpu *dst_r,
|
2019-02-11 00:34:47 +00:00
|
|
|
struct bch_fs_usage *src,
|
2019-01-21 20:32:13 +00:00
|
|
|
struct bch_replicas_cpu *src_r)
|
|
|
|
{
|
|
|
|
int src_idx, dst_idx;
|
|
|
|
|
|
|
|
*dst = *src;
|
|
|
|
|
|
|
|
for (src_idx = 0; src_idx < src_r->nr; src_idx++) {
|
2019-02-14 23:38:52 +00:00
|
|
|
if (!src->replicas[src_idx])
|
2019-01-21 20:32:13 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
dst_idx = __replicas_entry_idx(dst_r,
|
|
|
|
cpu_replicas_entry(src_r, src_idx));
|
|
|
|
BUG_ON(dst_idx < 0);
|
|
|
|
|
2019-02-14 23:38:52 +00:00
|
|
|
dst->replicas[dst_idx] = src->replicas[src_idx];
|
2019-01-21 20:32:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-11 00:34:47 +00:00
|
|
|
static void __replicas_table_update_pcpu(struct bch_fs_usage __percpu *dst_p,
|
|
|
|
struct bch_replicas_cpu *dst_r,
|
|
|
|
struct bch_fs_usage __percpu *src_p,
|
|
|
|
struct bch_replicas_cpu *src_r)
|
|
|
|
{
|
|
|
|
unsigned src_nr = sizeof(struct bch_fs_usage) / sizeof(u64) + src_r->nr;
|
|
|
|
struct bch_fs_usage *dst, *src = (void *)
|
2023-07-07 02:47:42 +00:00
|
|
|
bch2_acc_percpu_u64s((u64 __percpu *) src_p, src_nr);
|
2019-02-11 00:34:47 +00:00
|
|
|
|
|
|
|
preempt_disable();
|
|
|
|
dst = this_cpu_ptr(dst_p);
|
|
|
|
preempt_enable();
|
|
|
|
|
|
|
|
__replicas_table_update(dst, dst_r, src, src_r);
|
|
|
|
}
|
|
|
|
|
2019-01-21 20:32:13 +00:00
|
|
|
/*
|
|
|
|
* Resize filesystem accounting:
|
|
|
|
*/
|
|
|
|
static int replicas_table_update(struct bch_fs *c,
|
|
|
|
struct bch_replicas_cpu *new_r)
|
|
|
|
{
|
2020-11-13 23:36:33 +00:00
|
|
|
struct bch_fs_usage __percpu *new_usage[JOURNAL_BUF_NR];
|
2019-02-11 00:34:47 +00:00
|
|
|
struct bch_fs_usage_online *new_scratch = NULL;
|
|
|
|
struct bch_fs_usage __percpu *new_gc = NULL;
|
|
|
|
struct bch_fs_usage *new_base = NULL;
|
|
|
|
unsigned i, bytes = sizeof(struct bch_fs_usage) +
|
|
|
|
sizeof(u64) * new_r->nr;
|
|
|
|
unsigned scratch_bytes = sizeof(struct bch_fs_usage_online) +
|
2019-01-21 20:32:13 +00:00
|
|
|
sizeof(u64) * new_r->nr;
|
2020-11-13 23:36:33 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
memset(new_usage, 0, sizeof(new_usage));
|
|
|
|
|
2019-02-11 00:34:47 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(new_usage); i++)
|
|
|
|
if (!(new_usage[i] = __alloc_percpu_gfp(bytes,
|
2021-01-22 00:14:37 +00:00
|
|
|
sizeof(u64), GFP_KERNEL)))
|
2019-02-11 00:34:47 +00:00
|
|
|
goto err;
|
|
|
|
|
2021-01-22 00:14:37 +00:00
|
|
|
if (!(new_base = kzalloc(bytes, GFP_KERNEL)) ||
|
|
|
|
!(new_scratch = kmalloc(scratch_bytes, GFP_KERNEL)) ||
|
2019-02-11 00:34:47 +00:00
|
|
|
(c->usage_gc &&
|
2021-01-22 00:14:37 +00:00
|
|
|
!(new_gc = __alloc_percpu_gfp(bytes, sizeof(u64), GFP_KERNEL))))
|
2019-02-11 00:34:47 +00:00
|
|
|
goto err;
|
2019-02-15 01:39:17 +00:00
|
|
|
|
2019-02-11 00:34:47 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(new_usage); i++)
|
|
|
|
if (c->usage[i])
|
|
|
|
__replicas_table_update_pcpu(new_usage[i], new_r,
|
|
|
|
c->usage[i], &c->replicas);
|
|
|
|
if (c->usage_base)
|
|
|
|
__replicas_table_update(new_base, new_r,
|
|
|
|
c->usage_base, &c->replicas);
|
|
|
|
if (c->usage_gc)
|
|
|
|
__replicas_table_update_pcpu(new_gc, new_r,
|
|
|
|
c->usage_gc, &c->replicas);
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(new_usage); i++)
|
|
|
|
swap(c->usage[i], new_usage[i]);
|
|
|
|
swap(c->usage_base, new_base);
|
2019-02-15 01:39:17 +00:00
|
|
|
swap(c->usage_scratch, new_scratch);
|
2019-02-11 00:34:47 +00:00
|
|
|
swap(c->usage_gc, new_gc);
|
2019-02-15 01:39:17 +00:00
|
|
|
swap(c->replicas, *new_r);
|
2020-11-13 23:36:33 +00:00
|
|
|
out:
|
2019-02-11 00:34:47 +00:00
|
|
|
free_percpu(new_gc);
|
2019-03-15 22:20:46 +00:00
|
|
|
kfree(new_scratch);
|
2021-04-16 21:26:25 +00:00
|
|
|
for (i = 0; i < ARRAY_SIZE(new_usage); i++)
|
|
|
|
free_percpu(new_usage[i]);
|
2019-02-11 00:34:47 +00:00
|
|
|
kfree(new_base);
|
2019-01-21 20:32:13 +00:00
|
|
|
return ret;
|
2020-11-13 23:36:33 +00:00
|
|
|
err:
|
|
|
|
bch_err(c, "error updating replicas table: memory allocation failure");
|
2023-03-14 19:35:57 +00:00
|
|
|
ret = -BCH_ERR_ENOMEM_replicas_table;
|
2020-11-13 23:36:33 +00:00
|
|
|
goto out;
|
2019-01-21 20:32:13 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 22:12:00 +00:00
|
|
|
static unsigned reserve_journal_replicas(struct bch_fs *c,
|
|
|
|
struct bch_replicas_cpu *r)
|
|
|
|
{
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *e;
|
2019-01-24 22:12:00 +00:00
|
|
|
unsigned journal_res_u64s = 0;
|
|
|
|
|
|
|
|
/* nr_inodes: */
|
|
|
|
journal_res_u64s +=
|
|
|
|
DIV_ROUND_UP(sizeof(struct jset_entry_usage), sizeof(u64));
|
|
|
|
|
|
|
|
/* key_version: */
|
|
|
|
journal_res_u64s +=
|
|
|
|
DIV_ROUND_UP(sizeof(struct jset_entry_usage), sizeof(u64));
|
|
|
|
|
2019-02-10 00:20:57 +00:00
|
|
|
/* persistent_reserved: */
|
|
|
|
journal_res_u64s +=
|
|
|
|
DIV_ROUND_UP(sizeof(struct jset_entry_usage), sizeof(u64)) *
|
|
|
|
BCH_REPLICAS_MAX;
|
|
|
|
|
2019-01-24 22:12:00 +00:00
|
|
|
for_each_cpu_replicas_entry(r, e)
|
|
|
|
journal_res_u64s +=
|
2019-02-10 00:20:57 +00:00
|
|
|
DIV_ROUND_UP(sizeof(struct jset_entry_data_usage) +
|
2019-01-24 22:12:00 +00:00
|
|
|
e->nr_devs, sizeof(u64));
|
|
|
|
return journal_res_u64s;
|
|
|
|
}
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
noinline
|
|
|
|
static int bch2_mark_replicas_slowpath(struct bch_fs *c,
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *new_entry)
|
2017-03-17 06:18:50 +00:00
|
|
|
{
|
2018-12-01 15:32:48 +00:00
|
|
|
struct bch_replicas_cpu new_r, new_gc;
|
2020-04-29 16:57:04 +00:00
|
|
|
int ret = 0;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2019-09-20 18:28:35 +00:00
|
|
|
verify_replicas_entry(new_entry);
|
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
memset(&new_r, 0, sizeof(new_r));
|
|
|
|
memset(&new_gc, 0, sizeof(new_gc));
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
mutex_lock(&c->sb_lock);
|
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
if (c->replicas_gc.entries &&
|
|
|
|
!__replicas_has_entry(&c->replicas_gc, new_entry)) {
|
2023-11-26 02:42:08 +00:00
|
|
|
new_gc = cpu_replicas_add_entry(c, &c->replicas_gc, new_entry);
|
2023-03-14 19:35:57 +00:00
|
|
|
if (!new_gc.entries) {
|
|
|
|
ret = -BCH_ERR_ENOMEM_cpu_replicas;
|
2017-03-17 06:18:50 +00:00
|
|
|
goto err;
|
2023-03-14 19:35:57 +00:00
|
|
|
}
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
if (!__replicas_has_entry(&c->replicas, new_entry)) {
|
2023-11-26 02:42:08 +00:00
|
|
|
new_r = cpu_replicas_add_entry(c, &c->replicas, new_entry);
|
2023-03-14 19:35:57 +00:00
|
|
|
if (!new_r.entries) {
|
|
|
|
ret = -BCH_ERR_ENOMEM_cpu_replicas;
|
2017-03-17 06:18:50 +00:00
|
|
|
goto err;
|
2023-03-14 19:35:57 +00:00
|
|
|
}
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
ret = bch2_cpu_replicas_to_sb_replicas(c, &new_r);
|
2017-03-17 06:18:50 +00:00
|
|
|
if (ret)
|
|
|
|
goto err;
|
2019-01-24 22:12:00 +00:00
|
|
|
|
|
|
|
bch2_journal_entry_res_resize(&c->journal,
|
|
|
|
&c->replicas_journal_res,
|
|
|
|
reserve_journal_replicas(c, &new_r));
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
if (!new_r.entries &&
|
|
|
|
!new_gc.entries)
|
|
|
|
goto out;
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
/* allocations done, now commit: */
|
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
if (new_r.entries)
|
2017-03-17 06:18:50 +00:00
|
|
|
bch2_write_super(c);
|
|
|
|
|
|
|
|
/* don't update in memory replicas until changes are persistent */
|
2018-12-01 15:32:48 +00:00
|
|
|
percpu_down_write(&c->mark_lock);
|
|
|
|
if (new_r.entries)
|
2019-01-21 20:32:13 +00:00
|
|
|
ret = replicas_table_update(c, &new_r);
|
2018-12-01 15:32:48 +00:00
|
|
|
if (new_gc.entries)
|
|
|
|
swap(new_gc, c->replicas_gc);
|
|
|
|
percpu_up_write(&c->mark_lock);
|
|
|
|
out:
|
2017-03-17 06:18:50 +00:00
|
|
|
mutex_unlock(&c->sb_lock);
|
2018-12-01 15:32:48 +00:00
|
|
|
|
|
|
|
kfree(new_r.entries);
|
|
|
|
kfree(new_gc.entries);
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
return ret;
|
2020-04-29 16:57:04 +00:00
|
|
|
err:
|
2023-09-11 05:37:34 +00:00
|
|
|
bch_err_msg(c, ret, "adding replicas entry");
|
2020-04-29 16:57:04 +00:00
|
|
|
goto out;
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2023-11-09 18:52:35 +00:00
|
|
|
int bch2_mark_replicas(struct bch_fs *c, struct bch_replicas_entry_v1 *r)
|
2020-07-10 20:13:52 +00:00
|
|
|
{
|
2022-01-11 05:19:52 +00:00
|
|
|
return likely(bch2_replicas_marked(c, r))
|
|
|
|
? 0 : bch2_mark_replicas_slowpath(c, r);
|
2020-07-10 20:13:52 +00:00
|
|
|
}
|
|
|
|
|
2021-04-04 00:29:05 +00:00
|
|
|
/* replicas delta list: */
|
|
|
|
|
|
|
|
int bch2_replicas_delta_list_mark(struct bch_fs *c,
|
|
|
|
struct replicas_delta_list *r)
|
|
|
|
{
|
|
|
|
struct replicas_delta *d = r->d;
|
|
|
|
struct replicas_delta *top = (void *) r->d + r->used;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
for (d = r->d; !ret && d != top; d = replicas_delta_next(d))
|
|
|
|
ret = bch2_mark_replicas(c, &d->r);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Old replicas_gc mechanism: only used for journal replicas entries now, should
|
|
|
|
* die at some point:
|
|
|
|
*/
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
int bch2_replicas_gc_end(struct bch_fs *c, int ret)
|
|
|
|
{
|
|
|
|
lockdep_assert_held(&c->replicas_gc_lock);
|
|
|
|
|
|
|
|
mutex_lock(&c->sb_lock);
|
2019-02-11 00:34:47 +00:00
|
|
|
percpu_down_write(&c->mark_lock);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2023-10-27 03:02:42 +00:00
|
|
|
ret = ret ?:
|
|
|
|
bch2_cpu_replicas_to_sb_replicas(c, &c->replicas_gc) ?:
|
|
|
|
replicas_table_update(c, &c->replicas_gc);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
kfree(c->replicas_gc.entries);
|
|
|
|
c->replicas_gc.entries = NULL;
|
2019-02-11 00:34:47 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
percpu_up_write(&c->mark_lock);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2019-02-11 00:34:47 +00:00
|
|
|
if (!ret)
|
|
|
|
bch2_write_super(c);
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
mutex_unlock(&c->sb_lock);
|
2019-02-11 00:34:47 +00:00
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int bch2_replicas_gc_start(struct bch_fs *c, unsigned typemask)
|
|
|
|
{
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *e;
|
2018-12-01 15:32:48 +00:00
|
|
|
unsigned i = 0;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
|
|
|
lockdep_assert_held(&c->replicas_gc_lock);
|
|
|
|
|
|
|
|
mutex_lock(&c->sb_lock);
|
2018-12-01 15:32:48 +00:00
|
|
|
BUG_ON(c->replicas_gc.entries);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
c->replicas_gc.nr = 0;
|
|
|
|
c->replicas_gc.entry_size = 0;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2024-05-19 21:28:44 +00:00
|
|
|
for_each_cpu_replicas_entry(&c->replicas, e) {
|
|
|
|
/* Preserve unknown data types */
|
|
|
|
if (e->data_type >= BCH_DATA_NR ||
|
|
|
|
!((1 << e->data_type) & typemask)) {
|
2018-12-01 15:32:48 +00:00
|
|
|
c->replicas_gc.nr++;
|
|
|
|
c->replicas_gc.entry_size =
|
|
|
|
max_t(unsigned, c->replicas_gc.entry_size,
|
|
|
|
replicas_entry_bytes(e));
|
|
|
|
}
|
2024-05-19 21:28:44 +00:00
|
|
|
}
|
2018-12-01 15:32:48 +00:00
|
|
|
|
|
|
|
c->replicas_gc.entries = kcalloc(c->replicas_gc.nr,
|
|
|
|
c->replicas_gc.entry_size,
|
2021-01-22 00:14:37 +00:00
|
|
|
GFP_KERNEL);
|
2018-12-01 15:32:48 +00:00
|
|
|
if (!c->replicas_gc.entries) {
|
2017-03-17 06:18:50 +00:00
|
|
|
mutex_unlock(&c->sb_lock);
|
2020-04-29 16:57:04 +00:00
|
|
|
bch_err(c, "error allocating c->replicas_gc");
|
2023-03-14 19:35:57 +00:00
|
|
|
return -BCH_ERR_ENOMEM_replicas_gc;
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
for_each_cpu_replicas_entry(&c->replicas, e)
|
2024-05-19 21:28:44 +00:00
|
|
|
if (e->data_type >= BCH_DATA_NR ||
|
|
|
|
!((1 << e->data_type) & typemask))
|
2018-12-01 15:32:48 +00:00
|
|
|
memcpy(cpu_replicas_entry(&c->replicas_gc, i++),
|
|
|
|
e, c->replicas_gc.entry_size);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
bch2_cpu_replicas_sort(&c->replicas_gc);
|
2017-03-17 06:18:50 +00:00
|
|
|
mutex_unlock(&c->sb_lock);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-05-02 22:22:12 +00:00
|
|
|
/*
|
|
|
|
* New much simpler mechanism for clearing out unneeded replicas entries - drop
|
|
|
|
* replicas entries that have 0 sectors used.
|
|
|
|
*
|
|
|
|
* However, we don't track sector counts for journal usage, so this doesn't drop
|
|
|
|
* any BCH_DATA_journal entries; the old bch2_replicas_gc_(start|end) mechanism
|
|
|
|
* is retained for that.
|
|
|
|
*/
|
2019-04-30 21:15:39 +00:00
|
|
|
int bch2_replicas_gc2(struct bch_fs *c)
|
|
|
|
{
|
|
|
|
struct bch_replicas_cpu new = { 0 };
|
|
|
|
unsigned i, nr;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
bch2_journal_meta(&c->journal);
|
|
|
|
retry:
|
|
|
|
nr = READ_ONCE(c->replicas.nr);
|
|
|
|
new.entry_size = READ_ONCE(c->replicas.entry_size);
|
|
|
|
new.entries = kcalloc(nr, new.entry_size, GFP_KERNEL);
|
2020-04-29 16:57:04 +00:00
|
|
|
if (!new.entries) {
|
|
|
|
bch_err(c, "error allocating c->replicas_gc");
|
2023-03-14 19:35:57 +00:00
|
|
|
return -BCH_ERR_ENOMEM_replicas_gc;
|
2020-04-29 16:57:04 +00:00
|
|
|
}
|
2019-04-30 21:15:39 +00:00
|
|
|
|
|
|
|
mutex_lock(&c->sb_lock);
|
|
|
|
percpu_down_write(&c->mark_lock);
|
|
|
|
|
|
|
|
if (nr != c->replicas.nr ||
|
|
|
|
new.entry_size != c->replicas.entry_size) {
|
|
|
|
percpu_up_write(&c->mark_lock);
|
|
|
|
mutex_unlock(&c->sb_lock);
|
|
|
|
kfree(new.entries);
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < c->replicas.nr; i++) {
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *e =
|
2019-04-30 21:15:39 +00:00
|
|
|
cpu_replicas_entry(&c->replicas, i);
|
|
|
|
|
2020-07-09 22:28:11 +00:00
|
|
|
if (e->data_type == BCH_DATA_journal ||
|
2021-01-10 18:38:09 +00:00
|
|
|
c->usage_base->replicas[i] ||
|
|
|
|
percpu_u64_get(&c->usage[0]->replicas[i]) ||
|
|
|
|
percpu_u64_get(&c->usage[1]->replicas[i]) ||
|
|
|
|
percpu_u64_get(&c->usage[2]->replicas[i]) ||
|
|
|
|
percpu_u64_get(&c->usage[3]->replicas[i]))
|
2019-04-30 21:15:39 +00:00
|
|
|
memcpy(cpu_replicas_entry(&new, new.nr++),
|
|
|
|
e, new.entry_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
bch2_cpu_replicas_sort(&new);
|
|
|
|
|
2023-10-27 03:02:42 +00:00
|
|
|
ret = bch2_cpu_replicas_to_sb_replicas(c, &new) ?:
|
|
|
|
replicas_table_update(c, &new);
|
2019-04-30 21:15:39 +00:00
|
|
|
|
|
|
|
kfree(new.entries);
|
|
|
|
|
|
|
|
percpu_up_write(&c->mark_lock);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
bch2_write_super(c);
|
|
|
|
|
|
|
|
mutex_unlock(&c->sb_lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-01-25 00:09:49 +00:00
|
|
|
int bch2_replicas_set_usage(struct bch_fs *c,
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *r,
|
2019-01-25 00:09:49 +00:00
|
|
|
u64 sectors)
|
|
|
|
{
|
|
|
|
int ret, idx = bch2_replicas_entry_idx(c, r);
|
|
|
|
|
|
|
|
if (idx < 0) {
|
|
|
|
struct bch_replicas_cpu n;
|
|
|
|
|
2023-11-26 02:42:08 +00:00
|
|
|
n = cpu_replicas_add_entry(c, &c->replicas, r);
|
2019-01-25 00:09:49 +00:00
|
|
|
if (!n.entries)
|
2023-03-14 19:35:57 +00:00
|
|
|
return -BCH_ERR_ENOMEM_cpu_replicas;
|
2019-01-25 00:09:49 +00:00
|
|
|
|
|
|
|
ret = replicas_table_update(c, &n);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
kfree(n.entries);
|
|
|
|
|
|
|
|
idx = bch2_replicas_entry_idx(c, r);
|
|
|
|
BUG_ON(ret < 0);
|
|
|
|
}
|
|
|
|
|
2019-02-11 00:34:47 +00:00
|
|
|
c->usage_base->replicas[idx] = sectors;
|
2019-01-25 00:09:49 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
/* Replicas tracking - superblock: */
|
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
static int
|
|
|
|
__bch2_sb_replicas_to_cpu_replicas(struct bch_sb_field_replicas *sb_r,
|
|
|
|
struct bch_replicas_cpu *cpu_r)
|
2017-03-17 06:18:50 +00:00
|
|
|
{
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *e, *dst;
|
2018-10-30 18:32:47 +00:00
|
|
|
unsigned nr = 0, entry_size = 0, idx = 0;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-10-30 18:32:47 +00:00
|
|
|
for_each_replicas_entry(sb_r, e) {
|
|
|
|
entry_size = max_t(unsigned, entry_size,
|
|
|
|
replicas_entry_bytes(e));
|
|
|
|
nr++;
|
|
|
|
}
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2021-01-22 00:14:37 +00:00
|
|
|
cpu_r->entries = kcalloc(nr, entry_size, GFP_KERNEL);
|
2018-12-01 15:32:48 +00:00
|
|
|
if (!cpu_r->entries)
|
2023-03-14 19:35:57 +00:00
|
|
|
return -BCH_ERR_ENOMEM_cpu_replicas;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
|
|
|
cpu_r->nr = nr;
|
|
|
|
cpu_r->entry_size = entry_size;
|
|
|
|
|
2018-10-30 18:32:47 +00:00
|
|
|
for_each_replicas_entry(sb_r, e) {
|
|
|
|
dst = cpu_replicas_entry(cpu_r, idx++);
|
|
|
|
memcpy(dst, e, replicas_entry_bytes(e));
|
2021-02-02 20:56:44 +00:00
|
|
|
bch2_replicas_entry_sort(dst);
|
2018-10-30 18:32:47 +00:00
|
|
|
}
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
return 0;
|
2018-10-30 18:32:47 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
static int
|
|
|
|
__bch2_sb_replicas_v0_to_cpu_replicas(struct bch_sb_field_replicas_v0 *sb_r,
|
|
|
|
struct bch_replicas_cpu *cpu_r)
|
2018-10-30 18:32:47 +00:00
|
|
|
{
|
|
|
|
struct bch_replicas_entry_v0 *e;
|
|
|
|
unsigned nr = 0, entry_size = 0, idx = 0;
|
|
|
|
|
|
|
|
for_each_replicas_entry(sb_r, e) {
|
|
|
|
entry_size = max_t(unsigned, entry_size,
|
|
|
|
replicas_entry_bytes(e));
|
|
|
|
nr++;
|
|
|
|
}
|
|
|
|
|
2023-11-09 18:52:35 +00:00
|
|
|
entry_size += sizeof(struct bch_replicas_entry_v1) -
|
2018-10-30 18:32:47 +00:00
|
|
|
sizeof(struct bch_replicas_entry_v0);
|
|
|
|
|
2021-01-22 00:14:37 +00:00
|
|
|
cpu_r->entries = kcalloc(nr, entry_size, GFP_KERNEL);
|
2018-12-01 15:32:48 +00:00
|
|
|
if (!cpu_r->entries)
|
2023-03-14 19:35:57 +00:00
|
|
|
return -BCH_ERR_ENOMEM_cpu_replicas;
|
2018-10-30 18:32:47 +00:00
|
|
|
|
|
|
|
cpu_r->nr = nr;
|
|
|
|
cpu_r->entry_size = entry_size;
|
|
|
|
|
|
|
|
for_each_replicas_entry(sb_r, e) {
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *dst =
|
2018-10-30 18:32:47 +00:00
|
|
|
cpu_replicas_entry(cpu_r, idx++);
|
|
|
|
|
|
|
|
dst->data_type = e->data_type;
|
|
|
|
dst->nr_devs = e->nr_devs;
|
|
|
|
dst->nr_required = 1;
|
|
|
|
memcpy(dst->devs, e->devs, e->nr_devs);
|
2021-02-02 20:56:44 +00:00
|
|
|
bch2_replicas_entry_sort(dst);
|
2018-10-30 18:32:47 +00:00
|
|
|
}
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
return 0;
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int bch2_sb_replicas_to_cpu_replicas(struct bch_fs *c)
|
|
|
|
{
|
2018-10-30 18:32:47 +00:00
|
|
|
struct bch_sb_field_replicas *sb_v1;
|
|
|
|
struct bch_sb_field_replicas_v0 *sb_v0;
|
2018-12-01 15:32:48 +00:00
|
|
|
struct bch_replicas_cpu new_r = { 0, 0, NULL };
|
|
|
|
int ret = 0;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2023-09-26 21:49:34 +00:00
|
|
|
if ((sb_v1 = bch2_sb_field_get(c->disk_sb.sb, replicas)))
|
2018-12-01 15:32:48 +00:00
|
|
|
ret = __bch2_sb_replicas_to_cpu_replicas(sb_v1, &new_r);
|
2023-09-26 21:49:34 +00:00
|
|
|
else if ((sb_v0 = bch2_sb_field_get(c->disk_sb.sb, replicas_v0)))
|
2018-12-01 15:32:48 +00:00
|
|
|
ret = __bch2_sb_replicas_v0_to_cpu_replicas(sb_v0, &new_r);
|
|
|
|
if (ret)
|
2023-03-14 19:35:57 +00:00
|
|
|
return ret;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
bch2_cpu_replicas_sort(&new_r);
|
|
|
|
|
|
|
|
percpu_down_write(&c->mark_lock);
|
2019-01-24 22:12:00 +00:00
|
|
|
|
2019-01-21 20:32:13 +00:00
|
|
|
ret = replicas_table_update(c, &new_r);
|
2018-12-01 15:32:48 +00:00
|
|
|
percpu_up_write(&c->mark_lock);
|
2018-10-30 18:32:47 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
kfree(new_r.entries);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-10-30 18:32:47 +00:00
|
|
|
static int bch2_cpu_replicas_to_sb_replicas_v0(struct bch_fs *c,
|
|
|
|
struct bch_replicas_cpu *r)
|
|
|
|
{
|
|
|
|
struct bch_sb_field_replicas_v0 *sb_r;
|
|
|
|
struct bch_replicas_entry_v0 *dst;
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *src;
|
2018-10-30 18:32:47 +00:00
|
|
|
size_t bytes;
|
|
|
|
|
|
|
|
bytes = sizeof(struct bch_sb_field_replicas);
|
|
|
|
|
|
|
|
for_each_cpu_replicas_entry(r, src)
|
|
|
|
bytes += replicas_entry_bytes(src) - 1;
|
|
|
|
|
2023-09-26 21:49:34 +00:00
|
|
|
sb_r = bch2_sb_field_resize(&c->disk_sb, replicas_v0,
|
2018-10-30 18:32:47 +00:00
|
|
|
DIV_ROUND_UP(bytes, sizeof(u64)));
|
|
|
|
if (!sb_r)
|
2022-09-18 21:10:33 +00:00
|
|
|
return -BCH_ERR_ENOSPC_sb_replicas;
|
2018-10-30 18:32:47 +00:00
|
|
|
|
|
|
|
bch2_sb_field_delete(&c->disk_sb, BCH_SB_FIELD_replicas);
|
2023-09-26 21:49:34 +00:00
|
|
|
sb_r = bch2_sb_field_get(c->disk_sb.sb, replicas_v0);
|
2018-10-30 18:32:47 +00:00
|
|
|
|
|
|
|
memset(&sb_r->entries, 0,
|
|
|
|
vstruct_end(&sb_r->field) -
|
|
|
|
(void *) &sb_r->entries);
|
|
|
|
|
|
|
|
dst = sb_r->entries;
|
|
|
|
for_each_cpu_replicas_entry(r, src) {
|
|
|
|
dst->data_type = src->data_type;
|
|
|
|
dst->nr_devs = src->nr_devs;
|
|
|
|
memcpy(dst->devs, src->devs, src->nr_devs);
|
|
|
|
|
|
|
|
dst = replicas_entry_next(dst);
|
|
|
|
|
|
|
|
BUG_ON((void *) dst > vstruct_end(&sb_r->field));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
static int bch2_cpu_replicas_to_sb_replicas(struct bch_fs *c,
|
|
|
|
struct bch_replicas_cpu *r)
|
|
|
|
{
|
|
|
|
struct bch_sb_field_replicas *sb_r;
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *dst, *src;
|
2018-10-30 18:32:47 +00:00
|
|
|
bool need_v1 = false;
|
2018-10-30 18:14:19 +00:00
|
|
|
size_t bytes;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
|
|
|
bytes = sizeof(struct bch_sb_field_replicas);
|
|
|
|
|
2018-10-30 18:32:47 +00:00
|
|
|
for_each_cpu_replicas_entry(r, src) {
|
2018-10-30 18:14:19 +00:00
|
|
|
bytes += replicas_entry_bytes(src);
|
2018-10-30 18:32:47 +00:00
|
|
|
if (src->nr_required != 1)
|
|
|
|
need_v1 = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!need_v1)
|
|
|
|
return bch2_cpu_replicas_to_sb_replicas_v0(c, r);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2023-09-26 21:49:34 +00:00
|
|
|
sb_r = bch2_sb_field_resize(&c->disk_sb, replicas,
|
2018-10-30 18:14:19 +00:00
|
|
|
DIV_ROUND_UP(bytes, sizeof(u64)));
|
2017-03-17 06:18:50 +00:00
|
|
|
if (!sb_r)
|
2022-09-18 21:10:33 +00:00
|
|
|
return -BCH_ERR_ENOSPC_sb_replicas;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-10-30 18:32:47 +00:00
|
|
|
bch2_sb_field_delete(&c->disk_sb, BCH_SB_FIELD_replicas_v0);
|
2023-09-26 21:49:34 +00:00
|
|
|
sb_r = bch2_sb_field_get(c->disk_sb.sb, replicas);
|
2018-10-30 18:32:47 +00:00
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
memset(&sb_r->entries, 0,
|
|
|
|
vstruct_end(&sb_r->field) -
|
|
|
|
(void *) &sb_r->entries);
|
|
|
|
|
2018-10-30 18:14:19 +00:00
|
|
|
dst = sb_r->entries;
|
|
|
|
for_each_cpu_replicas_entry(r, src) {
|
|
|
|
memcpy(dst, src, replicas_entry_bytes(src));
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-10-30 18:14:19 +00:00
|
|
|
dst = replicas_entry_next(dst);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-10-30 18:14:19 +00:00
|
|
|
BUG_ON((void *) dst > vstruct_end(&sb_r->field));
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-01-04 04:38:50 +00:00
|
|
|
static int bch2_cpu_replicas_validate(struct bch_replicas_cpu *cpu_r,
|
|
|
|
struct bch_sb *sb,
|
|
|
|
struct printbuf *err)
|
2018-10-30 18:14:19 +00:00
|
|
|
{
|
2023-11-26 02:42:08 +00:00
|
|
|
unsigned i;
|
2018-10-30 18:14:19 +00:00
|
|
|
|
2024-03-22 23:26:33 +00:00
|
|
|
sort_r(cpu_r->entries,
|
|
|
|
cpu_r->nr,
|
|
|
|
cpu_r->entry_size,
|
|
|
|
bch2_memcmp, NULL,
|
|
|
|
(void *)(size_t)cpu_r->entry_size);
|
2018-10-30 18:14:19 +00:00
|
|
|
|
2022-01-04 04:38:50 +00:00
|
|
|
for (i = 0; i < cpu_r->nr; i++) {
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *e =
|
2018-10-30 18:14:19 +00:00
|
|
|
cpu_replicas_entry(cpu_r, i);
|
|
|
|
|
2023-11-26 02:42:08 +00:00
|
|
|
int ret = bch2_replicas_entry_validate(e, sb, err);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2022-01-04 04:38:50 +00:00
|
|
|
if (i + 1 < cpu_r->nr) {
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *n =
|
2022-01-04 04:38:50 +00:00
|
|
|
cpu_replicas_entry(cpu_r, i + 1);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2022-01-04 04:38:50 +00:00
|
|
|
BUG_ON(memcmp(e, n, cpu_r->entry_size) > 0);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2022-01-04 04:38:50 +00:00
|
|
|
if (!memcmp(e, n, cpu_r->entry_size)) {
|
2023-02-04 02:01:40 +00:00
|
|
|
prt_printf(err, "duplicate replicas entry ");
|
2022-01-04 04:38:50 +00:00
|
|
|
bch2_replicas_entry_to_text(err, e);
|
2022-11-20 03:39:08 +00:00
|
|
|
return -BCH_ERR_invalid_sb_replicas;
|
2022-01-04 04:38:50 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2022-01-04 04:38:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-02-20 10:00:45 +00:00
|
|
|
static int bch2_sb_replicas_validate(struct bch_sb *sb, struct bch_sb_field *f,
|
2024-05-08 22:49:14 +00:00
|
|
|
enum bch_validate_flags flags, struct printbuf *err)
|
2022-01-04 04:38:50 +00:00
|
|
|
{
|
|
|
|
struct bch_sb_field_replicas *sb_r = field_to_type(f, replicas);
|
|
|
|
struct bch_replicas_cpu cpu_r;
|
|
|
|
int ret;
|
|
|
|
|
2023-03-14 19:35:57 +00:00
|
|
|
ret = __bch2_sb_replicas_to_cpu_replicas(sb_r, &cpu_r);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2022-01-04 04:38:50 +00:00
|
|
|
ret = bch2_cpu_replicas_validate(&cpu_r, sb, err);
|
2018-12-01 15:32:48 +00:00
|
|
|
kfree(cpu_r.entries);
|
2022-01-04 04:38:50 +00:00
|
|
|
return ret;
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 06:24:07 +00:00
|
|
|
static void bch2_sb_replicas_to_text(struct printbuf *out,
|
|
|
|
struct bch_sb *sb,
|
|
|
|
struct bch_sb_field *f)
|
2017-03-17 06:18:50 +00:00
|
|
|
{
|
2018-11-09 06:24:07 +00:00
|
|
|
struct bch_sb_field_replicas *r = field_to_type(f, replicas);
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *e;
|
2017-03-17 06:18:50 +00:00
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
for_each_replicas_entry(r, e) {
|
|
|
|
if (!first)
|
2023-02-04 02:01:40 +00:00
|
|
|
prt_printf(out, " ");
|
2017-03-17 06:18:50 +00:00
|
|
|
first = false;
|
|
|
|
|
2019-01-21 20:32:13 +00:00
|
|
|
bch2_replicas_entry_to_text(out, e);
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
2023-02-04 02:01:40 +00:00
|
|
|
prt_newline(out);
|
2017-03-17 06:18:50 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 06:24:07 +00:00
|
|
|
const struct bch_sb_field_ops bch_sb_field_ops_replicas = {
|
2022-02-20 10:00:45 +00:00
|
|
|
.validate = bch2_sb_replicas_validate,
|
2018-11-09 06:24:07 +00:00
|
|
|
.to_text = bch2_sb_replicas_to_text,
|
|
|
|
};
|
|
|
|
|
2022-02-20 10:00:45 +00:00
|
|
|
static int bch2_sb_replicas_v0_validate(struct bch_sb *sb, struct bch_sb_field *f,
|
2024-05-08 22:49:14 +00:00
|
|
|
enum bch_validate_flags flags, struct printbuf *err)
|
2018-10-30 18:32:47 +00:00
|
|
|
{
|
|
|
|
struct bch_sb_field_replicas_v0 *sb_r = field_to_type(f, replicas_v0);
|
2022-01-04 04:38:50 +00:00
|
|
|
struct bch_replicas_cpu cpu_r;
|
|
|
|
int ret;
|
2018-10-30 18:32:47 +00:00
|
|
|
|
2023-03-14 19:35:57 +00:00
|
|
|
ret = __bch2_sb_replicas_v0_to_cpu_replicas(sb_r, &cpu_r);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2018-10-30 18:32:47 +00:00
|
|
|
|
2022-01-04 04:38:50 +00:00
|
|
|
ret = bch2_cpu_replicas_validate(&cpu_r, sb, err);
|
2018-12-01 15:32:48 +00:00
|
|
|
kfree(cpu_r.entries);
|
2022-01-04 04:38:50 +00:00
|
|
|
return ret;
|
2018-10-30 18:32:47 +00:00
|
|
|
}
|
|
|
|
|
2022-02-20 10:00:45 +00:00
|
|
|
static void bch2_sb_replicas_v0_to_text(struct printbuf *out,
|
|
|
|
struct bch_sb *sb,
|
|
|
|
struct bch_sb_field *f)
|
|
|
|
{
|
|
|
|
struct bch_sb_field_replicas_v0 *sb_r = field_to_type(f, replicas_v0);
|
|
|
|
struct bch_replicas_entry_v0 *e;
|
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
for_each_replicas_entry(sb_r, e) {
|
|
|
|
if (!first)
|
2023-02-04 02:01:40 +00:00
|
|
|
prt_printf(out, " ");
|
2022-02-20 10:00:45 +00:00
|
|
|
first = false;
|
|
|
|
|
|
|
|
bch2_replicas_entry_v0_to_text(out, e);
|
|
|
|
}
|
2023-02-04 02:01:40 +00:00
|
|
|
prt_newline(out);
|
2022-02-20 10:00:45 +00:00
|
|
|
}
|
|
|
|
|
2018-10-30 18:32:47 +00:00
|
|
|
const struct bch_sb_field_ops bch_sb_field_ops_replicas_v0 = {
|
2022-02-20 10:00:45 +00:00
|
|
|
.validate = bch2_sb_replicas_v0_validate,
|
|
|
|
.to_text = bch2_sb_replicas_v0_to_text,
|
2018-10-30 18:32:47 +00:00
|
|
|
};
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
/* Query replicas: */
|
|
|
|
|
2021-02-07 04:17:26 +00:00
|
|
|
bool bch2_have_enough_devs(struct bch_fs *c, struct bch_devs_mask devs,
|
|
|
|
unsigned flags, bool print)
|
2017-03-17 06:18:50 +00:00
|
|
|
{
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *e;
|
2021-02-07 04:17:26 +00:00
|
|
|
bool ret = true;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2018-12-01 15:32:48 +00:00
|
|
|
percpu_down_read(&c->mark_lock);
|
|
|
|
for_each_cpu_replicas_entry(&c->replicas, e) {
|
2024-04-30 19:45:05 +00:00
|
|
|
unsigned nr_online = 0, nr_failed = 0, dflags = 0;
|
2021-02-07 04:17:26 +00:00
|
|
|
bool metadata = e->data_type < BCH_DATA_user;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2021-10-21 04:38:13 +00:00
|
|
|
if (e->data_type == BCH_DATA_cached)
|
|
|
|
continue;
|
|
|
|
|
2024-04-30 19:45:05 +00:00
|
|
|
rcu_read_lock();
|
|
|
|
for (unsigned i = 0; i < e->nr_devs; i++) {
|
2021-02-07 04:17:26 +00:00
|
|
|
nr_online += test_bit(e->devs[i], devs.d);
|
2024-04-30 19:45:05 +00:00
|
|
|
|
|
|
|
struct bch_dev *ca = bch2_dev_rcu(c, e->devs[i]);
|
|
|
|
nr_failed += ca && ca->mi.state == BCH_MEMBER_STATE_failed;
|
2021-04-03 03:41:10 +00:00
|
|
|
}
|
2024-04-30 19:45:05 +00:00
|
|
|
rcu_read_unlock();
|
2021-04-03 03:41:10 +00:00
|
|
|
|
|
|
|
if (nr_failed == e->nr_devs)
|
|
|
|
continue;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2021-02-07 04:17:26 +00:00
|
|
|
if (nr_online < e->nr_required)
|
|
|
|
dflags |= metadata
|
|
|
|
? BCH_FORCE_IF_METADATA_LOST
|
|
|
|
: BCH_FORCE_IF_DATA_LOST;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2021-02-07 04:17:26 +00:00
|
|
|
if (nr_online < e->nr_devs)
|
|
|
|
dflags |= metadata
|
|
|
|
? BCH_FORCE_IF_METADATA_DEGRADED
|
|
|
|
: BCH_FORCE_IF_DATA_DEGRADED;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2021-02-07 04:17:26 +00:00
|
|
|
if (dflags & ~flags) {
|
|
|
|
if (print) {
|
2022-02-25 18:18:19 +00:00
|
|
|
struct printbuf buf = PRINTBUF;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2022-02-25 18:18:19 +00:00
|
|
|
bch2_replicas_entry_to_text(&buf, e);
|
2021-02-07 04:17:26 +00:00
|
|
|
bch_err(c, "insufficient devices online (%u) for replicas entry %s",
|
2022-02-25 18:18:19 +00:00
|
|
|
nr_online, buf.buf);
|
|
|
|
printbuf_exit(&buf);
|
2021-02-07 04:17:26 +00:00
|
|
|
}
|
|
|
|
ret = false;
|
|
|
|
break;
|
|
|
|
}
|
2017-03-17 06:18:50 +00:00
|
|
|
|
2021-02-07 04:17:26 +00:00
|
|
|
}
|
2018-12-01 15:32:48 +00:00
|
|
|
percpu_up_read(&c->mark_lock);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-02-20 10:00:45 +00:00
|
|
|
unsigned bch2_sb_dev_has_data(struct bch_sb *sb, unsigned dev)
|
2017-03-17 06:18:50 +00:00
|
|
|
{
|
2022-02-20 10:00:45 +00:00
|
|
|
struct bch_sb_field_replicas *replicas;
|
|
|
|
struct bch_sb_field_replicas_v0 *replicas_v0;
|
2024-05-19 21:28:44 +00:00
|
|
|
unsigned data_has = 0;
|
2022-02-20 10:00:45 +00:00
|
|
|
|
2023-09-26 21:49:34 +00:00
|
|
|
replicas = bch2_sb_field_get(sb, replicas);
|
|
|
|
replicas_v0 = bch2_sb_field_get(sb, replicas_v0);
|
2022-02-20 10:00:45 +00:00
|
|
|
|
|
|
|
if (replicas) {
|
2023-11-09 18:52:35 +00:00
|
|
|
struct bch_replicas_entry_v1 *r;
|
2022-02-20 10:00:45 +00:00
|
|
|
|
2024-05-19 21:28:44 +00:00
|
|
|
for_each_replicas_entry(replicas, r) {
|
|
|
|
if (r->data_type >= sizeof(data_has) * 8)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < r->nr_devs; i++)
|
2022-02-20 10:00:45 +00:00
|
|
|
if (r->devs[i] == dev)
|
|
|
|
data_has |= 1 << r->data_type;
|
2024-05-19 21:28:44 +00:00
|
|
|
}
|
|
|
|
|
2022-02-20 10:00:45 +00:00
|
|
|
} else if (replicas_v0) {
|
|
|
|
struct bch_replicas_entry_v0 *r;
|
|
|
|
|
2024-05-19 21:28:44 +00:00
|
|
|
for_each_replicas_entry_v0(replicas_v0, r) {
|
|
|
|
if (r->data_type >= sizeof(data_has) * 8)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < r->nr_devs; i++)
|
2022-02-20 10:00:45 +00:00
|
|
|
if (r->devs[i] == dev)
|
|
|
|
data_has |= 1 << r->data_type;
|
2024-05-19 21:28:44 +00:00
|
|
|
}
|
2022-02-20 10:00:45 +00:00
|
|
|
}
|
2017-03-17 06:18:50 +00:00
|
|
|
|
|
|
|
|
2022-02-20 10:00:45 +00:00
|
|
|
return data_has;
|
|
|
|
}
|
2018-10-30 18:14:19 +00:00
|
|
|
|
2022-02-20 10:00:45 +00:00
|
|
|
unsigned bch2_dev_has_data(struct bch_fs *c, struct bch_dev *ca)
|
|
|
|
{
|
|
|
|
unsigned ret;
|
|
|
|
|
|
|
|
mutex_lock(&c->sb_lock);
|
|
|
|
ret = bch2_sb_dev_has_data(c->disk_sb.sb, ca->dev_idx);
|
|
|
|
mutex_unlock(&c->sb_lock);
|
2017-03-17 06:18:50 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2019-01-24 22:12:00 +00:00
|
|
|
|
2021-04-24 04:24:25 +00:00
|
|
|
void bch2_fs_replicas_exit(struct bch_fs *c)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
kfree(c->usage_scratch);
|
|
|
|
for (i = 0; i < ARRAY_SIZE(c->usage); i++)
|
|
|
|
free_percpu(c->usage[i]);
|
|
|
|
kfree(c->usage_base);
|
|
|
|
kfree(c->replicas.entries);
|
|
|
|
kfree(c->replicas_gc.entries);
|
|
|
|
|
|
|
|
mempool_exit(&c->replicas_delta_pool);
|
|
|
|
}
|
|
|
|
|
2019-01-24 22:12:00 +00:00
|
|
|
int bch2_fs_replicas_init(struct bch_fs *c)
|
|
|
|
{
|
2021-02-03 18:10:55 +00:00
|
|
|
bch2_journal_entry_res_resize(&c->journal,
|
|
|
|
&c->replicas_journal_res,
|
|
|
|
reserve_journal_replicas(c, &c->replicas));
|
2019-02-15 01:39:17 +00:00
|
|
|
|
2021-04-24 04:24:25 +00:00
|
|
|
return mempool_init_kmalloc_pool(&c->replicas_delta_pool, 1,
|
|
|
|
REPLICAS_DELTA_LIST_MAX) ?:
|
|
|
|
replicas_table_update(c, &c->replicas);
|
2019-01-24 22:12:00 +00:00
|
|
|
}
|