]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bcachefs: bch_acct_snapshot
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 12 Feb 2024 07:17:02 +0000 (02:17 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 14 Jul 2024 23:00:14 +0000 (19:00 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/buckets.c
fs/bcachefs/disk_accounting.c
fs/bcachefs/disk_accounting_format.h

index 06e968d98018d477dc80fd87b7a9853608324a0a..caa79e84f2cc3a04631f723346963658a0208164 100644 (file)
@@ -778,6 +778,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, &replicas_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));
index 8c6e76e50a9b0c58c2e0be5fd03bb0c7bce52df4..f980cd5af41dc496bc0b43fd064ad9addbd5133c 100644 (file)
@@ -146,6 +146,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;
        }
 }
 
index 2ded8ae650016f802df586dbab2ea2525d4d8c99..355b8545df88d6143b495feac8eacc657b67bf87 100644 (file)
@@ -100,7 +100,8 @@ static inline bool data_type_is_hidden(enum bch_data_type type)
        x(persistent_reserved,  1)              \
        x(replicas,             2)              \
        x(dev_data_type,        3)              \
-       x(compression,          4)
+       x(compression,          4)              \
+       x(snapshot,             5)
 
 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;