Hi,
在 2025/09/09 16:16, John Garry 写道:
diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c
index 4fc80c6d5b31..73918e55bf04 100644
--- a/drivers/md/bcache/movinggc.c
+++ b/drivers/md/bcache/movinggc.c
@@ -145,9 +145,9 @@ static void read_moving(struct cache_set *c)
continue;
}
- io = kzalloc(struct_size(io, bio.bio.bi_inline_vecs,
- DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS)),
- GFP_KERNEL);
+ io = kzalloc(sizeof(*io) + sizeof(struct bio_vec) *
+ DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS),
+ GFP_KERNEL);
this seems a common pattern, so maybe another helper (which could be
used by bio_kmalloc)? I am not advocating it, but just putting the idea
out there... too many helpers makes it messy IMHO
Not sure how to do this, do you mean a marco to pass in the base
structure type, nr_vecs and the gfp_mask?
Thanks,
Kuai