summaryrefslogtreecommitdiff
path: root/fs/bcachefs/buckets.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-12-06 19:52:58 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:13 +0300
commit641ab736437a3f9881467c0005b0d677194fff63 (patch)
tree1b20da644db6b5cf9c3341c28f63124e2971a0d1 /fs/bcachefs/buckets.h
parent57cb2142ed1aadf2bf737f732bc74e5649dbcb15 (diff)
downloadlinux-641ab736437a3f9881467c0005b0d677194fff63.tar.xz
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.h14
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)