Skip to contentSkip to conversation

iomap: Break build if io_inline_bio is not last in iomap_ioend

PATCH Superseded Nikolay Borisov 2 participants 2 messages Jun 29, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iomap: Break build if io_inline_bio is not last in iomap_ioend

Comments are good but unfortunately they can't effectively enforce certain invariants, to that effect let's break the build in case io_inline_bio is, for whatever reason, not the last member of iomap_ioend.

---
 fs/iomap/buffered-io.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/iomap/buffered-io.c +4 -0
index 9023717c5188..f0421e139697 100644
@@ -1225,6 +1225,10 @@ iomap_alloc_ioend(struct inode *inode, struct iomap_writepage_ctx *wpc,
 	bio->bi_write_hint = inode->i_write_hint;
 	wbc_init_bio(wbc, bio);
 
+
+	BUILD_BUG_ON(offsetof(struct iomap_ioend, io_inline_bio) + sizeof(struct bio)
+		     != sizeof(struct iomap_ioend));
+
 	ioend = container_of(bio, struct iomap_ioend, io_inline_bio);
 	INIT_LIST_HEAD(&ioend->io_list);
 	ioend->io_type = wpc->iomap.type;
Signature · 1 line
2.25.1
#1 lore raw

fs/iomap/buffered-io.c iomap_alloc_ioend(struct inode *inode, struct iomap_writepage_ctx *wpc, · line 1230

Quoted 2 lines · Nikolay Borisov
fs/iomap/buffered-io.c +2 -0
+	BUILD_BUG_ON(offsetof(struct iomap_ioend, io_inline_bio) + sizeof(struct bio)
+		     != sizeof(struct iomap_ioend));

Please fix the overly long line and the incorrect operator placement.