bcachefs: Build fixes for 32bit x86
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 5 Nov 2020 17:16:05 +0000 (12:16 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:46 +0000 (17:08 -0400)
PAGE_SIZE and size_t are not unsigned longs on 32 bit, annoying...

also switch to atomic64_cmpxchg instead of cmpxchg() for
journal_seq_copy, as atomic64_cmpxchg has a fallback that uses spinlocks
for when it's not supported.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/ec.c
fs/bcachefs/fs.c
fs/bcachefs/io.c

index e5033b392432559722e38c2a05c60b78bc333c94..42331f0e54e7d69f24f2d409f05bd1d928d23cc4 100644 (file)
@@ -1586,7 +1586,7 @@ void bch2_stripes_heap_to_text(struct printbuf *out, struct bch_fs *c)
        size_t i;
 
        spin_lock(&c->ec_stripes_heap_lock);
-       for (i = 0; i < min(h->used, 20UL); i++) {
+       for (i = 0; i < min_t(size_t, h->used, 20); i++) {
                m = genradix_ptr(&c->stripes[0], h->data[i].idx);
 
                pr_buf(out, "%zu %u/%u+%u\n", h->data[i].idx,
index 917a08ddc14884c97aa027a0cbde177cc0730f4f..3e3ab4e53f33f4515d1c404146aa375e51574839 100644 (file)
@@ -44,6 +44,11 @@ static void journal_seq_copy(struct bch_fs *c,
                             struct bch_inode_info *dst,
                             u64 journal_seq)
 {
+       /*
+        * atomic64_cmpxchg has a fallback for archs that don't support it,
+        * cmpxchg does not:
+        */
+       atomic64_t *dst_seq = (void *) &dst->ei_journal_seq;
        u64 old, v = READ_ONCE(dst->ei_journal_seq);
 
        do {
@@ -51,7 +56,7 @@ static void journal_seq_copy(struct bch_fs *c,
 
                if (old >= journal_seq)
                        break;
-       } while ((v = cmpxchg(&dst->ei_journal_seq, old, journal_seq)) != old);
+       } while ((v = atomic64_cmpxchg(dst_seq, old, journal_seq)) != old);
 
        bch2_journal_set_has_inum(&c->journal, dst->v.i_ino, journal_seq);
 }
index 346d77d68adea4d788142e6d2087462ac63f2613..6df99ac013a1f008e69286350ba569db43f813ce 100644 (file)
@@ -180,7 +180,7 @@ void bch2_bio_alloc_pages_pool(struct bch_fs *c, struct bio *bio,
 
        while (size) {
                struct page *page = __bio_alloc_page_pool(c, &using_mempool);
-               unsigned len = min(PAGE_SIZE, size);
+               unsigned len = min_t(size_t, PAGE_SIZE, size);
 
                BUG_ON(!bio_add_page(bio, page, len, 0));
                size -= len;