bcachefs: kill bch_backpointer.bucket_offset usage
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 17 Nov 2024 23:26:54 +0000 (18:26 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Dec 2024 06:36:19 +0000 (01:36 -0500)
bch_backpointer.bucket_offset is going away - it's no longer needed
since we no longer store backpointers in alloc keys, the same
information is in the key position itself.

And we'll be reclaiming the space in bch_backpointer for the bucket
generation number.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/backpointers.c
fs/bcachefs/backpointers.h

index 5963217cd90c9f240702363bc6e7c56ecf77098d..620fa67db7a6cd3f964c554478fbb8b47cf6b4d5 100644 (file)
@@ -54,21 +54,20 @@ void bch2_backpointer_to_text(struct printbuf *out, struct bch_fs *c, struct bke
        struct bkey_s_c_backpointer bp = bkey_s_c_to_backpointer(k);
 
        rcu_read_lock();
-       struct bch_dev *ca = bch2_dev_rcu_noerror(c, k.k->p.inode);
+       struct bch_dev *ca = bch2_dev_rcu_noerror(c, bp.k->p.inode);
        if (ca) {
-               struct bpos bucket = bp_pos_to_bucket(ca, k.k->p);
+               u32 bucket_offset;
+               struct bpos bucket = bp_pos_to_bucket_and_offset(ca, bp.k->p, &bucket_offset);
                rcu_read_unlock();
-               prt_str(out, "bucket=");
-               bch2_bpos_to_text(out, bucket);
-               prt_str(out, " ");
+               prt_printf(out, "bucket=%llu:%llu:%u", bucket.inode, bucket.offset, bucket_offset);
        } else {
                rcu_read_unlock();
+               prt_printf(out, "sector=%llu:%llu", bp.k->p.inode, bp.k->p.offset >> MAX_EXTENT_COMPRESS_RATIO_SHIFT);
        }
 
        bch2_btree_id_level_to_text(out, bp.v->btree_id, bp.v->level);
-       prt_printf(out, " offset=%llu:%u len=%u pos=",
-                  (u64) (bp.v->bucket_offset >> MAX_EXTENT_COMPRESS_RATIO_SHIFT),
-                  (u32) bp.v->bucket_offset & ~(~0U << MAX_EXTENT_COMPRESS_RATIO_SHIFT),
+       prt_printf(out, " suboffset=%u len=%u pos=",
+                  (u32) bp.k->p.offset & ~(~0U << MAX_EXTENT_COMPRESS_RATIO_SHIFT),
                   bp.v->bucket_len);
        bch2_bpos_to_text(out, bp.v->pos);
 }
index 5f34a25b599a1e7e1adc5c1acc4a7bc434f5fade..d8a15f5fa7675a20ebf7c26331d5a1bc4ddefecd 100644 (file)
@@ -42,6 +42,14 @@ static inline struct bpos bp_pos_to_bucket(const struct bch_dev *ca, struct bpos
        return POS(bp_pos.inode, sector_to_bucket(ca, bucket_sector));
 }
 
+static inline struct bpos bp_pos_to_bucket_and_offset(const struct bch_dev *ca, struct bpos bp_pos,
+                                                     u32 *bucket_offset)
+{
+       u64 bucket_sector = bp_pos.offset >> MAX_EXTENT_COMPRESS_RATIO_SHIFT;
+
+       return POS(bp_pos.inode, sector_to_bucket_and_offset(ca, bucket_sector, bucket_offset));
+}
+
 static inline bool bp_pos_to_bucket_nodev_noerror(struct bch_fs *c, struct bpos bp_pos, struct bpos *bucket)
 {
        rcu_read_lock();