[PATCH 01/23] block: factor out a bvec_set_page helper
Bart Van Assche
bvanassche at acm.org
Mon Jan 30 09:09:23 PST 2023
On 1/30/23 01:21, Christoph Hellwig wrote:
> Add a helper to initialize a bvec based of a page pointer. This will help
> removing various open code bvec initializations.
Why do you want to remove the open-coded bvec initializations? What is
wrong with open-coding bvec initialization? This patch series modifies a
lot of code but does not improve code readability. Anyone who encounters
code that uses the new function bvec_set_page() has to look up the
definition of that function to figure out what it does.
> - iv = bip->bip_vec + bip->bip_vcnt;
> -
> if (bip->bip_vcnt &&
> bvec_gap_to_prev(&bdev_get_queue(bio->bi_bdev)->limits,
> &bip->bip_vec[bip->bip_vcnt - 1], offset))
> return 0;
>
> - iv->bv_page = page;
> - iv->bv_len = len;
> - iv->bv_offset = offset;
> + bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset);
> bip->bip_vcnt++;
Has it been considered to use structure assignment instead of
introducing bvec_set_page(), e.g. as follows?
bip->bip_vec[bip->bip_vcnt] = (struct bio_vec) {
.bv_page = page, .bv_len = len, .bv_offset = offset };
Thanks,
Bart.
More information about the Linux-nvme
mailing list