]> www.infradead.org Git - users/hch/block.git/commitdiff
remove nvme_meta_from_bio
authorChristoph Hellwig <hch@lst.de>
Fri, 6 May 2022 06:22:32 +0000 (08:22 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 6 May 2022 06:39:26 +0000 (08:39 +0200)
drivers/nvme/host/ioctl.c

index c6f844587864eb421964d9d1794e5c94d2568e63..6077c17be5951232a6f5c18ca2c5dfa6986a7dcb 100644 (file)
@@ -19,17 +19,6 @@ static void __user *nvme_to_user_ptr(uintptr_t ptrval)
        return (void __user *)ptrval;
 }
 
-static inline void *nvme_meta_from_bio(struct bio *bio)
-{
-       if (bio) {
-               struct bio_integrity_payload *bip = bio_integrity(bio);
-
-               return bip ? bvec_virt(bip->bip_vec) : NULL;
-       }
-
-       return NULL;
-}
-
 static void *nvme_add_user_metadata(struct bio *bio, void __user *ubuf,
                unsigned len, u32 seed, bool write)
 {
@@ -67,7 +56,7 @@ out:
 static struct request *nvme_alloc_user_request(struct request_queue *q,
                struct nvme_command *cmd, void __user *ubuffer,
                unsigned bufflen, void __user *meta_buffer, unsigned meta_len,
-               u32 meta_seed, unsigned timeout, bool vec)
+               u32 meta_seed, void **metap, unsigned timeout, bool vec)
 {
        bool write = nvme_is_write(cmd);
        struct nvme_ns *ns = q->queuedata;
@@ -116,6 +105,7 @@ static struct request *nvme_alloc_user_request(struct request_queue *q,
                                goto out_unmap;
                        }
                        req->cmd_flags |= REQ_INTEGRITY;
+                       *metap = meta;
                }
        }
 
@@ -130,17 +120,16 @@ out:
 }
 
 static int nvme_execute_user_rq(struct request *req, void __user *meta_buffer,
-               unsigned meta_len, u64 *result)
+               unsigned meta_len, void *meta, u64 *result)
 {
        struct bio *bio = req->bio;
-       void *meta = nvme_meta_from_bio(bio);
        int ret;
 
        ret = nvme_execute_passthru_rq(req);
 
        if (result)
                *result = le64_to_cpu(nvme_req(req)->result.u64);
-       if (meta) {
+       if (meta_len) {
                bool write = bio_op(bio) == REQ_OP_DRV_OUT;
 
                if (!ret && !write && copy_to_user(meta_buffer, meta, meta_len))
@@ -159,12 +148,13 @@ static int nvme_submit_user_cmd(struct request_queue *q,
                u32 meta_seed, u64 *result, unsigned timeout, bool vec)
 {
        struct request *req;
+       void *meta = NULL;
 
        req = nvme_alloc_user_request(q, cmd, ubuffer, bufflen, meta_buffer,
-                       meta_len, meta_seed, timeout, vec);
+                       meta_len, meta_seed, &meta, timeout, vec);
        if (IS_ERR(req))
                return PTR_ERR(req);
-       return nvme_execute_user_rq(req, meta_buffer, meta_len, result);
+       return nvme_execute_user_rq(req, meta_buffer, meta_len, meta, result);
 }
 
 static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)