Lines Matching full:req
126 u16 blk_to_nvme_status(struct nvmet_req *req, blk_status_t blk_sts) in blk_to_nvme_status() argument
141 req->error_loc = offsetof(struct nvme_rw_command, length); in blk_to_nvme_status()
145 req->error_loc = offsetof(struct nvme_rw_command, slba); in blk_to_nvme_status()
148 req->error_loc = offsetof(struct nvme_common_command, opcode); in blk_to_nvme_status()
149 switch (req->cmd->common.opcode) { in blk_to_nvme_status()
160 req->error_loc = offsetof(struct nvme_rw_command, nsid); in blk_to_nvme_status()
165 req->error_loc = offsetof(struct nvme_common_command, opcode); in blk_to_nvme_status()
168 switch (req->cmd->common.opcode) { in blk_to_nvme_status()
171 req->error_slba = le64_to_cpu(req->cmd->rw.slba); in blk_to_nvme_status()
174 req->error_slba = in blk_to_nvme_status()
175 le64_to_cpu(req->cmd->write_zeroes.slba); in blk_to_nvme_status()
178 req->error_slba = 0; in blk_to_nvme_status()
185 struct nvmet_req *req = bio->bi_private; in nvmet_bio_done() local
187 nvmet_req_complete(req, blk_to_nvme_status(req, bio->bi_status)); in nvmet_bio_done()
188 nvmet_req_bio_put(req, bio); in nvmet_bio_done()
192 static int nvmet_bdev_alloc_bip(struct nvmet_req *req, struct bio *bio, in nvmet_bdev_alloc_bip() argument
200 bi = bdev_get_integrity(req->ns->bdev); in nvmet_bdev_alloc_bip()
207 bio_max_segs(req->metadata_sg_cnt)); in nvmet_bdev_alloc_bip()
237 static int nvmet_bdev_alloc_bip(struct nvmet_req *req, struct bio *bio, in nvmet_bdev_alloc_bip() argument
244 static void nvmet_bdev_execute_rw(struct nvmet_req *req) in nvmet_bdev_execute_rw() argument
246 unsigned int sg_cnt = req->sg_cnt; in nvmet_bdev_execute_rw()
255 unsigned int total_len = nvmet_rw_data_len(req) + req->metadata_len; in nvmet_bdev_execute_rw()
257 if (!nvmet_check_transfer_len(req, total_len)) in nvmet_bdev_execute_rw()
260 if (!req->sg_cnt) { in nvmet_bdev_execute_rw()
261 nvmet_req_complete(req, 0); in nvmet_bdev_execute_rw()
265 if (req->cmd->rw.opcode == nvme_cmd_write) { in nvmet_bdev_execute_rw()
267 if (req->cmd->rw.control & cpu_to_le16(NVME_RW_FUA)) in nvmet_bdev_execute_rw()
275 if (is_pci_p2pdma_page(sg_page(req->sg))) in nvmet_bdev_execute_rw()
278 sector = nvmet_lba_to_sect(req->ns, req->cmd->rw.slba); in nvmet_bdev_execute_rw()
280 if (nvmet_use_inline_bvec(req)) { in nvmet_bdev_execute_rw()
281 bio = &req->b.inline_bio; in nvmet_bdev_execute_rw()
282 bio_init(bio, req->ns->bdev, req->inline_bvec, in nvmet_bdev_execute_rw()
283 ARRAY_SIZE(req->inline_bvec), opf); in nvmet_bdev_execute_rw()
285 bio = bio_alloc(req->ns->bdev, bio_max_segs(sg_cnt), opf, in nvmet_bdev_execute_rw()
289 bio->bi_private = req; in nvmet_bdev_execute_rw()
293 if (req->metadata_len) in nvmet_bdev_execute_rw()
294 sg_miter_start(&prot_miter, req->metadata_sg, in nvmet_bdev_execute_rw()
295 req->metadata_sg_cnt, iter_flags); in nvmet_bdev_execute_rw()
297 for_each_sg(req->sg, sg, req->sg_cnt, i) { in nvmet_bdev_execute_rw()
302 if (req->metadata_len) { in nvmet_bdev_execute_rw()
303 rc = nvmet_bdev_alloc_bip(req, bio, in nvmet_bdev_execute_rw()
311 bio = bio_alloc(req->ns->bdev, bio_max_segs(sg_cnt), in nvmet_bdev_execute_rw()
323 if (req->metadata_len) { in nvmet_bdev_execute_rw()
324 rc = nvmet_bdev_alloc_bip(req, bio, &prot_miter); in nvmet_bdev_execute_rw()
335 static void nvmet_bdev_execute_flush(struct nvmet_req *req) in nvmet_bdev_execute_flush() argument
337 struct bio *bio = &req->b.inline_bio; in nvmet_bdev_execute_flush()
339 if (!bdev_write_cache(req->ns->bdev)) { in nvmet_bdev_execute_flush()
340 nvmet_req_complete(req, NVME_SC_SUCCESS); in nvmet_bdev_execute_flush()
344 if (!nvmet_check_transfer_len(req, 0)) in nvmet_bdev_execute_flush()
347 bio_init(bio, req->ns->bdev, req->inline_bvec, in nvmet_bdev_execute_flush()
348 ARRAY_SIZE(req->inline_bvec), REQ_OP_WRITE | REQ_PREFLUSH); in nvmet_bdev_execute_flush()
349 bio->bi_private = req; in nvmet_bdev_execute_flush()
355 u16 nvmet_bdev_flush(struct nvmet_req *req) in nvmet_bdev_flush() argument
357 if (!bdev_write_cache(req->ns->bdev)) in nvmet_bdev_flush()
360 if (blkdev_issue_flush(req->ns->bdev)) in nvmet_bdev_flush()
365 static u16 nvmet_bdev_discard_range(struct nvmet_req *req, in nvmet_bdev_discard_range() argument
368 struct nvmet_ns *ns = req->ns; in nvmet_bdev_discard_range()
376 req->error_slba = le64_to_cpu(range->slba); in nvmet_bdev_discard_range()
377 return errno_to_nvme_status(req, ret); in nvmet_bdev_discard_range()
382 static void nvmet_bdev_execute_discard(struct nvmet_req *req) in nvmet_bdev_execute_discard() argument
389 for (i = 0; i <= le32_to_cpu(req->cmd->dsm.nr); i++) { in nvmet_bdev_execute_discard()
390 status = nvmet_copy_from_sgl(req, i * sizeof(range), &range, in nvmet_bdev_execute_discard()
395 status = nvmet_bdev_discard_range(req, &range, &bio); in nvmet_bdev_execute_discard()
401 bio->bi_private = req; in nvmet_bdev_execute_discard()
408 nvmet_req_complete(req, status); in nvmet_bdev_execute_discard()
412 static void nvmet_bdev_execute_dsm(struct nvmet_req *req) in nvmet_bdev_execute_dsm() argument
414 if (!nvmet_check_data_len_lte(req, nvmet_dsm_len(req))) in nvmet_bdev_execute_dsm()
417 switch (le32_to_cpu(req->cmd->dsm.attributes)) { in nvmet_bdev_execute_dsm()
419 nvmet_bdev_execute_discard(req); in nvmet_bdev_execute_dsm()
425 nvmet_req_complete(req, 0); in nvmet_bdev_execute_dsm()
430 static void nvmet_bdev_execute_write_zeroes(struct nvmet_req *req) in nvmet_bdev_execute_write_zeroes() argument
432 struct nvme_write_zeroes_cmd *write_zeroes = &req->cmd->write_zeroes; in nvmet_bdev_execute_write_zeroes()
438 if (!nvmet_check_transfer_len(req, 0)) in nvmet_bdev_execute_write_zeroes()
441 sector = nvmet_lba_to_sect(req->ns, write_zeroes->slba); in nvmet_bdev_execute_write_zeroes()
443 (req->ns->blksize_shift - 9)); in nvmet_bdev_execute_write_zeroes()
445 ret = __blkdev_issue_zeroout(req->ns->bdev, sector, nr_sector, in nvmet_bdev_execute_write_zeroes()
448 bio->bi_private = req; in nvmet_bdev_execute_write_zeroes()
452 nvmet_req_complete(req, errno_to_nvme_status(req, ret)); in nvmet_bdev_execute_write_zeroes()
456 u16 nvmet_bdev_parse_io_cmd(struct nvmet_req *req) in nvmet_bdev_parse_io_cmd() argument
458 switch (req->cmd->common.opcode) { in nvmet_bdev_parse_io_cmd()
461 req->execute = nvmet_bdev_execute_rw; in nvmet_bdev_parse_io_cmd()
462 if (req->sq->ctrl->pi_support && nvmet_ns_has_pi(req->ns)) in nvmet_bdev_parse_io_cmd()
463 req->metadata_len = nvmet_rw_metadata_len(req); in nvmet_bdev_parse_io_cmd()
466 req->execute = nvmet_bdev_execute_flush; in nvmet_bdev_parse_io_cmd()
469 req->execute = nvmet_bdev_execute_dsm; in nvmet_bdev_parse_io_cmd()
472 req->execute = nvmet_bdev_execute_write_zeroes; in nvmet_bdev_parse_io_cmd()
475 return nvmet_report_invalid_opcode(req); in nvmet_bdev_parse_io_cmd()