Skip to contentSkip to conversation

bcachefs: Suppress unnecessary inode_i_sectors_wrong fsck error

PATCH Applied Nikita Ofitserov 2 participants 2 messages Jul 3, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcachefs: Suppress unnecessary inode_i_sectors_wrong fsck error

It is possible that fsck first miscounted the expected sector count (due to applying other fixes at the same time, for example) and then corrected itself using extents. No need to log an fsck error and write the inode in this case.

---
 fs/bcachefs/fsck.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/bcachefs/fsck.c +2 -1
index 1ceca63c87a3bf3eb75d396f7a10949c502b0e8d..471e93a3f00c637050b5c485d72b27cfb284282d 100644
@@ -1638,7 +1638,8 @@ static int check_i_sectors_notnested(struct btree_trans *trans, struct inode_wal
 			i->count = count2;
 		}
 
-		if (fsck_err_on(!(i->inode.bi_flags & BCH_INODE_i_sectors_dirty),
+		if (fsck_err_on(!(i->inode.bi_flags & BCH_INODE_i_sectors_dirty) &&
+				i->inode.bi_sectors != i->count,
 				trans, inode_i_sectors_wrong,
 				"inode %llu:%u has incorrect i_sectors: got %llu, should be %llu",
 				w->last_pos.inode, i->inode.bi_snapshot,

---
base-commit: 14a12362bb22b3735c51ecdb712570a12992a695
change-id: 20250703-isectors-not-wrong-8e8a126cf307

Best regards,

Signature · 1 line
Nikita Ofitserov
#1 lore raw
Quoted 8 lines · On Thu, Jul 03, 2025 at 02:59:11AM +0300, Nikita Ofitserov via B4 Relay wrote:

From: Nikita Ofitserov <[email protected]>

It is possible that fsck first miscounted the expected sector count (due to applying other fixes at the same time, for example) and then corrected itself using extents. No need to log an fsck error and write the inode in this case.

Thanks, applied.

Quoted 28 lines
---
 fs/bcachefs/fsck.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/bcachefs/fsck.c +2 -2
index 1ceca63c87a3bf3eb75d396f7a10949c502b0e8d..471e93a3f00c637050b5c485d72b27cfb284282d 100644
@@ -1638,7 +1638,8 @@ static int check_i_sectors_notnested(struct btree_trans *trans, struct inode_wal
 			i->count = count2;
 		}
 
-		if (fsck_err_on(!(i->inode.bi_flags & BCH_INODE_i_sectors_dirty),
+		if (fsck_err_on(!(i->inode.bi_flags & BCH_INODE_i_sectors_dirty) &&
+				i->inode.bi_sectors != i->count,
 				trans, inode_i_sectors_wrong,
 				"inode %llu:%u has incorrect i_sectors: got %llu, should be %llu",
 				w->last_pos.inode, i->inode.bi_snapshot,
 
---

base-commit: 14a12362bb22b3735c51ecdb712570a12992a695
change-id: 20250703-isectors-not-wrong-8e8a126cf307

Best regards,

Signature · 1 line
Nikita Ofitserov