]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bcachefs: Add missing smp_rmb()
authorAlan Huang <mmpgouride@gmail.com>
Tue, 18 Mar 2025 07:50:00 +0000 (15:50 +0800)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 24 Mar 2025 13:50:35 +0000 (09:50 -0400)
The smp_rmb() guarantees that reads from reservations.counter
occur before accessing cur_entry_u64s. It's paired with the
atomic64_try_cmpxchg in journal_entry_open.

Signed-off-by: Alan Huang <mmpgouride@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal.h

index ab68c5c4d8d8c73f3f1d18dc93b81860c908e70a..47828771f9c2395f070949614d24dfd0c69182fe 100644 (file)
@@ -350,8 +350,10 @@ static inline int journal_res_get_fast(struct journal *j,
 
                /*
                 * Check if there is still room in the current journal
-                * entry:
+                * entry, smp_rmb() guarantees that reads from reservations.counter
+                * occur before accessing cur_entry_u64s:
                 */
+               smp_rmb();
                if (new.cur_entry_offset + res->u64s > j->cur_entry_u64s)
                        return 0;