diff options
| author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-12-24 04:22:20 -0500 |
|---|---|---|
| committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:19 -0400 |
| commit | 09943313d70fd04eb9475ef9a83c1538234874fe (patch) | |
| tree | b095d2efa1d0db1c7eb20cd8784fe0bffd81ab8b /fs/bcachefs/super.h | |
| parent | 7243498de74d32d0afe3b923cd893a6b49f70c3c (diff) | |
bcachefs: Rewrite bch2_bucket_alloc_new_fs()
This changes bch2_bucket_alloc_new_fs() to a simple bump allocator that
doesn't need to use the in memory bucket array, part of a larger patch
series to entirely get rid of the in memory bucket array, except for
gc/fsck.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/super.h')
| -rw-r--r-- | fs/bcachefs/super.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/bcachefs/super.h b/fs/bcachefs/super.h index b151bffcd3a3..a5249c54426d 100644 --- a/fs/bcachefs/super.h +++ b/fs/bcachefs/super.h @@ -194,6 +194,27 @@ static inline struct bch_devs_mask bch2_online_devs(struct bch_fs *c) return devs; } +static inline bool is_superblock_bucket(struct bch_dev *ca, u64 b) +{ + struct bch_sb_layout *layout = &ca->disk_sb.sb->layout; + u64 b_offset = bucket_to_sector(ca, b); + u64 b_end = bucket_to_sector(ca, b + 1); + unsigned i; + + if (!b) + return true; + + for (i = 0; i < layout->nr_superblocks; i++) { + u64 offset = le64_to_cpu(layout->sb_offset[i]); + u64 end = offset + (1 << layout->sb_max_size_bits); + + if (!(offset >= b_end || end <= b_offset)) + return true; + } + + return false; +} + struct bch_fs *bch2_dev_to_fs(dev_t); struct bch_fs *bch2_uuid_to_fs(__uuid_t); |
