mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-06 08:46:46 +00:00
bcachefs: cmp_int()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
a0e0bda117
commit
3ea2b1e128
12 changed files with 20 additions and 18 deletions
|
@ -687,16 +687,16 @@ static inline int bucket_alloc_cmp(alloc_heap *h,
|
||||||
struct alloc_heap_entry l,
|
struct alloc_heap_entry l,
|
||||||
struct alloc_heap_entry r)
|
struct alloc_heap_entry r)
|
||||||
{
|
{
|
||||||
return (l.key > r.key) - (l.key < r.key) ?:
|
return cmp_int(l.key, r.key) ?:
|
||||||
(l.nr < r.nr) - (l.nr > r.nr) ?:
|
cmp_int(r.nr, l.nr) ?:
|
||||||
(l.bucket > r.bucket) - (l.bucket < r.bucket);
|
cmp_int(l.bucket, r.bucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int bucket_idx_cmp(const void *_l, const void *_r)
|
static inline int bucket_idx_cmp(const void *_l, const void *_r)
|
||||||
{
|
{
|
||||||
const struct alloc_heap_entry *l = _l, *r = _r;
|
const struct alloc_heap_entry *l = _l, *r = _r;
|
||||||
|
|
||||||
return (l->bucket > r->bucket) - (l->bucket < r->bucket);
|
return cmp_int(l->bucket, r->bucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void find_reclaimable_buckets_lru(struct bch_fs *c, struct bch_dev *ca)
|
static void find_reclaimable_buckets_lru(struct bch_fs *c, struct bch_dev *ca)
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ static inline int __bkey_cmp_bits(const u64 *l, const u64 *r,
|
||||||
r_v = *r;
|
r_v = *r;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (l_v > r_v) - (l_v < r_v);
|
return cmp_int(l_v, r_v);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -217,8 +217,8 @@ void bch2_bkey_swab_key(const struct bkey_format *, struct bkey_packed *);
|
||||||
|
|
||||||
static __always_inline int bversion_cmp(struct bversion l, struct bversion r)
|
static __always_inline int bversion_cmp(struct bversion l, struct bversion r)
|
||||||
{
|
{
|
||||||
return (l.hi > r.hi) - (l.hi < r.hi) ?:
|
return cmp_int(l.hi, r.hi) ?:
|
||||||
(l.lo > r.lo) - (l.lo < r.lo);
|
cmp_int(l.lo, r.lo);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ZERO_VERSION ((struct bversion) { .hi = 0, .lo = 0 })
|
#define ZERO_VERSION ((struct bversion) { .hi = 0, .lo = 0 })
|
||||||
|
|
|
@ -465,7 +465,7 @@ static inline int bkey_iter_cmp(struct btree *b,
|
||||||
{
|
{
|
||||||
return bkey_cmp_packed(b, l, r)
|
return bkey_cmp_packed(b, l, r)
|
||||||
?: (int) bkey_deleted(r) - (int) bkey_deleted(l)
|
?: (int) bkey_deleted(r) - (int) bkey_deleted(l)
|
||||||
?: (l > r) - (l < r);
|
?: cmp_int(l, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int btree_node_iter_cmp(struct btree *b,
|
static inline int btree_node_iter_cmp(struct btree *b,
|
||||||
|
|
|
@ -55,7 +55,7 @@ static void btree_trans_unlock_write(struct btree_trans *trans)
|
||||||
static inline int btree_trans_cmp(struct btree_insert_entry l,
|
static inline int btree_trans_cmp(struct btree_insert_entry l,
|
||||||
struct btree_insert_entry r)
|
struct btree_insert_entry r)
|
||||||
{
|
{
|
||||||
return (l.deferred > r.deferred) - (l.deferred < r.deferred) ?:
|
return cmp_int(l.deferred, r.deferred) ?:
|
||||||
btree_iter_cmp(l.iter, r.iter);
|
btree_iter_cmp(l.iter, r.iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -951,7 +951,7 @@ static int unsigned_cmp(const void *_l, const void *_r)
|
||||||
unsigned l = *((const unsigned *) _l);
|
unsigned l = *((const unsigned *) _l);
|
||||||
unsigned r = *((const unsigned *) _r);
|
unsigned r = *((const unsigned *) _r);
|
||||||
|
|
||||||
return (l > r) - (l < r);
|
return cmp_int(l, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pick most common bucket size: */
|
/* pick most common bucket size: */
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct bch_inode_info {
|
||||||
|
|
||||||
static inline int ptrcmp(void *l, void *r)
|
static inline int ptrcmp(void *l, void *r)
|
||||||
{
|
{
|
||||||
return (l > r) - (l < r);
|
return cmp_int(l, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define __bch2_lock_inodes(_lock, ...) \
|
#define __bch2_lock_inodes(_lock, ...) \
|
||||||
|
|
|
@ -136,7 +136,7 @@ static int journal_seq_blacklist_table_cmp(const void *_l,
|
||||||
const struct journal_seq_blacklist_table_entry *l = _l;
|
const struct journal_seq_blacklist_table_entry *l = _l;
|
||||||
const struct journal_seq_blacklist_table_entry *r = _r;
|
const struct journal_seq_blacklist_table_entry *r = _r;
|
||||||
|
|
||||||
return (l->start > r->start) - (l->start < r->start);
|
return cmp_int(l->start, r->start);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bch2_journal_seq_is_blacklisted(struct bch_fs *c, u64 seq,
|
bool bch2_journal_seq_is_blacklisted(struct bch_fs *c, u64 seq,
|
||||||
|
|
|
@ -54,7 +54,7 @@ static inline int sectors_used_cmp(copygc_heap *heap,
|
||||||
struct copygc_heap_entry l,
|
struct copygc_heap_entry l,
|
||||||
struct copygc_heap_entry r)
|
struct copygc_heap_entry r)
|
||||||
{
|
{
|
||||||
return (l.sectors > r.sectors) - (l.sectors < r.sectors);
|
return cmp_int(l.sectors, r.sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bucket_offset_cmp(const void *_l, const void *_r, size_t size)
|
static int bucket_offset_cmp(const void *_l, const void *_r, size_t size)
|
||||||
|
@ -62,7 +62,7 @@ static int bucket_offset_cmp(const void *_l, const void *_r, size_t size)
|
||||||
const struct copygc_heap_entry *l = _l;
|
const struct copygc_heap_entry *l = _l;
|
||||||
const struct copygc_heap_entry *r = _r;
|
const struct copygc_heap_entry *r = _r;
|
||||||
|
|
||||||
return (l->offset > r->offset) - (l->offset < r->offset);
|
return cmp_int(l->offset, r->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool __copygc_pred(struct bch_dev *ca,
|
static bool __copygc_pred(struct bch_dev *ca,
|
||||||
|
|
|
@ -12,7 +12,7 @@ static int bch2_cpu_replicas_to_sb_replicas(struct bch_fs *,
|
||||||
|
|
||||||
static inline int u8_cmp(u8 l, u8 r)
|
static inline int u8_cmp(u8 l, u8 r)
|
||||||
{
|
{
|
||||||
return (l > r) - (l < r);
|
return cmp_int(l, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify_replicas_entry_sorted(struct bch_replicas_entry *e)
|
static void verify_replicas_entry_sorted(struct bch_replicas_entry *e)
|
||||||
|
|
|
@ -751,10 +751,10 @@ static unsigned bucket_oldest_gen_fn(struct bch_fs *c, struct bch_dev *ca,
|
||||||
|
|
||||||
static int unsigned_cmp(const void *_l, const void *_r)
|
static int unsigned_cmp(const void *_l, const void *_r)
|
||||||
{
|
{
|
||||||
unsigned l = *((unsigned *) _l);
|
const unsigned *l = _l;
|
||||||
unsigned r = *((unsigned *) _r);
|
const unsigned *r = _r;
|
||||||
|
|
||||||
return (l > r) - (l < r);
|
return cmp_int(*l, *r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t show_quantiles(struct bch_fs *c, struct bch_dev *ca,
|
static ssize_t show_quantiles(struct bch_fs *c, struct bch_dev *ca,
|
||||||
|
|
|
@ -743,4 +743,6 @@ static inline void acc_u64s_percpu(u64 *acc, const u64 __percpu *src,
|
||||||
|
|
||||||
u64 *bch2_acc_percpu_u64s(u64 __percpu *, unsigned);
|
u64 *bch2_acc_percpu_u64s(u64 __percpu *, unsigned);
|
||||||
|
|
||||||
|
#define cmp_int(l, r) ((l > r) - (l < r))
|
||||||
|
|
||||||
#endif /* _BCACHEFS_UTIL_H */
|
#endif /* _BCACHEFS_UTIL_H */
|
||||||
|
|
Loading…
Reference in a new issue