diff options
| author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-12-06 11:52:58 -0500 |
|---|---|---|
| committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:13 -0400 |
| commit | 641ab736437a3f9881467c0005b0d677194fff63 (patch) | |
| tree | 1b20da644db6b5cf9c3341c28f63124e2971a0d1 /fs/bcachefs/buckets.h | |
| parent | 57cb2142ed1aadf2bf737f732bc74e5649dbcb15 (diff) | |
| download | linux-641ab736437a3f9881467c0005b0d677194fff63.tar.gz linux-641ab736437a3f9881467c0005b0d677194fff63.tar.bz2 linux-641ab736437a3f9881467c0005b0d677194fff63.zip | |
bcachefs: improve/clarify ptr_disk_sectors()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/buckets.h')
| -rw-r--r-- | fs/bcachefs/buckets.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/bcachefs/buckets.h b/fs/bcachefs/buckets.h index a13f7e068c61..d76e65316245 100644 --- a/fs/bcachefs/buckets.h +++ b/fs/bcachefs/buckets.h @@ -136,6 +136,20 @@ static inline u8 ptr_stale(struct bch_dev *ca, return gen_after(ptr_bucket_mark(ca, ptr).gen, ptr->gen); } +static inline unsigned __ptr_disk_sectors(struct extent_ptr_decoded p, + unsigned live_size) +{ + return live_size && p.crc.compression_type + ? max(1U, DIV_ROUND_UP(live_size * p.crc.compressed_size, + p.crc.uncompressed_size)) + : live_size; +} + +static inline unsigned ptr_disk_sectors(struct extent_ptr_decoded p) +{ + return __ptr_disk_sectors(p, p.crc.live_size); +} + /* bucket gc marks */ static inline unsigned bucket_sectors_used(struct bucket_mark mark) |
