Lines Matching refs:ca

15 static inline u64 sector_to_bucket(const struct bch_dev *ca, sector_t s)  in sector_to_bucket()  argument
17 return div_u64(s, ca->mi.bucket_size); in sector_to_bucket()
20 static inline sector_t bucket_to_sector(const struct bch_dev *ca, size_t b) in bucket_to_sector() argument
22 return ((sector_t) b) * ca->mi.bucket_size; in bucket_to_sector()
25 static inline sector_t bucket_remainder(const struct bch_dev *ca, sector_t s) in bucket_remainder() argument
29 div_u64_rem(s, ca->mi.bucket_size, &remainder); in bucket_remainder()
33 static inline u64 sector_to_bucket_and_offset(const struct bch_dev *ca, sector_t s, u32 *offset) in sector_to_bucket_and_offset() argument
35 return div_u64_rem(s, ca->mi.bucket_size, offset); in sector_to_bucket_and_offset()
83 static inline struct bucket *gc_bucket(struct bch_dev *ca, size_t b) in gc_bucket() argument
85 return genradix_ptr(&ca->buckets_gc, b); in gc_bucket()
88 static inline struct bucket_gens *bucket_gens(struct bch_dev *ca) in bucket_gens() argument
90 return rcu_dereference_check(ca->bucket_gens, in bucket_gens()
91 !ca->fs || in bucket_gens()
92 percpu_rwsem_is_held(&ca->fs->mark_lock) || in bucket_gens()
93 lockdep_is_held(&ca->fs->state_lock) || in bucket_gens()
94 lockdep_is_held(&ca->bucket_lock)); in bucket_gens()
97 static inline u8 *bucket_gen(struct bch_dev *ca, size_t b) in bucket_gen() argument
99 struct bucket_gens *gens = bucket_gens(ca); in bucket_gen()
106 static inline int bucket_gen_get_rcu(struct bch_dev *ca, size_t b) in bucket_gen_get_rcu() argument
108 u8 *gen = bucket_gen(ca, b); in bucket_gen_get_rcu()
112 static inline int bucket_gen_get(struct bch_dev *ca, size_t b) in bucket_gen_get() argument
115 int ret = bucket_gen_get_rcu(ca, b); in bucket_gen_get()
120 static inline size_t PTR_BUCKET_NR(const struct bch_dev *ca, in PTR_BUCKET_NR() argument
123 return sector_to_bucket(ca, ptr->offset); in PTR_BUCKET_NR()
126 static inline struct bpos PTR_BUCKET_POS(const struct bch_dev *ca, in PTR_BUCKET_POS() argument
129 return POS(ptr->dev, PTR_BUCKET_NR(ca, ptr)); in PTR_BUCKET_POS()
132 static inline struct bpos PTR_BUCKET_POS_OFFSET(const struct bch_dev *ca, in PTR_BUCKET_POS_OFFSET() argument
136 return POS(ptr->dev, sector_to_bucket_and_offset(ca, ptr->offset, bucket_offset)); in PTR_BUCKET_POS_OFFSET()
139 static inline struct bucket *PTR_GC_BUCKET(struct bch_dev *ca, in PTR_GC_BUCKET() argument
142 return gc_bucket(ca, PTR_BUCKET_NR(ca, ptr)); in PTR_GC_BUCKET()
176 static inline int dev_ptr_stale_rcu(struct bch_dev *ca, const struct bch_extent_ptr *ptr) in dev_ptr_stale_rcu() argument
178 int gen = bucket_gen_get_rcu(ca, PTR_BUCKET_NR(ca, ptr)); in dev_ptr_stale_rcu()
186 static inline int dev_ptr_stale(struct bch_dev *ca, const struct bch_extent_ptr *ptr) in dev_ptr_stale() argument
189 int ret = dev_ptr_stale_rcu(ca, ptr); in dev_ptr_stale()
197 static inline struct bch_dev_usage bch2_dev_usage_read(struct bch_dev *ca) in bch2_dev_usage_read() argument
201 bch2_dev_usage_read_fast(ca, &ret); in bch2_dev_usage_read()
207 static inline u64 bch2_dev_buckets_reserved(struct bch_dev *ca, enum bch_watermark watermark) in bch2_dev_buckets_reserved() argument
215 reserved += ca->mi.nbuckets >> 6; in bch2_dev_buckets_reserved()
218 reserved += ca->mi.nbuckets >> 6; in bch2_dev_buckets_reserved()
221 reserved += ca->nr_btree_reserve; in bch2_dev_buckets_reserved()
224 reserved += ca->nr_btree_reserve; in bch2_dev_buckets_reserved()
235 static inline u64 dev_buckets_free(struct bch_dev *ca, in dev_buckets_free() argument
241 ca->nr_open_buckets - in dev_buckets_free()
242 bch2_dev_buckets_reserved(ca, watermark)); in dev_buckets_free()
245 static inline u64 __dev_buckets_available(struct bch_dev *ca, in __dev_buckets_available() argument
254 - ca->nr_open_buckets in __dev_buckets_available()
255 - bch2_dev_buckets_reserved(ca, watermark)); in __dev_buckets_available()
258 static inline u64 dev_buckets_available(struct bch_dev *ca, in dev_buckets_available() argument
261 return __dev_buckets_available(ca, bch2_dev_usage_read(ca), watermark); in dev_buckets_available()
311 static inline bool is_superblock_bucket(struct bch_dev *ca, u64 b) in is_superblock_bucket() argument
313 struct bch_sb_layout *layout = &ca->disk_sb.sb->layout; in is_superblock_bucket()
314 u64 b_offset = bucket_to_sector(ca, b); in is_superblock_bucket()
315 u64 b_end = bucket_to_sector(ca, b + 1); in is_superblock_bucket()