Skip to contentSkip to conversation

btrfs: remove assertions after btrfs_bio struct changes

PATCH In review Zhen Ni 2 participants 4 messages Dec 18, 2025 – Dec 19, 2025 Btrfs file system

lore
Share & tools
lore

Zhen Ni

author
#0 lore raw

PATCH 1/1 btrfs: remove assertions after btrfs_bio struct changes

Commit 81cea6cd7041 ("btrfs: remove btrfs_bio::fs_info by extracting it from btrfs_bio::inode") modified the btrfs_bio structure to make the inode field mandatory, making these assertions redundant:

- btrfs_check_read_bio(): inode is validated by btrfs_bio_init()
- btrfs_submit_bbio(): condition always passes since inode is never NULL

Remove these obsolete checks.

---
 fs/btrfs/bio.c | 6 ------
 1 file changed, 6 deletions(-)
fs/btrfs/bio.c +0 -6
index fa1d321a2fb8..2b6a97fba1b2 100644
@@ -307,9 +307,6 @@ static void btrfs_check_read_bio(struct btrfs_bio *bbio, struct btrfs_device *de
 	phys_addr_t paddr;
 	u32 offset = 0;
 
-	/* Read-repair requires the inode field to be set by the submitter. */
-	ASSERT(inode);
-
 	/*
 	 * Hand off repair bios to the repair code as there is no upper level
 	 * submitter for them.
@@ -899,9 +896,6 @@ static void assert_bbio_alignment(struct btrfs_bio *bbio)
 
 void btrfs_submit_bbio(struct btrfs_bio *bbio, int mirror_num)
 {
-	/* If bbio->inode is not populated, its file_offset must be 0. */
-	ASSERT(bbio->inode || bbio->file_offset == 0);
-
 	assert_bbio_alignment(bbio);
 
 	while (!btrfs_submit_chunk(bbio, mirror_num))
Signature · 1 line
2.20.1
#1 lore raw
Quoted 8 lines · Zhen Ni

Commit 81cea6cd7041 ("btrfs: remove btrfs_bio::fs_info by extracting it from btrfs_bio::inode") modified the btrfs_bio structure to make the inode field mandatory, making these assertions redundant:

- btrfs_check_read_bio(): inode is validated by btrfs_bio_init()
- btrfs_submit_bbio(): condition always passes since inode is never NULL

Remove these obsolete checks.

The assertions may be redundant and their purpose is to catch accidental changes to code or explicitly list some critical assumptions. We'd like to have more rather than fewer of them.

#2 lore raw
Quoted 5 lines · David Sterba
Quoted 4 lines · Zhen Ni

Commit 81cea6cd7041 ("btrfs: remove btrfs_bio::fs_info by extracting it from btrfs_bio::inode") modified the btrfs_bio structure to make the inode field mandatory, making these assertions redundant:

Quoted 8 lines
Quoted 4 lines

- btrfs_check_read_bio(): inode is validated by btrfs_bio_init()
- btrfs_submit_bbio(): condition always passes since inode is never NULL

Remove these obsolete checks.

The assertions may be redundant and their purpose is to catch accidental changes to code or explicitly list some critical assumptions. We'd like to have more rather than fewer of them.

https://btrfs.readthedocs.io/en/latest/dev/Development-notes.html#handling-unexpected-conditions

author
#3 lore raw
Quoted 9 lines · David Sterba
Quoted 8 lines · David Sterba
Quoted 7 lines · Zhen Ni

Commit 81cea6cd7041 ("btrfs: remove btrfs_bio::fs_info by extracting it from btrfs_bio::inode") modified the btrfs_bio structure to make the inode field mandatory, making these assertions redundant:

- btrfs_check_read_bio(): inode is validated by btrfs_bio_init()
- btrfs_submit_bbio(): condition always passes since inode is never NULL

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

Remove these obsolete checks.

The assertions may be redundant and their purpose is to catch accidental changes to code or explicitly list some critical assumptions. We'd like to have more rather than fewer of them.

https://btrfs.readthedocs.io/en/latest/dev/Development-notes.html#handling-unexpected-conditions

Thank you for pointing out the relevant documentation.

Maintaining these assertions (or even adding more) is the better approach. They not only prevent current errors but, more importantly, prevent future code modifications from introducing problems.