more integrity cleanups v3
Subsystems (4)
Christoph Hellwig
maintainerHi Jens and Martin,
this series has more cleanups to the block layer integrity code. It splits the bio integrity APIs into their own header as they are only used by very few source files, cleans up their stubs a little bit, and then in the last patch change when the bio_integrity_payload is freed when it is not owned by the block layer. This avoids having to know the submitter in the core code and will simplify adding other consuer of the API like file systems or the io_uring non-passthrough PI support.
This series is based on the block for-next branch as there are conflicting changes in 6.10-rc but not in the for-6.11/block branch.
Changes since v2:
- stop calling bio_uninit in bio_endio
- fix a commit message typo
Changes since v1:
- rebased to for-next
Diffstat:
block/bio-integrity.c | 87 ++++++++--------------- block/bio.c | 16 +++- block/blk-map.c | 3 block/blk.h | 14 +++ block/bounce.c | 2 drivers/md/dm.c | 1 drivers/nvme/host/ioctl.c | 16 +--- drivers/scsi/sd.c | 3 include/linux/bio-integrity.h | 152 ++++++++++++++++++++++++++++++++++++++++ include/linux/bio.h | 156 ------------------------------------------ include/linux/blk-integrity.h | 1 11 files changed, 222 insertions(+), 229 deletions(-)
Christoph Hellwig
maintainerPATCH 1/6 block: split integrity support out of bio.h
Split struct bio_integrity_payload and the related prototypes out of bio.h into a separate bio-integrity.h header so that it is only pulled in by the few places that need it.
--- block/bio.c | 2 +- block/blk.h | 1 + block/bounce.c | 2 +- drivers/md/dm.c | 1 + drivers/nvme/host/ioctl.c | 1 + drivers/scsi/sd.c | 3 +- include/linux/bio-integrity.h | 153 +++++++++++++++++++++++++++++++++ include/linux/bio.h | 156 ---------------------------------- include/linux/blk-integrity.h | 1 + 9 files changed, 161 insertions(+), 159 deletions(-) create mode 100644 include/linux/bio-integrity.h
block/bio.c +1 -1
@@ -4,7 +4,7 @@*/ #include <linux/mm.h> #include <linux/swap.h> -#include <linux/bio.h> +#include <linux/bio-integrity.h> #include <linux/blkdev.h> #include <linux/uio.h> #include <linux/iocontext.h>
block/blk.h +1 -0
@@ -2,6 +2,7 @@#ifndef BLK_INTERNAL_H #define BLK_INTERNAL_H +#include <linux/bio-integrity.h> #include <linux/blk-crypto.h> #include <linux/memblock.h> /* for max_pfn/max_low_pfn */ #include <linux/sched/sysctl.h>
block/bounce.c +1 -1
@@ -10,7 +10,7 @@#include <linux/export.h> #include <linux/swap.h> #include <linux/gfp.h> -#include <linux/bio.h> +#include <linux/bio-integrity.h> #include <linux/pagemap.h> #include <linux/mempool.h> #include <linux/blkdev.h>
drivers/md/dm.c +1 -0
@@ -11,6 +11,7 @@#include "dm-uevent.h" #include "dm-ima.h" +#include <linux/bio-integrity.h> #include <linux/init.h> #include <linux/module.h> #include <linux/mutex.h>
drivers/nvme/host/ioctl.c +1 -0
@@ -3,6 +3,7 @@* Copyright (c) 2011-2014, Intel Corporation. * Copyright (c) 2017-2021 Christoph Hellwig. */ +#include <linux/bio-integrity.h> #include <linux/ptrace.h> /* for force_successful_syscall_return */ #include <linux/nvme_ioctl.h> #include <linux/io_uring/cmd.h>
drivers/scsi/sd.c +2 -1
@@ -33,11 +33,12 @@* than the level indicated above to trigger output. */ +#include <linux/bio-integrity.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/kernel.h> #include <linux/mm.h> -#include <linux/bio.h> +#include <linux/bio-integrity.h> #include <linux/hdreg.h> #include <linux/errno.h> #include <linux/idr.h>
include/linux/bio-integrity.h new file +153 -0
153 lines not on this page · raw message
include/linux/bio.h +0 -156
168 lines not on this page · raw message
include/linux/blk-integrity.h +1 -0
@@ -3,6 +3,7 @@#define _LINUX_BLK_INTEGRITY_H#include <linux/blk-mq.h> +#include <linux/bio-integrity.h> struct request ;
Signature · 1 line
2.43.0
Re: [PATCH 1/6] block: split integrity support out of bio.h
Looks good,
Christoph Hellwig
maintainerPATCH 2/6 block: also return bio_integrity_payload * from stubs
In reply to Christoph Hellwigstruct bio_integrity_payload is defined unconditionally. No need to return void * from bio_integrity() and bio_integrity_alloc().
--- include/linux/bio-integrity.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/bio-integrity.h +3 -3
@@ -85,7 +85,7 @@ void bio_integrity_init(void);#else /* CONFIG_BLK_DEV_INTEGRITY */ -static inline void *bio_integrity (struct bio *bio) +static inline struct bio_integrity_payload *bio_integrity (struct bio *bio) {return NULL ; }
@@ -138,8 +138,8 @@ static inline bool bio_integrity_flagged(struct bio *bio, enum bip_flags flag)return false; } -static inline void *bio_integrity_alloc (struct bio *bio,gfp_t gfp, -unsigned int nr) +static inline struct bio_integrity_payload * +bio_integrity_alloc (struct bio *bio,gfp_t gfp,unsigned int nr) {return ERR_PTR (-EINVAL ); }
Signature · 1 line
2.43.0
Re: [PATCH 2/6] block: also return bio_integrity_payload * from stubs
Looks good,
Christoph Hellwig
maintainerPATCH 3/6 block: don't call bio_uninit from bio_endio
In reply to Christoph HellwigCommit b222dd2fdd53 ("block: call bio_uninit in bio_endio") added a call to bio_uninit in bio_endio to work around callers that use bio_init but fail to call bio_uninit after they are done to release the resources. While this is an abuse of the bio_init API we still have quite a few of those left. But this early uninit causes a problem for integrity data, as at least some users need the bio_integrity_payload. Right now the only one is the NVMe passthrough which archives this by adding a special case to skip the freeing if the BIP_INTEGRITY_USER flag is set.
Sort this out by only putting bi_blkg in bio_endio as that is the cause of the actual leaks - the few users of the crypto context and integrity data all properly call bio_uninit, usually through bio_put for dynamically allocated bios.
--- block/bio.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
block/bio.c +12 -2
@@ -1630,8 +1630,18 @@ void bio_endio(struct bio *bio) goto again; } -/* release cgroup info */ -bio_uninit (bio); +#ifdef CONFIG_BLK_CGROUP +/* +* Release cgroup info. We shouldn't have to do this here, but quite +* a few callers of bio_init fail to call bio_uninit, so we cover up +* for that here at least for now. +*/ +if (bio->bi_blkg) { +blkg_put (bio->bi_blkg); + bio->bi_blkg =NULL ; + } +#endif +if (bio->bi_end_io) bio->bi_end_io (bio); }
Signature · 1 line
2.43.0
Re: [PATCH 3/6] block: don't call bio_uninit from bio_endio
Quoted 34 lines · Christoph Hellwig
Commit
b222dd2fdd53("block: callbio_uninitinbio_endio") added a call tobio_uninitinbio_endioto work around callers that usebio_initbut fail to callbio_uninitafter they are done to release the resources. While this is an abuse of thebio_initAPI we still have quite a few of those left. But this early uninit causes a problem for integrity data, as at least some users need thebio_integrity_payload. Right now the only one is the NVMe passthrough which archives this by adding a special case to skip the freeing if theBIP_INTEGRITY_USERflag is set.Sort this out by only putting
bi_blkginbio_endioas that is the cause of the actual leaks - the few users of the crypto context and integrity data all properly callbio_uninit, usually throughbio_putfor dynamically allocated bios.Signed-off-by Christoph Hellwig <[email protected]>--- block/bio.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)block/bio.c +5
-2@@ -1630,8 +1630,18 @@ void bio_endio(struct bio *bio) goto again; } -/* release cgroup info */ -bio_uninit (bio); +#ifdef CONFIG_BLK_CGROUP +/* +* Release cgroup info. We shouldn't have to do this here, but quite +* a few callers of bio_init fail to call bio_uninit, so we cover up +* for that here at least for now.
block/bio.c void bio_endio(struct bio *bio) · line 1647
Quoted 10 lines
block/bio.c +7
-0+*/ +if (bio->bi_blkg) { +blkg_put (bio->bi_blkg); + bio->bi_blkg =NULL ; + } +#endif +if (bio->bi_end_io) bio->bi_end_io (bio); }
Can we have sth. like this on top to avoid the duplication?:
block/bio.c +0 -0
@@ -210,14 +210,21 @@ struct bio_vec *bvec_alloc(mempool_t *pool,
unsigned short *nr_vecs,
return mempool_alloc(pool, gfp_mask);
}
-void bio_uninit(struct bio *bio)
+static void bio_uninit_blkg(struct bio *bio)
{
#ifdef CONFIG_BLK_CGROUP
- if (bio->bi_blkg) {
- blkg_put(bio->bi_blkg);
- bio->bi_blkg = NULL;
- }
+ if (!bio->bi_blkg)
+ return;
+
+ blkg_put(bio->bi_blkg);
+ bio->bi_blkg = NULL;
#endif
+}
+
+void bio_uninit(struct bio *bio)
+{
+ bio_uninit_blkg(bio);
+
if (bio_integrity(bio))
bio_integrity_free(bio);@@ -1630,17 +1637,12 @@ void bio_endio(struct bio *bio)
goto again;
}-#ifdef CONFIG_BLK_CGROUP
/*
* Release cgroup info. We shouldn't have to do this here, but
quite
* a few callers of bio_init fail to call bio_uninit, so we
cover up
* for that here at least for now.
*/
- if (bio->bi_blkg) {
- blkg_put(bio->bi_blkg);
- bio->bi_blkg = NULL;
- }
-#endif
+ bio_uninit_blkg(bio);
if (bio->bi_end_io)
bio->bi_end_io(bio);hch
maintainerRe: [PATCH 3/6] block: don't call bio_uninit from bio_endio
Quoted 1 line · Johannes Thumshirn
Can we have sth. like this on top to avoid the duplication?:
I hope I can just get rid of it over the next merge window or two. Right now the only two offenders I've found are bcache and bcachefs, so it might not be that much work.
Christoph Hellwig
maintainerPATCH 4/6 block: call bio_integrity_unmap_free_user from blk_rq_unmap_user
In reply to Christoph Hellwigblk_rq_unmap_user always unmaps user space pass-through request. If such a request has integrity data attached it must come from a user mapping as well. Call bio_integrity_unmap_free_user from blk_rq_unmap_user and remove the nvme_unmap_bio wrapper in the nvme driver.
--- block/bio-integrity.c | 1 - block/blk-map.c | 3 +++ drivers/nvme/host/ioctl.c | 15 ++++----------- 3 files changed, 7 insertions(+), 12 deletions(-)
block/bio-integrity.c +0 -1
@@ -174,7 +174,6 @@ void bio_integrity_unmap_free_user(struct bio *bio) bio->bi_integrity =NULL ; bio->bi_opf &= ~REQ_INTEGRITY ; } -EXPORT_SYMBOL (bio_integrity_unmap_free_user);/** * bio_integrity_add_page - Attach integrity metadata
block/blk-map.c +3 -0
@@ -757,6 +757,9 @@ int blk_rq_unmap_user(struct bio *bio)bio_release_pages (bio,bio_data_dir (bio) ==READ ); } +if (bio_integrity (bio)) +bio_integrity_unmap_free_user (bio); + next_bio = bio; bio = bio->bi_next;blk_mq_map_bio_put (next_bio);
drivers/nvme/host/ioctl.c +4 -11
@@ -112,13 +112,6 @@ static struct request *nvme_alloc_user_request(struct request_queue *q,return req; } -static void nvme_unmap_bio (struct bio *bio) -{ -if (bio_integrity (bio)) -bio_integrity_unmap_free_user (bio); -blk_rq_unmap_user (bio); -} -static int nvme_map_user_request (struct request *req,u64 ubuffer,unsigned bufflen,void __user *meta_buffer,unsigned meta_len,u32 meta_seed,struct io_uring_cmd *ioucmd,unsigned int flags)
@@ -165,7 +158,7 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer, out_unmap:if (bio) -nvme_unmap_bio (bio); +blk_rq_unmap_user (bio); out:blk_mq_free_request (req);return ret;
@@ -203,7 +196,7 @@ static int nvme_submit_user_cmd(struct request_queue *q,if (result) *result =le64_to_cpu (nvme_req (req)->result.u64);if (bio) -nvme_unmap_bio (bio); +blk_rq_unmap_user (bio);blk_mq_free_request (req);if (effects)
@@ -414,7 +407,7 @@ static void nvme_uring_task_cb(struct io_uring_cmd *ioucmd,struct nvme_uring_cmd_pdu *pdu =nvme_uring_cmd_pdu (ioucmd);if (pdu->bio) -nvme_unmap_bio (pdu->bio); +blk_rq_unmap_user (pdu->bio);io_uring_cmd_done (ioucmd, pdu->status, pdu->result, issue_flags); }
@@ -440,7 +433,7 @@ static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req,*/ if (blk_rq_is_poll (req)) {if (pdu->bio) -nvme_unmap_bio (pdu->bio); +blk_rq_unmap_user (pdu->bio);io_uring_cmd_iopoll_done (ioucmd, pdu->result, pdu->status); }else {io_uring_cmd_do_in_task_lazy (ioucmd, nvme_uring_task_cb);
Signature · 1 line
2.43.0
Re: [PATCH 4/6] block: call bio_integrity_unmap_free_user from blk_rq_unmap_user
Looks good,
Christoph Hellwig
maintainerPATCH 5/6 block: don't free submitter owned integrity payload on I/O completion
In reply to Christoph HellwigCurrently __bio_integrity_endio frees the integrity payload unless it is explicitly marked as user-mapped. This means in-kernel callers that allocate their own integrity payload never get to see it on I/O completion. The current two users don't need it as they just pre-mapped PI tuples received over the network, but this limits uses of integrity data lot.
Change bio_integrity_endio to call __bio_integrity_endio for block layer generated integrity data only, and leave freeing of submitter allocated integrity data to bio_uninit which also gets called from the final bio_put. This requires that unmapping user mapped or copied integrity data is now always done by the caller, and the special BIP_INTEGRITY_USER flag can go away.
--- block/bio-integrity.c | 57 ++++++++++++++--------------------- block/blk.h | 13 ++++++-- include/linux/bio-integrity.h | 3 +- 3 files changed, 34 insertions(+), 39 deletions(-)
block/bio-integrity.c +22 -35
@@ -22,9 +22,17 @@ void blk_flush_integrity(void)flush_workqueue (kintegrityd_wq); } -static void __bio_integrity_free (struct bio_set *bs, -struct bio_integrity_payload *bip) +/** +* bio_integrity_free - Free bio integrity payload +* @bio: bio containing bip to be freed +* +* Description: Free the integrity portion of a bio. +*/ +void bio_integrity_free (struct bio *bio) { +struct bio_integrity_payload *bip =bio_integrity (bio); +struct bio_set *bs = bio->bi_pool; +if (bs &&mempool_initialized (&bs->bio_integrity_pool)) {if (bip->bip_vec) bvec_free(&bs->bvec_integrity_pool, bip->bip_vec,
@@ -33,6 +41,8 @@ static void __bio_integrity_free(struct bio_set *bs, }else {kfree (bip); } + bio->bi_integrity =NULL ; + bio->bi_opf &= ~REQ_INTEGRITY ; }/**
@@ -86,7 +96,10 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,return bip; err: -__bio_integrity_free (bs, bip); +if (bs &&mempool_initialized (&bs->bio_integrity_pool)) +mempool_free (bip, &bs->bio_integrity_pool); +else +kfree (bip);return ERR_PTR (-ENOMEM ); }EXPORT_SYMBOL (bio_integrity_alloc);
@@ -132,28 +145,6 @@ static void bio_integrity_unmap_user(struct bio_integrity_payload *bip)bio_integrity_unpin_bvec (bip->bip_vec, bip->bip_max_vcnt, dirty); } -/** -* bio_integrity_free - Free bio integrity payload -* @bio: bio containing bip to be freed -* -* Description: Used to free the integrity portion of a bio. Usually -* called from bio_free(). -*/ -void bio_integrity_free (struct bio *bio) -{ -struct bio_integrity_payload *bip =bio_integrity (bio); -struct bio_set *bs = bio->bi_pool; - -if (bip->bip_flags &BIP_INTEGRITY_USER ) -return ; -if (bip->bip_flags &BIP_BLOCK_INTEGRITY ) -kfree (bvec_virt (bip->bip_vec)); - -__bio_integrity_free (bs, bip); - bio->bi_integrity =NULL ; - bio->bi_opf &= ~REQ_INTEGRITY ; -} -/** * bio_integrity_unmap_free_user - Unmap and free bio user integrity payload * @bio: bio containing bip to be unmapped and freed
@@ -165,14 +156,9 @@ void bio_integrity_free(struct bio *bio)void bio_integrity_unmap_free_user (struct bio *bio) {struct bio_integrity_payload *bip =bio_integrity (bio); -struct bio_set *bs = bio->bi_pool; -if (WARN_ON_ONCE (!(bip->bip_flags &BIP_INTEGRITY_USER ))) -return ;bio_integrity_unmap_user (bip); -__bio_integrity_free (bs, bip); - bio->bi_integrity =NULL ; - bio->bi_opf &= ~REQ_INTEGRITY ; +bio_integrity_free (bio); }/**
@@ -273,7 +259,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec, goto free_bip; } - bip->bip_flags |=BIP_INTEGRITY_USER |BIP_COPY_USER ; + bip->bip_flags |=BIP_COPY_USER ; bip->bip_iter.bi_sector = seed; bip->bip_vcnt = nr_vecs;return 0 ;
@@ -294,7 +280,6 @@ static int bio_integrity_init_user(struct bio *bio, struct bio_vec *bvec,return PTR_ERR (bip);memcpy (bip->bip_vec, bvec, nr_vecs *sizeof (*bvec)); - bip->bip_flags |=BIP_INTEGRITY_USER ; bip->bip_iter.bi_sector = seed; bip->bip_iter.bi_size = len; bip->bip_vcnt = nr_vecs;
@@ -502,6 +487,8 @@ static void bio_integrity_verify_fn(struct work_struct *work)struct bio *bio = bip->bip_bio;blk_integrity_verify (bio); + +kfree (bvec_virt (bip->bip_vec));bio_integrity_free (bio);bio_endio (bio); }
@@ -522,13 +509,13 @@ bool __bio_integrity_endio(struct bio *bio)struct blk_integrity *bi =blk_get_integrity (bio->bi_bdev->bd_disk);struct bio_integrity_payload *bip =bio_integrity (bio); -if (bio_op (bio) ==REQ_OP_READ && !bio->bi_status && - (bip->bip_flags &BIP_BLOCK_INTEGRITY ) && bi->csum_type) { +if (bio_op (bio) ==REQ_OP_READ && !bio->bi_status && bi->csum_type) {INIT_WORK (&bip->bip_work, bio_integrity_verify_fn);queue_work (kintegrityd_wq, &bip->bip_work);return false; } +kfree (bvec_virt (bip->bip_vec));bio_integrity_free (bio);return true; }
block/blk.h +11 -2
@@ -202,11 +202,20 @@ static inline unsigned int blk_queue_get_max_sectors(struct request *rq)#ifdef CONFIG_BLK_DEV_INTEGRITY void blk_flush_integrity (void ); -bool __bio_integrity_endio (struct bio *);void bio_integrity_free (struct bio *bio); + +/* +* Integrity payloads can either be owned by the submitter, in which case +* bio_uninit will free them, or owned and generated by the block layer, +* in which case we'll verify them here (for reads) and free them before +* the bio is handed back to the submitted. +*/ +bool __bio_integrity_endio (struct bio *bio);static inline bool bio_integrity_endio (struct bio *bio) { -if (bio_integrity (bio)) +struct bio_integrity_payload *bip =bio_integrity (bio); + +if (bip && (bip->bip_flags &BIP_BLOCK_INTEGRITY ))return __bio_integrity_endio (bio);return true; }
include/linux/bio-integrity.h +1 -2
@@ -10,8 +10,7 @@ enum bip_flags {BIP_CTRL_NOCHECK =1 <<2 ,/* disable HBA integrity checking */ BIP_DISK_NOCHECK =1 <<3 ,/* disable disk integrity checking */ BIP_IP_CHECKSUM =1 <<4 ,/* IP checksum */ -BIP_INTEGRITY_USER =1 <<5 ,/* Integrity payload is user address */ - BIP_COPY_USER = 1 << 6, /* Kernel bounce buffer in use */ + BIP_COPY_USER = 1 << 5, /* Kernel bounce buffer in use */ }; struct bio_integrity_payload {
Signature · 1 line
2.43.0
Re: [PATCH 5/6] block: don't free submitter owned integrity payload on I/O completion
Looks good,
Re: [PATCH 5/6] block: don't free submitter owned integrity payload on I/O completion
In reply to Christoph HellwigQuoted 4 lines · Christoph Hellwig
+ * Integrity payloads can either be owned by the submitter, in which case
+ *bio_uninitwill free them, or owned and generated by the block layer,
+ * in which case we'll verify them here (for reads) and free them before
+ * the bio is handed back to the submitted.
s/submitted/submitter?
With that
Christoph Hellwig
maintainerPATCH 6/6 block: don't free the integrity payload in bio_integrity_unmap_free_user
In reply to Christoph HellwigNow that the integrity payload is always freed in bio_uninit, don't bother freeing it a little earlier in bio_integrity_unmap_free_user. With that the separate bio_integrity_unmap_free_user can go away by just passing the bio to bio_integrity_unmap_user.
--- block/bio-integrity.c | 31 +++++++++++-------------------- block/blk-map.c | 2 +- include/linux/bio-integrity.h | 4 ++-- 3 files changed, 14 insertions(+), 23 deletions(-)
block/bio-integrity.c +11 -20
@@ -131,34 +131,25 @@ static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)bio_integrity_unpin_bvec (copy, nr_vecs, true); } -static void bio_integrity_unmap_user (struct bio_integrity_payload *bip) +/** +* bio_integrity_unmap_user - Unmap user integrity payload +* @bio: bio containing bip to be unmapped +* +* Unmap the user mapped integrity portion of a bio. +*/ +void bio_integrity_unmap_user (struct bio *bio) { -bool dirty =bio_data_dir (bip->bip_bio) ==READ ; +struct bio_integrity_payload *bip =bio_integrity (bio);if (bip->bip_flags &BIP_COPY_USER ) { -if (dirty) +if (bio_data_dir (bio) ==READ )bio_integrity_uncopy_user (bip);kfree (bvec_virt (bip->bip_vec));return ; } -bio_integrity_unpin_bvec (bip->bip_vec, bip->bip_max_vcnt, dirty); -} - -/** -* bio_integrity_unmap_free_user - Unmap and free bio user integrity payload -* @bio: bio containing bip to be unmapped and freed -* -* Description: Used to unmap and free the user mapped integrity portion of a -* bio. Submitter attaching the user integrity buffer is responsible for -* unmapping and freeing it during completion. -*/ -void bio_integrity_unmap_free_user (struct bio *bio) -{ -struct bio_integrity_payload *bip =bio_integrity (bio); - -bio_integrity_unmap_user (bip); -bio_integrity_free (bio); +bio_integrity_unpin_bvec (bip->bip_vec, bip->bip_max_vcnt, +bio_data_dir (bio) ==READ ); }/**
block/blk-map.c +1 -1
@@ -758,7 +758,7 @@ int blk_rq_unmap_user(struct bio *bio) }if (bio_integrity (bio)) -bio_integrity_unmap_free_user (bio); +bio_integrity_unmap_user (bio); next_bio = bio; bio = bio->bi_next;
include/linux/bio-integrity.h +2 -2
@@ -73,7 +73,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio, gfp_t gfp,int bio_integrity_add_page (struct bio *bio,struct page *page,unsigned int len,unsigned int offset);int bio_integrity_map_user (struct bio *bio,void __user *ubuf,ssize_t len,u32 seed); -void bio_integrity_unmap_free_user (struct bio *bio); +void bio_integrity_unmap_user (struct bio *bio);bool bio_integrity_prep (struct bio *bio);void bio_integrity_advance (struct bio *bio,unsigned int bytes_done);void bio_integrity_trim (struct bio *bio);
@@ -104,7 +104,7 @@ static inline int bio_integrity_map_user(struct bio *bio, void __user *ubuf,return -EINVAL ; } -static inline void bio_integrity_unmap_free_user (struct bio *bio) +static inline void bio_integrity_unmap_user (struct bio *bio) { }
Signature · 1 line
2.43.0
Re: [PATCH 6/6] block: don't free the integrity payload in bio_integrity_unmap_free_user
Looks good,
Re: [PATCH 6/6] block: don't free the integrity payload in bio_integrity_unmap_free_user
In reply to Christoph HellwigMartin K. Petersen
Reviewed-byChristoph,
Quoted 8 lines
this series has more cleanups to the block layer integrity code. It splits the bio integrity APIs into their own header as they are only used by very few source files, cleans up their stubs a little bit, and then in the last patch change when the
bio_integrity_payloadis freed when it is not owned by the block layer. This avoids having to know the submitter in the core code and will simplify adding other consuer of the API like file systems or theio_uringnon-passthrough PI support.
Looks good to me and is more in line with how this originally worked.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 10 lines · Christoph Hellwig
this series has more cleanups to the block layer integrity code. It splits the bio integrity APIs into their own header as they are only used by very few source files, cleans up their stubs a little bit, and then in the last patch change when the
bio_integrity_payloadis freed when it is not owned by the block layer. This avoids having to know the submitter in the core code and will simplify adding other consuer of the API like file systems or theio_uringnon-passthrough PI support.[...]
Applied, thanks!
[1/6] block: split integrity support out of bio.h
commit: da042a3655151157c06e71a583e883ab2d86d1ff
[2/6] block: also return bio_integrity_payload * from stubs
commit: 21671a1ed1ff22e158ebe9d619943f926f03f5cd
[3/6] block: don't call bio_uninit from bio_endio
commit: bf4c89fc8797f5c0964a0c3d561fbe7e8483b62f
[4/6] block: call bio_integrity_unmap_free_user from blk_rq_unmap_user
commit: f8924374fd37a8b41d554acd8b7407af7d354c0d
[5/6] block: don't free submitter owned integrity payload on I/O completion
commit: 85253bac4d02b1f95d6109c221aeccd7a262ec4d
[6/6] block: don't free the integrity payload in bio_integrity_unmap_free_user
commit: 74cc150282e41c6c0704cd305c9a4392dc64ef4dBest regards,
Signature · 1 line
Jens Axboe