bcachefs: kill bch2_fs_usage_read()
With bch2_ioctl_fs_usage(), this is now dead code. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
6b39638b84
commit
3afb8dbf03
@ -896,10 +896,6 @@ struct bch_fs {
|
|||||||
struct bch_fs_usage __percpu *usage_gc;
|
struct bch_fs_usage __percpu *usage_gc;
|
||||||
u64 __percpu *online_reserved;
|
u64 __percpu *online_reserved;
|
||||||
|
|
||||||
/* single element mempool: */
|
|
||||||
struct mutex usage_scratch_lock;
|
|
||||||
struct bch_fs_usage_online *usage_scratch;
|
|
||||||
|
|
||||||
struct io_clock io_clock[2];
|
struct io_clock io_clock[2];
|
||||||
|
|
||||||
/* JOURNAL SEQ BLACKLIST */
|
/* JOURNAL SEQ BLACKLIST */
|
||||||
|
@ -64,40 +64,6 @@ u64 bch2_fs_usage_read_one(struct bch_fs *c, u64 *v)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct bch_fs_usage_online *bch2_fs_usage_read(struct bch_fs *c)
|
|
||||||
{
|
|
||||||
struct bch_fs_usage_online *ret;
|
|
||||||
unsigned nr_replicas = READ_ONCE(c->replicas.nr);
|
|
||||||
unsigned seq, i;
|
|
||||||
retry:
|
|
||||||
ret = kmalloc(__fs_usage_online_u64s(nr_replicas) * sizeof(u64), GFP_KERNEL);
|
|
||||||
if (unlikely(!ret))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
percpu_down_read(&c->mark_lock);
|
|
||||||
|
|
||||||
if (nr_replicas != c->replicas.nr) {
|
|
||||||
nr_replicas = c->replicas.nr;
|
|
||||||
percpu_up_read(&c->mark_lock);
|
|
||||||
kfree(ret);
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret->online_reserved = percpu_u64_get(c->online_reserved);
|
|
||||||
|
|
||||||
do {
|
|
||||||
seq = read_seqcount_begin(&c->usage_lock);
|
|
||||||
unsafe_memcpy(&ret->u, c->usage_base,
|
|
||||||
__fs_usage_u64s(nr_replicas) * sizeof(u64),
|
|
||||||
"embedded variable length struct");
|
|
||||||
for (i = 0; i < ARRAY_SIZE(c->usage); i++)
|
|
||||||
acc_u64s_percpu((u64 *) &ret->u, (u64 __percpu *) c->usage[i],
|
|
||||||
__fs_usage_u64s(nr_replicas));
|
|
||||||
} while (read_seqcount_retry(&c->usage_lock, seq));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void bch2_fs_usage_acc_to_base(struct bch_fs *c, unsigned idx)
|
void bch2_fs_usage_acc_to_base(struct bch_fs *c, unsigned idx)
|
||||||
{
|
{
|
||||||
unsigned u64s = fs_usage_u64s(c);
|
unsigned u64s = fs_usage_u64s(c);
|
||||||
|
@ -300,8 +300,6 @@ static inline unsigned dev_usage_u64s(void)
|
|||||||
|
|
||||||
u64 bch2_fs_usage_read_one(struct bch_fs *, u64 *);
|
u64 bch2_fs_usage_read_one(struct bch_fs *, u64 *);
|
||||||
|
|
||||||
struct bch_fs_usage_online *bch2_fs_usage_read(struct bch_fs *);
|
|
||||||
|
|
||||||
void bch2_fs_usage_acc_to_base(struct bch_fs *, unsigned);
|
void bch2_fs_usage_acc_to_base(struct bch_fs *, unsigned);
|
||||||
|
|
||||||
void bch2_fs_usage_to_text(struct printbuf *,
|
void bch2_fs_usage_to_text(struct printbuf *,
|
||||||
|
@ -518,9 +518,7 @@ static long bch2_ioctl_fs_usage(struct bch_fs *c,
|
|||||||
struct bch_ioctl_fs_usage __user *user_arg)
|
struct bch_ioctl_fs_usage __user *user_arg)
|
||||||
{
|
{
|
||||||
struct bch_ioctl_fs_usage arg;
|
struct bch_ioctl_fs_usage arg;
|
||||||
struct bch_fs_usage_online *src = NULL;
|
|
||||||
darray_char replicas = {};
|
darray_char replicas = {};
|
||||||
unsigned i;
|
|
||||||
u32 replica_entries_bytes;
|
u32 replica_entries_bytes;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -536,25 +534,26 @@ static long bch2_ioctl_fs_usage(struct bch_fs *c,
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
struct bch_fs_usage_short u = bch2_fs_usage_read_short(c);
|
||||||
arg.capacity = c->capacity;
|
arg.capacity = c->capacity;
|
||||||
arg.used = bch2_fs_sectors_used(c, src);
|
arg.used = u.used;
|
||||||
arg.online_reserved = src->online_reserved;
|
arg.online_reserved = percpu_u64_get(c->online_reserved);
|
||||||
arg.replica_entries_bytes = replicas.nr;
|
arg.replica_entries_bytes = replicas.nr;
|
||||||
|
|
||||||
src = bch2_fs_usage_read(c);
|
for (unsigned i = 0; i < BCH_REPLICAS_MAX; i++) {
|
||||||
if (!src) {
|
struct disk_accounting_pos k = {
|
||||||
ret = -ENOMEM;
|
.type = BCH_DISK_ACCOUNTING_persistent_reserved,
|
||||||
goto err;
|
.persistent_reserved.nr_replicas = i,
|
||||||
}
|
};
|
||||||
|
|
||||||
for (i = 0; i < BCH_REPLICAS_MAX; i++)
|
bch2_accounting_mem_read(c,
|
||||||
arg.persistent_reserved[i] = src->u.persistent_reserved[i];
|
disk_accounting_pos_to_bpos(&k),
|
||||||
percpu_up_read(&c->mark_lock);
|
&arg.persistent_reserved[i], 1);
|
||||||
|
}
|
||||||
|
|
||||||
ret = copy_to_user_errcode(user_arg, &arg, sizeof(arg));
|
ret = copy_to_user_errcode(user_arg, &arg, sizeof(arg));
|
||||||
err:
|
err:
|
||||||
darray_exit(&replicas);
|
darray_exit(&replicas);
|
||||||
kfree(src);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
* replay).
|
* replay).
|
||||||
*
|
*
|
||||||
* To do a disk accounting update:
|
* To do a disk accounting update:
|
||||||
* - initialize a disk_accounting_key, to specify which counter is being update
|
* - initialize a disk_accounting_pos, to specify which counter is being update
|
||||||
* - initialize counter deltas, as an array of 1-3 s64s
|
* - initialize counter deltas, as an array of 1-3 s64s
|
||||||
* - call bch2_disk_accounting_mod()
|
* - call bch2_disk_accounting_mod()
|
||||||
*
|
*
|
||||||
|
@ -308,13 +308,10 @@ static int replicas_table_update(struct bch_fs *c,
|
|||||||
struct bch_replicas_cpu *new_r)
|
struct bch_replicas_cpu *new_r)
|
||||||
{
|
{
|
||||||
struct bch_fs_usage __percpu *new_usage[JOURNAL_BUF_NR];
|
struct bch_fs_usage __percpu *new_usage[JOURNAL_BUF_NR];
|
||||||
struct bch_fs_usage_online *new_scratch = NULL;
|
|
||||||
struct bch_fs_usage __percpu *new_gc = NULL;
|
struct bch_fs_usage __percpu *new_gc = NULL;
|
||||||
struct bch_fs_usage *new_base = NULL;
|
struct bch_fs_usage *new_base = NULL;
|
||||||
unsigned i, bytes = sizeof(struct bch_fs_usage) +
|
unsigned i, bytes = sizeof(struct bch_fs_usage) +
|
||||||
sizeof(u64) * new_r->nr;
|
sizeof(u64) * new_r->nr;
|
||||||
unsigned scratch_bytes = sizeof(struct bch_fs_usage_online) +
|
|
||||||
sizeof(u64) * new_r->nr;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
memset(new_usage, 0, sizeof(new_usage));
|
memset(new_usage, 0, sizeof(new_usage));
|
||||||
@ -325,7 +322,6 @@ static int replicas_table_update(struct bch_fs *c,
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!(new_base = kzalloc(bytes, GFP_KERNEL)) ||
|
if (!(new_base = kzalloc(bytes, GFP_KERNEL)) ||
|
||||||
!(new_scratch = kmalloc(scratch_bytes, GFP_KERNEL)) ||
|
|
||||||
(c->usage_gc &&
|
(c->usage_gc &&
|
||||||
!(new_gc = __alloc_percpu_gfp(bytes, sizeof(u64), GFP_KERNEL))))
|
!(new_gc = __alloc_percpu_gfp(bytes, sizeof(u64), GFP_KERNEL))))
|
||||||
goto err;
|
goto err;
|
||||||
@ -344,12 +340,10 @@ static int replicas_table_update(struct bch_fs *c,
|
|||||||
for (i = 0; i < ARRAY_SIZE(new_usage); i++)
|
for (i = 0; i < ARRAY_SIZE(new_usage); i++)
|
||||||
swap(c->usage[i], new_usage[i]);
|
swap(c->usage[i], new_usage[i]);
|
||||||
swap(c->usage_base, new_base);
|
swap(c->usage_base, new_base);
|
||||||
swap(c->usage_scratch, new_scratch);
|
|
||||||
swap(c->usage_gc, new_gc);
|
swap(c->usage_gc, new_gc);
|
||||||
swap(c->replicas, *new_r);
|
swap(c->replicas, *new_r);
|
||||||
out:
|
out:
|
||||||
free_percpu(new_gc);
|
free_percpu(new_gc);
|
||||||
kfree(new_scratch);
|
|
||||||
for (i = 0; i < ARRAY_SIZE(new_usage); i++)
|
for (i = 0; i < ARRAY_SIZE(new_usage); i++)
|
||||||
free_percpu(new_usage[i]);
|
free_percpu(new_usage[i]);
|
||||||
kfree(new_base);
|
kfree(new_base);
|
||||||
@ -1028,7 +1022,6 @@ void bch2_fs_replicas_exit(struct bch_fs *c)
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
kfree(c->usage_scratch);
|
|
||||||
for (i = 0; i < ARRAY_SIZE(c->usage); i++)
|
for (i = 0; i < ARRAY_SIZE(c->usage); i++)
|
||||||
free_percpu(c->usage[i]);
|
free_percpu(c->usage[i]);
|
||||||
kfree(c->usage_base);
|
kfree(c->usage_base);
|
||||||
|
@ -791,8 +791,6 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
|
|||||||
|
|
||||||
INIT_LIST_HEAD(&c->list);
|
INIT_LIST_HEAD(&c->list);
|
||||||
|
|
||||||
mutex_init(&c->usage_scratch_lock);
|
|
||||||
|
|
||||||
mutex_init(&c->bio_bounce_pages_lock);
|
mutex_init(&c->bio_bounce_pages_lock);
|
||||||
mutex_init(&c->snapshot_table_lock);
|
mutex_init(&c->snapshot_table_lock);
|
||||||
init_rwsem(&c->snapshot_create_lock);
|
init_rwsem(&c->snapshot_create_lock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user