Re: [PATCH 10/10] nvme: add separate handling for user integrity buffer

Keith Busch
2024-04-25T19:56:22Z

On Fri, Apr 26, 2024 at 12:09:43AM +0530, Kanchan Joshi wrote:
> @@ -983,6 +1009,14 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns,
> if (WARN_ON_ONCE(!nvme_ns_has_pi(ns->head)))
> return BLK_STS_NOTSUPP;
> control |= NVME_RW_PRINFO_PRACT;
> + } else {
> + /* process user-created integrity */
> + if (bio_integrity(req->bio)->bip_flags &
> + BIP_INTEGRITY_USER) {

Make this an "else if" instead of nesting it an extra level.

> + nvme_setup_user_integrity(ns, req, cmnd,
> + &control);
> + goto out;
> + }

And this can be structured a little differently so that you don't need
the "goto"; IMO, goto is good for error unwinding, but using it in a
good path harms readablilty.

This is getting complex enough that splitting it off in a helper
funciton, maybe nvme_setup_rw_meta(), might be a good idea.