Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-5.16/passthrough-flag-2021-10-29' of git://git.kernel.dk/linux-block

Pull QUEUE_FLAG_SCSI_PASSTHROUGH removal from Jens Axboe:
"This contains a series leading to the removal of the
QUEUE_FLAG_SCSI_PASSTHROUGH queue flag"

* tag 'for-5.16/passthrough-flag-2021-10-29' of git://git.kernel.dk/linux-block:
block: remove blk_{get,put}_request
block: remove QUEUE_FLAG_SCSI_PASSTHROUGH
block: remove the initialize_rq_fn blk_mq_ops method
scsi: add a scsi_alloc_request helper
bsg-lib: initialize the bsg_job in bsg_transport_sg_io_fn
nfsd/blocklayout: use ->get_unique_id instead of sending SCSI commands
sd: implement ->get_unique_id
block: add a ->get_unique_id method

+189 -242
-28
block/blk-core.c
··· 597 597 } 598 598 EXPORT_SYMBOL(blk_get_queue); 599 599 600 - /** 601 - * blk_get_request - allocate a request 602 - * @q: request queue to allocate a request for 603 - * @op: operation (REQ_OP_*) and REQ_* flags, e.g. REQ_SYNC. 604 - * @flags: BLK_MQ_REQ_* flags, e.g. BLK_MQ_REQ_NOWAIT. 605 - */ 606 - struct request *blk_get_request(struct request_queue *q, unsigned int op, 607 - blk_mq_req_flags_t flags) 608 - { 609 - struct request *req; 610 - 611 - WARN_ON_ONCE(op & REQ_NOWAIT); 612 - WARN_ON_ONCE(flags & ~(BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_PM)); 613 - 614 - req = blk_mq_alloc_request(q, op, flags); 615 - if (!IS_ERR(req) && q->mq_ops->initialize_rq_fn) 616 - q->mq_ops->initialize_rq_fn(req); 617 - 618 - return req; 619 - } 620 - EXPORT_SYMBOL(blk_get_request); 621 - 622 - void blk_put_request(struct request *req) 623 - { 624 - blk_mq_free_request(req); 625 - } 626 - EXPORT_SYMBOL(blk_put_request); 627 - 628 600 static void handle_bad_sector(struct bio *bio, sector_t maxsector) 629 601 { 630 602 char b[BDEVNAME_SIZE];
-1
block/blk-mq-debugfs.c
··· 124 124 QUEUE_FLAG_NAME(STATS), 125 125 QUEUE_FLAG_NAME(POLL_STATS), 126 126 QUEUE_FLAG_NAME(REGISTERED), 127 - QUEUE_FLAG_NAME(SCSI_PASSTHROUGH), 128 127 QUEUE_FLAG_NAME(QUIESCED), 129 128 QUEUE_FLAG_NAME(PCI_P2PDMA), 130 129 QUEUE_FLAG_NAME(ZONE_RESETALL),
+13 -19
block/bsg-lib.c
··· 31 31 struct bsg_job *job; 32 32 struct request *rq; 33 33 struct bio *bio; 34 + void *reply; 34 35 int ret; 35 36 36 37 if (hdr->protocol != BSG_PROTOCOL_SCSI || ··· 40 39 if (!capable(CAP_SYS_RAWIO)) 41 40 return -EPERM; 42 41 43 - rq = blk_get_request(q, hdr->dout_xfer_len ? 42 + rq = blk_mq_alloc_request(q, hdr->dout_xfer_len ? 44 43 REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 45 44 if (IS_ERR(rq)) 46 45 return PTR_ERR(rq); 47 46 rq->timeout = timeout; 48 47 49 48 job = blk_mq_rq_to_pdu(rq); 49 + reply = job->reply; 50 + memset(job, 0, sizeof(*job)); 51 + job->reply = reply; 52 + job->reply_len = SCSI_SENSE_BUFFERSIZE; 53 + job->dd_data = job + 1; 54 + 50 55 job->request_len = hdr->request_len; 51 56 job->request = memdup_user(uptr64(hdr->request), hdr->request_len); 52 57 if (IS_ERR(job->request)) { 53 58 ret = PTR_ERR(job->request); 54 - goto out_put_request; 59 + goto out_free_rq; 55 60 } 56 61 57 62 if (hdr->dout_xfer_len && hdr->din_xfer_len) { 58 - job->bidi_rq = blk_get_request(rq->q, REQ_OP_DRV_IN, 0); 63 + job->bidi_rq = blk_mq_alloc_request(rq->q, REQ_OP_DRV_IN, 0); 59 64 if (IS_ERR(job->bidi_rq)) { 60 65 ret = PTR_ERR(job->bidi_rq); 61 66 goto out_free_job_request; ··· 141 134 blk_rq_unmap_user(job->bidi_bio); 142 135 out_free_bidi_rq: 143 136 if (job->bidi_rq) 144 - blk_put_request(job->bidi_rq); 137 + blk_mq_free_request(job->bidi_rq); 145 138 out_free_job_request: 146 139 kfree(job->request); 147 - out_put_request: 148 - blk_put_request(rq); 140 + out_free_rq: 141 + blk_mq_free_request(rq); 149 142 return ret; 150 143 } 151 144 ··· 309 302 return 0; 310 303 } 311 304 312 - /* called right before the request is given to the request_queue user */ 313 - static void bsg_initialize_rq(struct request *req) 314 - { 315 - struct bsg_job *job = blk_mq_rq_to_pdu(req); 316 - void *reply = job->reply; 317 - 318 - memset(job, 0, sizeof(*job)); 319 - job->reply = reply; 320 - job->reply_len = SCSI_SENSE_BUFFERSIZE; 321 - job->dd_data = job + 1; 322 - } 323 - 324 305 static void bsg_exit_rq(struct blk_mq_tag_set *set, struct request *req, 325 306 unsigned int hctx_idx) 326 307 { ··· 345 350 .queue_rq = bsg_queue_rq, 346 351 .init_request = bsg_init_rq, 347 352 .exit_request = bsg_exit_rq, 348 - .initialize_rq_fn = bsg_initialize_rq, 349 353 .complete = bsg_complete, 350 354 .timeout = bsg_timeout, 351 355 };
+1 -1
drivers/block/Kconfig
··· 281 281 config CDROM_PKTCDVD 282 282 tristate "Packet writing on CD/DVD media (DEPRECATED)" 283 283 depends on !UML 284 + depends on SCSI 284 285 select CDROM 285 - select SCSI_COMMON 286 286 help 287 287 Note: This driver is deprecated and will be removed from the 288 288 kernel in the near future!
+2 -2
drivers/block/paride/pd.c
··· 775 775 struct request *rq; 776 776 struct pd_req *req; 777 777 778 - rq = blk_get_request(disk->gd->queue, REQ_OP_DRV_IN, 0); 778 + rq = blk_mq_alloc_request(disk->gd->queue, REQ_OP_DRV_IN, 0); 779 779 if (IS_ERR(rq)) 780 780 return PTR_ERR(rq); 781 781 req = blk_mq_rq_to_pdu(rq); 782 782 783 783 req->func = func; 784 784 blk_execute_rq(disk->gd, rq, 0); 785 - blk_put_request(rq); 785 + blk_mq_free_request(rq); 786 786 return 0; 787 787 } 788 788
+6 -3
drivers/block/pktcdvd.c
··· 703 703 struct request *rq; 704 704 int ret = 0; 705 705 706 - rq = blk_get_request(q, (cgc->data_direction == CGC_DATA_WRITE) ? 706 + rq = scsi_alloc_request(q, (cgc->data_direction == CGC_DATA_WRITE) ? 707 707 REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 708 708 if (IS_ERR(rq)) 709 709 return PTR_ERR(rq); ··· 726 726 if (scsi_req(rq)->result) 727 727 ret = -EIO; 728 728 out: 729 - blk_put_request(rq); 729 + blk_mq_free_request(rq); 730 730 return ret; 731 731 } 732 732 ··· 2536 2536 int i; 2537 2537 char b[BDEVNAME_SIZE]; 2538 2538 struct block_device *bdev; 2539 + struct scsi_device *sdev; 2539 2540 2540 2541 if (pd->pkt_dev == dev) { 2541 2542 pkt_err(pd, "recursive setup not allowed\n"); ··· 2560 2559 bdev = blkdev_get_by_dev(dev, FMODE_READ | FMODE_NDELAY, NULL); 2561 2560 if (IS_ERR(bdev)) 2562 2561 return PTR_ERR(bdev); 2563 - if (!blk_queue_scsi_passthrough(bdev_get_queue(bdev))) { 2562 + sdev = scsi_device_from_queue(bdev->bd_disk->queue); 2563 + if (!sdev) { 2564 2564 blkdev_put(bdev, FMODE_READ | FMODE_NDELAY); 2565 2565 return -EINVAL; 2566 2566 } 2567 + put_device(&sdev->sdev_gendev); 2567 2568 2568 2569 /* This is safe, since we have a reference from open(). */ 2569 2570 __module_get(THIS_MODULE);
+2 -2
drivers/block/virtio_blk.c
··· 312 312 struct request *req; 313 313 int err; 314 314 315 - req = blk_get_request(q, REQ_OP_DRV_IN, 0); 315 + req = blk_mq_alloc_request(q, REQ_OP_DRV_IN, 0); 316 316 if (IS_ERR(req)) 317 317 return PTR_ERR(req); 318 318 ··· 323 323 blk_execute_rq(vblk->disk, req, false); 324 324 err = blk_status_to_errno(virtblk_result(blk_mq_rq_to_pdu(req))); 325 325 out: 326 - blk_put_request(req); 326 + blk_mq_free_request(req); 327 327 return err; 328 328 } 329 329
+2 -2
drivers/md/dm-mpath.c
··· 530 530 531 531 bdev = pgpath->path.dev->bdev; 532 532 q = bdev_get_queue(bdev); 533 - clone = blk_get_request(q, rq->cmd_flags | REQ_NOMERGE, 533 + clone = blk_mq_alloc_request(q, rq->cmd_flags | REQ_NOMERGE, 534 534 BLK_MQ_REQ_NOWAIT); 535 535 if (IS_ERR(clone)) { 536 536 /* EBUSY, ENODEV or EWOULDBLOCK: requeue */ ··· 579 579 clone->io_start_time_ns); 580 580 } 581 581 582 - blk_put_request(clone); 582 + blk_mq_free_request(clone); 583 583 } 584 584 585 585 /*
+10 -10
drivers/mmc/core/block.c
··· 258 258 mq = &md->queue; 259 259 260 260 /* Dispatch locking to the block layer */ 261 - req = blk_get_request(mq->queue, REQ_OP_DRV_OUT, 0); 261 + req = blk_mq_alloc_request(mq->queue, REQ_OP_DRV_OUT, 0); 262 262 if (IS_ERR(req)) { 263 263 count = PTR_ERR(req); 264 264 goto out_put; ··· 266 266 req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_BOOT_WP; 267 267 blk_execute_rq(NULL, req, 0); 268 268 ret = req_to_mmc_queue_req(req)->drv_op_result; 269 - blk_put_request(req); 269 + blk_mq_free_request(req); 270 270 271 271 if (!ret) { 272 272 pr_info("%s: Locking boot partition ro until next power on\n", ··· 646 646 * Dispatch the ioctl() into the block request queue. 647 647 */ 648 648 mq = &md->queue; 649 - req = blk_get_request(mq->queue, 649 + req = blk_mq_alloc_request(mq->queue, 650 650 idata->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 651 651 if (IS_ERR(req)) { 652 652 err = PTR_ERR(req); ··· 660 660 blk_execute_rq(NULL, req, 0); 661 661 ioc_err = req_to_mmc_queue_req(req)->drv_op_result; 662 662 err = mmc_blk_ioctl_copy_to_user(ic_ptr, idata); 663 - blk_put_request(req); 663 + blk_mq_free_request(req); 664 664 665 665 cmd_done: 666 666 kfree(idata->buf); ··· 716 716 * Dispatch the ioctl()s into the block request queue. 717 717 */ 718 718 mq = &md->queue; 719 - req = blk_get_request(mq->queue, 719 + req = blk_mq_alloc_request(mq->queue, 720 720 idata[0]->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 721 721 if (IS_ERR(req)) { 722 722 err = PTR_ERR(req); ··· 733 733 for (i = 0; i < num_of_cmds && !err; i++) 734 734 err = mmc_blk_ioctl_copy_to_user(&cmds[i], idata[i]); 735 735 736 - blk_put_request(req); 736 + blk_mq_free_request(req); 737 737 738 738 cmd_err: 739 739 for (i = 0; i < num_of_cmds; i++) { ··· 2730 2730 int ret; 2731 2731 2732 2732 /* Ask the block layer about the card status */ 2733 - req = blk_get_request(mq->queue, REQ_OP_DRV_IN, 0); 2733 + req = blk_mq_alloc_request(mq->queue, REQ_OP_DRV_IN, 0); 2734 2734 if (IS_ERR(req)) 2735 2735 return PTR_ERR(req); 2736 2736 req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_CARD_STATUS; ··· 2740 2740 *val = ret; 2741 2741 ret = 0; 2742 2742 } 2743 - blk_put_request(req); 2743 + blk_mq_free_request(req); 2744 2744 2745 2745 return ret; 2746 2746 } ··· 2766 2766 return -ENOMEM; 2767 2767 2768 2768 /* Ask the block layer for the EXT CSD */ 2769 - req = blk_get_request(mq->queue, REQ_OP_DRV_IN, 0); 2769 + req = blk_mq_alloc_request(mq->queue, REQ_OP_DRV_IN, 0); 2770 2770 if (IS_ERR(req)) { 2771 2771 err = PTR_ERR(req); 2772 2772 goto out_free; ··· 2775 2775 req_to_mmc_queue_req(req)->drv_op_data = &ext_csd; 2776 2776 blk_execute_rq(NULL, req, 0); 2777 2777 err = req_to_mmc_queue_req(req)->drv_op_result; 2778 - blk_put_request(req); 2778 + blk_mq_free_request(req); 2779 2779 if (err) { 2780 2780 pr_err("FAILED %d\n", err); 2781 2781 goto out_free;
+3 -3
drivers/scsi/scsi_bsg.c
··· 25 25 return -EOPNOTSUPP; 26 26 } 27 27 28 - rq = blk_get_request(q, hdr->dout_xfer_len ? 29 - REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 28 + rq = scsi_alloc_request(q, hdr->dout_xfer_len ? 29 + REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 30 30 if (IS_ERR(rq)) 31 31 return PTR_ERR(rq); 32 32 rq->timeout = timeout; ··· 95 95 out_free_cmd: 96 96 scsi_req_free_cmd(scsi_req(rq)); 97 97 out_put_request: 98 - blk_put_request(rq); 98 + blk_mq_free_request(rq); 99 99 return ret; 100 100 } 101 101
+2 -2
drivers/scsi/scsi_error.c
··· 1979 1979 1980 1980 static void eh_lock_door_done(struct request *req, blk_status_t status) 1981 1981 { 1982 - blk_put_request(req); 1982 + blk_mq_free_request(req); 1983 1983 } 1984 1984 1985 1985 /** ··· 1998 1998 struct request *req; 1999 1999 struct scsi_request *rq; 2000 2000 2001 - req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN, 0); 2001 + req = scsi_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, 0); 2002 2002 if (IS_ERR(req)) 2003 2003 return; 2004 2004 rq = scsi_req(req);
+4 -4
drivers/scsi/scsi_ioctl.c
··· 438 438 at_head = 1; 439 439 440 440 ret = -ENOMEM; 441 - rq = blk_get_request(sdev->request_queue, writing ? 441 + rq = scsi_alloc_request(sdev->request_queue, writing ? 442 442 REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 443 443 if (IS_ERR(rq)) 444 444 return PTR_ERR(rq); ··· 490 490 out_free_cdb: 491 491 scsi_req_free_cmd(req); 492 492 out_put_request: 493 - blk_put_request(rq); 493 + blk_mq_free_request(rq); 494 494 return ret; 495 495 } 496 496 ··· 561 561 562 562 } 563 563 564 - rq = blk_get_request(q, in_len ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 564 + rq = scsi_alloc_request(q, in_len ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 565 565 if (IS_ERR(rq)) { 566 566 err = PTR_ERR(rq); 567 567 goto error_free_buffer; ··· 634 634 } 635 635 636 636 error: 637 - blk_put_request(rq); 637 + blk_mq_free_request(rq); 638 638 639 639 error_free_buffer: 640 640 kfree(buffer);
+22 -7
drivers/scsi/scsi_lib.c
··· 216 216 struct scsi_request *rq; 217 217 int ret; 218 218 219 - req = blk_get_request(sdev->request_queue, 219 + req = scsi_alloc_request(sdev->request_queue, 220 220 data_direction == DMA_TO_DEVICE ? 221 221 REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 222 222 rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0); ··· 260 260 scsi_normalize_sense(rq->sense, rq->sense_len, sshdr); 261 261 ret = rq->result; 262 262 out: 263 - blk_put_request(req); 263 + blk_mq_free_request(req); 264 264 265 265 return ret; 266 266 } ··· 1079 1079 * This function initializes the members of struct scsi_cmnd that must be 1080 1080 * initialized before request processing starts and that won't be 1081 1081 * reinitialized if a SCSI command is requeued. 1082 - * 1083 - * Called from inside blk_get_request() for pass-through requests and from 1084 - * inside scsi_init_command() for filesystem requests. 1085 1082 */ 1086 1083 static void scsi_initialize_rq(struct request *rq) 1087 1084 { ··· 1094 1097 cmd->jiffies_at_alloc = jiffies; 1095 1098 cmd->retries = 0; 1096 1099 } 1100 + 1101 + struct request *scsi_alloc_request(struct request_queue *q, 1102 + unsigned int op, blk_mq_req_flags_t flags) 1103 + { 1104 + struct request *rq; 1105 + 1106 + rq = blk_mq_alloc_request(q, op, flags); 1107 + if (!IS_ERR(rq)) 1108 + scsi_initialize_rq(rq); 1109 + return rq; 1110 + } 1111 + EXPORT_SYMBOL_GPL(scsi_alloc_request); 1097 1112 1098 1113 /* 1099 1114 * Only called when the request isn't completed by SCSI, and not freed by ··· 1873 1864 #endif 1874 1865 .init_request = scsi_mq_init_request, 1875 1866 .exit_request = scsi_mq_exit_request, 1876 - .initialize_rq_fn = scsi_initialize_rq, 1877 1867 .cleanup_rq = scsi_cleanup_rq, 1878 1868 .busy = scsi_mq_lld_busy, 1879 1869 .map_queues = scsi_map_queues, ··· 1902 1894 #endif 1903 1895 .init_request = scsi_mq_init_request, 1904 1896 .exit_request = scsi_mq_exit_request, 1905 - .initialize_rq_fn = scsi_initialize_rq, 1906 1897 .cleanup_rq = scsi_cleanup_rq, 1907 1898 .busy = scsi_mq_lld_busy, 1908 1899 .map_queues = scsi_map_queues, ··· 1967 1960 1968 1961 return sdev; 1969 1962 } 1963 + /* 1964 + * pktcdvd should have been integrated into the SCSI layers, but for historical 1965 + * reasons like the old IDE driver it isn't. This export allows it to safely 1966 + * probe if a given device is a SCSI one and only attach to that. 1967 + */ 1968 + #ifdef CONFIG_CDROM_PKTCDVD_MODULE 1969 + EXPORT_SYMBOL_GPL(scsi_device_from_queue); 1970 + #endif 1970 1971 1971 1972 /** 1972 1973 * scsi_block_requests - Utility function used by low-level drivers to prevent
-1
drivers/scsi/scsi_scan.c
··· 280 280 sdev->request_queue = q; 281 281 q->queuedata = sdev; 282 282 __scsi_init_queue(sdev->host, q); 283 - blk_queue_flag_set(QUEUE_FLAG_SCSI_PASSTHROUGH, q); 284 283 WARN_ON_ONCE(!blk_get_queue(q)); 285 284 286 285 depth = sdev->host->cmd_per_lun ?: 1;
+39
drivers/scsi/sd.c
··· 1757 1757 sd_revalidate_disk(sdkp->disk); 1758 1758 } 1759 1759 1760 + static int sd_get_unique_id(struct gendisk *disk, u8 id[16], 1761 + enum blk_unique_id type) 1762 + { 1763 + struct scsi_device *sdev = scsi_disk(disk)->device; 1764 + const struct scsi_vpd *vpd; 1765 + const unsigned char *d; 1766 + int ret = -ENXIO, len; 1767 + 1768 + rcu_read_lock(); 1769 + vpd = rcu_dereference(sdev->vpd_pg83); 1770 + if (!vpd) 1771 + goto out_unlock; 1772 + 1773 + ret = -EINVAL; 1774 + for (d = vpd->data + 4; d < vpd->data + vpd->len; d += d[3] + 4) { 1775 + /* we only care about designators with LU association */ 1776 + if (((d[1] >> 4) & 0x3) != 0x00) 1777 + continue; 1778 + if ((d[1] & 0xf) != type) 1779 + continue; 1780 + 1781 + /* 1782 + * Only exit early if a 16-byte descriptor was found. Otherwise 1783 + * keep looking as one with more entropy might still show up. 1784 + */ 1785 + len = d[3]; 1786 + if (len != 8 && len != 12 && len != 16) 1787 + continue; 1788 + ret = len; 1789 + memcpy(id, d + 4, len); 1790 + if (len == 16) 1791 + break; 1792 + } 1793 + out_unlock: 1794 + rcu_read_unlock(); 1795 + return ret; 1796 + } 1797 + 1760 1798 static char sd_pr_type(enum pr_type type) 1761 1799 { 1762 1800 switch (type) { ··· 1899 1861 .check_events = sd_check_events, 1900 1862 .unlock_native_capacity = sd_unlock_native_capacity, 1901 1863 .report_zones = sd_zbc_report_zones, 1864 + .get_unique_id = sd_get_unique_id, 1902 1865 .pr_ops = &sd_pr_ops, 1903 1866 }; 1904 1867
+5 -5
drivers/scsi/sg.c
··· 815 815 if (atomic_read(&sdp->detaching)) { 816 816 if (srp->bio) { 817 817 scsi_req_free_cmd(scsi_req(srp->rq)); 818 - blk_put_request(srp->rq); 818 + blk_mq_free_request(srp->rq); 819 819 srp->rq = NULL; 820 820 } 821 821 ··· 1390 1390 */ 1391 1391 srp->rq = NULL; 1392 1392 scsi_req_free_cmd(scsi_req(rq)); 1393 - blk_put_request(rq); 1393 + blk_mq_free_request(rq); 1394 1394 1395 1395 write_lock_irqsave(&sfp->rq_list_lock, iflags); 1396 1396 if (unlikely(srp->orphan)) { ··· 1718 1718 * 1719 1719 * With scsi-mq enabled, there are a fixed number of preallocated 1720 1720 * requests equal in number to shost->can_queue. If all of the 1721 - * preallocated requests are already in use, then blk_get_request() 1721 + * preallocated requests are already in use, then scsi_alloc_request() 1722 1722 * will sleep until an active command completes, freeing up a request. 1723 1723 * Although waiting in an asynchronous interface is less than ideal, we 1724 1724 * do not want to use BLK_MQ_REQ_NOWAIT here because userspace might 1725 1725 * not expect an EWOULDBLOCK from this condition. 1726 1726 */ 1727 - rq = blk_get_request(q, hp->dxfer_direction == SG_DXFER_TO_DEV ? 1727 + rq = scsi_alloc_request(q, hp->dxfer_direction == SG_DXFER_TO_DEV ? 1728 1728 REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 1729 1729 if (IS_ERR(rq)) { 1730 1730 kfree(long_cmdp); ··· 1830 1830 1831 1831 if (srp->rq) { 1832 1832 scsi_req_free_cmd(scsi_req(srp->rq)); 1833 - blk_put_request(srp->rq); 1833 + blk_mq_free_request(srp->rq); 1834 1834 } 1835 1835 1836 1836 if (srp->res_used)
+2 -2
drivers/scsi/sr.c
··· 967 967 struct bio *bio; 968 968 int ret; 969 969 970 - rq = blk_get_request(disk->queue, REQ_OP_DRV_IN, 0); 970 + rq = scsi_alloc_request(disk->queue, REQ_OP_DRV_IN, 0); 971 971 if (IS_ERR(rq)) 972 972 return PTR_ERR(rq); 973 973 req = scsi_req(rq); ··· 1003 1003 if (blk_rq_unmap_user(bio)) 1004 1004 ret = -EFAULT; 1005 1005 out_put_request: 1006 - blk_put_request(rq); 1006 + blk_mq_free_request(rq); 1007 1007 return ret; 1008 1008 } 1009 1009
+3 -3
drivers/scsi/st.c
··· 530 530 complete(SRpnt->waiting); 531 531 532 532 blk_rq_unmap_user(tmp); 533 - blk_put_request(req); 533 + blk_mq_free_request(req); 534 534 } 535 535 536 536 static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd, ··· 543 543 int err = 0; 544 544 struct scsi_tape *STp = SRpnt->stp; 545 545 546 - req = blk_get_request(SRpnt->stp->device->request_queue, 546 + req = scsi_alloc_request(SRpnt->stp->device->request_queue, 547 547 data_direction == DMA_TO_DEVICE ? 548 548 REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 549 549 if (IS_ERR(req)) ··· 557 557 err = blk_rq_map_user(req->q, req, mdata, NULL, bufflen, 558 558 GFP_KERNEL); 559 559 if (err) { 560 - blk_put_request(req); 560 + blk_mq_free_request(req); 561 561 return err; 562 562 } 563 563 }
+10 -10
drivers/scsi/ufs/ufshcd.c
··· 2920 2920 * Even though we use wait_event() which sleeps indefinitely, 2921 2921 * the maximum wait time is bounded by SCSI request timeout. 2922 2922 */ 2923 - req = blk_get_request(q, REQ_OP_DRV_OUT, 0); 2923 + req = blk_mq_alloc_request(q, REQ_OP_DRV_OUT, 0); 2924 2924 if (IS_ERR(req)) { 2925 2925 err = PTR_ERR(req); 2926 2926 goto out_unlock; ··· 2947 2947 (struct utp_upiu_req *)lrbp->ucd_rsp_ptr); 2948 2948 2949 2949 out: 2950 - blk_put_request(req); 2950 + blk_mq_free_request(req); 2951 2951 out_unlock: 2952 2952 up_read(&hba->clk_scaling_lock); 2953 2953 return err; ··· 6512 6512 int task_tag, err; 6513 6513 6514 6514 /* 6515 - * blk_get_request() is used here only to get a free tag. 6515 + * blk_mq_alloc_request() is used here only to get a free tag. 6516 6516 */ 6517 - req = blk_get_request(q, REQ_OP_DRV_OUT, 0); 6517 + req = blk_mq_alloc_request(q, REQ_OP_DRV_OUT, 0); 6518 6518 if (IS_ERR(req)) 6519 6519 return PTR_ERR(req); 6520 6520 ··· 6570 6570 spin_unlock_irqrestore(hba->host->host_lock, flags); 6571 6571 6572 6572 ufshcd_release(hba); 6573 - blk_put_request(req); 6573 + blk_mq_free_request(req); 6574 6574 6575 6575 return err; 6576 6576 } ··· 6655 6655 6656 6656 down_read(&hba->clk_scaling_lock); 6657 6657 6658 - req = blk_get_request(q, REQ_OP_DRV_OUT, 0); 6658 + req = blk_mq_alloc_request(q, REQ_OP_DRV_OUT, 0); 6659 6659 if (IS_ERR(req)) { 6660 6660 err = PTR_ERR(req); 6661 6661 goto out_unlock; ··· 6736 6736 (struct utp_upiu_req *)lrbp->ucd_rsp_ptr); 6737 6737 6738 6738 out: 6739 - blk_put_request(req); 6739 + blk_mq_free_request(req); 6740 6740 out_unlock: 6741 6741 up_read(&hba->clk_scaling_lock); 6742 6742 return err; ··· 7907 7907 if (error != BLK_STS_OK) 7908 7908 pr_err("%s: REQUEST SENSE failed (%d)\n", __func__, error); 7909 7909 kfree(rq->end_io_data); 7910 - blk_put_request(rq); 7910 + blk_mq_free_request(rq); 7911 7911 } 7912 7912 7913 7913 static int ··· 7927 7927 if (!buffer) 7928 7928 return -ENOMEM; 7929 7929 7930 - req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN, 7930 + req = blk_mq_alloc_request(sdev->request_queue, REQ_OP_DRV_IN, 7931 7931 /*flags=*/BLK_MQ_REQ_PM); 7932 7932 if (IS_ERR(req)) { 7933 7933 ret = PTR_ERR(req); ··· 7952 7952 return 0; 7953 7953 7954 7954 out_put: 7955 - blk_put_request(req); 7955 + blk_mq_free_request(req); 7956 7956 out_free: 7957 7957 kfree(buffer); 7958 7958 return ret;
+2 -2
drivers/scsi/ufs/ufshpb.c
··· 449 449 return NULL; 450 450 451 451 retry: 452 - req = blk_get_request(hpb->sdev_ufs_lu->request_queue, dir, 452 + req = blk_mq_alloc_request(hpb->sdev_ufs_lu->request_queue, dir, 453 453 BLK_MQ_REQ_NOWAIT); 454 454 455 455 if (!atomic && (PTR_ERR(req) == -EWOULDBLOCK) && (--retries > 0)) { ··· 473 473 474 474 static void ufshpb_put_req(struct ufshpb_lu *hpb, struct ufshpb_req *rq) 475 475 { 476 - blk_put_request(rq->req); 476 + blk_mq_free_request(rq->req); 477 477 kmem_cache_free(hpb->map_req_cache, rq); 478 478 } 479 479
+3 -4
drivers/target/target_core_pscsi.c
··· 980 980 memcpy(pt->pscsi_cdb, cmd->t_task_cdb, 981 981 scsi_command_size(cmd->t_task_cdb)); 982 982 983 - req = blk_get_request(pdv->pdv_sd->request_queue, 983 + req = scsi_alloc_request(pdv->pdv_sd->request_queue, 984 984 cmd->data_direction == DMA_TO_DEVICE ? 985 985 REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0); 986 986 if (IS_ERR(req)) { 987 - pr_err("PSCSI: blk_get_request() failed\n"); 988 987 ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 989 988 goto fail; 990 989 } ··· 1011 1012 return 0; 1012 1013 1013 1014 fail_put_request: 1014 - blk_put_request(req); 1015 + blk_mq_free_request(req); 1015 1016 fail: 1016 1017 kfree(pt); 1017 1018 return ret; ··· 1066 1067 break; 1067 1068 } 1068 1069 1069 - blk_put_request(req); 1070 + blk_mq_free_request(req); 1070 1071 kfree(pt); 1071 1072 } 1072 1073
-1
fs/nfsd/Kconfig
··· 109 109 depends on NFSD_V4 && BLOCK 110 110 select NFSD_PNFS 111 111 select EXPORTFS_BLOCK_OPS 112 - select SCSI_COMMON 113 112 help 114 113 This option enables support for the exporting pNFS SCSI layouts 115 114 in the kernel's NFS server. The pNFS SCSI layout enables NFS
+41 -117
fs/nfsd/blocklayout.c
··· 9 9 #include <linux/pr.h> 10 10 11 11 #include <linux/nfsd/debug.h> 12 - #include <scsi/scsi_proto.h> 13 - #include <scsi/scsi_common.h> 14 - #include <scsi/scsi_request.h> 15 12 16 13 #include "blocklayoutxdr.h" 17 14 #include "pnfs.h" ··· 208 211 #endif /* CONFIG_NFSD_BLOCKLAYOUT */ 209 212 210 213 #ifdef CONFIG_NFSD_SCSILAYOUT 211 - static int nfsd4_scsi_identify_device(struct block_device *bdev, 212 - struct pnfs_block_volume *b) 213 - { 214 - struct request_queue *q = bdev->bd_disk->queue; 215 - struct request *rq; 216 - struct scsi_request *req; 217 - /* 218 - * The allocation length (passed in bytes 3 and 4 of the INQUIRY 219 - * command descriptor block) specifies the number of bytes that have 220 - * been allocated for the data-in buffer. 221 - * 252 is the highest one-byte value that is a multiple of 4. 222 - * 65532 is the highest two-byte value that is a multiple of 4. 223 - */ 224 - size_t bufflen = 252, maxlen = 65532, len, id_len; 225 - u8 *buf, *d, type, assoc; 226 - int retries = 1, error; 227 - 228 - if (WARN_ON_ONCE(!blk_queue_scsi_passthrough(q))) 229 - return -EINVAL; 230 - 231 - again: 232 - buf = kzalloc(bufflen, GFP_KERNEL); 233 - if (!buf) 234 - return -ENOMEM; 235 - 236 - rq = blk_get_request(q, REQ_OP_DRV_IN, 0); 237 - if (IS_ERR(rq)) { 238 - error = -ENOMEM; 239 - goto out_free_buf; 240 - } 241 - req = scsi_req(rq); 242 - 243 - error = blk_rq_map_kern(q, rq, buf, bufflen, GFP_KERNEL); 244 - if (error) 245 - goto out_put_request; 246 - 247 - req->cmd[0] = INQUIRY; 248 - req->cmd[1] = 1; 249 - req->cmd[2] = 0x83; 250 - req->cmd[3] = bufflen >> 8; 251 - req->cmd[4] = bufflen & 0xff; 252 - req->cmd_len = COMMAND_SIZE(INQUIRY); 253 - 254 - blk_execute_rq(NULL, rq, 1); 255 - if (req->result) { 256 - pr_err("pNFS: INQUIRY 0x83 failed with: %x\n", 257 - req->result); 258 - error = -EIO; 259 - goto out_put_request; 260 - } 261 - 262 - len = (buf[2] << 8) + buf[3] + 4; 263 - if (len > bufflen) { 264 - if (len <= maxlen && retries--) { 265 - blk_put_request(rq); 266 - kfree(buf); 267 - bufflen = len; 268 - goto again; 269 - } 270 - pr_err("pNFS: INQUIRY 0x83 response invalid (len = %zd)\n", 271 - len); 272 - goto out_put_request; 273 - } 274 - 275 - d = buf + 4; 276 - for (d = buf + 4; d < buf + len; d += id_len + 4) { 277 - id_len = d[3]; 278 - type = d[1] & 0xf; 279 - assoc = (d[1] >> 4) & 0x3; 280 - 281 - /* 282 - * We only care about a EUI-64 and NAA designator types 283 - * with LU association. 284 - */ 285 - if (assoc != 0x00) 286 - continue; 287 - if (type != 0x02 && type != 0x03) 288 - continue; 289 - if (id_len != 8 && id_len != 12 && id_len != 16) 290 - continue; 291 - 292 - b->scsi.code_set = PS_CODE_SET_BINARY; 293 - b->scsi.designator_type = type == 0x02 ? 294 - PS_DESIGNATOR_EUI64 : PS_DESIGNATOR_NAA; 295 - b->scsi.designator_len = id_len; 296 - memcpy(b->scsi.designator, d + 4, id_len); 297 - 298 - /* 299 - * If we found a 8 or 12 byte descriptor continue on to 300 - * see if a 16 byte one is available. If we find a 301 - * 16 byte descriptor we're done. 302 - */ 303 - if (id_len == 16) 304 - break; 305 - } 306 - 307 - out_put_request: 308 - blk_put_request(rq); 309 - out_free_buf: 310 - kfree(buf); 311 - return error; 312 - } 313 - 314 214 #define NFSD_MDS_PR_KEY 0x0100000000000000ULL 315 215 316 216 /* ··· 219 325 return ((u64)clp->cl_clientid.cl_boot << 32) | clp->cl_clientid.cl_id; 220 326 } 221 327 328 + static const u8 designator_types[] = { 329 + PS_DESIGNATOR_EUI64, 330 + PS_DESIGNATOR_NAA, 331 + }; 332 + 333 + static int 334 + nfsd4_block_get_unique_id(struct gendisk *disk, struct pnfs_block_volume *b) 335 + { 336 + int ret, i; 337 + 338 + for (i = 0; i < ARRAY_SIZE(designator_types); i++) { 339 + u8 type = designator_types[i]; 340 + 341 + ret = disk->fops->get_unique_id(disk, b->scsi.designator, type); 342 + if (ret > 0) { 343 + b->scsi.code_set = PS_CODE_SET_BINARY; 344 + b->scsi.designator_type = type; 345 + b->scsi.designator_len = ret; 346 + return 0; 347 + } 348 + } 349 + 350 + return -EINVAL; 351 + } 352 + 222 353 static int 223 354 nfsd4_block_get_device_info_scsi(struct super_block *sb, 224 355 struct nfs4_client *clp, ··· 252 333 struct pnfs_block_deviceaddr *dev; 253 334 struct pnfs_block_volume *b; 254 335 const struct pr_ops *ops; 255 - int error; 336 + int ret; 256 337 257 338 dev = kzalloc(sizeof(struct pnfs_block_deviceaddr) + 258 339 sizeof(struct pnfs_block_volume), GFP_KERNEL); ··· 266 347 b->type = PNFS_BLOCK_VOLUME_SCSI; 267 348 b->scsi.pr_key = nfsd4_scsi_pr_key(clp); 268 349 269 - error = nfsd4_scsi_identify_device(sb->s_bdev, b); 270 - if (error) 271 - return error; 350 + ret = nfsd4_block_get_unique_id(sb->s_bdev->bd_disk, b); 351 + if (ret < 0) 352 + goto out_free_dev; 272 353 354 + ret = -EINVAL; 273 355 ops = sb->s_bdev->bd_disk->fops->pr_ops; 274 356 if (!ops) { 275 357 pr_err("pNFS: device %s does not support PRs.\n", 276 358 sb->s_id); 277 - return -EINVAL; 359 + goto out_free_dev; 278 360 } 279 361 280 - error = ops->pr_register(sb->s_bdev, 0, NFSD_MDS_PR_KEY, true); 281 - if (error) { 362 + ret = ops->pr_register(sb->s_bdev, 0, NFSD_MDS_PR_KEY, true); 363 + if (ret) { 282 364 pr_err("pNFS: failed to register key for device %s.\n", 283 365 sb->s_id); 284 - return -EINVAL; 366 + goto out_free_dev; 285 367 } 286 368 287 - error = ops->pr_reserve(sb->s_bdev, NFSD_MDS_PR_KEY, 369 + ret = ops->pr_reserve(sb->s_bdev, NFSD_MDS_PR_KEY, 288 370 PR_EXCLUSIVE_ACCESS_REG_ONLY, 0); 289 - if (error) { 371 + if (ret) { 290 372 pr_err("pNFS: failed to reserve device %s.\n", 291 373 sb->s_id); 292 - return -EINVAL; 374 + goto out_free_dev; 293 375 } 294 376 295 377 return 0; 378 + 379 + out_free_dev: 380 + kfree(dev); 381 + return ret; 296 382 } 297 383 298 384 static __be32
+3 -2
fs/nfsd/nfs4layouts.c
··· 145 145 #ifdef CONFIG_NFSD_SCSILAYOUT 146 146 if (sb->s_export_op->map_blocks && 147 147 sb->s_export_op->commit_blocks && 148 - sb->s_bdev && sb->s_bdev->bd_disk->fops->pr_ops && 149 - blk_queue_scsi_passthrough(sb->s_bdev->bd_disk->queue)) 148 + sb->s_bdev && 149 + sb->s_bdev->bd_disk->fops->pr_ops && 150 + sb->s_bdev->bd_disk->fops->get_unique_id) 150 151 exp->ex_layout_types |= 1 << LAYOUT_SCSI; 151 152 #endif 152 153 }
-8
include/linux/blk-mq.h
··· 567 567 unsigned int); 568 568 569 569 /** 570 - * @initialize_rq_fn: Called from inside blk_get_request(). 571 - */ 572 - void (*initialize_rq_fn)(struct request *rq); 573 - 574 - /** 575 570 * @cleanup_rq: Called before freeing one request which isn't completed 576 571 * yet, and usually for freeing the driver private data. 577 572 */ ··· 892 897 } 893 898 894 899 void blk_rq_init(struct request_queue *q, struct request *rq); 895 - void blk_put_request(struct request *rq); 896 - struct request *blk_get_request(struct request_queue *q, unsigned int op, 897 - blk_mq_req_flags_t flags); 898 900 int blk_rq_prep_clone(struct request *rq, struct request *rq_src, 899 901 struct bio_set *bs, gfp_t gfp_mask, 900 902 int (*bio_ctr)(struct bio *, struct bio *, void *), void *data);
+11 -3
include/linux/blkdev.h
··· 399 399 #define QUEUE_FLAG_STATS 20 /* track IO start and completion times */ 400 400 #define QUEUE_FLAG_POLL_STATS 21 /* collecting stats for hybrid polling */ 401 401 #define QUEUE_FLAG_REGISTERED 22 /* queue has been registered to a disk */ 402 - #define QUEUE_FLAG_SCSI_PASSTHROUGH 23 /* queue supports SCSI commands */ 403 402 #define QUEUE_FLAG_QUIESCED 24 /* queue has been quiesced */ 404 403 #define QUEUE_FLAG_PCI_P2PDMA 25 /* device supports PCI p2p requests */ 405 404 #define QUEUE_FLAG_ZONE_RESETALL 26 /* supports Zone Reset All */ ··· 432 433 #define blk_queue_secure_erase(q) \ 433 434 (test_bit(QUEUE_FLAG_SECERASE, &(q)->queue_flags)) 434 435 #define blk_queue_dax(q) test_bit(QUEUE_FLAG_DAX, &(q)->queue_flags) 435 - #define blk_queue_scsi_passthrough(q) \ 436 - test_bit(QUEUE_FLAG_SCSI_PASSTHROUGH, &(q)->queue_flags) 437 436 #define blk_queue_pci_p2pdma(q) \ 438 437 test_bit(QUEUE_FLAG_PCI_P2PDMA, &(q)->queue_flags) 439 438 #ifdef CONFIG_BLK_RQ_ALLOC_TIME ··· 1185 1188 1186 1189 #endif /* CONFIG_BLK_INLINE_ENCRYPTION */ 1187 1190 1191 + enum blk_unique_id { 1192 + /* these match the Designator Types specified in SPC */ 1193 + BLK_UID_T10 = 1, 1194 + BLK_UID_EUI64 = 2, 1195 + BLK_UID_NAA = 3, 1196 + }; 1197 + 1198 + #define NFL4_UFLG_MASK 0x0000003F 1188 1199 1189 1200 struct block_device_operations { 1190 1201 void (*submit_bio)(struct bio *bio); ··· 1211 1206 int (*report_zones)(struct gendisk *, sector_t sector, 1212 1207 unsigned int nr_zones, report_zones_cb cb, void *data); 1213 1208 char *(*devnode)(struct gendisk *disk, umode_t *mode); 1209 + /* returns the length of the identifier or a negative errno: */ 1210 + int (*get_unique_id)(struct gendisk *disk, u8 id[16], 1211 + enum blk_unique_id id_type); 1214 1212 struct module *owner; 1215 1213 const struct pr_ops *pr_ops; 1216 1214
+3
include/scsi/scsi_cmnd.h
··· 396 396 extern void scsi_build_sense(struct scsi_cmnd *scmd, int desc, 397 397 u8 key, u8 asc, u8 ascq); 398 398 399 + struct request *scsi_alloc_request(struct request_queue *q, 400 + unsigned int op, blk_mq_req_flags_t flags); 401 + 399 402 #endif /* _SCSI_SCSI_CMND_H */