bcachefs: made changes to support clang, fixed a couple bugs
authorBrett Holman <bpholman5@gmail.com>
Mon, 17 May 2021 03:53:55 +0000 (21:53 -0600)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:03 +0000 (17:09 -0400)
fs/bcachefs/bset.c              edited prefetch macro to add clang support
fs/bcachefs/btree_iter.c        bugfix: initialize iter->real_pos in bch2_btree_iter_init for later use
fs/bcachefs/io.c                bugfix: eliminated undefined behavior (negative bitshift)
fs/bcachefs/buckets.c           bugfix: invert sign to handle 64bit abs()

Signed-off-by: Brett Holman <bpholman5@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bset.c
fs/bcachefs/btree_iter.c
fs/bcachefs/buckets.c
fs/bcachefs/io.c

index 8c038da3c1082a564fc649f3edc5ccf22b4d89bc..e569d9a9b906f8174855b21c32afb1ee187b135d 100644 (file)
@@ -1181,7 +1181,7 @@ static struct bkey_packed *bset_search_write_set(const struct btree *b,
 
 static inline void prefetch_four_cachelines(void *p)
 {
-#ifdef CONFIG_X86_64
+#if (CONFIG_X86_64 && !defined(__clang__))
        asm(".intel_syntax noprefix;"
            "prefetcht0 [%0 - 127 + 64 * 0];"
            "prefetcht0 [%0 - 127 + 64 * 1];"
index 8c343d5cec0c2666b07dd2fd77564eb452bdd224..745f1ac4f538d539bb01113767351dfca672e7ea 100644 (file)
@@ -1898,6 +1898,7 @@ static inline void bch2_btree_iter_init(struct btree_trans *trans,
        iter->trans                     = trans;
        iter->uptodate                  = BTREE_ITER_NEED_TRAVERSE;
        iter->btree_id                  = btree_id;
+       iter->real_pos                  = POS_MIN;
        iter->level                     = 0;
        iter->min_depth                 = 0;
        iter->locks_want                = 0;
index dad1c7d27bab5dc37391dabcf7e290e25d7d661d..a167e30e14121f1689536c6dbaeb47088ff58129 100644 (file)
@@ -1801,7 +1801,9 @@ static int bch2_trans_mark_reflink_p(struct btree_trans *trans,
        unsigned front_frag, back_frag;
        s64 ret = 0;
 
-       sectors = abs(sectors);
+       if (sectors < 0)
+               sectors = -sectors;
+
        BUG_ON(offset + sectors > p.k->size);
 
        front_frag = offset;
index 2b2e118114bd17f76297dc59688621700d8917db..9fc858a0a49623007c1b310bc7b8144142d30a3c 100644 (file)
@@ -121,7 +121,7 @@ void bch2_latency_acct(struct bch_dev *ca, u64 submit_time, int rw)
                 * the time:
                 */
                if (abs((int) (old - io_latency)) < (old >> 1) &&
-                   now & ~(~0 << 5))
+                   now & ~(~0U << 5))
                        break;
 
                new = ewma_add(old, io_latency, 5);