2017-03-17 06:18:50 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _BUCKETS_TYPES_H
|
|
|
|
#define _BUCKETS_TYPES_H
|
|
|
|
|
2018-07-24 17:33:07 +00:00
|
|
|
#include "bcachefs_format.h"
|
2017-03-17 06:18:50 +00:00
|
|
|
#include "util.h"
|
|
|
|
|
2018-07-22 02:57:20 +00:00
|
|
|
#define BUCKET_JOURNAL_SEQ_BITS 16
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
struct bucket_mark {
|
|
|
|
union {
|
2018-07-22 03:36:11 +00:00
|
|
|
atomic64_t v;
|
2017-03-17 06:18:50 +00:00
|
|
|
|
|
|
|
struct {
|
2018-07-22 03:36:11 +00:00
|
|
|
u8 gen;
|
|
|
|
u8 data_type:3,
|
|
|
|
owned_by_allocator:1,
|
|
|
|
journal_seq_valid:1,
|
|
|
|
stripe:1;
|
|
|
|
u16 dirty_sectors;
|
|
|
|
u16 cached_sectors;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* low bits of journal sequence number when this bucket was most
|
|
|
|
* recently modified: if journal_seq_valid is set, this bucket can't be
|
|
|
|
* reused until the journal sequence number written to disk is >= the
|
|
|
|
* bucket's journal sequence number:
|
|
|
|
*/
|
|
|
|
u16 journal_seq;
|
2017-03-17 06:18:50 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bucket {
|
|
|
|
union {
|
|
|
|
struct bucket_mark _mark;
|
|
|
|
const struct bucket_mark mark;
|
|
|
|
};
|
|
|
|
|
|
|
|
u16 io_time[2];
|
2019-02-12 00:27:33 +00:00
|
|
|
u8 oldest_gen;
|
2020-06-15 19:10:54 +00:00
|
|
|
u8 gc_gen;
|
2018-07-22 03:36:11 +00:00
|
|
|
unsigned gen_valid:1;
|
2020-07-23 03:11:48 +00:00
|
|
|
u8 ec_redundancy;
|
2017-03-17 06:18:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bucket_array {
|
|
|
|
struct rcu_head rcu;
|
|
|
|
u16 first_bucket;
|
|
|
|
size_t nbuckets;
|
|
|
|
struct bucket b[];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bch_dev_usage {
|
|
|
|
u64 buckets[BCH_DATA_NR];
|
|
|
|
u64 buckets_unavailable;
|
|
|
|
|
|
|
|
/* _compressed_ sectors: */
|
|
|
|
u64 sectors[BCH_DATA_NR];
|
|
|
|
u64 sectors_fragmented;
|
2020-06-19 01:06:42 +00:00
|
|
|
|
|
|
|
u64 buckets_ec;
|
|
|
|
u64 sectors_ec;
|
2017-03-17 06:18:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bch_fs_usage {
|
|
|
|
/* all fields are in units of 512 byte sectors: */
|
2019-02-14 23:38:52 +00:00
|
|
|
u64 hidden;
|
2019-03-30 02:22:45 +00:00
|
|
|
u64 btree;
|
2019-02-14 23:38:52 +00:00
|
|
|
u64 data;
|
|
|
|
u64 cached;
|
|
|
|
u64 reserved;
|
|
|
|
u64 nr_inodes;
|
2019-01-21 20:32:13 +00:00
|
|
|
|
2019-02-14 23:38:52 +00:00
|
|
|
/* XXX: add stats for compression ratio */
|
2019-01-21 20:32:13 +00:00
|
|
|
#if 0
|
2019-02-14 23:38:52 +00:00
|
|
|
u64 uncompressed;
|
|
|
|
u64 compressed;
|
2019-01-21 20:32:13 +00:00
|
|
|
#endif
|
2018-12-01 16:32:12 +00:00
|
|
|
|
|
|
|
/* broken out: */
|
2018-07-24 18:54:39 +00:00
|
|
|
|
2019-01-21 20:32:13 +00:00
|
|
|
u64 persistent_reserved[BCH_REPLICAS_MAX];
|
2019-02-14 23:38:52 +00:00
|
|
|
u64 replicas[];
|
2018-11-27 13:23:22 +00:00
|
|
|
};
|
|
|
|
|
2019-02-11 00:34:47 +00:00
|
|
|
struct bch_fs_usage_online {
|
|
|
|
u64 online_reserved;
|
|
|
|
struct bch_fs_usage u;
|
|
|
|
};
|
|
|
|
|
2018-11-27 13:23:22 +00:00
|
|
|
struct bch_fs_usage_short {
|
|
|
|
u64 capacity;
|
|
|
|
u64 used;
|
2019-02-14 23:38:52 +00:00
|
|
|
u64 free;
|
2018-11-27 13:23:22 +00:00
|
|
|
u64 nr_inodes;
|
2017-03-17 06:18:50 +00:00
|
|
|
};
|
|
|
|
|
2019-03-11 18:59:58 +00:00
|
|
|
struct replicas_delta {
|
|
|
|
s64 delta;
|
|
|
|
struct bch_replicas_entry r;
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
struct replicas_delta_list {
|
2019-05-15 19:47:43 +00:00
|
|
|
unsigned size;
|
|
|
|
unsigned used;
|
2019-10-20 02:22:29 +00:00
|
|
|
|
|
|
|
struct {} memset_start;
|
|
|
|
u64 nr_inodes;
|
|
|
|
u64 persistent_reserved[BCH_REPLICAS_MAX];
|
|
|
|
struct {} memset_end;
|
2019-03-11 18:59:58 +00:00
|
|
|
struct replicas_delta d[0];
|
|
|
|
};
|
|
|
|
|
2017-03-17 06:18:50 +00:00
|
|
|
/*
|
|
|
|
* A reservation for space on disk:
|
|
|
|
*/
|
|
|
|
struct disk_reservation {
|
2018-11-27 13:23:22 +00:00
|
|
|
u64 sectors;
|
|
|
|
u32 gen;
|
|
|
|
unsigned nr_replicas;
|
2017-03-17 06:18:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct copygc_heap_entry {
|
2020-07-11 20:28:54 +00:00
|
|
|
u8 dev;
|
2017-03-17 06:18:50 +00:00
|
|
|
u8 gen;
|
2020-07-23 03:11:48 +00:00
|
|
|
u8 replicas;
|
2020-08-12 17:49:09 +00:00
|
|
|
u16 fragmentation;
|
2017-03-17 06:18:50 +00:00
|
|
|
u32 sectors;
|
|
|
|
u64 offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef HEAP(struct copygc_heap_entry) copygc_heap;
|
|
|
|
|
|
|
|
#endif /* _BUCKETS_TYPES_H */
|