Lines Matching full:req

105 static u16 blk_to_nvme_status(struct nvmet_req *req, blk_status_t blk_sts)  in blk_to_nvme_status()  argument
120 req->error_loc = offsetof(struct nvme_rw_command, length); in blk_to_nvme_status()
124 req->error_loc = offsetof(struct nvme_rw_command, slba); in blk_to_nvme_status()
127 req->error_loc = offsetof(struct nvme_common_command, opcode); in blk_to_nvme_status()
128 switch (req->cmd->common.opcode) { in blk_to_nvme_status()
139 req->error_loc = offsetof(struct nvme_rw_command, nsid); in blk_to_nvme_status()
144 req->error_loc = offsetof(struct nvme_common_command, opcode); in blk_to_nvme_status()
147 switch (req->cmd->common.opcode) { in blk_to_nvme_status()
150 req->error_slba = le64_to_cpu(req->cmd->rw.slba); in blk_to_nvme_status()
153 req->error_slba = in blk_to_nvme_status()
154 le64_to_cpu(req->cmd->write_zeroes.slba); in blk_to_nvme_status()
157 req->error_slba = 0; in blk_to_nvme_status()
164 struct nvmet_req *req = bio->bi_private; in nvmet_bio_done() local
166 nvmet_req_complete(req, blk_to_nvme_status(req, bio->bi_status)); in nvmet_bio_done()
167 if (bio != &req->b.inline_bio) in nvmet_bio_done()
172 static int nvmet_bdev_alloc_bip(struct nvmet_req *req, struct bio *bio, in nvmet_bdev_alloc_bip() argument
177 struct block_device *bdev = req->ns->bdev; in nvmet_bdev_alloc_bip()
188 min_t(unsigned int, req->metadata_sg_cnt, BIO_MAX_PAGES)); in nvmet_bdev_alloc_bip()
219 static int nvmet_bdev_alloc_bip(struct nvmet_req *req, struct bio *bio, in nvmet_bdev_alloc_bip() argument
226 static void nvmet_bdev_execute_rw(struct nvmet_req *req) in nvmet_bdev_execute_rw() argument
228 int sg_cnt = req->sg_cnt; in nvmet_bdev_execute_rw()
236 unsigned int total_len = nvmet_rw_data_len(req) + req->metadata_len; in nvmet_bdev_execute_rw()
238 if (!nvmet_check_transfer_len(req, total_len)) in nvmet_bdev_execute_rw()
241 if (!req->sg_cnt) { in nvmet_bdev_execute_rw()
242 nvmet_req_complete(req, 0); in nvmet_bdev_execute_rw()
246 if (req->cmd->rw.opcode == nvme_cmd_write) { in nvmet_bdev_execute_rw()
248 if (req->cmd->rw.control & cpu_to_le16(NVME_RW_FUA)) in nvmet_bdev_execute_rw()
256 if (is_pci_p2pdma_page(sg_page(req->sg))) in nvmet_bdev_execute_rw()
259 sector = le64_to_cpu(req->cmd->rw.slba); in nvmet_bdev_execute_rw()
260 sector <<= (req->ns->blksize_shift - 9); in nvmet_bdev_execute_rw()
262 if (req->transfer_len <= NVMET_MAX_INLINE_DATA_LEN) { in nvmet_bdev_execute_rw()
263 bio = &req->b.inline_bio; in nvmet_bdev_execute_rw()
264 bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec)); in nvmet_bdev_execute_rw()
268 bio_set_dev(bio, req->ns->bdev); in nvmet_bdev_execute_rw()
270 bio->bi_private = req; in nvmet_bdev_execute_rw()
275 if (req->metadata_len) in nvmet_bdev_execute_rw()
276 sg_miter_start(&prot_miter, req->metadata_sg, in nvmet_bdev_execute_rw()
277 req->metadata_sg_cnt, iter_flags); in nvmet_bdev_execute_rw()
279 for_each_sg(req->sg, sg, req->sg_cnt, i) { in nvmet_bdev_execute_rw()
284 if (req->metadata_len) { in nvmet_bdev_execute_rw()
285 rc = nvmet_bdev_alloc_bip(req, bio, in nvmet_bdev_execute_rw()
294 bio_set_dev(bio, req->ns->bdev); in nvmet_bdev_execute_rw()
306 if (req->metadata_len) { in nvmet_bdev_execute_rw()
307 rc = nvmet_bdev_alloc_bip(req, bio, &prot_miter); in nvmet_bdev_execute_rw()
318 static void nvmet_bdev_execute_flush(struct nvmet_req *req) in nvmet_bdev_execute_flush() argument
320 struct bio *bio = &req->b.inline_bio; in nvmet_bdev_execute_flush()
322 if (!nvmet_check_transfer_len(req, 0)) in nvmet_bdev_execute_flush()
325 bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec)); in nvmet_bdev_execute_flush()
326 bio_set_dev(bio, req->ns->bdev); in nvmet_bdev_execute_flush()
327 bio->bi_private = req; in nvmet_bdev_execute_flush()
334 u16 nvmet_bdev_flush(struct nvmet_req *req) in nvmet_bdev_flush() argument
336 if (blkdev_issue_flush(req->ns->bdev, GFP_KERNEL)) in nvmet_bdev_flush()
341 static u16 nvmet_bdev_discard_range(struct nvmet_req *req, in nvmet_bdev_discard_range() argument
344 struct nvmet_ns *ns = req->ns; in nvmet_bdev_discard_range()
352 req->error_slba = le64_to_cpu(range->slba); in nvmet_bdev_discard_range()
353 return errno_to_nvme_status(req, ret); in nvmet_bdev_discard_range()
358 static void nvmet_bdev_execute_discard(struct nvmet_req *req) in nvmet_bdev_execute_discard() argument
365 for (i = 0; i <= le32_to_cpu(req->cmd->dsm.nr); i++) { in nvmet_bdev_execute_discard()
366 status = nvmet_copy_from_sgl(req, i * sizeof(range), &range, in nvmet_bdev_execute_discard()
371 status = nvmet_bdev_discard_range(req, &range, &bio); in nvmet_bdev_execute_discard()
377 bio->bi_private = req; in nvmet_bdev_execute_discard()
384 nvmet_req_complete(req, status); in nvmet_bdev_execute_discard()
388 static void nvmet_bdev_execute_dsm(struct nvmet_req *req) in nvmet_bdev_execute_dsm() argument
390 if (!nvmet_check_data_len_lte(req, nvmet_dsm_len(req))) in nvmet_bdev_execute_dsm()
393 switch (le32_to_cpu(req->cmd->dsm.attributes)) { in nvmet_bdev_execute_dsm()
395 nvmet_bdev_execute_discard(req); in nvmet_bdev_execute_dsm()
401 nvmet_req_complete(req, 0); in nvmet_bdev_execute_dsm()
406 static void nvmet_bdev_execute_write_zeroes(struct nvmet_req *req) in nvmet_bdev_execute_write_zeroes() argument
408 struct nvme_write_zeroes_cmd *write_zeroes = &req->cmd->write_zeroes; in nvmet_bdev_execute_write_zeroes()
414 if (!nvmet_check_transfer_len(req, 0)) in nvmet_bdev_execute_write_zeroes()
418 (req->ns->blksize_shift - 9); in nvmet_bdev_execute_write_zeroes()
420 (req->ns->blksize_shift - 9)); in nvmet_bdev_execute_write_zeroes()
422 ret = __blkdev_issue_zeroout(req->ns->bdev, sector, nr_sector, in nvmet_bdev_execute_write_zeroes()
425 bio->bi_private = req; in nvmet_bdev_execute_write_zeroes()
429 nvmet_req_complete(req, errno_to_nvme_status(req, ret)); in nvmet_bdev_execute_write_zeroes()
433 u16 nvmet_bdev_parse_io_cmd(struct nvmet_req *req) in nvmet_bdev_parse_io_cmd() argument
435 struct nvme_command *cmd = req->cmd; in nvmet_bdev_parse_io_cmd()
440 req->execute = nvmet_bdev_execute_rw; in nvmet_bdev_parse_io_cmd()
441 if (req->sq->ctrl->pi_support && nvmet_ns_has_pi(req->ns)) in nvmet_bdev_parse_io_cmd()
442 req->metadata_len = nvmet_rw_metadata_len(req); in nvmet_bdev_parse_io_cmd()
445 req->execute = nvmet_bdev_execute_flush; in nvmet_bdev_parse_io_cmd()
448 req->execute = nvmet_bdev_execute_dsm; in nvmet_bdev_parse_io_cmd()
451 req->execute = nvmet_bdev_execute_write_zeroes; in nvmet_bdev_parse_io_cmd()
455 req->sq->qid); in nvmet_bdev_parse_io_cmd()
456 req->error_loc = offsetof(struct nvme_common_command, opcode); in nvmet_bdev_parse_io_cmd()