Message ID | 20210629072051.2875413-1-nborisov@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] iomap: Break build if io_inline_bio is not last in iomap_ioend | expand |
On Tue, Jun 29, 2021 at 10:20:51AM +0300, Nikolay Borisov wrote: > 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. Looks good, Reviewed-by: Christoph Hellwig <hch@lst.de>
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 9023717c5188..62e27faacc6e 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1225,6 +1225,9 @@ 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;
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. Signed-off-by: Nikolay Borisov <nborisov@suse.com> --- V2: - Fix indentation and long lines fs/iomap/buffered-io.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.25.1