* [PATCH] iomap: Break build if io_inline_bio is not last in iomap_ioend
@ 2021-06-29 6:41 Nikolay Borisov
2021-06-29 6:52 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Borisov @ 2021-06-29 6:41 UTC (permalink / raw)
To: hch; +Cc: djwong, linux-fsdevel, Nikolay Borisov
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>
---
fs/iomap/buffered-io.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 9023717c5188..f0421e139697 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -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;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iomap: Break build if io_inline_bio is not last in iomap_ioend
2021-06-29 6:41 [PATCH] iomap: Break build if io_inline_bio is not last in iomap_ioend Nikolay Borisov
@ 2021-06-29 6:52 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2021-06-29 6:52 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: hch, djwong, linux-fsdevel
On Tue, Jun 29, 2021 at 09:41:49AM +0300, Nikolay Borisov wrote:
> + 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-29 6:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-29 6:41 [PATCH] iomap: Break build if io_inline_bio is not last in iomap_ioend Nikolay Borisov
2021-06-29 6:52 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).