add bvec initialization helpers
Subsystems (26)
Christoph Hellwig
maintainerHi all,
this series adds the helpers to initalize a bvec. These remove open coding of bvec internals and help with experimenting with other representations like a phys_addr_t instead of page + offset.
Diffstat:
block/bio-integrity.c | 7 ------ block/bio.c | 12 +---------- drivers/block/rbd.c | 7 ++---- drivers/block/virtio_blk.c | 4 --- drivers/block/zram/zram_drv.c | 15 +++----------- drivers/nvme/host/core.c | 4 --- drivers/nvme/target/io-cmd-file.c | 10 +-------- drivers/nvme/target/tcp.c | 5 +--- drivers/scsi/sd.c | 36 ++++++++++++++++------------------ drivers/target/target_core_file.c | 18 +++++------------ drivers/vhost/vringh.c | 5 +--- fs/afs/write.c | 8 ++----- fs/ceph/file.c | 10 ++++----- fs/cifs/connect.c | 5 ++-- fs/cifs/fscache.c | 16 +++++---------- fs/cifs/misc.c | 5 +--- fs/cifs/smb2ops.c | 6 ++--- fs/coredump.c | 7 +----- fs/nfs/fscache.c | 16 +++++---------- fs/orangefs/inode.c | 22 ++++++-------------- fs/splice.c | 5 +--- include/linux/bvec.h | 40 ++++++++++++++++++++++++++++++++++++++ io_uring/rsrc.c | 4 --- mm/page_io.c | 8 +------ net/ceph/messenger_v1.c | 7 +----- net/ceph/messenger_v2.c | 28 ++++++++++---------------- net/rxrpc/rxperf.c | 8 ++----- net/sunrpc/svcsock.c | 7 +----- net/sunrpc/xdr.c | 5 +--- 29 files changed, 143 insertions(+), 187 deletions(-)
Christoph Hellwig
maintainerPATCH 1/23 block: factor out a bvec_set_page helper
Add a helper to initialize a bvec based of a page pointer. This will help removing various open code bvec initializations.
--- block/bio-integrity.c | 7 +------ block/bio.c | 12 ++---------- include/linux/bvec.h | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 16 deletions(-)
block/bio-integrity.c +1 -6
@@ -124,23 +124,18 @@ int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset) {struct bio_integrity_payload *bip =bio_integrity (bio); -struct bio_vec *iv;if (bip->bip_vcnt >= bip->bip_max_vcnt) {printk (KERN_ERR "%s: bip_vec full\n" , __func__);return 0 ; } - 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++;return len;
block/bio.c +2 -10
@@ -1029,10 +1029,7 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio,if (bio->bi_vcnt >=queue_max_segments (q))return 0 ; - bvec = &bio->bi_io_vec[bio->bi_vcnt]; - bvec->bv_page = page; - bvec->bv_len = len; - bvec->bv_offset = offset; +bvec_set_page (&bio->bi_io_vec[bio->bi_vcnt], page, len, offset); bio->bi_vcnt++; bio->bi_iter.bi_size += len;return len;
@@ -1108,15 +1105,10 @@ EXPORT_SYMBOL_GPL(bio_add_zone_append_page);void __bio_add_page (struct bio *bio,struct page *page,unsigned int len,unsigned int off) { -struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt]; -WARN_ON_ONCE (bio_flagged (bio,BIO_CLONED ));WARN_ON_ONCE (bio_full (bio, len)); - bv->bv_page = page; - bv->bv_offset = off; - bv->bv_len = len; - +bvec_set_page (&bio->bi_io_vec[bio->bi_vcnt], page, len, off); bio->bi_iter.bi_size += len; bio->bi_vcnt++; }
include/linux/bvec.h +15 -0
@@ -35,6 +35,21 @@ struct bio_vec {unsigned int bv_offset; }; +/** +* bvec_set_page - initialize a bvec based off a struct page +* @bv: bvec to initialize +* @page: page the bvec should point to +* @len: length of the bvec +* @offset: offset into the page +*/ +static inline void bvec_set_page (struct bio_vec *bv,struct page *page, +unsigned int len,unsigned int offset) +{ + bv->bv_page = page; + bv->bv_len = len; + bv->bv_offset = offset; +} +struct bvec_iter {sector_t bi_sector;/* device address in 512 byte sectors */
Signature · 1 line
2.39.0
David Howells
maintainerRe: [PATCH 01/23] block: factor out a bvec_set_page helper
include/linux/bvec.h struct bio_vec { · line 46
Quoted 2 lines · Christoph Hellwig
include/linux/bvec.h +2
-0+static inline void bvec_set_page (struct bio_vec *bv,struct page *page, +unsigned int len,unsigned int offset)
Could you swap len and offset around? It reads better offset first. You move offset into the page and then do something with len bytes.
David
Christoph Hellwig
maintainerRe: [PATCH 01/23] block: factor out a bvec_set_page helper
Quoted 7 lines · David Howells
include/linux/bvec.h struct bio_vec { · line 46
Quoted 2 lines · Christoph Hellwig
include/linux/bvec.h +2
-0+static inline void bvec_set_page (struct bio_vec *bv,struct page *page, +unsigned int len,unsigned int offset)Could you swap len and offset around? It reads better offset first. You move offset into the page and then do something with len bytes.
This matches bio_add_page and the order inside bio_vec itself. willy wanted to switch it around for bio_add_folio but Jens didn't like it, so I'll stick to the current convention in this area as well.
Ilya Dryomov
maintainerRe: [PATCH 01/23] block: factor out a bvec_set_page helper
Quoted 7 lines · Christoph Hellwig
Quoted 5 lines · David Howells
Quoted 2 lines · Christoph Hellwig
include/linux/bvec.h +2
-0+static inline void bvec_set_page (struct bio_vec *bv,struct page *page, +unsigned int len,unsigned int offset)
Quoted 6 lines
Quoted 2 lines
Could you swap len and offset around? It reads better offset first. You move offset into the page and then do something with len bytes.
This matches
bio_add_pageand the order insidebio_vecitself. willy wanted to switch it around forbio_add_foliobut Jens didn't like it, so I'll stick to the current convention in this area as well.
This also matches sg_set_page() so sticking to the current convention is definitely a good idea!
Thanks,
Ilya
Re: [PATCH 01/23] block: factor out a bvec_set_page helper
In reply to Christoph HellwigLooks good,
Re: [PATCH 01/23] block: factor out a bvec_set_page helper
In reply to Christoph HellwigQuoted 2 lines · Christoph Hellwig
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.
block/bio-integrity.c int bio_integrity_add_page(struct bio *bio, struct page *page, · line 139
Quoted 12 lines
block/bio-integrity.c +1
-5- 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.
Re: [PATCH 01/23] block: factor out a bvec_set_page helper
Quoted 5 lines · Bart Van Assche
Quoted 2 lines · Christoph Hellwig
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.
Please ignore the above question - I just noticed that this question has been answered in the cover letter.
Bart.
Christoph Hellwig
maintainerRe: [PATCH 01/23] block: factor out a bvec_set_page helper
In reply to Bart Van AsscheQuoted 5 lines · Bart Van Assche
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 };
Unless it's hidden behind a macro it doesn't solve the problem of abstraction away the layout. I'm also find it less readable.
Jakub Kicinski
maintainerRe: [PATCH 01/23] block: factor out a bvec_set_page helper
In reply to Christoph HellwigQuoted 12 lines · On Mon, 30 Jan 2023 10:21:35 +0100 Christoph Hellwig wrote:
include/linux/bvec.h +4
-0@@ -35,6 +35,21 @@ struct bio_vec {unsigned int bv_offset; }; +/** +* bvec_set_page - initialize a bvec based off a struct page +* @bv: bvec to initialize +* @page: page the bvec should point to
include/linux/bvec.h struct bio_vec { · line 51
Quoted 10 lines
include/linux/bvec.h +10
-0+* @len: length of the bvec +* @offset: offset into the page +*/ +static inline void bvec_set_page (struct bio_vec *bv,struct page *page, +unsigned int len,unsigned int offset) +{ + bv->bv_page = page; + bv->bv_len = len; + bv->bv_offset = offset; +}
kinda random thought but since we're touching this area - could we perhaps move the definition of struct bio_vec and trivial helpers like this into a new header? bvec.h pulls in mm.h which is a right behemoth :S
Re: [PATCH 01/23] block: factor out a bvec_set_page helper
Quoted 4 lines · Jakub Kicinski
kinda random thought but since we're touching this area - could we perhaps move the definition of struct
bio_vecand trivial helpers like this into a new header?bvec.hpulls inmm.hwhich is a right behemoth :S
I bet we can drop mm.h now. It was originally added for nth_page() in 3d75ca0adef4 but those were all removed by b8753433fc61.
A quick smoke test on my default testing config doesn't find any problems. Let me send a patch and see if the build bots complain.
Re: [PATCH 01/23] block: factor out a bvec_set_page helper
Quoted 11 lines · Matthew Wilcox
Quoted 4 lines · Jakub Kicinski
kinda random thought but since we're touching this area - could we perhaps move the definition of struct
bio_vecand trivial helpers like this into a new header?bvec.hpulls inmm.hwhich is a right behemoth :SI bet we can drop
mm.hnow. It was originally added fornth_page()in3d75ca0adef4but those were all removed byb8753433fc61.A quick smoke test on my default testing config doesn't find any problems. Let me send a patch and see if the build bots complain.
Disappointingly, it doesn't really change anything. 1134 files depend on mm.h both before and after [1]. Looks like it's due to arch/x86/include/asm/cacheflush.h pulling in linux/mm.h, judging by the contents of .build_test_kernel-x86_64/net/ipv6/.inet6_hashtables.o.cmd. But *lots* of header files pull in mm.h, including scatterlist.h, vt_kern.h, net.h, nfs_fs.h, sunrpc/svc.h and security.h.
I suppose it may cut down on include loops to drop it here, so I'm still in favour of the patch I posted, but this illustrates how deeply entangled our headers still are.
[1] find .build_test_kernel-x86_64/ -name '.*.cmd' |xargs grep 'include/linux/mm.h' |wc -l
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Jakub Kicinski
maintainerRe: [PATCH 01/23] block: factor out a bvec_set_page helper
Quoted 13 lines · On Tue, 31 Jan 2023 05:28:19 +0000 Matthew Wilcox wrote:
Quoted 5 lines
I bet we can drop
mm.hnow. It was originally added fornth_page()in3d75ca0adef4but those were all removed byb8753433fc61.A quick smoke test on my default testing config doesn't find any problems. Let me send a patch and see if the build bots complain.
Disappointingly, it doesn't really change anything. 1134 files depend on
mm.hboth before and after [1]. Looks like it's due toarch/x86/include/asm/cacheflush.hpulling inlinux/mm.h, judging by the contents of .build_test_kernel-x86_64/net/ipv6/.inet6_hashtables.o.cmd. But *lots* of header files pull inmm.h, includingscatterlist.h,vt_kern.h,net.h,nfs_fs.h,sunrpc/svc.handsecurity.h.
Quoted 3 lines
I suppose it may cut down on include loops to drop it here, so I'm still in favour of the patch I posted, but this illustrates how deeply entangled our headers still are.
+1 it's a bit of a chicken and an egg problem. Until mm.h is gone from bvec there's no point removing other headers which pull it in to skbuff.h.
Re: [PATCH 01/23] block: factor out a bvec_set_page helper
In reply to Christoph HellwigQuoted 5 lines · Christoph Hellwig
Add a helper to initialize a bvec based of a page pointer. This will help removing various open code bvec initializations.
Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
-ck
Christoph Hellwig
maintainerPATCH 2/23 block: add a bvec_set_folio helper
In reply to Christoph HellwigA smaller wrapper around bvec_set_page that takes a folio instead. There are only two potential users for this in the tree, but the number will grow in the future.
--- include/linux/bvec.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/linux/bvec.h +13 -0
@@ -50,6 +50,19 @@ static inline void bvec_set_page(struct bio_vec *bv, struct page *page, bv->bv_offset = offset; } +/** +* bvec_set_folio - initialize a bvec based off a struct folio +* @bv: bvec to initialize +* @page: folio the bvec should point to +* @len: length of the bvec +* @offset: offset into the folio +*/ +static inline void bvec_set_folio (struct bio_vec *bv,struct folio *folio, +unsigned int len,unsigned int offset) +{ +bvec_set_page (bv, &folio->page, len, offset); +} +struct bvec_iter {sector_t bi_sector;/* device address in 512 byte sectors */
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 02/23] block: add a bvec_set_folio helper
Quoted 4 lines · Christoph Hellwig
+/**
+ *bvec_set_folio- initialize a bvec based off a struct folio
+ * @bv: bvec to initialize
+ * @page: folio the bvec should point to
s/page/folio
Quoted 3 lines
+ * @len: length of the bvec
+ * @offset: offset into the folio
+ */
Otherwise,
Re: [PATCH 02/23] block: add a bvec_set_folio helper
In reply to Christoph HellwigQuoted 6 lines · Christoph Hellwig
A smaller wrapper around
bvec_set_pagethat takes a folio instead. There are only two potential users for this in the tree, but the number will grow in the future.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
-ck
Christoph Hellwig
maintainerPATCH 3/23 block: add a bvec_set_virt helper
In reply to Christoph HellwigA small wrapper around bvec_set_page for callers that have a virtual address.
--- include/linux/bvec.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/linux/bvec.h +12 -0
@@ -63,6 +63,18 @@ static inline void bvec_set_folio(struct bio_vec *bv, struct folio *folio,bvec_set_page (bv, &folio->page, len, offset); } +/** +* bvec_set_virt - initialize a bvec based on a virtual address +* @bv: bvec to initialize +* @vaddr: virtual address to set the bvec to +* @len: length of the bvec +*/ +static inline void bvec_set_virt (struct bio_vec *bv,void *vaddr, +unsigned int len) +{ +bvec_set_page (bv,virt_to_page (vaddr), len,offset_in_page (vaddr)); +} +struct bvec_iter {sector_t bi_sector;/* device address in 512 byte sectors */
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 03/23] block: add a bvec_set_virt helper
Looks good,
Re: [PATCH 03/23] block: add a bvec_set_virt helper
In reply to Christoph HellwigQuoted 5 lines · Christoph Hellwig
A small wrapper around
bvec_set_pagefor callers that have a virtual address.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
-ck
Christoph Hellwig
maintainerPATCH 4/23 sd: factor out a sd_set_special_bvec helper
In reply to Christoph HellwigAdd a helper for setting up the special_bvec instead of open coding it in three place, and use the new bvec_set_page helper to initialize special_vec.
--- drivers/scsi/sd.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-)
drivers/scsi/sd.c +17 -19
@@ -831,6 +831,19 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)blk_queue_max_discard_sectors (q, max_blocks * (logical_block_size >>9 )); } +static void *sd_set_special_bvec (struct request *rq,unsigned int data_len) +{ +struct page *page; + + page =mempool_alloc (sd_page_pool,GFP_ATOMIC ); +if (!page) +return NULL ; +clear_highpage (page); +bvec_set_page (&rq->special_vec, page, data_len,0 ); + rq->rq_flags |=RQF_SPECIAL_PAYLOAD ; +return bvec_virt (&rq->special_vec); +} +static blk_status_t sd_setup_unmap_cmnd (struct scsi_cmnd *cmd) {struct scsi_device *sdp = cmd->device;
@@ -841,19 +854,14 @@ static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd)unsigned int data_len =24 ;char *buf; - rq->special_vec.bv_page =mempool_alloc (sd_page_pool,GFP_ATOMIC ); -if (!rq->special_vec.bv_page) + buf =sd_set_special_bvec (rq, data_len); +if (!buf)return BLK_STS_RESOURCE ; -clear_highpage (rq->special_vec.bv_page); - rq->special_vec.bv_offset =0 ; - rq->special_vec.bv_len = data_len; - rq->rq_flags |=RQF_SPECIAL_PAYLOAD ; cmd->cmd_len =10 ; cmd->cmnd[0 ] =UNMAP ; cmd->cmnd[8 ] =24 ; - buf =bvec_virt (&rq->special_vec);put_unaligned_be16 (6 +16 , &buf[0 ]);put_unaligned_be16 (16 , &buf[2 ]);put_unaligned_be64 (lba, &buf[8 ]);
@@ -876,13 +884,8 @@ static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd,u32 nr_blocks =sectors_to_logical (sdp,blk_rq_sectors (rq));u32 data_len = sdp->sector_size; - rq->special_vec.bv_page =mempool_alloc (sd_page_pool,GFP_ATOMIC ); -if (!rq->special_vec.bv_page) +if (!sd_set_special_bvec (rq, data_len))return BLK_STS_RESOURCE ; -clear_highpage (rq->special_vec.bv_page); - rq->special_vec.bv_offset =0 ; - rq->special_vec.bv_len = data_len; - rq->rq_flags |=RQF_SPECIAL_PAYLOAD ; cmd->cmd_len =16 ; cmd->cmnd[0 ] =WRITE_SAME_16 ;
@@ -908,13 +911,8 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,u32 nr_blocks =sectors_to_logical (sdp,blk_rq_sectors (rq));u32 data_len = sdp->sector_size; - rq->special_vec.bv_page =mempool_alloc (sd_page_pool,GFP_ATOMIC ); -if (!rq->special_vec.bv_page) +if (!sd_set_special_bvec (rq, data_len))return BLK_STS_RESOURCE ; -clear_highpage (rq->special_vec.bv_page); - rq->special_vec.bv_offset =0 ; - rq->special_vec.bv_len = data_len; - rq->rq_flags |=RQF_SPECIAL_PAYLOAD ; cmd->cmd_len =10 ; cmd->cmnd[0 ] =WRITE_SAME ;
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 04/23] sd: factor out a sd_set_special_bvec helper
Quoted 6 lines · Christoph Hellwig
Add a helper for setting up the
special_bvecinstead of open coding it in three place, and use the newbvec_set_pagehelper to initializespecial_vec.Signed-off-by Christoph Hellwig <[email protected]>---
Much needed, looks good.
-ck
Christoph Hellwig
maintainerPATCH 5/23 target: use bvec_set_page to initialize bvecs
In reply to Christoph HellwigUse the bvec_set_page helper to initialize bvecs.
--- drivers/target/target_core_file.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/target/target_core_file.c +6 -12
@@ -281,10 +281,8 @@ fd_execute_rw_aio(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ;for_each_sg (sgl, sg, sgl_nents, i) { - aio_cmd->bvecs[i].bv_page =sg_page (sg); - aio_cmd->bvecs[i].bv_len = sg->length; - aio_cmd->bvecs[i].bv_offset = sg->offset; - +bvec_set_page (&aio_cmd->bvecs[i],sg_page (sg), sg->length, + sg->offset); len += sg->length; }
@@ -329,10 +327,7 @@ static int fd_do_rw(struct se_cmd *cmd, struct file *fd, }for_each_sg (sgl, sg, sgl_nents, i) { - bvec[i].bv_page =sg_page (sg); - bvec[i].bv_len = sg->length; - bvec[i].bv_offset = sg->offset; - +bvec_set_page (&bvec[i],sg_page (sg), sg->length, sg->offset); len += sg->length; }
@@ -465,10 +460,9 @@ fd_execute_write_same(struct se_cmd *cmd)return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ;for (i =0 ; i < nolb; i++) { - bvec[i].bv_page =sg_page (&cmd->t_data_sg[0 ]); - bvec[i].bv_len = cmd->t_data_sg[0 ].length; - bvec[i].bv_offset = cmd->t_data_sg[0 ].offset; - +bvec_set_page (&bvec[i],sg_page (&cmd->t_data_sg[0 ]), + cmd->t_data_sg[0 ].length, + cmd->t_data_sg[0 ].offset); len += se_dev->dev_attrib.block_size; }
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 05/23] target: use bvec_set_page to initialize bvecs
Quoted 4 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize bvecs.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
-ck
Christoph Hellwig
maintainerPATCH 6/23 nvmet: use bvec_set_page to initialize bvecs
In reply to Christoph HellwigUse the bvec_set_page helper to initialize bvecs.
--- drivers/nvme/target/io-cmd-file.c | 10 ++-------- drivers/nvme/target/tcp.c | 5 ++--- 2 files changed, 4 insertions(+), 11 deletions(-)
drivers/nvme/target/io-cmd-file.c +2 -8
@@ -73,13 +73,6 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns)return ret; } -static void nvmet_file_init_bvec (struct bio_vec *bv,struct scatterlist *sg) -{ - bv->bv_page =sg_page (sg); - bv->bv_offset = sg->offset; - bv->bv_len = sg->length; -} -static ssize_t nvmet_file_submit_bvec (struct nvmet_req *req,loff_t pos,unsigned long nr_segs,size_t count,int ki_flags) {
@@ -146,7 +139,8 @@ static bool nvmet_file_execute_io(struct nvmet_req *req, int ki_flags)memset (&req->f.iocb,0 ,sizeof (struct kiocb ));for_each_sg (req->sg, sg, req->sg_cnt, i) { -nvmet_file_init_bvec (&req->f.bvec[bv_cnt], sg); +bvec_set_page (&req->f.bvec[bv_cnt],sg_page (sg), sg->length, + sg->offset); len += req->f.bvec[bv_cnt].bv_len; total_len += req->f.bvec[bv_cnt].bv_len; bv_cnt++;
drivers/nvme/target/tcp.c +2 -3
@@ -321,9 +321,8 @@ static void nvmet_tcp_build_pdu_iovec(struct nvmet_tcp_cmd *cmd)while (length) {u32 iov_len =min_t (u32, length, sg->length - sg_offset); - iov->bv_page =sg_page (sg); - iov->bv_len = sg->length; - iov->bv_offset = sg->offset + sg_offset; +bvec_set_page (iov,sg_page (sg), sg->length, + sg->offset + sg_offset); length -= iov_len; sg =sg_next (sg);
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 06/23] nvmet: use bvec_set_page to initialize bvecs
Looks good,
Re: [PATCH 06/23] nvmet: use bvec_set_page to initialize bvecs
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize bvecs.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
-ck
Christoph Hellwig
maintainerPATCH 7/23 nvme: use bvec_set_virt to initialize special_vec
In reply to Christoph HellwigUse the bvec_set_virt helper to initialize the special_vec.
--- drivers/nvme/host/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/nvme/host/core.c +1 -3
@@ -806,9 +806,7 @@ static blk_status_t nvme_setup_discard(struct nvme_ns *ns, struct request *req, cmnd->dsm.nr =cpu_to_le32 (segments -1 ); cmnd->dsm.attributes =cpu_to_le32 (NVME_DSMGMT_AD ); - req->special_vec.bv_page =virt_to_page (range); - req->special_vec.bv_offset =offset_in_page (range); - req->special_vec.bv_len = alloc_size; +bvec_set_virt (&req->special_vec, range, alloc_size); req->rq_flags |=RQF_SPECIAL_PAYLOAD ;return BLK_STS_OK ;
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 07/23] nvme: use bvec_set_virt to initialize special_vec
Looks good,
Re: [PATCH 07/23] nvme: use bvec_set_virt to initialize special_vec
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
Use the
bvec_set_virthelper to initialize thespecial_vec.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
-ck
Christoph Hellwig
maintainerPATCH 8/23 rbd: use bvec_set_page to initialize the copy up bvec
In reply to Christoph HellwigUse the bvec_set_page helper to initialize the copy up bvec.
--- drivers/block/rbd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/block/rbd.c +3 -4
@@ -3068,13 +3068,12 @@ static int setup_copyup_bvecs(struct rbd_obj_request *obj_req, u64 obj_overlap)for (i =0 ; i < obj_req->copyup_bvec_count; i++) {unsigned int len =min (obj_overlap, (u64 )PAGE_SIZE ); +struct page *page =alloc_page (GFP_NOIO ); - obj_req->copyup_bvecs[i].bv_page =alloc_page (GFP_NOIO ); -if (!obj_req->copyup_bvecs[i].bv_page) +if (!page)return -ENOMEM ; - obj_req->copyup_bvecs[i].bv_offset =0 ; - obj_req->copyup_bvecs[i].bv_len = len; +bvec_set_page (&obj_req->copyup_bvecs[i], page, len,0 ); obj_overlap -= len; }
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 08/23] rbd: use bvec_set_page to initialize the copy up bvec
Quoted 30 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize the copy up bvec.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/block/rbd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/block/rbd.c +3
-5@@ -3068,13 +3068,12 @@ static int setup_copyup_bvecs(struct rbd_obj_request *obj_req, u64 obj_overlap)for (i =0 ; i < obj_req->copyup_bvec_count; i++) {unsigned int len =min (obj_overlap, (u64 )PAGE_SIZE ); +struct page *page =alloc_page (GFP_NOIO ); - obj_req->copyup_bvecs[i].bv_page =alloc_page (GFP_NOIO ); -if (!obj_req->copyup_bvecs[i].bv_page) +if (!page)return -ENOMEM ; - obj_req->copyup_bvecs[i].bv_offset =0 ; - obj_req->copyup_bvecs[i].bv_len = len; +bvec_set_page (&obj_req->copyup_bvecs[i], page, len,0 ); obj_overlap -= len; } --
Quoted 2 lines
2.39.0
Thanks,
Ilya
Christoph Hellwig
maintainerPATCH 9/23 virtio_blk: use bvec_set_virt to initialize special_vec
In reply to Christoph HellwigUse the bvec_set_virt helper to initialize the special_vec.
--- drivers/block/virtio_blk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/block/virtio_blk.c +1 -3
@@ -170,9 +170,7 @@ static int virtblk_setup_discard_write_zeroes_erase(struct request *req, bool unWARN_ON_ONCE (n != segments); - req->special_vec.bv_page =virt_to_page (range); - req->special_vec.bv_offset =offset_in_page (range); - req->special_vec.bv_len =sizeof (*range) * segments; +bvec_set_virt (&req->special_vec, range,sizeof (*range) * segments); req->rq_flags |=RQF_SPECIAL_PAYLOAD ;return 0 ;
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 09/23] virtio_blk: use bvec_set_virt to initialize special_vec
Quoted 3 lines · Christoph Hellwig
Use the
bvec_set_virthelper to initialize thespecial_vec.Signed-off-by Christoph Hellwig <[email protected]>
Quoted 21 lines
--- drivers/block/virtio_blk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/block/virtio_blk.c +1
-3@@ -170,9 +170,7 @@ static int virtblk_setup_discard_write_zeroes_erase(struct request *req, bool unWARN_ON_ONCE (n != segments); - req->special_vec.bv_page =virt_to_page (range); - req->special_vec.bv_offset =offset_in_page (range); - req->special_vec.bv_len =sizeof (*range) * segments; +bvec_set_virt (&req->special_vec, range,sizeof (*range) * segments); req->rq_flags |=RQF_SPECIAL_PAYLOAD ;return 0 ;Signature · 1 line
2.39.0
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Jason Wang
Acked-byRe: [PATCH 09/23] virtio_blk: use bvec_set_virt to initialize special_vec
Quoted 7 lines · Michael S. Tsirkin
Quoted 3 lines · Christoph Hellwig
Use the
bvec_set_virthelper to initialize thespecial_vec.Signed-off-by Christoph Hellwig <[email protected]>
Thanks
Quoted 20 lines
Quoted 20 lines
--- drivers/block/virtio_blk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/block/virtio_blk.c +1
-3@@ -170,9 +170,7 @@ static int virtblk_setup_discard_write_zeroes_erase(struct request *req, bool unWARN_ON_ONCE (n != segments); - req->special_vec.bv_page =virt_to_page (range); - req->special_vec.bv_offset =offset_in_page (range); - req->special_vec.bv_len =sizeof (*range) * segments; +bvec_set_virt (&req->special_vec, range,sizeof (*range) * segments); req->rq_flags |=RQF_SPECIAL_PAYLOAD ;
Quoted 4 lines
Quoted 3 lines
drivers/block/virtio_blk.c +0
-1return 0 ; --2.39.0
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 09/23] virtio_blk: use bvec_set_virt to initialize special_vec
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
Use the
bvec_set_virthelper to initialize thespecial_vec.Signed-off-by Christoph Hellwig <[email protected]>---
Looks good.
-ck
Christoph Hellwig
maintainerPATCH 10/23 zram: use bvec_set_page to initialize bvecs
In reply to Christoph HellwigUse the bvec_set_page helper to initialize bvecs.
--- drivers/block/zram/zram_drv.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/block/zram/zram_drv.c +4 -11
@@ -703,9 +703,7 @@ static ssize_t writeback_store(struct device *dev,for (; nr_pages !=0 ; index++, nr_pages--) {struct bio_vec bvec; - bvec.bv_page = page; - bvec.bv_len =PAGE_SIZE ; - bvec.bv_offset =0 ; +bvec_set_page (&bvec, page,PAGE_SIZE ,0 );spin_lock (&zram->wb_limit_lock);if (zram->wb_limit_enable && !zram->bd_wb_limit) {
@@ -1380,12 +1378,9 @@ static void zram_free_page(struct zram *zram, size_t index)static int zram_bvec_read_from_bdev (struct zram *zram,struct page *page,u32 index,struct bio *bio,bool partial_io) { -struct bio_vec bvec = { - .bv_page = page, - .bv_len =PAGE_SIZE , - .bv_offset =0 , - }; +struct bio_vec bvec; +bvec_set_page (&bvec, page,PAGE_SIZE ,0 );return read_from_bdev (zram, &bvec,zram_get_element (zram, index), bio, partial_io); }
@@ -1652,9 +1647,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec,memcpy_from_bvec (dst + offset, bvec);kunmap_atomic (dst); - vec.bv_page = page; - vec.bv_len =PAGE_SIZE ; - vec.bv_offset =0 ; +bvec_set_page (&vec, page,PAGE_SIZE ,0 ); } ret =__zram_bvec_write (zram, &vec, index, bio);
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 10/23] zram: use bvec_set_page to initialize bvecs
Looks good,
Re: [PATCH 10/23] zram: use bvec_set_page to initialize bvecs
In reply to Christoph HellwigQuoted 3 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize bvecs.Signed-off-by Christoph Hellwig <[email protected]>
Christoph Hellwig
maintainerPATCH 11/23 afs: use bvec_set_folio to initialize a bvec
In reply to Christoph HellwigUse the bvec_set_folio helper to initialize a bvec.
--- fs/afs/write.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
fs/afs/write.c +3 -5
@@ -992,7 +992,7 @@ int afs_launder_folio(struct folio *folio) {struct afs_vnode *vnode =AFS_FS_I (folio_inode (folio));struct iov_iter iter; -struct bio_vec bv[1 ]; +struct bio_vec bv;unsigned long priv;unsigned int f, t;int ret =0 ;
@@ -1008,10 +1008,8 @@ int afs_launder_folio(struct folio *folio) t =afs_folio_dirty_to (folio, priv); } - bv[0 ].bv_page = &folio->page; - bv[0 ].bv_offset = f; - bv[0 ].bv_len = t - f; -iov_iter_bvec (&iter,ITER_SOURCE , bv,1 , bv[0 ].bv_len); +bvec_set_folio (&bv, folio, t - f, f); +iov_iter_bvec (&iter,ITER_SOURCE , &bv,1 , bv.bv_len);trace_afs_folio_dirty (vnode,tracepoint_string ("launder" ), folio); ret =afs_store_data (vnode, &iter,folio_pos (folio) + f, true);
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 11/23] afs: use bvec_set_folio to initialize a bvec
Quoted 3 lines · Christoph Hellwig
Use the
bvec_set_foliohelper to initialize a bvec.Signed-off-by Christoph Hellwig <[email protected]>
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Christoph Hellwig
maintainerPATCH 12/23 ceph: use bvec_set_page to initialize a bvec
In reply to Christoph HellwigUse the bvec_set_page helper to initialize a bvec.
--- fs/ceph/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/ceph/file.c +5 -5
@@ -103,11 +103,11 @@ static ssize_t __iter_get_bvecs(struct iov_iter *iter, size_t maxsize, size += bytes;for ( ; bytes; idx++, bvec_idx++) { -struct bio_vec bv = { - .bv_page = pages[idx], - .bv_len =min_t (int, bytes,PAGE_SIZE - start), - .bv_offset = start, - }; +struct bio_vec bv; + +bvec_set_page (&bv, pages[idx], +min_t (int, bytes,PAGE_SIZE - start), + start); bvecs[bvec_idx] = bv; bytes -= bv.bv_len;
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Ilya Dryomov
maintainerRe: [PATCH 12/23] ceph: use bvec_set_page to initialize a bvec
Quoted 14 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize a bvec.Signed-off-by Christoph Hellwig <[email protected]>--- fs/ceph/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)fs/ceph/file.c +0
-0@@ -103,11 +103,11 @@ static ssize_t __iter_get_bvecs(struct iov_iter *iter, size_t maxsize, size += bytes;
fs/ceph/file.c static ssize_t __iter_get_bvecs(struct iov_iter *iter, size_t maxsize, · line 108
Quoted 10 lines
fs/ceph/file.c +3
-5for ( ; bytes; idx++, bvec_idx++) { -struct bio_vec bv = { - .bv_page = pages[idx], - .bv_len =min_t (int, bytes,PAGE_SIZE - start), - .bv_offset = start, - }; +struct bio_vec bv; + + bvec_set_page(&bv, pages[idx],
Hi Christoph,
There is trailing whitespace on this line which git complains about and it made me take a second look. I think bvec_set_page() allows to make this more compact:
for ( ; bytes; idx++, bvec_idx++) {
int len = min_t(int, bytes, PAGE_SIZE - start);
bvec_set_page(&bvecs[bvec_idx], pages[idx], len, start);
bytes -= len;
start = 0;
}Thanks,
Ilya
Re: [PATCH 12/23] ceph: use bvec_set_page to initialize a bvec
Quoted 30 lines · Ilya Dryomov
Quoted 13 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize a bvec.Signed-off-by Christoph Hellwig <[email protected]>--- fs/ceph/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)fs/ceph/file.c +0
-0@@ -103,11 +103,11 @@ static ssize_t __iter_get_bvecs(struct iov_iter *iter, size_t maxsize, size += bytes;fs/ceph/file.c static ssize_t __iter_get_bvecs(struct iov_iter *iter, size_t maxsize, · line 108
Quoted 10 lines
fs/ceph/file.c +3
-5for ( ; bytes; idx++, bvec_idx++) { -struct bio_vec bv = { - .bv_page = pages[idx], - .bv_len =min_t (int, bytes,PAGE_SIZE - start), - .bv_offset = start, - }; +struct bio_vec bv; + + bvec_set_page(&bv, pages[idx],Hi Christoph,
There is trailing whitespace on this line which git complains about and it made me take a second look. I think
bvec_set_page()allows to make this more compact:
Quoted 8 lines
for ( ; bytes; idx++, bvec_idx++) {
int len = min_t(int, bytes, PAGE_SIZE - start);
bvec_set_page(&bvecs[bvec_idx], pages[idx], len, start);
bytes -= len;
start = 0;
}This looks better.
Thanks
Christoph Hellwig
maintainerPATCH 13/23 cifs: use bvec_set_page to initialize bvecs
In reply to Christoph HellwigUse the bvec_set_page helper to initialize bvecs.
--- fs/cifs/connect.c | 5 +++-- fs/cifs/fscache.c | 16 ++++++---------- fs/cifs/misc.c | 5 ++--- fs/cifs/smb2ops.c | 6 +++--- 4 files changed, 14 insertions(+), 18 deletions(-)
fs/cifs/connect.c +3 -2
@@ -759,8 +759,9 @@ cifs_read_page_from_socket(struct TCP_Server_Info *server, struct page *page, unsigned int page_offset, unsigned int to_read) {struct msghdr smb_msg = {}; -struct bio_vec bv = { - .bv_page = page, .bv_len = to_read, .bv_offset = page_offset}; +struct bio_vec bv; + +bvec_set_page (&bv, page, to_read, page_offset);iov_iter_bvec (&smb_msg.msg_iter,ITER_DEST , &bv,1 , to_read);return cifs_readv_from_socket (server, &smb_msg); }
fs/cifs/fscache.c +6 -10
@@ -143,14 +143,12 @@ static int fscache_fallback_read_page(struct inode *inode, struct page *page)struct netfs_cache_resources cres;struct fscache_cookie *cookie =cifs_inode_cookie (inode);struct iov_iter iter; -struct bio_vec bvec[1 ]; +struct bio_vec bvec;int ret;memset (&cres,0 ,sizeof (cres)); - bvec[0 ].bv_page = page; - bvec[0 ].bv_offset =0 ; - bvec[0 ].bv_len =PAGE_SIZE ; -iov_iter_bvec (&iter,ITER_DEST , bvec,ARRAY_SIZE (bvec),PAGE_SIZE ); +bvec_set_page (&bvec, page,PAGE_SIZE ,0 ); +iov_iter_bvec (&iter,ITER_DEST , &bvec,1 ,PAGE_SIZE ); ret =fscache_begin_read_operation (&cres, cookie);if (ret <0 )
@@ -171,16 +169,14 @@ static int fscache_fallback_write_page(struct inode *inode, struct page *page,struct netfs_cache_resources cres;struct fscache_cookie *cookie =cifs_inode_cookie (inode);struct iov_iter iter; -struct bio_vec bvec[1 ]; +struct bio_vec bvec;loff_t start =page_offset (page);size_t len =PAGE_SIZE ;int ret;memset (&cres,0 ,sizeof (cres)); - bvec[0 ].bv_page = page; - bvec[0 ].bv_offset =0 ; - bvec[0 ].bv_len =PAGE_SIZE ; -iov_iter_bvec (&iter,ITER_SOURCE , bvec,ARRAY_SIZE (bvec),PAGE_SIZE ); +bvec_set_page (&bvec, page,PAGE_SIZE ,0 ); +iov_iter_bvec (&iter,ITER_SOURCE , &bvec,1 ,PAGE_SIZE ); ret =fscache_begin_write_operation (&cres, cookie);if (ret <0 )
fs/cifs/misc.c +2 -3
@@ -1054,9 +1054,8 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw)for (i =0 ; i < cur_npages; i++) { len = rc >PAGE_SIZE ?PAGE_SIZE : rc; - bv[npages + i].bv_page = pages[i]; - bv[npages + i].bv_offset = start; - bv[npages + i].bv_len = len - start; +bvec_set_page (&bv[npages + i], pages[i], len - start, + start); rc -= len; start =0 ; }
fs/cifs/smb2ops.c +3 -3
@@ -4598,9 +4598,9 @@ init_read_bvec(struct page **pages, unsigned int npages, unsigned int data_size,return -ENOMEM ;for (i =0 ; i < npages; i++) { - bvec[i].bv_page = pages[i]; - bvec[i].bv_offset = (i ==0 ) ? cur_off :0 ; - bvec[i].bv_len = min_t(unsigned int, PAGE_SIZE, data_size); +bvec_set_page (&bvec[i], pages[i], + min_t(unsigned int, PAGE_SIZE, data_size), + i ==0 ? cur_off :0 ); data_size -= bvec[i].bv_len; }
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 13/23] cifs: use bvec_set_page to initialize bvecs
Quoted 9 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize bvecs.Signed-off-by Christoph Hellwig <[email protected]>--- fs/cifs/connect.c | 5 +++-- fs/cifs/fscache.c | 16 ++++++---------- fs/cifs/misc.c | 5 ++--- fs/cifs/smb2ops.c | 6 +++--- 4 files changed, 14 insertions(+), 18 deletions(-)
Christoph Hellwig
maintainerPATCH 14/23 coredump: use bvec_set_page to initialize a bvec
In reply to Christoph HellwigUse the bvec_set_page helper to initialize a bvec.
--- fs/coredump.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
fs/coredump.c +2 -5
@@ -840,11 +840,7 @@ static int __dump_skip(struct coredump_params *cprm, size_t nr)static int dump_emit_page (struct coredump_params *cprm,struct page *page) { -struct bio_vec bvec = { - .bv_page = page, - .bv_offset =0 , - .bv_len =PAGE_SIZE , - }; +struct bio_vec bvec;struct iov_iter iter;struct file *file = cprm->file;loff_t pos;
@@ -860,6 +856,7 @@ static int dump_emit_page(struct coredump_params *cprm, struct page *page)if (dump_interrupted ())return 0 ; pos = file->f_pos; +bvec_set_page (&bvec, page,PAGE_SIZE ,0 );iov_iter_bvec (&iter,ITER_SOURCE , &bvec,1 ,PAGE_SIZE ); n =__kernel_write_iter (cprm->file, &iter, &pos);if (n !=PAGE_SIZE )
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Christoph Hellwig
maintainerPATCH 15/23 nfs: use bvec_set_page to initialize bvecs
In reply to Christoph HellwigUse the bvec_set_page helper to initialize bvecs.
--- fs/nfs/fscache.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
fs/nfs/fscache.c +6 -10
@@ -245,14 +245,12 @@ static int fscache_fallback_read_page(struct inode *inode, struct page *page)struct netfs_cache_resources cres;struct fscache_cookie *cookie =nfs_i_fscache (inode);struct iov_iter iter; -struct bio_vec bvec[1 ]; +struct bio_vec bvec;int ret;memset (&cres,0 ,sizeof (cres)); - bvec[0 ].bv_page = page; - bvec[0 ].bv_offset =0 ; - bvec[0 ].bv_len =PAGE_SIZE ; -iov_iter_bvec (&iter,ITER_DEST , bvec,ARRAY_SIZE (bvec),PAGE_SIZE ); +bvec_set_page (&bvec, page,PAGE_SIZE ,0 ); +iov_iter_bvec (&iter,ITER_DEST , &bvec,1 ,PAGE_SIZE ); ret =fscache_begin_read_operation (&cres, cookie);if (ret <0 )
@@ -273,16 +271,14 @@ static int fscache_fallback_write_page(struct inode *inode, struct page *page,struct netfs_cache_resources cres;struct fscache_cookie *cookie =nfs_i_fscache (inode);struct iov_iter iter; -struct bio_vec bvec[1 ]; +struct bio_vec bvec;loff_t start =page_offset (page);size_t len =PAGE_SIZE ;int ret;memset (&cres,0 ,sizeof (cres)); - bvec[0 ].bv_page = page; - bvec[0 ].bv_offset =0 ; - bvec[0 ].bv_len =PAGE_SIZE ; -iov_iter_bvec (&iter,ITER_SOURCE , bvec,ARRAY_SIZE (bvec),PAGE_SIZE ); +bvec_set_page (&bvec, page,PAGE_SIZE ,0 ); +iov_iter_bvec (&iter,ITER_SOURCE , &bvec,1 ,PAGE_SIZE ); ret =fscache_begin_write_operation (&cres, cookie);if (ret <0 )
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Christoph Hellwig
maintainerPATCH 16/23 orangefs: use bvec_set_{page,folio} to initialize bvecs
In reply to Christoph HellwigUse the bvec_set_page and bvec_set_folio helpers to initialize bvecs.
--- fs/orangefs/inode.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
fs/orangefs/inode.c +7 -15
@@ -49,10 +49,8 @@ static int orangefs_writepage_locked(struct page *page,/* Should've been handled in orangefs_invalidate_folio. */ WARN_ON (off == len || off + wlen > len); - bv.bv_page = page; - bv.bv_len = wlen; - bv.bv_offset = off %PAGE_SIZE ;WARN_ON (wlen ==0 ); +bvec_set_page (&bv, page, wlen, off %PAGE_SIZE );iov_iter_bvec (&iter,ITER_SOURCE , &bv,1 , wlen); ret = wait_for_direct_io(ORANGEFS_IO_WRITE, inode, &off, &iter, wlen,
@@ -102,15 +100,11 @@ static int orangefs_writepages_work(struct orangefs_writepages *ow,for (i =0 ; i < ow->npages; i++) {set_page_writeback (ow->pages[i]); - ow->bv[i].bv_page = ow->pages[i]; - ow->bv[i].bv_len =min (page_offset (ow->pages[i]) +PAGE_SIZE , - ow->off + ow->len) - -max (ow->off,page_offset (ow->pages[i])); -if (i ==0 ) - ow->bv[i].bv_offset = ow->off - -page_offset (ow->pages[i]); -else - ow->bv[i].bv_offset =0 ; +bvec_set_page (&ow->bv[i], ow->pages[i], +min (page_offset (ow->pages[i]) +PAGE_SIZE , + ow->off + ow->len) - +max (ow->off,page_offset (ow->pages[i])), + i ==0 ? ow->off -page_offset (ow->pages[i]) :0 ); }iov_iter_bvec (&iter,ITER_SOURCE , ow->bv, ow->npages, ow->len);
@@ -300,9 +294,7 @@ static int orangefs_read_folio(struct file *file, struct folio *folio)orangefs_launder_folio (folio); off =folio_pos (folio); - bv.bv_page = &folio->page; - bv.bv_len =folio_size (folio); - bv.bv_offset =0 ; +bvec_set_folio (&bv, folio,folio_size (folio),0 );iov_iter_bvec (&iter,ITER_DEST , &bv,1 ,folio_size (folio)); ret = wait_for_direct_io(ORANGEFS_IO_READ, inode, &off, &iter,
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Christoph Hellwig
maintainerPATCH 17/23 splice: use bvec_set_page to initialize a bvec
In reply to Christoph HellwigUse the bvec_set_page helper to initialize a bvec.
--- fs/splice.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/splice.c +2 -3
@@ -675,9 +675,8 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out, goto done; } - array[n].bv_page = buf->page; - array[n].bv_len = this_len; - array[n].bv_offset = buf->offset; +bvec_set_page (&array[n], buf->page, this_len, + buf->offset); left -= this_len; n++; }
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Christoph Hellwig
maintainerPATCH 18/23 io_uring: use bvec_set_page to initialize a bvec
In reply to Christoph HellwigUse the bvec_set_page helper to initialize a bvec.
--- io_uring/rsrc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
io_uring/rsrc.c +1 -3
@@ -1237,9 +1237,7 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov,size_t vec_len; vec_len =min_t (size_t, size,PAGE_SIZE - off); - imu->bvec[i].bv_page = pages[i]; - imu->bvec[i].bv_len = vec_len; - imu->bvec[i].bv_offset = off; +bvec_set_page (&imu->bvec[i], pages[i], vec_len, off); off =0 ; size -= vec_len; }
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 18/23] io_uring: use bvec_set_page to initialize a bvec
Quoted 4 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize a bvec.Signed-off-by Christoph Hellwig <[email protected]>
Looks good.
-ck
Christoph Hellwig
maintainerPATCH 19/23 swap: use bvec_set_page to initialize bvecs
In reply to Christoph HellwigUse the bvec_set_page helper to initialize bvecs.
--- mm/page_io.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
mm/page_io.c +2 -6
@@ -318,9 +318,7 @@ static int swap_writepage_fs(struct page *page, struct writeback_control *wbc) sio->pages =0 ; sio->len =0 ; } - sio->bvec[sio->pages].bv_page = page; - sio->bvec[sio->pages].bv_len =thp_size (page); - sio->bvec[sio->pages].bv_offset =0 ; +bvec_set_page (&sio->bvec[sio->pages], page,thp_size (page),0 ); sio->len +=thp_size (page); sio->pages +=1 ;if (sio->pages ==ARRAY_SIZE (sio->bvec) || !wbc->swap_plug) {
@@ -432,9 +430,7 @@ static void swap_readpage_fs(struct page *page, sio->pages =0 ; sio->len =0 ; } - sio->bvec[sio->pages].bv_page = page; - sio->bvec[sio->pages].bv_len =thp_size (page); - sio->bvec[sio->pages].bv_offset =0 ; +bvec_set_page (&sio->bvec[sio->pages], page,thp_size (page),0 ); sio->len +=thp_size (page); sio->pages +=1 ;if (sio->pages ==ARRAY_SIZE (sio->bvec) || !plug) {
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Christoph Hellwig
maintainerPATCH 20/23 rxrpc: use bvec_set_page to initialize a bvec
In reply to Christoph HellwigUse the bvec_set_page helper to initialize a bvec.
--- net/rxrpc/rxperf.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
net/rxrpc/rxperf.c +3 -5
@@ -493,7 +493,7 @@ static int rxperf_deliver_request(struct rxperf_call *call)static int rxperf_process_call (struct rxperf_call *call) {struct msghdr msg = {}; -struct bio_vec bv[1 ]; +struct bio_vec bv;struct kvec iov[1 ];ssize_t n;size_t reply_len = call->reply_len, len;
@@ -503,10 +503,8 @@ static int rxperf_process_call(struct rxperf_call *call)while (reply_len >0 ) { len =min_t (size_t, reply_len,PAGE_SIZE ); - bv[0 ].bv_page =ZERO_PAGE (0 ); - bv[0 ].bv_offset =0 ; - bv[0 ].bv_len = len; -iov_iter_bvec (&msg.msg_iter,WRITE , bv,1 , len); +bvec_set_page (&bv,ZERO_PAGE (0 ), len,0 ); +iov_iter_bvec (&msg.msg_iter,WRITE , &bv,1 , len); msg.msg_flags =MSG_MORE ; n =rxrpc_kernel_send_data (rxperf_socket, call->rxcall, &msg, len, rxperf_notify_end_reply_tx);
Signature · 1 line
2.39.0
David Howells
maintainerRe: [PATCH 20/23] rxrpc: use bvec_set_page to initialize a bvec
net/rxrpc/rxperf.c static int rxperf_process_call(struct rxperf_call *call) · line 506
Quoted 1 line · Christoph Hellwig
net/rxrpc/rxperf.c +1
-0+bvec_set_page (&bv,ZERO_PAGE (0 ), len,0 );
Maybe bvec_set_zero_page()?
David
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Christoph Hellwig
maintainerRe: [PATCH 20/23] rxrpc: use bvec_set_page to initialize a bvec
Quoted 5 lines · David Howells
net/rxrpc/rxperf.c static int rxperf_process_call(struct rxperf_call *call) · line 506
Quoted 1 line · Christoph Hellwig
net/rxrpc/rxperf.c +1
-0+bvec_set_page (&bv,ZERO_PAGE (0 ), len,0 );Maybe
bvec_set_zero_page()?
Why?
David Howells
maintainerRe: [PATCH 20/23] rxrpc: use bvec_set_page to initialize a bvec
Quoted 8 lines · Christoph Hellwig
Quoted 5 lines · David Howells
net/rxrpc/rxperf.c static int rxperf_process_call(struct rxperf_call *call) · line 506
Quoted 1 line · Christoph Hellwig
net/rxrpc/rxperf.c +1
-0+bvec_set_page (&bv,ZERO_PAGE (0 ), len,0 );Maybe
bvec_set_zero_page()?Why?
Seems to be something people want to do quite a lot and don't know about. I've seen places where someone allocates a buffer and clears it just to use as a source of zeros. There's at least one place in cifs, for example. I know about it from wrangling arch code, but most people working on Linux haven't done that.
David
Christoph Hellwig
maintainerRe: [PATCH 20/23] rxrpc: use bvec_set_page to initialize a bvec
Quoted 1 line · David Howells
Seems to be something people want to do quite a lot and don't know about.
Hmm. Right now there is one case where it would be used, and there's about three that are and should be using bio_add_page.
Quoted 4 lines
I've seen places where someone allocates a buffer and clears it just to use as a source of zeros. There's at least one place in cifs, for example. I know about it from wrangling arch code, but most people working on Linux haven't done that.
But we don't really need a helper for every possible page use for that. People just need to learn about ZERO_PAGE.
Re: [PATCH 20/23] rxrpc: use bvec_set_page to initialize a bvec
In reply to Christoph HellwigQuoted 3 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize a bvec.Signed-off-by Christoph Hellwig <[email protected]>
Christoph Hellwig
maintainerPATCH 21/23 sunrpc: use bvec_set_page to initialize bvecs
In reply to Christoph HellwigUse the bvec_set_page helper to initialize bvecs.
--- net/sunrpc/svcsock.c | 7 ++----- net/sunrpc/xdr.c | 5 ++--- 2 files changed, 4 insertions(+), 8 deletions(-)
net/sunrpc/svcsock.c +2 -5
@@ -252,11 +252,8 @@ static ssize_t svc_tcp_read_msg(struct svc_rqst *rqstp, size_t buflen,clear_bit (XPT_DATA , &svsk->sk_xprt.xpt_flags); -for (i =0 , t =0 ; t < buflen; i++, t +=PAGE_SIZE ) { - bvec[i].bv_page = rqstp->rq_pages[i]; - bvec[i].bv_len =PAGE_SIZE ; - bvec[i].bv_offset =0 ; - } +for (i =0 , t =0 ; t < buflen; i++, t +=PAGE_SIZE ) +bvec_set_page (&bvec[i], rqstp->rq_pages[i],PAGE_SIZE ,0 ); rqstp->rq_respages = &rqstp->rq_pages[i]; rqstp->rq_next_page = rqstp->rq_respages +1 ;
net/sunrpc/xdr.c +2 -3
@@ -150,9 +150,8 @@ xdr_alloc_bvec(struct xdr_buf *buf, gfp_t gfp)if (!buf->bvec)return -ENOMEM ;for (i =0 ; i < n; i++) { - buf->bvec[i].bv_page = buf->pages[i]; - buf->bvec[i].bv_len =PAGE_SIZE ; - buf->bvec[i].bv_offset =0 ; +bvec_set_page (&buf->bvec[i], buf->pages[i],PAGE_SIZE , +0 ); } }return 0 ;
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 21/23] sunrpc: use bvec_set_page to initialize bvecs
Quoted 7 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize bvecs.Signed-off-by Christoph Hellwig <[email protected]>
Quoted 42 lines
---
net/sunrpc/svcsock.c| 7 ++-----net/sunrpc/xdr.c| 5 ++---2 files changed, 4 insertions(+), 8 deletions(-)net/sunrpc/svcsock.c +2
-5@@ -252,11 +252,8 @@ static ssize_t svc_tcp_read_msg(struct svc_rqst *rqstp, size_t buflen,clear_bit (XPT_DATA , &svsk->sk_xprt.xpt_flags); -for (i =0 , t =0 ; t < buflen; i++, t +=PAGE_SIZE ) { - bvec[i].bv_page = rqstp->rq_pages[i]; - bvec[i].bv_len =PAGE_SIZE ; - bvec[i].bv_offset =0 ; - } +for (i =0 , t =0 ; t < buflen; i++, t +=PAGE_SIZE ) +bvec_set_page (&bvec[i], rqstp->rq_pages[i],PAGE_SIZE ,0 ); rqstp->rq_respages = &rqstp->rq_pages[i]; rqstp->rq_next_page = rqstp->rq_respages +1 ;net/sunrpc/xdr.c +2
-3@@ -150,9 +150,8 @@ xdr_alloc_bvec(struct xdr_buf *buf, gfp_t gfp)if (!buf->bvec)return -ENOMEM ;for (i =0 ; i < n; i++) { - buf->bvec[i].bv_page = buf->pages[i]; - buf->bvec[i].bv_len =PAGE_SIZE ; - buf->bvec[i].bv_offset =0 ; +bvec_set_page (&buf->bvec[i], buf->pages[i],PAGE_SIZE , +0 ); } }return 0 ;Signature · 1 line
2.39.0
--
Chuck Lever
Christoph Hellwig
maintainerPATCH 22/23 vring: use bvec_set_page to initialize a bvec
In reply to Christoph HellwigUse the bvec_set_page helper to initialize a bvec.
--- drivers/vhost/vringh.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/vhost/vringh.c +2 -3
@@ -1126,9 +1126,8 @@ static int iotlb_translate(const struct vringh *vrh, size = map->size - addr + map->start; pa = map->addr + addr - map->start; pfn = pa >>PAGE_SHIFT ; - iov[ret].bv_page =pfn_to_page (pfn); - iov[ret].bv_len =min (len - s, size); - iov[ret].bv_offset = pa & (PAGE_SIZE -1 ); +bvec_set_page (&iov[ret],pfn_to_page (pfn),min (len - s, size), + pa & (PAGE_SIZE -1 )); s += size; addr += size; ++ret;
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 22/23] vring: use bvec_set_page to initialize a bvec
Quoted 3 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize a bvec.Signed-off-by Christoph Hellwig <[email protected]>
Quoted 22 lines
--- drivers/vhost/vringh.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/vhost/vringh.c +2
-3@@ -1126,9 +1126,8 @@ static int iotlb_translate(const struct vringh *vrh, size = map->size - addr + map->start; pa = map->addr + addr - map->start; pfn = pa >>PAGE_SHIFT ; - iov[ret].bv_page =pfn_to_page (pfn); - iov[ret].bv_len =min (len - s, size); - iov[ret].bv_offset = pa & (PAGE_SIZE -1 ); +bvec_set_page (&iov[ret],pfn_to_page (pfn),min (len - s, size), + pa & (PAGE_SIZE -1 )); s += size; addr += size; ++ret;Signature · 1 line
2.39.0
Re: [PATCH 22/23] vring: use bvec_set_page to initialize a bvec
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize a bvec.Signed-off-by Christoph Hellwig <[email protected]>
A typo in the subject, should be "vringh".
Other than this
Thanks
Quoted 21 lines
--- drivers/vhost/vringh.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/vhost/vringh.c +2
-4@@ -1126,9 +1126,8 @@ static int iotlb_translate(const struct vringh *vrh, size = map->size - addr + map->start; pa = map->addr + addr - map->start; pfn = pa >>PAGE_SHIFT ; - iov[ret].bv_page =pfn_to_page (pfn); - iov[ret].bv_len =min (len - s, size); - iov[ret].bv_offset = pa & (PAGE_SIZE -1 ); +bvec_set_page (&iov[ret],pfn_to_page (pfn),min (len - s, size), + pa & (PAGE_SIZE -1 )); s += size; addr += size; ++ret; --
Quoted 2 lines
2.39.0
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Christoph Hellwig
maintainerPATCH 23/23 net-ceph: use bvec_set_page to initialize bvecs
In reply to Christoph HellwigUse the bvec_set_page helper to initialize bvecs.
--- net/ceph/messenger_v1.c | 7 ++----- net/ceph/messenger_v2.c | 28 +++++++++++----------------- 2 files changed, 13 insertions(+), 22 deletions(-)
net/ceph/messenger_v1.c +2 -5
@@ -40,15 +40,12 @@ static int ceph_tcp_recvmsg(struct socket *sock, void *buf, size_t len)static int ceph_tcp_recvpage (struct socket *sock,struct page *page,int page_offset,size_t length) { -struct bio_vec bvec = { - .bv_page = page, - .bv_offset = page_offset, - .bv_len = length - }; +struct bio_vec bvec;struct msghdr msg = { .msg_flags =MSG_DONTWAIT |MSG_NOSIGNAL };int r;BUG_ON (page_offset + length >PAGE_SIZE ); +bvec_set_page (&bvec, page, length, page_offset);iov_iter_bvec (&msg.msg_iter,ITER_DEST , &bvec,1 , length); r =sock_recvmsg (sock, &msg, msg.msg_flags);if (r == -EAGAIN )
net/ceph/messenger_v2.c +11 -17
@@ -149,10 +149,10 @@ static int do_try_sendpage(struct socket *sock, struct iov_iter *it)while (iov_iter_count (it)) {/* iov_iter_iovec() for ITER_BVEC */ - bv.bv_page = it->bvec->bv_page; - bv.bv_offset = it->bvec->bv_offset + it->iov_offset; - bv.bv_len =min (iov_iter_count (it), - it->bvec->bv_len - it->iov_offset); +bvec_set_page (&bv, it->bvec->bv_page, +min (iov_iter_count (it), + it->bvec->bv_len - it->iov_offset), + it->bvec->bv_offset + it->iov_offset);/* * sendpage cannot properly handle pages with
@@ -286,9 +286,8 @@ static void set_out_bvec_zero(struct ceph_connection *con)WARN_ON (iov_iter_count (&con->v2.out_iter));WARN_ON (!con->v2.out_zero); - con->v2.out_bvec.bv_page = ceph_zero_page; - con->v2.out_bvec.bv_offset =0 ; - con->v2.out_bvec.bv_len =min (con->v2.out_zero, (int )PAGE_SIZE ); +bvec_set_page (&con->v2.out_bvec, ceph_zero_page, +min (con->v2.out_zero, (int )PAGE_SIZE ),0 ); con->v2.out_iter_sendpage = true;iov_iter_bvec (&con->v2.out_iter,ITER_SOURCE , &con->v2.out_bvec,1 , con->v2.out_bvec.bv_len);
@@ -863,10 +862,7 @@ static void get_bvec_at(struct ceph_msg_data_cursor *cursor,/* get a piece of data, cursor isn't advanced */ page =ceph_msg_data_next (cursor, &off, &len); - - bv->bv_page = page; - bv->bv_offset = off; - bv->bv_len = len; +bvec_set_page (bv, page, len, off); }static int calc_sg_cnt (void *buf,int buf_len)
@@ -1855,9 +1851,8 @@ static void prepare_read_enc_page(struct ceph_connection *con) con->v2.in_enc_resid);WARN_ON (!con->v2.in_enc_resid); - bv.bv_page = con->v2.in_enc_pages[con->v2.in_enc_i]; - bv.bv_offset =0 ; - bv.bv_len =min (con->v2.in_enc_resid, (int )PAGE_SIZE ); +bvec_set_page (&bv, con->v2.in_enc_pages[con->v2.in_enc_i], +min (con->v2.in_enc_resid, (int )PAGE_SIZE ),0 );set_in_bvec (con, &bv); con->v2.in_enc_i++;
@@ -2998,9 +2993,8 @@ static void queue_enc_page(struct ceph_connection *con) con->v2.out_enc_resid);WARN_ON (!con->v2.out_enc_resid); - bv.bv_page = con->v2.out_enc_pages[con->v2.out_enc_i]; - bv.bv_offset =0 ; - bv.bv_len =min (con->v2.out_enc_resid, (int )PAGE_SIZE ); +bvec_set_page (&bv, con->v2.out_enc_pages[con->v2.out_enc_i], +min (con->v2.out_enc_resid, (int )PAGE_SIZE ),0 );set_out_bvec (con, &bv, false); con->v2.out_enc_i++;
Signature · 6 lines
2.39.0 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH 23/23] net-ceph: use bvec_set_page to initialize bvecs
Quoted 99 lines · Christoph Hellwig
Use the
bvec_set_pagehelper to initialize bvecs.Signed-off-by Christoph Hellwig <[email protected]>--- net/ceph/messenger_v1.c | 7 ++----- net/ceph/messenger_v2.c | 28 +++++++++++----------------- 2 files changed, 13 insertions(+), 22 deletions(-)net/ceph/messenger_v1.c +2
-5@@ -40,15 +40,12 @@ static int ceph_tcp_recvmsg(struct socket *sock, void *buf, size_t len)static int ceph_tcp_recvpage (struct socket *sock,struct page *page,int page_offset,size_t length) { -struct bio_vec bvec = { - .bv_page = page, - .bv_offset = page_offset, - .bv_len = length - }; +struct bio_vec bvec;struct msghdr msg = { .msg_flags =MSG_DONTWAIT |MSG_NOSIGNAL };int r;BUG_ON (page_offset + length >PAGE_SIZE ); +bvec_set_page (&bvec, page, length, page_offset);iov_iter_bvec (&msg.msg_iter,ITER_DEST , &bvec,1 , length); r =sock_recvmsg (sock, &msg, msg.msg_flags);if (r == -EAGAIN )net/ceph/messenger_v2.c +11
-18@@ -149,10 +149,10 @@ static int do_try_sendpage(struct socket *sock, struct iov_iter *it)while (iov_iter_count (it)) {/* iov_iter_iovec() for ITER_BVEC */ - bv.bv_page = it->bvec->bv_page; - bv.bv_offset = it->bvec->bv_offset + it->iov_offset; - bv.bv_len =min (iov_iter_count (it), - it->bvec->bv_len - it->iov_offset); +bvec_set_page (&bv, it->bvec->bv_page, +min (iov_iter_count (it), + it->bvec->bv_len - it->iov_offset), + it->bvec->bv_offset + it->iov_offset);/* * sendpage cannot properly handle pages with @@ -286,9 +286,8 @@ static void set_out_bvec_zero(struct ceph_connection *con)WARN_ON (iov_iter_count (&con->v2.out_iter));WARN_ON (!con->v2.out_zero); - con->v2.out_bvec.bv_page = ceph_zero_page; - con->v2.out_bvec.bv_offset =0 ; - con->v2.out_bvec.bv_len =min (con->v2.out_zero, (int )PAGE_SIZE ); +bvec_set_page (&con->v2.out_bvec, ceph_zero_page, +min (con->v2.out_zero, (int )PAGE_SIZE ),0 ); con->v2.out_iter_sendpage = true;iov_iter_bvec (&con->v2.out_iter,ITER_SOURCE , &con->v2.out_bvec,1 , con->v2.out_bvec.bv_len);@@ -863,10 +862,7 @@ static void get_bvec_at(struct ceph_msg_data_cursor *cursor,/* get a piece of data, cursor isn't advanced */ page =ceph_msg_data_next (cursor, &off, &len); - - bv->bv_page = page; - bv->bv_offset = off; - bv->bv_len = len; +bvec_set_page (bv, page, len, off); }static int calc_sg_cnt (void *buf,int buf_len)@@ -1855,9 +1851,8 @@ static void prepare_read_enc_page(struct ceph_connection *con) con->v2.in_enc_resid);WARN_ON (!con->v2.in_enc_resid); - bv.bv_page = con->v2.in_enc_pages[con->v2.in_enc_i]; - bv.bv_offset =0 ; - bv.bv_len =min (con->v2.in_enc_resid, (int )PAGE_SIZE ); +bvec_set_page (&bv, con->v2.in_enc_pages[con->v2.in_enc_i], +min (con->v2.in_enc_resid, (int )PAGE_SIZE ),0 );set_in_bvec (con, &bv); con->v2.in_enc_i++;@@ -2998,9 +2993,8 @@ static void queue_enc_page(struct ceph_connection *con) con->v2.out_enc_resid);WARN_ON (!con->v2.out_enc_resid); - bv.bv_page = con->v2.out_enc_pages[con->v2.out_enc_i]; - bv.bv_offset =0 ; - bv.bv_len =min (con->v2.out_enc_resid, (int )PAGE_SIZE ); +bvec_set_page (&bv, con->v2.out_enc_pages[con->v2.out_enc_i], +min (con->v2.out_enc_resid, (int )PAGE_SIZE ),0 );set_out_bvec (con, &bv, false); con->v2.out_enc_i++; --
Quoted 2 lines
2.39.0
Hi Christoph,
Nit on the patch title: this subsystem should be referred to as libceph instead of net-ceph or similar, see "git log -- net/ceph" or MAINTAINERS.
Thanks,
Ilya