Skip to contentSkip to conversation

bcachefs: Fix incorrect state count

PATCH Applied Alan Huang 2 participants 2 messages Mar 17, 2025 – Mar 18, 2025

lore
Share & tools
lore

Alan Huang

author
#0 lore raw

PATCH 1/1 bcachefs: Fix incorrect state count

atomic64_read(&j->seq) - j->seq_write_started == JOURNAL_STATE_BUF_NR is the condition in journal_entry_open where we return JOURNAL_ERR_max_open, so journal_cur_seq(j) - seq == JOURNAL_STATE_BUF_NR means that the buf corresponding to seq has started to write.

---
 fs/bcachefs/journal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/bcachefs/journal.h +1 -1
index 1c460ded2a11..ab68c5c4d8d8 100644
@@ -161,7 +161,7 @@ static inline int journal_state_count(union journal_res_state s, int idx)
 static inline int journal_state_seq_count(struct journal *j,
 					  union journal_res_state s, u64 seq)
 {
-	if (journal_cur_seq(j) - seq <= JOURNAL_STATE_BUF_NR)
+	if (journal_cur_seq(j) - seq < JOURNAL_STATE_BUF_NR)
 		return journal_state_count(s, seq & JOURNAL_STATE_BUF_MASK);
 	else
 		return 0;
Signature · 1 line
2.48.1
#1 lore raw
Quoted 6 lines · Alan Huang

atomic64_read(&j->seq) - j->seq_write_started == JOURNAL_STATE_BUF_NR is the condition in journal_entry_open where we return JOURNAL_ERR_max_open, so journal_cur_seq(j) - seq == JOURNAL_STATE_BUF_NR means that the buf corresponding to seq has started to write.

Applied

Quoted 20 lines
---
 fs/bcachefs/journal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/bcachefs/journal.h +1 -1
index 1c460ded2a11..ab68c5c4d8d8 100644
@@ -161,7 +161,7 @@ static inline int journal_state_count(union journal_res_state s, int idx)
 static inline int journal_state_seq_count(struct journal *j,
 					  union journal_res_state s, u64 seq)
 {
-	if (journal_cur_seq(j) - seq <= JOURNAL_STATE_BUF_NR)
+	if (journal_cur_seq(j) - seq < JOURNAL_STATE_BUF_NR)
 		return journal_state_count(s, seq & JOURNAL_STATE_BUF_MASK);
 	else
 		return 0;
Signature · 1 line
2.48.1