[PATCH next] bcachefs: Fix bitwise math on 32 bit systems

Dan Carpenter posted 1 patch 1 month, 2 weeks ago
fs/bcachefs/btree_iter.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH next] bcachefs: Fix bitwise math on 32 bit systems
Posted by Dan Carpenter 1 month, 2 weeks ago
The ~0UL needs to be ~0ULL for this mask and shift to work correctly on
32 bit systems.

Fixes: bad8626ae088 ("bcachefs: CONFIG_BCACHEFS_INJECT_TRANSACTION_RESTARTS")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 fs/bcachefs/btree_iter.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h
index 6c9bc09c0597..f5f19340654a 100644
--- a/fs/bcachefs/btree_iter.h
+++ b/fs/bcachefs/btree_iter.h
@@ -362,7 +362,7 @@ static int btree_trans_restart(struct btree_trans *trans, int err)
 static inline int trans_maybe_inject_restart(struct btree_trans *trans, unsigned long ip)
 {
 #ifdef CONFIG_BCACHEFS_INJECT_TRANSACTION_RESTARTS
-	if (!(ktime_get_ns() & ~(~0UL << min(63, (10 + trans->restart_count_this_trans))))) {
+	if (!(ktime_get_ns() & ~(~0ULL << min(63, (10 + trans->restart_count_this_trans))))) {
 		trace_and_count(trans->c, trans_restart_injected, trans, ip);
 		return btree_trans_restart_ip(trans,
 					BCH_ERR_transaction_restart_fault_inject, ip);
-- 
2.45.2
Re: [PATCH next] bcachefs: Fix bitwise math on 32 bit systems
Posted by Kent Overstreet 1 month, 2 weeks ago
On Thu, Oct 10, 2024 at 09:35:53PM GMT, Dan Carpenter wrote:
> The ~0UL needs to be ~0ULL for this mask and shift to work correctly on
> 32 bit systems.
> 
> Fixes: bad8626ae088 ("bcachefs: CONFIG_BCACHEFS_INJECT_TRANSACTION_RESTARTS")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Thanks! Applied.