summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-02-12 02:17:02 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-04-05 23:43:22 -0400
commitd46939d673482171e2f34ca213fa0d7e30a24112 (patch)
tree805d6c32b52a42b2d44b065dffc657de0bb899df
parenta20c22c5410ad3cb67c3b6084278f15ff1428b69 (diff)
bcachefs: bch_acct_snapshot
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/buckets.c10
-rw-r--r--fs/bcachefs/disk_accounting.c3
-rw-r--r--fs/bcachefs/disk_accounting_format.h8
3 files changed, 20 insertions, 1 deletions
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index b0d88c40b373..2ccf5297ef49 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -577,6 +577,16 @@ static int __trigger_extent(struct btree_trans *trans,
return ret;
}
+ if (acc_replicas_key.replicas.nr_devs && !level && k.k->p.snapshot) {
+ struct disk_accounting_pos acc_snapshot_key = {
+ .type = BCH_DISK_ACCOUNTING_snapshot,
+ .snapshot.id = k.k->p.snapshot,
+ };
+ ret = bch2_disk_accounting_mod(trans, &acc_snapshot_key, &dirty_sectors, 1, gc);
+ if (ret)
+ return ret;
+ }
+
if (acct_compression_key.compression.type) {
if (flags & BTREE_TRIGGER_OVERWRITE)
bch2_u64s_neg(compression_acct, ARRAY_SIZE(compression_acct));
diff --git a/fs/bcachefs/disk_accounting.c b/fs/bcachefs/disk_accounting.c
index ec37b7c794ce..289008fda441 100644
--- a/fs/bcachefs/disk_accounting.c
+++ b/fs/bcachefs/disk_accounting.c
@@ -143,6 +143,9 @@ void bch2_accounting_key_to_text(struct printbuf *out, struct disk_accounting_po
case BCH_DISK_ACCOUNTING_compression:
bch2_prt_compression_type(out, k->compression.type);
break;
+ case BCH_DISK_ACCOUNTING_snapshot:
+ prt_printf(out, "id=%u", k->snapshot.id);
+ break;
}
}
diff --git a/fs/bcachefs/disk_accounting_format.h b/fs/bcachefs/disk_accounting_format.h
index 3feee34ceb9d..090108a4e0a5 100644
--- a/fs/bcachefs/disk_accounting_format.h
+++ b/fs/bcachefs/disk_accounting_format.h
@@ -100,7 +100,8 @@ static inline bool data_type_is_hidden(enum bch_data_type type)
x(replicas, 2) \
x(dev_data_type, 3) \
x(dev_stripe_buckets, 4) \
- x(compression, 5)
+ x(compression, 5) \
+ x(snapshot, 6)
enum disk_accounting_type {
#define x(f, nr) BCH_DISK_ACCOUNTING_##f = nr,
@@ -129,6 +130,10 @@ struct bch_acct_compression {
__u8 type;
};
+struct bch_acct_snapshot {
+ __u32 id;
+};
+
struct disk_accounting_pos {
union {
struct {
@@ -140,6 +145,7 @@ struct disk_accounting_pos {
struct bch_dev_data_type dev_data_type;
struct bch_dev_stripe_buckets dev_stripe_buckets;
struct bch_acct_compression compression;
+ struct bch_acct_snapshot snapshot;
};
};
struct bpos _pad;