blk-mq driver conversions and legacy path removal
Subsystems (16)
Jens Axboe
maintainerv2 cover blk-mq driver conversions and legacy path removal
Elements of the previous series went into mainline, this is a v2 posting with those killed, series reshuffled, bugs fixed, etc.
his patch series converts the remaining drivers to blk-mq. SCSI supports both paths, this removes the legacy IO path from SCSI. At the end, legacy IO code and schedulers are killed off.
I'm not aware of any issues with this series.
This patch series is on top of current -git. It can also be bound in my mq-conversions branch.
Changes since v1:
- Fix removed q->mq_ops non-NULL check in wbt_enable_default()
- Remove spurious return in ide-io.c:ide_timer_expiry()
- Dropped DM legacy path removal patch, now in mainline
- Dropped ib_srp patch, now in mainline
- Fixed a missing port unlock in IDE
- Add SCSI ufs to the BSG conversions
- Add patch to remove bsg-lib queue hook dependencies
- Fixed missing clear of IO contexts
- Added blk-mq backend for blk_lld_busy()
Documentation/block/biodoc.txt | 88 - Documentation/block/cfq-iosched.txt | 291 -- Documentation/scsi/scsi-parameters.txt | 5 - block/Kconfig | 6 - block/Kconfig.iosched | 61 - block/Makefile | 5 +- block/bfq-iosched.c | 1 - block/blk-cgroup.c | 55 - block/blk-core.c | 1836 +----------- block/blk-exec.c | 20 +- block/blk-flush.c | 154 +- block/blk-ioc.c | 33 +- block/blk-merge.c | 35 +- block/blk-mq-debugfs.c | 2 - block/blk-mq-tag.c | 6 +- block/blk-mq.c | 13 +- block/blk-settings.c | 49 - block/blk-softirq.c | 20 - block/blk-sysfs.c | 39 +- block/blk-tag.c | 378 --- block/blk-timeout.c | 99 +- block/blk-wbt.c | 3 +- block/blk.h | 60 +- block/bsg-lib.c | 146 +- block/cfq-iosched.c | 4916 -------------------------------- block/deadline-iosched.c | 560 ---- block/elevator.c | 447 +-- block/kyber-iosched.c | 1 - block/mq-deadline.c | 1 - block/noop-iosched.c | 124 - drivers/block/sunvdc.c | 149 +- drivers/ide/ide-atapi.c | 25 +- drivers/ide/ide-cd.c | 175 +- drivers/ide/ide-disk.c | 5 +- drivers/ide/ide-io.c | 100 +- drivers/ide/ide-park.c | 4 +- drivers/ide/ide-pm.c | 28 +- drivers/ide/ide-probe.c | 68 +- drivers/memstick/core/ms_block.c | 110 +- drivers/memstick/core/ms_block.h | 1 + drivers/memstick/core/mspro_block.c | 121 +- drivers/s390/block/dasd_ioctl.c | 22 +- drivers/scsi/Kconfig | 12 - drivers/scsi/cxlflash/main.c | 6 - drivers/scsi/hosts.c | 29 +- drivers/scsi/lpfc/lpfc_scsi.c | 2 +- drivers/scsi/osd/osd_initiator.c | 4 +- drivers/scsi/osst.c | 2 +- drivers/scsi/qedi/qedi_main.c | 3 +- drivers/scsi/qla2xxx/qla_os.c | 30 +- drivers/scsi/scsi.c | 5 +- drivers/scsi/scsi_debug.c | 3 +- drivers/scsi/scsi_error.c | 4 +- drivers/scsi/scsi_lib.c | 599 +--- drivers/scsi/scsi_priv.h | 1 - drivers/scsi/scsi_scan.c | 10 +- drivers/scsi/scsi_sysfs.c | 8 +- drivers/scsi/scsi_transport_fc.c | 71 +- drivers/scsi/scsi_transport_iscsi.c | 7 +- drivers/scsi/scsi_transport_sas.c | 10 +- drivers/scsi/sg.c | 2 +- drivers/scsi/st.c | 2 +- drivers/scsi/ufs/ufs_bsg.c | 4 +- drivers/scsi/ufs/ufshcd.c | 6 - drivers/target/target_core_pscsi.c | 2 +- include/linux/blk-cgroup.h | 108 - include/linux/blk-mq.h | 6 + include/linux/blkdev.h | 176 +- include/linux/bsg-lib.h | 6 +- include/linux/elevator.h | 90 +- include/linux/ide.h | 13 +- include/linux/init.h | 1 - include/scsi/scsi_host.h | 18 +- include/scsi/scsi_tcq.h | 14 +- init/do_mounts_initrd.c | 3 - init/initramfs.c | 6 - init/main.c | 12 - 77 files changed, 825 insertions(+), 10712 deletions(-)
Signature · 1 line
Jens Axboe
Jens Axboe
maintainerPATCH v2 1/29 sunvdc: convert to blk-mq
Convert from the old request_fn style driver to blk-mq.
--- drivers/block/sunvdc.c | 149 +++++++++++++++++++++++++++-------------- 1 file changed, 98 insertions(+), 51 deletions(-)
drivers/block/sunvdc.c +98 -51
@@ -6,7 +6,7 @@#include <linux/module.h> #include <linux/kernel.h> #include <linux/types.h> -#include <linux/blkdev.h> +#include <linux/blk-mq.h> #include <linux/hdreg.h> #include <linux/genhd.h> #include <linux/cdrom.h>
@@ -66,9 +66,10 @@ struct vdc_port {u64 max_xfer_size;u32 vdisk_block_size; +u32 drain;u64 ldc_timeout; -struct timer_list ldc_reset_timer; +struct delayed_work ldc_reset_timer_work;struct work_struct ldc_reset_work;/* The server fills these in for us in the disk attribute
@@ -80,12 +81,14 @@ struct vdc_port {u8 vdisk_mtype;u32 vdisk_phys_blksz; +struct blk_mq_tag_set tag_set; +char disk_name[32 ]; };static void vdc_ldc_reset (struct vdc_port *port);static void vdc_ldc_reset_work (struct work_struct *work); -static void vdc_ldc_reset_timer (struct timer_list *t); +static void vdc_ldc_reset_timer_work (struct work_struct *work);static inline struct vdc_port *to_vdc_port (struct vio_driver_state *vio) {
@@ -175,11 +178,8 @@ static void vdc_blk_queue_start(struct vdc_port *port)* handshake completes, so check for initial handshake before we've * allocated a disk. */ -if (port->disk &&blk_queue_stopped (port->disk->queue) && -vdc_tx_dring_avail (dr) *100 /VDC_TX_RING_SIZE >=50 ) { -blk_start_queue (port->disk->queue); - } - +if (port->disk &&vdc_tx_dring_avail (dr) *100 /VDC_TX_RING_SIZE >=50 ) +blk_mq_start_hw_queues (port->disk->queue); }static void vdc_finish (struct vio_driver_state *vio,int err,int waiting_for)
@@ -197,7 +197,7 @@ static void vdc_handshake_complete(struct vio_driver_state *vio) {struct vdc_port *port =to_vdc_port (vio); -del_timer (&port->ldc_reset_timer); +cancel_delayed_work (&port->ldc_reset_timer_work);vdc_finish (vio,0 ,WAITING_FOR_LINK_UP );vdc_blk_queue_start (port); }
@@ -320,7 +320,7 @@ static void vdc_end_one(struct vdc_port *port, struct vio_dring_state *dr, rqe->req =NULL ; -__blk_end_request (req, (desc->status ?BLK_STS_IOERR :0 ), desc->size); +blk_mq_end_request (req, desc->status ?BLK_STS_IOERR :0 );vdc_blk_queue_start (port); }
@@ -525,29 +525,40 @@ static int __send_request(struct request *req)return err; } -static void do_vdc_request (struct request_queue *rq) +static blk_status_t vdc_queue_rq (struct blk_mq_hw_ctx *hctx, +const struct blk_mq_queue_data *bd) { -struct request *req; +struct vdc_port *port = hctx->queue->queuedata; +struct vio_dring_state *dr; +unsigned long flags; -while ((req =blk_peek_request (rq)) !=NULL ) { -struct vdc_port *port; -struct vio_dring_state *dr; + dr = &port->vio.drings[VIO_DRIVER_TX_RING ]; - port = req->rq_disk->private_data; - dr = &port->vio.drings[VIO_DRIVER_TX_RING ]; -if (unlikely (vdc_tx_dring_avail (dr) <1 )) - goto wait; +blk_mq_start_request (bd->rq); -blk_start_request (req); +spin_lock_irqsave (&port->vio.lock, flags); -if (__send_request (req) <0 ) { -blk_requeue_request (rq, req); -wait: -/* Avoid pointless unplugs. */ -blk_stop_queue (rq); -break ; - } +/* +* Doing drain, just end the request in error +*/ +if (unlikely (port->drain)) { +spin_unlock_irqrestore (&port->vio.lock, flags); +return BLK_STS_IOERR ; } + +if (unlikely (vdc_tx_dring_avail (dr) <1 )) { +spin_unlock_irqrestore (&port->vio.lock, flags); +blk_mq_stop_hw_queue (hctx); +return BLK_STS_DEV_RESOURCE ; + } + +if (__send_request (bd->rq) <0 ) { +spin_unlock_irqrestore (&port->vio.lock, flags); +return BLK_STS_IOERR ; + } + +spin_unlock_irqrestore (&port->vio.lock, flags); +return BLK_STS_OK ; }static int generic_request (struct vdc_port *port,u8 op,void *buf,int len)
@@ -759,6 +770,32 @@ static void vdc_port_down(struct vdc_port *port)vio_ldc_free (&port->vio); } +static const struct blk_mq_ops vdc_mq_ops = { + .queue_rq = vdc_queue_rq, +}; + +static void cleanup_queue (struct request_queue *q) +{ +struct vdc_port *port = q->queuedata; + +blk_cleanup_queue (q); +blk_mq_free_tag_set (&port->tag_set); +} + +static struct request_queue *init_queue (struct vdc_port *port) +{ +struct request_queue *q; +int ret; + + q =blk_mq_init_sq_queue (&port->tag_set, &vdc_mq_ops,VDC_TX_RING_SIZE , +BLK_MQ_F_SHOULD_MERGE ); +if (IS_ERR (q)) +return q; + + q->queuedata = port; +return q; +} +static int probe_disk (struct vdc_port *port) {struct request_queue *q;
@@ -796,17 +833,17 @@ static int probe_disk(struct vdc_port *port) (u64)geom.num_sec); } - q =blk_init_queue (do_vdc_request, &port->vio.lock); -if (!q) { + q =init_queue (port); +if (IS_ERR (q)) { printk(KERN_ERR PFX "%s: Could not allocate queue.\n", port->vio.name); -return -ENOMEM ; +return PTR_ERR (q); } g =alloc_disk (1 <<PARTITION_SHIFT );if (!g) { printk(KERN_ERR PFX "%s: Could not allocate gendisk.\n", port->vio.name); -blk_cleanup_queue (q); +cleanup_queue (q);return -ENOMEM ; }
@@ -981,7 +1018,7 @@ static int vdc_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)*/ ldc_timeout =mdesc_get_property (hp, vdev->mp,"vdc-timeout" ,NULL ); port->ldc_timeout = ldc_timeout ? *ldc_timeout :0 ; -timer_setup (&port->ldc_reset_timer, vdc_ldc_reset_timer,0 ); +INIT_DELAYED_WORK (&port->ldc_reset_timer_work, vdc_ldc_reset_timer_work);INIT_WORK (&port->ldc_reset_work, vdc_ldc_reset_work); err = vio_driver_init(&port->vio, vdev, VDEV_DISK,
@@ -1034,18 +1071,14 @@ static int vdc_port_remove(struct vio_dev *vdev)struct vdc_port *port =dev_get_drvdata (&vdev->dev);if (port) { -unsigned long flags; - -spin_lock_irqsave (&port->vio.lock, flags); -blk_stop_queue (port->disk->queue); -spin_unlock_irqrestore (&port->vio.lock, flags); +blk_mq_stop_hw_queues (port->disk->queue);flush_work (&port->ldc_reset_work); -del_timer_sync (&port->ldc_reset_timer); +cancel_delayed_work_sync (&port->ldc_reset_timer_work);del_timer_sync (&port->vio.timer);del_gendisk (port->disk); -blk_cleanup_queue (port->disk->queue); +cleanup_queue (port->disk->queue);put_disk (port->disk); port->disk =NULL ;
@@ -1080,32 +1113,46 @@ static void vdc_requeue_inflight(struct vdc_port *port) } rqe->req =NULL ; -blk_requeue_request (port->disk->queue, req); +blk_mq_requeue_request (req, false); } }static void vdc_queue_drain (struct vdc_port *port) { -struct request *req; +struct request_queue *q = port->disk->queue; -while ((req =blk_fetch_request (port->disk->queue)) !=NULL ) -__blk_end_request_all (req,BLK_STS_IOERR ); +/* +* Mark the queue as draining, then freeze/quiesce to ensure +* that all existing requests are seen in ->queue_rq() and killed +*/ + port->drain =1 ; +spin_unlock_irq (&port->vio.lock); + +blk_mq_freeze_queue (q); +blk_mq_quiesce_queue (q); + +spin_lock_irq (&port->vio.lock); + port->drain =0 ; +blk_mq_unquiesce_queue (q); +blk_mq_unfreeze_queue (q); } -static void vdc_ldc_reset_timer (struct timer_list *t) +static void vdc_ldc_reset_timer_work (struct work_struct *work) { -struct vdc_port *port =from_timer (port, t, ldc_reset_timer); -struct vio_driver_state *vio = &port->vio; -unsigned long flags; +struct vdc_port *port; +struct vio_driver_state *vio; -spin_lock_irqsave (&vio->lock, flags); + port = container_of(work, struct vdc_port, ldc_reset_timer_work.work); + vio = &port->vio; + +spin_lock_irq (&vio->lock);if (!(port->vio.hs_state &VIO_HS_COMPLETE )) {pr_warn (PFX "%s ldc down %llu seconds, draining queue\n" , port->disk_name, port->ldc_timeout);vdc_queue_drain (port);vdc_blk_queue_start (port); } -spin_unlock_irqrestore (&vio->lock, flags); +spin_unlock_irq (&vio->lock); }static void vdc_ldc_reset_work (struct work_struct *work)
@@ -1129,7 +1176,7 @@ static void vdc_ldc_reset(struct vdc_port *port)assert_spin_locked (&port->vio.lock);pr_warn (PFX "%s ldc link reset\n" , port->disk_name); -blk_stop_queue (port->disk->queue); +blk_mq_stop_hw_queues (port->disk->queue);vdc_requeue_inflight (port);vdc_port_down (port);
@@ -1146,7 +1193,7 @@ static void vdc_ldc_reset(struct vdc_port *port) }if (port->ldc_timeout) -mod_timer (&port->ldc_reset_timer, +mod_delayed_work (system_wq, &port->ldc_reset_timer_work,round_jiffies (jiffies +HZ * port->ldc_timeout));mod_timer (&port->vio.timer,round_jiffies (jiffies +HZ ));return ;
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 2/29 ms_block: convert to blk-mq
In reply to Jens AxboeStraight forward conversion, room for optimization in how everything is punted to a work queue. Also looks plenty racy all over the map, with the state changes. I fixed a bunch of them up while doing the conversion, but there are surely more.
--- drivers/memstick/core/ms_block.c | 110 +++++++++++++++++-------------- drivers/memstick/core/ms_block.h | 1 + 2 files changed, 62 insertions(+), 49 deletions(-)
drivers/memstick/core/ms_block.c +61 -49
@@ -15,7 +15,7 @@#define pr_fmt (fmt) DRIVER_NAME ": " fmt#include <linux/module.h> -#include <linux/blkdev.h> +#include <linux/blk-mq.h> #include <linux/memstick.h> #include <linux/idr.h> #include <linux/hdreg.h>
@@ -1873,69 +1873,65 @@ static void msb_io_work(struct work_struct *work) struct msb_data *msb = container_of(work, struct msb_data, io_work);int page, error, len;sector_t lba; -unsigned long flags;struct scatterlist *sg = msb->prealloc_sg; +struct request *req;dbg_verbose ("IO: work started" );while (1 ) { -spin_lock_irqsave (&msb->q_lock, flags); +spin_lock_irq (&msb->q_lock);if (msb->need_flush_cache) { msb->need_flush_cache = false; -spin_unlock_irqrestore (&msb->q_lock, flags); +spin_unlock_irq (&msb->q_lock);msb_cache_flush (msb);continue ; } -if (!msb->req) { - msb->req =blk_fetch_request (msb->queue); -if (!msb->req) { -dbg_verbose ("IO: no more requests exiting" ); -spin_unlock_irqrestore (&msb->q_lock, flags); -return ; - } + req = msb->req; +if (!req) { +dbg_verbose ("IO: no more requests exiting" ); +spin_unlock_irq (&msb->q_lock); +return ; } -spin_unlock_irqrestore (&msb->q_lock, flags); - -/* If card was removed meanwhile */ -if (!msb->req) -return ; +spin_unlock_irq (&msb->q_lock);/* process the request */ dbg_verbose ("IO: processing new request" ); -blk_rq_map_sg (msb->queue, msb->req, sg); +blk_rq_map_sg (msb->queue, req, sg); - lba =blk_rq_pos (msb->req); + lba =blk_rq_pos (req);sector_div (lba, msb->page_size /512 ); page =sector_div (lba, msb->pages_in_block);if (rq_data_dir (msb->req) ==READ ) error =msb_do_read_request (msb, lba, page, sg, -blk_rq_bytes (msb->req), &len); +blk_rq_bytes (req), &len);else error =msb_do_write_request (msb, lba, page, sg, -blk_rq_bytes (msb->req), &len); - -spin_lock_irqsave (&msb->q_lock, flags); +blk_rq_bytes (req), &len); -if (len) -if (!__blk_end_request (msb->req,BLK_STS_OK , len)) - msb->req =NULL ; +if (len && !blk_update_request (req,BLK_STS_OK , len)) { +__blk_mq_end_request (req,BLK_STS_OK ); +spin_lock_irq (&msb->q_lock); + msb->req =NULL ; +spin_unlock_irq (&msb->q_lock); + }if (error && msb->req) {blk_status_t ret =errno_to_blk_status (error); +dbg_verbose ("IO: ending one sector of the request with error" ); -if (!__blk_end_request (msb->req, ret, msb->page_size)) - msb->req =NULL ; +blk_mq_end_request (req, ret); +spin_lock_irq (&msb->q_lock); + msb->req =NULL ; +spin_unlock_irq (&msb->q_lock); }if (msb->req)dbg_verbose ("IO: request still pending" ); - -spin_unlock_irqrestore (&msb->q_lock, flags); } }
@@ -2002,29 +1998,40 @@ static int msb_bd_getgeo(struct block_device *bdev,return 0 ; } -static void msb_submit_req (struct request_queue *q) +static blk_status_t msb_queue_rq (struct blk_mq_hw_ctx *hctx, +const struct blk_mq_queue_data *bd) { -struct memstick_dev *card = q->queuedata; +struct memstick_dev *card = hctx->queue->queuedata;struct msb_data *msb =memstick_get_drvdata (card); -struct request *req =NULL ; +struct request *req = bd->rq;dbg_verbose ("Submit request" ); +spin_lock_irq (&msb->q_lock); +if (msb->card_dead) {dbg ("Refusing requests on removed card" );WARN_ON (!msb->io_queue_stopped); -while ((req =blk_fetch_request (q)) !=NULL ) -__blk_end_request_all (req,BLK_STS_IOERR ); -return ; +spin_unlock_irq (&msb->q_lock); +blk_mq_start_request (req); +return BLK_STS_IOERR ; } -if (msb->req) -return ; +if (msb->req) { +spin_unlock_irq (&msb->q_lock); +return BLK_STS_DEV_RESOURCE ; + } + +blk_mq_start_request (req); + msb->req = req;if (!msb->io_queue_stopped)queue_work (msb->io_queue, &msb->io_work); + +spin_unlock_irq (&msb->q_lock); +return BLK_STS_OK ; }static int msb_check_card (struct memstick_dev *card)
@@ -2040,21 +2047,20 @@ static void msb_stop(struct memstick_dev *card)dbg ("Stopping all msblock IO" ); +blk_mq_stop_hw_queues (msb->queue);spin_lock_irqsave (&msb->q_lock, flags); -blk_stop_queue (msb->queue); msb->io_queue_stopped = true;spin_unlock_irqrestore (&msb->q_lock, flags);del_timer_sync (&msb->cache_flush_timer);flush_workqueue (msb->io_queue); +spin_lock_irqsave (&msb->q_lock, flags);if (msb->req) { -spin_lock_irqsave (&msb->q_lock, flags); -blk_requeue_request (msb->queue, msb->req); +blk_mq_requeue_request (msb->req, false); msb->req =NULL ; -spin_unlock_irqrestore (&msb->q_lock, flags); } - +spin_unlock_irqrestore (&msb->q_lock, flags); }static void msb_start (struct memstick_dev *card)
@@ -2077,9 +2083,7 @@ static void msb_start(struct memstick_dev *card) msb->need_flush_cache = true; msb->io_queue_stopped = false; -spin_lock_irqsave (&msb->q_lock, flags); -blk_start_queue (msb->queue); -spin_unlock_irqrestore (&msb->q_lock, flags); +blk_mq_start_hw_queues (msb->queue);queue_work (msb->io_queue, &msb->io_work);
@@ -2092,10 +2096,15 @@ static const struct block_device_operations msb_bdops = { .owner = THIS_MODULE }; +static const struct blk_mq_ops msb_mq_ops = { + .queue_rq = msb_queue_rq, +}; +/* Registers the block device */ static int msb_init_disk (struct memstick_dev *card) {struct msb_data *msb =memstick_get_drvdata (card); +struct blk_mq_tag_set *set =NULL ;int rc;unsigned long capacity;
@@ -2112,9 +2121,11 @@ static int msb_init_disk(struct memstick_dev *card) goto out_release_id; } - msb->queue =blk_init_queue (msb_submit_req, &msb->q_lock); -if (!msb->queue) { - rc = -ENOMEM ; + msb->queue =blk_mq_init_sq_queue (&msb->tag_set, &msb_mq_ops,2 , +BLK_MQ_F_SHOULD_MERGE ); +if (IS_ERR (msb->queue)) { + rc =PTR_ERR (msb->queue); + msb->queue =NULL ; goto out_put_disk; }
@@ -2202,12 +2213,13 @@ static void msb_remove(struct memstick_dev *card)/* Take care of unhandled + new requests from now on */ spin_lock_irqsave (&msb->q_lock, flags); msb->card_dead = true; -blk_start_queue (msb->queue);spin_unlock_irqrestore (&msb->q_lock, flags); +blk_mq_start_hw_queues (msb->queue);/* Remove the disk */ del_gendisk (msb->disk);blk_cleanup_queue (msb->queue); +blk_mq_free_tag_set (&msb->tag_set); msb->queue =NULL ;mutex_lock (&msb_disk_lock);
drivers/memstick/core/ms_block.h +1 -0
@@ -152,6 +152,7 @@ struct msb_data {struct gendisk *disk;struct request_queue *queue;spinlock_t q_lock; +struct blk_mq_tag_set tag_set;struct hd_geometry geometry;struct attribute_group attr_group;struct request *req;
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 3/29 mspro_block: convert to blk-mq
In reply to Jens AxboeStraight forward conversion, there's room for improvement.
--- drivers/memstick/core/mspro_block.c | 121 +++++++++++++++------------- 1 file changed, 66 insertions(+), 55 deletions(-)
drivers/memstick/core/mspro_block.c +66 -55
@@ -12,7 +12,7 @@* */ -#include <linux/blkdev.h> +#include <linux/blk-mq.h> #include <linux/idr.h> #include <linux/hdreg.h> #include <linux/kthread.h>
@@ -142,6 +142,7 @@ struct mspro_block_data {struct gendisk *disk;struct request_queue *queue;struct request *block_req; +struct blk_mq_tag_set tag_set;spinlock_t q_lock;unsigned short page_size;
@@ -152,7 +153,6 @@ struct mspro_block_data {unsigned char system; unsigned char read_only:1, eject:1, - has_request:1, data_dir:1, active:1;unsigned char transfer_cmd;
@@ -694,13 +694,12 @@ static void h_mspro_block_setup_cmd(struct memstick_dev *card, u64 offset,/*** Data transfer ***/ -static int mspro_block_issue_req (struct memstick_dev *card,int chunk) +static int mspro_block_issue_req (struct memstick_dev *card,bool chunk) {struct mspro_block_data *msb =memstick_get_drvdata (card);u64 t_off;unsigned int count; -try_again:while (chunk) { msb->current_page =0 ; msb->current_seg =0 ;
@@ -709,9 +708,17 @@ static int mspro_block_issue_req(struct memstick_dev *card, int chunk) msb->req_sg);if (!msb->seg_count) { - chunk =__blk_end_request_cur (msb->block_req, -BLK_STS_RESOURCE ); -continue ; +unsigned int bytes =blk_rq_cur_bytes (msb->block_req); + + chunk =blk_update_request (msb->block_req, +BLK_STS_RESOURCE , + bytes); +if (chunk) +continue ; +__blk_mq_end_request (msb->block_req, +BLK_STS_RESOURCE ); + msb->block_req =NULL ; +break ; } t_off =blk_rq_pos (msb->block_req);
@@ -729,30 +736,22 @@ static int mspro_block_issue_req(struct memstick_dev *card, int chunk)return 0 ; } -dev_dbg (&card->dev,"blk_fetch\n" ); - msb->block_req =blk_fetch_request (msb->queue); -if (!msb->block_req) { -dev_dbg (&card->dev,"issue end\n" ); -return -EAGAIN ; - } - -dev_dbg (&card->dev,"trying again\n" ); - chunk =1 ; - goto try_again; +return 1 ; }static int mspro_block_complete_req (struct memstick_dev *card,int error) {struct mspro_block_data *msb =memstick_get_drvdata (card); -int chunk, cnt; +int cnt; +bool chunk;unsigned int t_len =0 ;unsigned long flags;spin_lock_irqsave (&msb->q_lock, flags); -dev_dbg (&card->dev,"complete %d, %d\n" , msb->has_request ?1 :0 , +dev_dbg (&card->dev,"complete %d, %d\n" , msb->block_req ?1 :0 , error); -if (msb->has_request) { +if (msb->block_req) {/* Nothing to do - not really an error */ if (error == -EAGAIN ) error =0 ;
@@ -777,15 +776,17 @@ static int mspro_block_complete_req(struct memstick_dev *card, int error)if (error && !t_len) t_len =blk_rq_cur_bytes (msb->block_req); - chunk =__blk_end_request (msb->block_req, + chunk =blk_update_request (msb->block_req,errno_to_blk_status (error), t_len); - - error =mspro_block_issue_req (card, chunk); - -if (!error) - goto out; -else - msb->has_request =0 ; +if (chunk) { + error =mspro_block_issue_req (card, chunk); +if (!error) + goto out; + }else { +__blk_mq_end_request (msb->block_req, +errno_to_blk_status (error)); + msb->block_req =NULL ; + } }else {if (!error) error = -EAGAIN ;
@@ -806,8 +807,8 @@ static void mspro_block_stop(struct memstick_dev *card)while (1 ) {spin_lock_irqsave (&msb->q_lock, flags); -if (!msb->has_request) { -blk_stop_queue (msb->queue); +if (!msb->block_req) { +blk_mq_stop_hw_queues (msb->queue); rc =1 ; }spin_unlock_irqrestore (&msb->q_lock, flags);
@@ -822,32 +823,37 @@ static void mspro_block_stop(struct memstick_dev *card)static void mspro_block_start (struct memstick_dev *card) {struct mspro_block_data *msb =memstick_get_drvdata (card); -unsigned long flags; -spin_lock_irqsave (&msb->q_lock, flags); -blk_start_queue (msb->queue); -spin_unlock_irqrestore (&msb->q_lock, flags); +blk_mq_start_hw_queues (msb->queue); } -static void mspro_block_submit_req (struct request_queue *q) +static blk_status_t mspro_queue_rq (struct blk_mq_hw_ctx *hctx, +const struct blk_mq_queue_data *bd) { -struct memstick_dev *card = q->queuedata; +struct memstick_dev *card = hctx->queue->queuedata;struct mspro_block_data *msb =memstick_get_drvdata (card); -struct request *req =NULL ; -if (msb->has_request) -return ; +spin_lock_irq (&msb->q_lock); -if (msb->eject) { -while ((req =blk_fetch_request (q)) !=NULL ) -__blk_end_request_all (req,BLK_STS_IOERR ); +if (msb->block_req) { +spin_unlock_irq (&msb->q_lock); +return BLK_STS_DEV_RESOURCE ; + } -return ; +if (msb->eject) { +spin_unlock_irq (&msb->q_lock); +blk_mq_start_request (bd->rq); +return BLK_STS_IOERR ; } - msb->has_request =1 ; -if (mspro_block_issue_req (card,0 )) - msb->has_request =0 ; + msb->block_req = bd->rq; +blk_mq_start_request (bd->rq); + +if (mspro_block_issue_req (card, true)) + msb->block_req =NULL ; + +spin_unlock_irq (&msb->q_lock); +return BLK_STS_OK ; }/*** Initialization ***/
@@ -1167,6 +1173,10 @@ static int mspro_block_init_card(struct memstick_dev *card) } +static const struct blk_mq_ops mspro_mq_ops = { + .queue_rq = mspro_queue_rq, +}; +static int mspro_block_init_disk (struct memstick_dev *card) {struct mspro_block_data *msb =memstick_get_drvdata (card);
@@ -1206,9 +1216,11 @@ static int mspro_block_init_disk(struct memstick_dev *card) goto out_release_id; } - msb->queue =blk_init_queue (mspro_block_submit_req, &msb->q_lock); -if (!msb->queue) { - rc = -ENOMEM ; + msb->queue =blk_mq_init_sq_queue (&msb->tag_set, &mspro_mq_ops,2 , +BLK_MQ_F_SHOULD_MERGE ); +if (IS_ERR (msb->queue)) { + rc =PTR_ERR (msb->queue); + msb->queue =NULL ; goto out_put_disk; }
@@ -1318,13 +1330,14 @@ static void mspro_block_remove(struct memstick_dev *card)spin_lock_irqsave (&msb->q_lock, flags); msb->eject =1 ; -blk_start_queue (msb->queue);spin_unlock_irqrestore (&msb->q_lock, flags); +blk_mq_start_hw_queues (msb->queue);del_gendisk (msb->disk);dev_dbg (&card->dev,"mspro block remove\n" );blk_cleanup_queue (msb->queue); +blk_mq_free_tag_set (&msb->tag_set); msb->queue =NULL ;sysfs_remove_group (&card->dev.kobj, &msb->attr_group);
@@ -1344,8 +1357,9 @@ static int mspro_block_suspend(struct memstick_dev *card, pm_message_t state)struct mspro_block_data *msb =memstick_get_drvdata (card);unsigned long flags; +blk_mq_stop_hw_queues (msb->queue); +spin_lock_irqsave (&msb->q_lock, flags); -blk_stop_queue (msb->queue); msb->active =0 ;spin_unlock_irqrestore (&msb->q_lock, flags);
@@ -1355,7 +1369,6 @@ static int mspro_block_suspend(struct memstick_dev *card, pm_message_t state)static int mspro_block_resume (struct memstick_dev *card) {struct mspro_block_data *msb =memstick_get_drvdata (card); -unsigned long flags;int rc =0 ;#ifdef CONFIG_MEMSTICK_UNSAFE_RESUME
@@ -1401,9 +1414,7 @@ static int mspro_block_resume(struct memstick_dev *card)#endif /* CONFIG_MEMSTICK_UNSAFE_RESUME */ -spin_lock_irqsave (&msb->q_lock, flags); -blk_start_queue (msb->queue); -spin_unlock_irqrestore (&msb->q_lock, flags); +blk_mq_start_hw_queues (msb->queue);return rc; }
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 4/29 ide: convert to blk-mq
In reply to Jens Axboeide-disk and ide-cd tested as working just fine, ide-tape and ide-floppy haven't. But the latter don't require changes, so they should work without issue.
Add helper function to insert a request from a work queue, since we cannot invoke the blk-mq request insertion from IRQ context.
--- drivers/ide/ide-atapi.c | 25 ++++-- drivers/ide/ide-cd.c | 175 +++++++++++++++++++++------------------- drivers/ide/ide-disk.c | 5 +- drivers/ide/ide-io.c | 100 +++++++++++++---------- drivers/ide/ide-park.c | 4 +- drivers/ide/ide-pm.c | 28 ++----- drivers/ide/ide-probe.c | 68 +++++++++++----- include/linux/ide.h | 13 ++- 8 files changed, 239 insertions(+), 179 deletions(-)
drivers/ide/ide-atapi.c +17 -8
@@ -172,8 +172,8 @@ EXPORT_SYMBOL_GPL(ide_create_request_sense_cmd);void ide_prep_sense (ide_drive_t *drive,struct request *rq) {struct request_sense *sense = &drive->sense_data; -struct request *sense_rq = drive->sense_rq; -struct scsi_request *req =scsi_req (sense_rq); +struct request *sense_rq; +struct scsi_request *req;unsigned int cmd_len, sense_len;int err;
@@ -196,9 +196,16 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)if (ata_sense_request (rq) || drive->sense_rq_armed)return ; + sense_rq = drive->sense_rq; +if (!sense_rq) { + sense_rq =blk_mq_alloc_request (drive->queue,REQ_OP_DRV_IN , +BLK_MQ_REQ_RESERVED |BLK_MQ_REQ_NOWAIT ); + drive->sense_rq = sense_rq; + } + req =scsi_req (sense_rq); +memset (sense,0 ,sizeof (*sense)); -blk_rq_init (rq->q, sense_rq);scsi_req_init (req); err = blk_rq_map_kern(drive->queue, sense_rq, sense, sense_len,
@@ -207,6 +214,8 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)if (printk_ratelimit ()) printk(KERN_WARNING PFX "%s: failed to map sense ""buffer\n" , drive->name); +blk_mq_free_request (sense_rq); + drive->sense_rq =NULL ;return ; }
@@ -226,6 +235,8 @@ EXPORT_SYMBOL_GPL(ide_prep_sense);int ide_queue_sense_rq (ide_drive_t *drive,void *special) { +struct request *sense_rq = drive->sense_rq; +/* deferred failure from ide_prep_sense() */ if (!drive->sense_rq_armed) { printk(KERN_WARNING PFX "%s: error queuing a sense request\n",
@@ -233,12 +244,12 @@ int ide_queue_sense_rq(ide_drive_t *drive, void *special)return -ENOMEM ; } - drive->sense_rq->special = special; + sense_rq->special = special; drive->sense_rq_armed = false; drive->hwif->rq =NULL ; -elv_add_request (drive->queue, drive->sense_rq,ELEVATOR_INSERT_FRONT ); +ide_insert_request_head (drive, sense_rq);return 0 ; }EXPORT_SYMBOL_GPL (ide_queue_sense_rq);
@@ -270,10 +281,8 @@ void ide_retry_pc(ide_drive_t *drive)*/ drive->hwif->rq =NULL ;ide_requeue_and_plug (drive, failed_rq); -if (ide_queue_sense_rq (drive, pc)) { -blk_start_request (failed_rq); +if (ide_queue_sense_rq (drive, pc))ide_complete_rq (drive,BLK_STS_IOERR ,blk_rq_bytes (failed_rq)); - } }EXPORT_SYMBOL_GPL (ide_retry_pc);
drivers/ide/ide-cd.c +94 -81
227 lines not on this page · raw message
drivers/ide/ide-disk.c +2 -3
@@ -427,9 +427,8 @@ static void ide_disk_unlock_native_capacity(ide_drive_t *drive) drive->dev_flags |=IDE_DFLAG_NOHPA ;/* disable HPA on resume */ } -static int idedisk_prep_fn (struct request_queue *q,struct request *rq) +static int idedisk_prep_fn (ide_drive_t *drive,struct request *rq) { -ide_drive_t *drive = q->queuedata;struct ide_cmd *cmd;if (req_op (rq) !=REQ_OP_FLUSH )
@@ -548,7 +547,7 @@ static void update_flush(ide_drive_t *drive)if (barrier) { wc = true; -blk_queue_prep_rq (drive->queue, idedisk_prep_fn); + drive->prep_rq = idedisk_prep_fn; } }
drivers/ide/ide-io.c +56 -44
168 lines not on this page · raw message
drivers/ide/ide-park.c +2 -2
@@ -27,7 +27,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)spin_unlock_irq (&hwif->lock);if (start_queue) -blk_run_queue (q); +blk_mq_run_hw_queues (q, true);return ; }spin_unlock_irq (&hwif->lock);
@@ -54,7 +54,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)scsi_req (rq)->cmd[0 ] =REQ_UNPARK_HEADS ;scsi_req (rq)->cmd_len =1 ;ide_req (rq)->type =ATA_PRIV_MISC ; -elv_add_request (q, rq,ELEVATOR_INSERT_FRONT ); +ide_insert_request_head (drive, rq); out:return ;
drivers/ide/ide-pm.c +7 -21
@@ -40,32 +40,20 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)return ret; } -static void ide_end_sync_rq (struct request *rq,blk_status_t error) -{ -complete (rq->end_io_data); -} -static int ide_pm_execute_rq (struct request *rq) {struct request_queue *q = rq->q; -DECLARE_COMPLETION_ONSTACK (wait); - - rq->end_io_data = &wait; - rq->end_io = ide_end_sync_rq;spin_lock_irq (q->queue_lock);if (unlikely (blk_queue_dying (q))) { rq->rq_flags |=RQF_QUIET ;scsi_req (rq)->result = -ENXIO ; -__blk_end_request_all (rq,BLK_STS_OK );spin_unlock_irq (q->queue_lock); +blk_mq_end_request (rq,BLK_STS_OK );return -ENXIO ; } -__elv_add_request (q, rq,ELEVATOR_INSERT_FRONT ); -__blk_run_queue_uncond (q);spin_unlock_irq (q->queue_lock); - -wait_for_completion_io (&wait); +blk_execute_rq (q,NULL , rq, true);return scsi_req (rq)->result ? -EIO :0 ; }
@@ -79,6 +67,8 @@ int generic_ide_resume(struct device *dev)struct ide_pm_state rqpm;int err; +blk_mq_start_stopped_hw_queues (drive->queue, true); +if (ide_port_acpi (hwif)) {/* call ACPI _PS0 / _STM only once */ if ((drive->dn &1 ) ==0 || pair ==NULL ) {
@@ -226,15 +216,14 @@ void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)#endif spin_lock_irqsave (q->queue_lock, flags);if (ide_req (rq)->type ==ATA_PRIV_PM_SUSPEND ) -blk_stop_queue (q); +blk_mq_stop_hw_queues (q);else drive->dev_flags &= ~IDE_DFLAG_BLOCKED ;spin_unlock_irqrestore (q->queue_lock, flags); drive->hwif->rq =NULL ; -if (blk_end_request (rq,BLK_STS_OK ,0 )) -BUG (); +blk_mq_end_request (rq,BLK_STS_OK ); }void ide_check_pm_state (ide_drive_t *drive,struct request *rq)
@@ -260,7 +249,6 @@ void ide_check_pm_state(ide_drive_t *drive, struct request *rq)ide_hwif_t *hwif = drive->hwif;const struct ide_tp_ops *tp_ops = hwif->tp_ops;struct request_queue *q = drive->queue; -unsigned long flags;int rc;#ifdef DEBUG_PM printk ("%s: Wakeup request inited, waiting for !BSY...\n" , drive->name);
@@ -274,8 +262,6 @@ void ide_check_pm_state(ide_drive_t *drive, struct request *rq)if (rc)printk (KERN_WARNING "%s: drive not ready on wakeup\n" , drive->name); -spin_lock_irqsave (q->queue_lock, flags); -blk_start_queue (q); -spin_unlock_irqrestore (q->queue_lock, flags); +blk_mq_start_hw_queues (q); } }
drivers/ide/ide-probe.c +50 -18
137 lines not on this page · raw message
include/linux/ide.h +11 -2
@@ -10,7 +10,7 @@#include <linux/init.h> #include <linux/ioport.h> #include <linux/ata.h> -#include <linux/blkdev.h> +#include <linux/blk-mq.h> #include <linux/proc_fs.h> #include <linux/interrupt.h> #include <linux/bitops.h>
@@ -529,6 +529,10 @@ struct ide_drive_s {struct request_queue *queue;/* request queue */ +int (*prep_rq)(struct ide_drive_s *,struct request *); + +struct blk_mq_tag_set tag_set; +struct request *rq;/* current request */ void *driver_data;/* extra driver data */ u16 *id;/* identification info */
@@ -612,6 +616,10 @@ struct ide_drive_s {bool sense_rq_armed;struct request *sense_rq;struct request_sense sense_data; + +/* async sense insertion */ +struct work_struct rq_work; +struct list_head rq_list; };typedef struct ide_drive_s ide_drive_t ;
@@ -1089,6 +1097,7 @@ extern int ide_pci_clk;int ide_end_rq (ide_drive_t *,struct request *,blk_status_t ,unsigned int );void ide_kill_rq (ide_drive_t *,struct request *); +void ide_insert_request_head (ide_drive_t *,struct request *);void __ide_set_handler (ide_drive_t *,ide_handler_t *,unsigned int );void ide_set_handler (ide_drive_t *,ide_handler_t *,unsigned int );
@@ -1208,7 +1217,7 @@ extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout);extern void ide_timer_expiry (struct timer_list *t);extern irqreturn_t ide_intr (int irq,void *dev_id); -extern void do_ide_request (struct request_queue *); +extern blk_status_t ide_queue_rq (struct blk_mq_hw_ctx *,const struct blk_mq_queue_data *);extern void ide_requeue_and_plug (ide_drive_t *drive,struct request *rq);void ide_init_disk (struct gendisk *,ide_drive_t *);
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 5/29 blk-mq: remove the request_list usage
In reply to Jens AxboeWe don't do anything with it, that's just the legacy path.
--- block/blk-mq.c | 5 ----- 1 file changed, 5 deletions(-)
block/blk-mq.c +0 -5
@@ -510,9 +510,6 @@ void blk_mq_free_request(struct request *rq)rq_qos_done (q, rq); -if (blk_rq_rl (rq)) -blk_put_rl (blk_rq_rl (rq)); -WRITE_ONCE (rq->state,MQ_RQ_IDLE );if (refcount_dec_and_test (&rq->ref))__blk_mq_free_request (rq);
@@ -1675,8 +1672,6 @@ static void blk_mq_bio_to_request(struct request *rq, struct bio *bio) {blk_init_request_from_bio (rq, bio); -blk_rq_set_rl (rq,blk_get_rl (rq->q, bio)); -blk_account_io_start (rq, true); }
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 6/29 blk-mq: remove legacy check in queue blk_freeze_queue()
In reply to Jens Axboe--- block/blk-mq.c | 2 -- 1 file changed, 2 deletions(-)
block/blk-mq.c +0 -2
@@ -177,8 +177,6 @@ void blk_freeze_queue(struct request_queue *q)* exported to drivers as the only user for unfreeze is blk_mq. */ blk_freeze_queue_start (q); -if (!q->mq_ops) -blk_drain_queue (q);blk_mq_freeze_queue_wait (q); }
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 7/29 blk-mq: provide mq_ops->busy() hook
In reply to Jens AxboeWe'll hook into this from blk_lld_busy(), allowing blk-mq to also return whether or not a given queue currently has requests in progress.
--- block/blk-core.c | 2 ++ include/linux/blk-mq.h | 6 ++++++ 2 files changed, 8 insertions(+)
block/blk-core.c +2 -0
@@ -3429,6 +3429,8 @@ int blk_lld_busy(struct request_queue *q) {if (q->lld_busy_fn)return q->lld_busy_fn (q); +if (q->mq_ops && q->mq_ops->busy) +return q->mq_ops->busy (q);return 0 ; }
include/linux/blk-mq.h +6 -0
@@ -114,6 +114,7 @@ typedef void (busy_iter_fn)(struct blk_mq_hw_ctx *, struct request *, void *,typedef void (busy_tag_iter_fn )(struct request *,void *,bool );typedef int (poll_fn )(struct blk_mq_hw_ctx *,unsigned int );typedef int (map_queues_fn )(struct blk_mq_tag_set *set); +typedef bool (busy_fn )(struct request_queue *);struct blk_mq_ops {
@@ -165,6 +166,11 @@ struct blk_mq_ops {/* Called from inside blk_get_request() */ void (*initialize_rq_fn)(struct request *rq); +/* +* If set, returns whether or not this queue currently is busy +*/ +busy_fn *busy; +map_queues_fn *map_queues;#ifdef CONFIG_BLK_DEBUG_FS
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 8/29 scsi: provide mq_ops->busy() hook
In reply to Jens AxboeOnly the SCSI legacy path provides a way to check if target is currently busy, provide the same for the MQ path.
--- drivers/scsi/scsi_lib.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/scsi/scsi_lib.c +6 -0
@@ -1675,6 +1675,11 @@ static int scsi_lld_busy(struct request_queue *q)return 0 ; } +static bool scsi_mq_lld_busy (struct request_queue *q) +{ +return scsi_lld_busy (q); +} +/* * Kill a request for a dead device */
@@ -2326,6 +2331,7 @@ static const struct blk_mq_ops scsi_mq_ops = { .init_request = scsi_mq_init_request, .exit_request = scsi_mq_exit_request, .initialize_rq_fn = scsi_initialize_rq, + .busy = scsi_mq_lld_busy, .map_queues = scsi_map_queues, };
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 9/29 scsi: kill off the legacy IO path
In reply to Jens Axboe--- Documentation/scsi/scsi-parameters.txt | 5 - drivers/scsi/Kconfig | 12 - drivers/scsi/cxlflash/main.c | 6 - drivers/scsi/hosts.c | 29 +- drivers/scsi/lpfc/lpfc_scsi.c | 2 +- drivers/scsi/qedi/qedi_main.c | 3 +- drivers/scsi/qla2xxx/qla_os.c | 30 +- drivers/scsi/scsi.c | 5 +- drivers/scsi/scsi_debug.c | 3 +- drivers/scsi/scsi_error.c | 2 +- drivers/scsi/scsi_lib.c | 603 ++----------------------- drivers/scsi/scsi_priv.h | 1 - drivers/scsi/scsi_scan.c | 10 +- drivers/scsi/scsi_sysfs.c | 8 +- drivers/scsi/ufs/ufshcd.c | 6 - include/scsi/scsi_host.h | 18 +- include/scsi/scsi_tcq.h | 14 +- 17 files changed, 77 insertions(+), 680 deletions(-)
Documentation/scsi/scsi-parameters.txt +0 -5
@@ -97,11 +97,6 @@ parameters may be changed at runtime by the command allowing boot to proceed. none ignores them, expecting user space to do the scan. - scsi_mod.use_blk_mq= - [SCSI] use blk-mq I/O path by default - See SCSI_MQ_DEFAULT in drivers/scsi/Kconfig. - Format: <y/n> - sim710= [SCSI,HW] See header of drivers/scsi/sim710.c.
drivers/scsi/Kconfig +0 -12
@@ -50,18 +50,6 @@ config SCSI_NETLINK default n depends on NET -config SCSI_MQ_DEFAULT - bool "SCSI: use blk-mq I/O path by default" - default y - depends on SCSI - ---help--- - This option enables the blk-mq based I/O path for SCSI devices by - default. With this option the scsi_mod.use_blk_mq module/boot - option defaults to Y, without it to N, but it can still be - overridden either way. - - If unsure say Y. - config SCSI_PROC_FS bool "legacy /proc/scsi/ support" depends on SCSI && PROC_FS
drivers/scsi/cxlflash/main.c +0 -6
@@ -3088,12 +3088,6 @@ static ssize_t hwq_mode_store(struct device *dev,return -EINVAL ; } -if ((mode ==HWQ_MODE_TAG ) && !shost_use_blk_mq (shost)) { -dev_info (cfgdev,"SCSI-MQ is not enabled, use a different " -"HWQ steering mode.\n" ); -return -EINVAL ; - } - afu->hwq_mode = mode;return count;
drivers/scsi/hosts.c +6 -23
@@ -222,18 +222,9 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,if (error) goto fail; -if (shost_use_blk_mq (shost)) { - error =scsi_mq_setup_tags (shost); -if (error) - goto fail; - }else { - shost->bqt =blk_init_tags (shost->can_queue, - shost->hostt->tag_alloc_policy); -if (!shost->bqt) { - error = -ENOMEM ; - goto fail; - } - } + error =scsi_mq_setup_tags (shost); +if (error) + goto fail;if (!shost->shost_gendev.parent) shost->shost_gendev.parent = dev ? dev : &platform_bus;
@@ -309,8 +300,7 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,pm_runtime_disable (&shost->shost_gendev);pm_runtime_set_suspended (&shost->shost_gendev);pm_runtime_put_noidle (&shost->shost_gendev); -if (shost_use_blk_mq (shost)) -scsi_mq_destroy_tags (shost); +scsi_mq_destroy_tags (shost); fail:return error; }
@@ -344,13 +334,8 @@ static void scsi_host_dev_release(struct device *dev)kfree (dev_name (&shost->shost_dev)); } -if (shost_use_blk_mq (shost)) { -if (shost->tag_set.tags) -scsi_mq_destroy_tags (shost); - }else { -if (shost->bqt) -blk_free_tags (shost->bqt); - } +if (shost->tag_set.tags) +scsi_mq_destroy_tags (shost);kfree (shost->shost_data);
@@ -472,8 +457,6 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)else shost->dma_boundary =0xffffffff ; - shost->use_blk_mq = scsi_use_blk_mq || shost->hostt->force_blk_mq; -device_initialize (&shost->shost_gendev);dev_set_name (&shost->shost_gendev,"host%d" , shost->host_no); shost->shost_gendev.bus = &scsi_bus_type;
drivers/scsi/lpfc/lpfc_scsi.c +1 -1
@@ -3914,7 +3914,7 @@ int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba,uint32_t tag;uint16_t hwq; -if (cmnd &&shost_use_blk_mq (cmnd->device->host)) { +if (cmnd) { tag =blk_mq_unique_tag (cmnd->request); hwq =blk_mq_unique_tag_to_hwq (tag);
drivers/scsi/qedi/qedi_main.c +1 -2
@@ -644,8 +644,7 @@ static struct qedi_ctx *qedi_host_alloc(struct pci_dev *pdev) qedi->max_active_conns =ISCSI_MAX_SESS_PER_HBA ; qedi->max_sqes =QEDI_SQ_SIZE ; -if (shost_use_blk_mq (shost)) - shost->nr_hw_queues =MIN_NUM_CPUS_MSIX (qedi); + shost->nr_hw_queues =MIN_NUM_CPUS_MSIX (qedi);pci_set_drvdata (pdev, qedi);
drivers/scsi/qla2xxx/qla_os.c +9 -21
@@ -857,13 +857,9 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) }if (ha->mqenable) { -if (shost_use_blk_mq (vha->host)) { - tag =blk_mq_unique_tag (cmd->request); - hwq =blk_mq_unique_tag_to_hwq (tag); - qpair = ha->queue_pair_map[hwq]; - }else if (vha->vp_idx && vha->qpair) { - qpair = vha->qpair; - } + tag =blk_mq_unique_tag (cmd->request); + hwq =blk_mq_unique_tag_to_hwq (tag); + qpair = ha->queue_pair_map[hwq];if (qpair)return qla2xxx_mqueuecommand (host, cmd, qpair);
@@ -3153,7 +3149,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) goto probe_failed; } -if (ha->mqenable &&shost_use_blk_mq (host)) { +if (ha->mqenable) {/* number of hardware queues supported by blk/scsi-mq*/ host->nr_hw_queues = ha->max_qpairs;
@@ -3265,25 +3261,17 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) base_vha->mgmt_svr_loop_id, host->sg_tablesize);if (ha->mqenable) { -bool mq = false;bool startit = false; -if (QLA_TGT_MODE_ENABLED ()) { - mq = true; +if (QLA_TGT_MODE_ENABLED ()) startit = false; - } -if ((ql2x_ini_mode ==QLA2XXX_INI_MODE_ENABLED ) && -shost_use_blk_mq (host)) { - mq = true; +if (ql2x_ini_mode ==QLA2XXX_INI_MODE_ENABLED ) startit = true; - } -if (mq) { -/* Create start of day qpairs for Block MQ */ -for (i =0 ; i < ha->max_qpairs; i++) -qla2xxx_create_qpair (base_vha,5 ,0 , startit); - } +/* Create start of day qpairs for Block MQ */ +for (i =0 ; i < ha->max_qpairs; i++) +qla2xxx_create_qpair (base_vha,5 ,0 , startit); }if (ha->flags.running_gold_fw)
drivers/scsi/scsi.c +1 -4
@@ -780,11 +780,8 @@ MODULE_LICENSE("GPL");module_param (scsi_logging_level, int,S_IRUGO |S_IWUSR );MODULE_PARM_DESC (scsi_logging_level,"a bit mask of logging levels" ); -#ifdef CONFIG_SCSI_MQ_DEFAULT +/* Kill module parameter */ bool scsi_use_blk_mq = true; -#else -bool scsi_use_blk_mq = false; -#endif module_param_named (use_blk_mq, scsi_use_blk_mq, bool,S_IWUSR |S_IRUGO );static int __init init_scsi (void )
drivers/scsi/scsi_debug.c +1 -2
@@ -5881,8 +5881,7 @@ static int sdebug_driver_probe(struct device *dev) }/* Decide whether to tell scsi subsystem that we want mq */ /* Following should give the same answer for each host */ -if (shost_use_blk_mq (hpnt)) - hpnt->nr_hw_queues = submit_queues; + hpnt->nr_hw_queues = submit_queues; sdbg_host->shost = hpnt; *((struct sdebug_host_info **)hpnt->hostdata) = sdbg_host;
drivers/scsi/scsi_error.c +1 -1
@@ -308,7 +308,7 @@ enum blk_eh_timer_return scsi_times_out(struct request *req)* error handler. In that case we can return immediately as no * further action is required. */ -if (req->q->mq_ops && !blk_mq_mark_complete (req)) +if (!blk_mq_mark_complete (req))return rtn;if (scsi_abort_command (scmd) !=SUCCESS ) {set_host_byte (scmd,DID_TIME_OUT );
drivers/scsi/scsi_lib.c +42 -561
752 lines not on this page · raw message
drivers/scsi/scsi_priv.h +0 -1
@@ -92,7 +92,6 @@ extern void scsi_queue_insert(struct scsi_cmnd *cmd, int reason);extern void scsi_io_completion (struct scsi_cmnd *,unsigned int );extern void scsi_run_host_queues (struct Scsi_Host *shost);extern void scsi_requeue_run_queue (struct work_struct *work); -extern struct request_queue *scsi_old_alloc_queue (struct scsi_device *sdev);extern struct request_queue *scsi_mq_alloc_queue (struct scsi_device *sdev);extern void scsi_start_queue (struct scsi_device *sdev);extern int scsi_mq_setup_tags (struct Scsi_Host *shost);
drivers/scsi/scsi_scan.c +1 -9
@@ -266,10 +266,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,*/ sdev->borken =1 ; -if (shost_use_blk_mq (shost)) - sdev->request_queue =scsi_mq_alloc_queue (sdev); -else - sdev->request_queue =scsi_old_alloc_queue (sdev); + sdev->request_queue =scsi_mq_alloc_queue (sdev);if (!sdev->request_queue) {/* release fn is set up in scsi_sysfs_device_initialise, so * have to free and put manually here */
@@ -280,11 +277,6 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,WARN_ON_ONCE (!blk_get_queue (sdev->request_queue)); sdev->request_queue->queuedata = sdev; -if (!shost_use_blk_mq (sdev->host)) { -blk_queue_init_tags (sdev->request_queue, - sdev->host->cmd_per_lun, shost->bqt, - shost->hostt->tag_alloc_policy); - }scsi_change_queue_depth (sdev, sdev->host->cmd_per_lun ? sdev->host->cmd_per_lun :1 );
drivers/scsi/scsi_sysfs.c +7 -1
@@ -367,7 +367,6 @@ store_shost_eh_deadline(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR(eh_deadline, S_IRUGO | S_IWUSR, show_shost_eh_deadline, store_shost_eh_deadline); -shost_rd_attr (use_blk_mq,"%d\n" );shost_rd_attr (unique_id,"%u\n" );shost_rd_attr (cmd_per_lun,"%hd\n" );shost_rd_attr (can_queue,"%hd\n" );
@@ -386,6 +385,13 @@ show_host_busy(struct device *dev, struct device_attribute *attr, char *buf) } static DEVICE_ATTR(host_busy, S_IRUGO, show_host_busy, NULL); +static ssize_t +show_use_blk_mq (struct device *dev,struct device_attribute *attr,char *buf) +{ +return snprintf (buf,20 ,"1\n" ); +} +static DEVICE_ATTR(use_blk_mq, S_IRUGO, show_use_blk_mq, NULL); +static struct attribute *scsi_sysfs_shost_attrs[] = { &dev_attr_use_blk_mq.attr, &dev_attr_unique_id.attr,
drivers/scsi/ufs/ufshcd.c +0 -6
@@ -8100,12 +8100,6 @@ int ufshcd_alloc_host(struct device *dev, struct ufs_hba **hba_handle) goto out_error; } -/* -* Do not use blk-mq at this time because blk-mq does not support -* runtime pm. -*/ - host->use_blk_mq = false; - hba =shost_priv (host); hba->host = host; hba->dev = dev;
include/scsi/scsi_host.h +2 -16
@@ -11,7 +11,6 @@#include <linux/blk-mq.h> #include <scsi/scsi.h> -struct request_queue ;struct block_device ;struct completion ;struct module ;
@@ -22,7 +21,6 @@ struct scsi_target;struct Scsi_Host ;struct scsi_host_cmd_pool ;struct scsi_transport_template ; -struct blk_queue_tags ;/*
@@ -547,14 +545,8 @@ struct Scsi_Host {struct scsi_host_template *hostt;struct scsi_transport_template *transportt; -/* -* Area to keep a shared tag map (if needed, will be -* NULL if not). -*/ -union { -struct blk_queue_tag *bqt; -struct blk_mq_tag_set tag_set; - }; +/* Area to keep a shared tag map */ +struct blk_mq_tag_set tag_set;atomic_t host_busy;/* commands actually active on low-level */ atomic_t host_blocked;
@@ -648,7 +640,6 @@ struct Scsi_Host {/* The controller does not support WRITE SAME */ unsigned no_write_same:1; - unsigned use_blk_mq:1; unsigned use_cmd_list:1;/* Host responded with short (<36 bytes) INQUIRY result */
@@ -742,11 +733,6 @@ static inline int scsi_host_in_recovery(struct Scsi_Host *shost) shost->tmf_in_progress; } -static inline bool shost_use_blk_mq (struct Scsi_Host *shost) -{ -return shost->use_blk_mq; -} -extern int scsi_queue_work (struct Scsi_Host *,struct work_struct *);extern void scsi_flush_work (struct Scsi_Host *);
include/scsi/scsi_tcq.h +5 -9
@@ -23,19 +23,15 @@ static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost, int tag) {struct request *req =NULL ; +u16 hwq;if (tag ==SCSI_NO_TAG )return NULL ; -if (shost_use_blk_mq (shost)) { -u16 hwq =blk_mq_unique_tag_to_hwq (tag); - -if (hwq < shost->tag_set.nr_hw_queues) { - req =blk_mq_tag_to_rq (shost->tag_set.tags[hwq], -blk_mq_unique_tag_to_tag (tag)); - } - }else { - req =blk_map_queue_find_tag (shost->bqt, tag); + hwq =blk_mq_unique_tag_to_hwq (tag); +if (hwq < shost->tag_set.nr_hw_queues) { + req =blk_mq_tag_to_rq (shost->tag_set.tags[hwq], +blk_mq_unique_tag_to_tag (tag)); }if (!req)
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 10/29 block: remove q->lld_busy_fn()
In reply to Jens AxboeNobody is using the legacy path for blk_lld_busy() anymore, remove it.
--- block/blk-core.c | 2 -- block/blk-settings.c | 6 ------ include/linux/blkdev.h | 3 --- 3 files changed, 11 deletions(-)
block/blk-core.c +0 -2
@@ -3427,8 +3427,6 @@ EXPORT_SYMBOL_GPL(rq_flush_dcache_pages);*/ int blk_lld_busy (struct request_queue *q) { -if (q->lld_busy_fn) -return q->lld_busy_fn (q);if (q->mq_ops && q->mq_ops->busy)return q->mq_ops->busy (q);
block/blk-settings.c +0 -6
@@ -73,12 +73,6 @@ void blk_queue_rq_timed_out(struct request_queue *q, rq_timed_out_fn *fn) }EXPORT_SYMBOL_GPL (blk_queue_rq_timed_out); -void blk_queue_lld_busy (struct request_queue *q,lld_busy_fn *fn) -{ - q->lld_busy_fn = fn; -} -EXPORT_SYMBOL_GPL (blk_queue_lld_busy); -/** * blk_set_default_limits - reset limits to default values * @lim: the queue_limits structure to reset
include/linux/blkdev.h +0 -3
@@ -320,7 +320,6 @@ typedef void (unprep_rq_fn) (struct request_queue *, struct request *);struct bio_vec ;typedef void (softirq_done_fn )(struct request *);typedef int (dma_drain_needed_fn )(struct request *); -typedef int (lld_busy_fn ) (struct request_queue *q);typedef int (bsg_job_fn ) (struct bsg_job *);typedef int (init_rq_fn )(struct request_queue *,struct request *,gfp_t );typedef void (exit_rq_fn )(struct request_queue *,struct request *);
@@ -466,7 +465,6 @@ struct request_queue {softirq_done_fn *softirq_done_fn;rq_timed_out_fn *rq_timed_out_fn;dma_drain_needed_fn *dma_drain_needed; -lld_busy_fn *lld_busy_fn;/* Called just after a request is allocated */ init_rq_fn *init_rq_fn;/* Called just before a request is freed */
@@ -1255,7 +1253,6 @@ extern void blk_queue_update_dma_pad(struct request_queue *, unsigned int);extern int blk_queue_dma_drain (struct request_queue *q,dma_drain_needed_fn *dma_drain_needed,void *buf,unsigned int size); -extern void blk_queue_lld_busy (struct request_queue *q,lld_busy_fn *fn);extern void blk_queue_segment_boundary (struct request_queue *,unsigned long );extern void blk_queue_virt_boundary (struct request_queue *,unsigned long );extern void blk_queue_prep_rq (struct request_queue *,prep_rq_fn *pfn);
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 11/29 dasd: remove dead code
In reply to Jens AxboeSince e443343e509a we haven't had a request_fn attached to this driver, hence any code inside an if (q->request_fn) is unreachable.
--- drivers/s390/block/dasd_ioctl.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-)
drivers/s390/block/dasd_ioctl.c +5 -17
@@ -412,6 +412,7 @@ static int dasd_ioctl_information(struct dasd_block *block,struct ccw_dev_id dev_id;struct dasd_device *base;struct ccw_device *cdev; +struct list_head *l;unsigned long flags;int rc;
@@ -462,23 +463,10 @@ static int dasd_ioctl_information(struct dasd_block *block,memcpy (dasd_info->type, base->discipline->name,4 ); -if (block->request_queue->request_fn) { -struct list_head *l; -#ifdef DASD_EXTENDED_PROFILING - { -struct list_head *l; -spin_lock_irqsave (&block->lock, flags); -list_for_each (l, &block->request_queue->queue_head) - dasd_info->req_queue_len++; -spin_unlock_irqrestore (&block->lock, flags); - } -#endif /* DASD_EXTENDED_PROFILING */ -spin_lock_irqsave (get_ccwdev_lock (base->cdev), flags); -list_for_each (l, &base->ccw_queue) - dasd_info->chanq_len++; -spin_unlock_irqrestore (get_ccwdev_lock (base->cdev), - flags); - } +spin_lock_irqsave (&block->queue_lock, flags); +list_for_each (l, &base->ccw_queue) + dasd_info->chanq_len++; +spin_unlock_irqrestore (&block->queue_lock, flags); rc =0 ; if (copy_to_user(argp, dasd_info,
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 12/29 bsg: pass in desired timeout handler
In reply to Jens AxboeThis will ease in the conversion to blk-mq, where we can't set a timeout handler after queue init.
--- block/bsg-lib.c | 3 ++- drivers/scsi/scsi_transport_fc.c | 7 +++---- drivers/scsi/scsi_transport_iscsi.c | 2 +- drivers/scsi/scsi_transport_sas.c | 4 ++-- drivers/scsi/ufs/ufs_bsg.c | 2 +- include/linux/bsg-lib.h | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-)
block/bsg-lib.c +2 -1
@@ -304,7 +304,7 @@ static void bsg_exit_rq(struct request_queue *q, struct request *req)* @dd_job_size: size of LLD data needed for each job */ struct request_queue *bsg_setup_queue (struct device *dev,const char *name, -bsg_job_fn *job_fn,int dd_job_size) +bsg_job_fn *job_fn,rq_timed_out_fn *timeout,int dd_job_size) {struct request_queue *q;int ret;
@@ -327,6 +327,7 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name,blk_queue_flag_set (QUEUE_FLAG_BIDI , q);blk_queue_softirq_done (q, bsg_softirq_done);blk_queue_rq_timeout (q,BLK_DEFAULT_SG_TIMEOUT ); +blk_queue_rq_timed_out (q, timeout); ret =bsg_register_queue (q, dev, name, &bsg_transport_ops);if (ret) {
drivers/scsi/scsi_transport_fc.c +3 -4
@@ -3780,7 +3780,8 @@ fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host)snprintf (bsg_name,sizeof (bsg_name),"fc_host%d" , shost->host_no); - q =bsg_setup_queue (dev, bsg_name, fc_bsg_dispatch, i->f->dd_bsg_size); + q =bsg_setup_queue (dev, bsg_name, fc_bsg_dispatch, fc_bsg_job_timeout, + i->f->dd_bsg_size);if (IS_ERR (q)) { dev_err(dev, "fc_host%d: bsg interface failed to initialize - setup queue\n",
@@ -3788,7 +3789,6 @@ fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host)return PTR_ERR (q); }__scsi_init_queue (shost, q); -blk_queue_rq_timed_out (q, fc_bsg_job_timeout);blk_queue_rq_timeout (q,FC_DEFAULT_BSG_TIMEOUT ); fc_host->rqst_q = q;return 0 ;
@@ -3826,14 +3826,13 @@ fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport)return -ENOTSUPP ; q =bsg_setup_queue (dev,dev_name (dev), fc_bsg_dispatch, - i->f->dd_bsg_size); + fc_bsg_job_timeout, i->f->dd_bsg_size);if (IS_ERR (q)) {dev_err (dev,"failed to setup bsg queue\n" );return PTR_ERR (q); }__scsi_init_queue (shost, q);blk_queue_prep_rq (q, fc_bsg_rport_prep); -blk_queue_rq_timed_out (q, fc_bsg_job_timeout);blk_queue_rq_timeout (q,BLK_DEFAULT_SG_TIMEOUT ); rport->rqst_q = q;return 0 ;
drivers/scsi/scsi_transport_iscsi.c +1 -1
@@ -1542,7 +1542,7 @@ iscsi_bsg_host_add(struct Scsi_Host *shost, struct iscsi_cls_host *ihost)return -ENOTSUPP ;snprintf (bsg_name,sizeof (bsg_name),"iscsi_host%d" , shost->host_no); - q =bsg_setup_queue (dev, bsg_name, iscsi_bsg_host_dispatch,0 ); + q =bsg_setup_queue (dev, bsg_name, iscsi_bsg_host_dispatch,NULL ,0 );if (IS_ERR (q)) {shost_printk (KERN_ERR , shost,"bsg interface failed to " "initialize - no request queue\n" );
drivers/scsi/scsi_transport_sas.c +2 -2
@@ -198,7 +198,7 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy)if (rphy) { q =bsg_setup_queue (&rphy->dev,dev_name (&rphy->dev), - sas_smp_dispatch,0 ); + sas_smp_dispatch,NULL ,0 );if (IS_ERR (q))return PTR_ERR (q); rphy->q = q;
@@ -207,7 +207,7 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy)snprintf (name,sizeof (name),"sas_host%d" , shost->host_no); q =bsg_setup_queue (&shost->shost_gendev, name, - sas_smp_dispatch,0 ); + sas_smp_dispatch,NULL ,0 );if (IS_ERR (q))return PTR_ERR (q);to_sas_host_attrs (shost)->q = q;
drivers/scsi/ufs/ufs_bsg.c +1 -1
@@ -193,7 +193,7 @@ int ufs_bsg_probe(struct ufs_hba *hba)if (ret) goto out; - q =bsg_setup_queue (bsg_dev,dev_name (bsg_dev), ufs_bsg_request,0 ); + q =bsg_setup_queue (bsg_dev,dev_name (bsg_dev), ufs_bsg_request,NULL ,0 );if (IS_ERR (q)) { ret =PTR_ERR (q); goto out;
include/linux/bsg-lib.h +1 -1
@@ -72,7 +72,7 @@ struct bsg_job {void bsg_job_done (struct bsg_job *job,int result,unsigned int reply_payload_rcv_len);struct request_queue *bsg_setup_queue (struct device *dev,const char *name, -bsg_job_fn *job_fn,int dd_job_size); +bsg_job_fn *job_fn,rq_timed_out_fn *timeout,int dd_job_size);void bsg_job_put (struct bsg_job *job);int __must_check bsg_job_get (struct bsg_job *job);
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 13/29 bsg: provide bsg_remove_queue() helper
In reply to Jens AxboeAll drivers do unregister + cleanup, provide a helper for that.
--- block/bsg-lib.c | 9 +++++++++ drivers/scsi/scsi_transport_fc.c | 5 +---- drivers/scsi/scsi_transport_iscsi.c | 5 +---- drivers/scsi/scsi_transport_sas.c | 6 +----- drivers/scsi/ufs/ufs_bsg.c | 2 +- include/linux/bsg-lib.h | 1 + 6 files changed, 14 insertions(+), 14 deletions(-)
block/bsg-lib.c +9 -0
@@ -296,6 +296,15 @@ static void bsg_exit_rq(struct request_queue *q, struct request *req)kfree (job->reply); } +void bsg_remove_queue (struct request_queue *q) +{ +if (q) { +bsg_unregister_queue (q); +blk_cleanup_queue (q); + } +} +EXPORT_SYMBOL_GPL (bsg_remove_queue); +/** * bsg_setup_queue - Create and add the bsg hooks so we can receive requests * @dev: device to attach bsg device to
drivers/scsi/scsi_transport_fc.c +1 -4
@@ -3851,10 +3851,7 @@ fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport)static void fc_bsg_remove (struct request_queue *q) { -if (q) { -bsg_unregister_queue (q); -blk_cleanup_queue (q); - } +bsg_remove_queue (q); }
drivers/scsi/scsi_transport_iscsi.c +1 -4
@@ -1576,10 +1576,7 @@ static int iscsi_remove_host(struct transport_container *tc,struct Scsi_Host *shost =dev_to_shost (dev);struct iscsi_cls_host *ihost = shost->shost_data; -if (ihost->bsg_q) { -bsg_unregister_queue (ihost->bsg_q); -blk_cleanup_queue (ihost->bsg_q); - } +bsg_remove_queue (ihost->bsg_q);return 0 ; }
drivers/scsi/scsi_transport_sas.c +1 -5
@@ -246,11 +246,7 @@ static int sas_host_remove(struct transport_container *tc, struct device *dev,struct Scsi_Host *shost =dev_to_shost (dev);struct request_queue *q =to_sas_host_attrs (shost)->q; -if (q) { -bsg_unregister_queue (q); -blk_cleanup_queue (q); - } - +bsg_remove_queue (q);return 0 ; }
drivers/scsi/ufs/ufs_bsg.c +1 -1
@@ -157,7 +157,7 @@ void ufs_bsg_remove(struct ufs_hba *hba)if (!hba->bsg_queue)return ; -bsg_unregister_queue (hba->bsg_queue); +bsg_remove_queue (hba->bsg_queue);device_del (bsg_dev);put_device (bsg_dev);
include/linux/bsg-lib.h +1 -0
@@ -73,6 +73,7 @@ void bsg_job_done(struct bsg_job *job, int result, unsigned int reply_payload_rcv_len);struct request_queue *bsg_setup_queue (struct device *dev,const char *name,bsg_job_fn *job_fn,rq_timed_out_fn *timeout,int dd_job_size); +void bsg_remove_queue (struct request_queue *q);void bsg_job_put (struct bsg_job *job);int __must_check bsg_job_get (struct bsg_job *job);
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 14/29 bsg: convert to use blk-mq
In reply to Jens AxboeRequires a few changes to the FC transport class as well.
--- block/bsg-lib.c | 123 +++++++++++++++++++------------ drivers/scsi/scsi_transport_fc.c | 59 +++++++++------ 2 files changed, 110 insertions(+), 72 deletions(-)
block/bsg-lib.c +75 -48
@@ -21,7 +21,7 @@* */ #include <linux/slab.h> -#include <linux/blkdev.h> +#include <linux/blk-mq.h> #include <linux/delay.h> #include <linux/scatterlist.h> #include <linux/bsg-lib.h>
@@ -129,7 +129,7 @@ static void bsg_teardown_job(struct kref *kref)kfree (job->request_payload.sg_list);kfree (job->reply_payload.sg_list); -blk_end_request_all (rq,BLK_STS_OK ); +blk_mq_end_request (rq,BLK_STS_OK ); }void bsg_job_put (struct bsg_job *job)
@@ -157,15 +157,15 @@ void bsg_job_done(struct bsg_job *job, int result, { job->result = result; job->reply_payload_rcv_len = reply_payload_rcv_len; -blk_complete_request (blk_mq_rq_from_pdu (job)); +blk_mq_complete_request (blk_mq_rq_from_pdu (job)); }EXPORT_SYMBOL_GPL (bsg_job_done);/** -* bsg_softirq_done - softirq done routine for destroying the bsg requests +* bsg_complete - softirq done routine for destroying the bsg requests * @rq: BSG request that holds the job to be destroyed */ -static void bsg_softirq_done (struct request *rq) +static void bsg_complete (struct request *rq) {struct bsg_job *job =blk_mq_rq_to_pdu (rq);
@@ -224,54 +224,46 @@ static bool bsg_prepare_job(struct device *dev, struct request *req) }/** -* bsg_request_fn - generic handler for bsg requests -* @q: request queue to manage +* bsg_queue_rq - generic handler for bsg requests +* @hctx: hardware queue +* @bd: queue data * * On error the create_bsg_job function should return a -Exyz error value * that will be set to ->result. * * Drivers/subsys should pass this to the queue init function. */ -static void bsg_request_fn (struct request_queue *q) - __releases(q->queue_lock) - __acquires(q->queue_lock) +static blk_status_t bsg_queue_rq (struct blk_mq_hw_ctx *hctx, +const struct blk_mq_queue_data *bd) { +struct request_queue *q = hctx->queue;struct device *dev = q->queuedata; -struct request *req; +struct request *req = bd->rq;int ret; +blk_mq_start_request (req); +if (!get_device (dev)) -return ; - -while (1 ) { - req =blk_fetch_request (q); -if (!req) -break ; -spin_unlock_irq (q->queue_lock); - -if (!bsg_prepare_job (dev, req)) { -blk_end_request_all (req,BLK_STS_OK ); -spin_lock_irq (q->queue_lock); -continue ; - } - - ret = q->bsg_job_fn (blk_mq_rq_to_pdu (req)); -spin_lock_irq (q->queue_lock); -if (ret) -break ; - } +return BLK_STS_IOERR ; + +if (!bsg_prepare_job (dev, req)) +return BLK_STS_IOERR ; + + ret = q->bsg_job_fn (blk_mq_rq_to_pdu (req)); +if (ret) +return BLK_STS_IOERR ; -spin_unlock_irq (q->queue_lock);put_device (dev); -spin_lock_irq (q->queue_lock); +return BLK_STS_OK ; }/* called right after the request is allocated for the request_queue */ -static int bsg_init_rq (struct request_queue *q,struct request *req,gfp_t gfp) +static int bsg_init_rq (struct blk_mq_tag_set *set,struct request *req, +unsigned int hctx_idx,unsigned int numa_node) {struct bsg_job *job =blk_mq_rq_to_pdu (req); - job->reply =kzalloc (SCSI_SENSE_BUFFERSIZE , gfp); + job->reply =kzalloc (SCSI_SENSE_BUFFERSIZE ,GFP_KERNEL );if (!job->reply)return -ENOMEM ;return 0 ;
@@ -289,7 +281,8 @@ static void bsg_initialize_rq(struct request *req) job->dd_data = job +1 ; } -static void bsg_exit_rq (struct request_queue *q,struct request *req) +static void bsg_exit_rq (struct blk_mq_tag_set *set,struct request *req, +unsigned int hctx_idx) {struct bsg_job *job =blk_mq_rq_to_pdu (req);
@@ -299,12 +292,36 @@ static void bsg_exit_rq(struct request_queue *q, struct request *req)void bsg_remove_queue (struct request_queue *q) {if (q) { +struct blk_mq_tag_set *set = q->tag_set; +bsg_unregister_queue (q);blk_cleanup_queue (q); +blk_mq_free_tag_set (set); +kfree (set); } }EXPORT_SYMBOL_GPL (bsg_remove_queue); +static enum blk_eh_timer_return bsg_timeout (struct request *rq,bool reserved) +{ +enum blk_eh_timer_return ret =BLK_EH_DONE ; +struct request_queue *q = rq->q; + +if (q->rq_timed_out_fn) + ret = q->rq_timed_out_fn (rq); + +return ret; +} + +static const struct blk_mq_ops bsg_mq_ops = { + .queue_rq = bsg_queue_rq, + .init_request = bsg_init_rq, + .exit_request = bsg_exit_rq, + .initialize_rq_fn = bsg_initialize_rq, + .complete = bsg_complete, + .timeout = bsg_timeout, +}; +/** * bsg_setup_queue - Create and add the bsg hooks so we can receive requests * @dev: device to attach bsg device to
@@ -315,28 +332,34 @@ EXPORT_SYMBOL_GPL(bsg_remove_queue);struct request_queue *bsg_setup_queue (struct device *dev,const char *name,bsg_job_fn *job_fn,rq_timed_out_fn *timeout,int dd_job_size) { +struct blk_mq_tag_set *set;struct request_queue *q; -int ret; +int ret = -ENOMEM ; - q =blk_alloc_queue (GFP_KERNEL ); -if (!q) + set =kzalloc (sizeof (*set),GFP_KERNEL ); +if (!set)return ERR_PTR (-ENOMEM ); - q->cmd_size =sizeof (struct bsg_job ) + dd_job_size; - q->init_rq_fn = bsg_init_rq; - q->exit_rq_fn = bsg_exit_rq; - q->initialize_rq_fn = bsg_initialize_rq; - q->request_fn = bsg_request_fn; - ret =blk_init_allocated_queue (q); -if (ret) - goto out_cleanup_queue; + set->ops = &bsg_mq_ops, + set->nr_hw_queues =1 ; + set->queue_depth =128 ; + set->numa_node =NUMA_NO_NODE ; + set->cmd_size =sizeof (struct bsg_job ) + dd_job_size; + set->flags =BLK_MQ_F_NO_SCHED |BLK_MQ_F_BLOCKING ; +if (blk_mq_alloc_tag_set (set)) + goto out_tag_set; + + q =blk_mq_init_queue (set); +if (IS_ERR (q)) { + ret =PTR_ERR (q); + goto out_queue; + } q->queuedata = dev; q->bsg_job_fn = job_fn;blk_queue_flag_set (QUEUE_FLAG_BIDI , q); -blk_queue_softirq_done (q, bsg_softirq_done);blk_queue_rq_timeout (q,BLK_DEFAULT_SG_TIMEOUT ); -blk_queue_rq_timed_out (q, timeout); + q->rq_timed_out_fn = timeout; ret =bsg_register_queue (q, dev, name, &bsg_transport_ops);if (ret) {
@@ -348,6 +371,10 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name,return q; out_cleanup_queue:blk_cleanup_queue (q); +out_queue: +blk_mq_free_tag_set (set); +out_tag_set: +kfree (set);return ERR_PTR (ret); }EXPORT_SYMBOL_GPL (bsg_setup_queue);
drivers/scsi/scsi_transport_fc.c +35 -24
96 lines not on this page · raw message
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 15/29 block: remove blk_complete_request()
In reply to Jens AxboeIt's now unused.
--- block/blk-softirq.c | 20 -------------------- include/linux/blkdev.h | 1 - 2 files changed, 21 deletions(-)
block/blk-softirq.c +0 -20
@@ -145,26 +145,6 @@ void __blk_complete_request(struct request *req) }EXPORT_SYMBOL (__blk_complete_request); -/** -* blk_complete_request - end I/O on a request -* @req: the request being processed -* -* Description: -* Ends all I/O on a request. It does not handle partial completions, -* unless the driver actually implements this in its completion callback -* through requeueing. The actual completion happens out-of-order, -* through a softirq handler. The user must have registered a completion -* callback through blk_queue_softirq_done(). -**/ -void blk_complete_request (struct request *req) -{ -if (unlikely (blk_should_fake_timeout (req->q))) -return ; -if (!blk_mark_rq_complete (req)) -__blk_complete_request (req); -} -EXPORT_SYMBOL (blk_complete_request); -static __init int blk_softirq_init (void ) {int i;
include/linux/blkdev.h +0 -1
@@ -1203,7 +1203,6 @@ extern bool __blk_end_request(struct request *rq, blk_status_t error,extern void __blk_end_request_all (struct request *rq,blk_status_t error);extern bool __blk_end_request_cur (struct request *rq,blk_status_t error); -extern void blk_complete_request (struct request *);extern void __blk_complete_request (struct request *);extern void blk_abort_request (struct request *);extern void blk_unprep_request (struct request *);
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 16/29 blk-wbt: kill check for legacy queue type
In reply to Jens AxboeEverything is blk-mq at this point, so it doesn't make any sense to have this option available as it does nothing.
--- block/Kconfig | 6 ------ block/blk-wbt.c | 3 +-- 2 files changed, 1 insertion(+), 8 deletions(-)
block/Kconfig +0 -6
@@ -155,12 +155,6 @@ config BLK_CGROUP_IOLATENCY Note, this is an experimental interface and could be changed someday. -config BLK_WBT_SQ - bool "Single queue writeback throttling" - depends on BLK_WBT - ---help--- - Enable writeback throttling by default on legacy single queue devices - config BLK_WBT_MQ bool "Multiqueue writeback throttling" default y
block/blk-wbt.c +1 -2
@@ -709,8 +709,7 @@ void wbt_enable_default(struct request_queue *q)if (!test_bit (QUEUE_FLAG_REGISTERED , &q->queue_flags))return ; -if ((q->mq_ops &&IS_ENABLED (CONFIG_BLK_WBT_MQ )) || - (q->request_fn &&IS_ENABLED (CONFIG_BLK_WBT_SQ ))) +if (q->mq_ops &&IS_ENABLED (CONFIG_BLK_WBT_MQ ))wbt_init (q); }EXPORT_SYMBOL_GPL (wbt_enable_default);
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 17/29 blk-cgroup: remove legacy queue bypassing
In reply to Jens AxboeWe only support mq devices now.
--- block/blk-cgroup.c | 8 -------- 1 file changed, 8 deletions(-)
block/blk-cgroup.c +0 -8
@@ -1446,8 +1446,6 @@ int blkcg_activate_policy(struct request_queue *q,if (q->mq_ops)blk_mq_freeze_queue (q); -else -blk_queue_bypass_start (q); pd_prealloc:if (!pd_prealloc) { pd_prealloc = pol->pd_alloc_fn (GFP_KERNEL , q->node);
@@ -1487,8 +1485,6 @@ int blkcg_activate_policy(struct request_queue *q, out_bypass_end:if (q->mq_ops)blk_mq_unfreeze_queue (q); -else -blk_queue_bypass_end (q);if (pd_prealloc) pol->pd_free_fn (pd_prealloc);return ret;
@@ -1513,8 +1509,6 @@ void blkcg_deactivate_policy(struct request_queue *q,if (q->mq_ops)blk_mq_freeze_queue (q); -else -blk_queue_bypass_start (q);spin_lock_irq (q->queue_lock);
@@ -1533,8 +1527,6 @@ void blkcg_deactivate_policy(struct request_queue *q,if (q->mq_ops)blk_mq_unfreeze_queue (q); -else -blk_queue_bypass_end (q); }EXPORT_SYMBOL_GPL (blkcg_deactivate_policy);
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 18/29 block: remove legacy rq tagging
In reply to Jens AxboeIt's now unused, kill it.
--- Documentation/block/biodoc.txt | 88 -------- block/Makefile | 2 +- block/blk-core.c | 6 - block/blk-mq-debugfs.c | 2 - block/blk-mq-tag.c | 6 +- block/blk-sysfs.c | 3 - block/blk-tag.c | 378 --------------------------------- include/linux/blkdev.h | 35 --- 8 files changed, 3 insertions(+), 517 deletions(-) delete mode 100644 block/blk-tag.c
Documentation/block/biodoc.txt +0 -88
@@ -65,7 +65,6 @@ Description of Contents: 3.2.3 I/O completion 3.2.4 Implications for drivers that do not interpret bios (don't handle multiple segments) - 3.2.5 Request command tagging 3.3 I/O submission 4. The I/O scheduler 5. Scalability related changes
@@ -708,93 +707,6 @@ is crossed on completion of a transfer. (The end*request* functions should be used if only if the request has come down from block/bio path, not for direct access requests which only specify rq->buffer without a valid rq->bio) -3.2.5 Generic request command tagging - -3.2.5.1 Tag helpers - -Block now offers some simple generic functionality to help support command -queueing (typically known as tagged command queueing), ie manage more than -one outstanding command on a queue at any given time. - - blk_queue_init_tags(struct request_queue *q, int depth) - - Initialize internal command tagging structures for a maximum - depth of 'depth'. - - blk_queue_free_tags((struct request_queue *q) - - Teardown tag info associated with the queue. This will be done - automatically by block if blk_queue_cleanup() is called on a queue - that is using tagging. - -The above are initialization and exit management, the main helpers during -normal operations are: - - blk_queue_start_tag(struct request_queue *q, struct request *rq) - - Start tagged operation for this request. A free tag number between - 0 and 'depth' is assigned to the request (rq->tag holds this number), - and 'rq' is added to the internal tag management. If the maximum depth - for this queue is already achieved (or if the tag wasn't started for - some other reason), 1 is returned. Otherwise 0 is returned. - - blk_queue_end_tag(struct request_queue *q, struct request *rq) - - End tagged operation on this request. 'rq' is removed from the internal - book keeping structures. - -To minimize struct request and queue overhead, the tag helpers utilize some -of the same request members that are used for normal request queue management. -This means that a request cannot both be an active tag and be on the queue -list at the same time. blk_queue_start_tag() will remove the request, but -the driver must remember to call blk_queue_end_tag() before signalling -completion of the request to the block layer. This means ending tag -operations before calling end_that_request_last()! For an example of a user -of these helpers, see the IDE tagged command queueing support. - -3.2.5.2 Tag info - -Some block functions exist to query current tag status or to go from a -tag number to the associated request. These are, in no particular order: - - blk_queue_tagged(q) - - Returns 1 if the queue 'q' is using tagging, 0 if not. - - blk_queue_tag_request(q, tag) - - Returns a pointer to the request associated with tag 'tag'. - - blk_queue_tag_depth(q) - - Return current queue depth. - - blk_queue_tag_queue(q) - - Returns 1 if the queue can accept a new queued command, 0 if we are - at the maximum depth already. - - blk_queue_rq_tagged(rq) - - Returns 1 if the request 'rq' is tagged. - -3.2.5.2 Internal structure - -Internally, block manages tags in the blk_queue_tag structure: - - struct blk_queue_tag { - struct request **tag_index; /* array or pointers to rq */ - unsigned long *tag_map; /* bitmap of free tags */ - struct list_head busy_list; /* fifo list of busy tags */ - int busy; /* queue depth */ - int max_depth; /* max queue depth */ - }; - -Most of the above is simple and straight forward, however busy_list may need -a bit of explaining. Normally we don't care too much about request ordering, -but in the event of any barrier requests in the tag queue we need to ensure -that requests are restarted in the order they were queue. - 3.3 I/O Submission The routine submit_bio() is used to submit a single io. Higher level i/o
block/Makefile +1 -1
@@ -3,7 +3,7 @@ # Makefile for the kernel block layer # -obj-$(CONFIG_BLOCK) := bio.o elevator.o blk-core.o blk-tag.o blk-sysfs.o \ +obj-$(CONFIG_BLOCK) := bio.o elevator.o blk-core.o blk-sysfs.o \ blk-flush.o blk-settings.o blk-ioc.o blk-map.o \ blk-exec.o blk-merge.o blk-softirq.o blk-timeout.o \ blk-lib.o blk-mq.o blk-mq-tag.o blk-stat.o \
block/blk-core.c +0 -6
@@ -1655,9 +1655,6 @@ void blk_requeue_request(struct request_queue *q, struct request *rq)trace_block_rq_requeue (q, rq);rq_qos_requeue (q, rq); -if (rq->rq_flags &RQF_QUEUED ) -blk_queue_end_tag (q, rq); -BUG_ON (blk_queued_rq (rq));elv_requeue_request (q, rq);
@@ -3172,9 +3169,6 @@ void blk_finish_request(struct request *req, blk_status_t error)if (req->rq_flags &RQF_STATS )blk_stat_add (req, now); -if (req->rq_flags &RQF_QUEUED ) -blk_queue_end_tag (q, req); -BUG_ON (blk_queued_rq (req));if (unlikely (laptop_mode) && !blk_rq_is_passthrough (req))
block/blk-mq-debugfs.c +0 -2
@@ -112,7 +112,6 @@ static int queue_pm_only_show(void *data, struct seq_file *m)#define QUEUE_FLAG_NAME (name) [QUEUE_FLAG_##name] = #namestatic const char *const blk_queue_flag_name[] = { -QUEUE_FLAG_NAME (QUEUED ),QUEUE_FLAG_NAME (STOPPED ),QUEUE_FLAG_NAME (DYING ),QUEUE_FLAG_NAME (BYPASS ),
@@ -318,7 +317,6 @@ static const char *const cmd_flag_name[] = {static const char *const rqf_name[] = {RQF_NAME (SORTED ),RQF_NAME (STARTED ), -RQF_NAME (QUEUED ),RQF_NAME (SOFTBARRIER ),RQF_NAME (FLUSH_SEQ ),RQF_NAME (MIXED_MERGE ),
block/blk-mq-tag.c +2 -4
@@ -530,10 +530,8 @@ u32 blk_mq_unique_tag(struct request *rq)struct blk_mq_hw_ctx *hctx;int hwq =0 ; -if (q->mq_ops) { - hctx =blk_mq_map_queue (q, rq->mq_ctx->cpu); - hwq = hctx->queue_num; - } + hctx =blk_mq_map_queue (q, rq->mq_ctx->cpu); + hwq = hctx->queue_num;return (hwq <<BLK_MQ_UNIQUE_TAG_BITS ) | (rq->tag &BLK_MQ_UNIQUE_TAG_MASK );
block/blk-sysfs.c +0 -3
@@ -849,9 +849,6 @@ static void __blk_release_queue(struct work_struct *work)blk_exit_rl (q, &q->root_rl); -if (q->queue_tags) -__blk_queue_free_tags (q); -blk_queue_free_zone_bitmaps (q);if (!q->mq_ops) {
block/blk-tag.c deleted +0 -378
378 lines not on this page · raw message
include/linux/blkdev.h +0 -35
@@ -85,8 +85,6 @@ typedef __u32 __bitwise req_flags_t;#define RQF_SORTED ((__force req_flags_t)(1 << 0))/* drive already may have started this one */ #define RQF_STARTED ((__force req_flags_t)(1 << 1)) -/* uses tagged queueing */ -#define RQF_QUEUED ((__force req_flags_t)(1 << 2))/* may not be passed by ioscheduler */ #define RQF_SOFTBARRIER ((__force req_flags_t)(1 << 3))/* request for flush sequence */
@@ -336,15 +334,6 @@ enum blk_queue_state { Queue_up, }; -struct blk_queue_tag { -struct request **tag_index;/* map of busy tags */ -unsigned long *tag_map;/* bit map of free/busy tags */ -int max_depth;/* what we will send to device */ -int real_max_depth;/* what the array can hold */ -atomic_t refcnt;/* map can be shared */ -int alloc_policy;/* tag allocation policy */ -int next_tag;/* next tag */ -};#define BLK_TAG_ALLOC_FIFO 0/* allocate starting from 0 */ #define BLK_TAG_ALLOC_RR 1/* allocate starting from last allocated tag */
@@ -568,8 +557,6 @@ struct request_queue {unsigned int dma_pad_mask;unsigned int dma_alignment; -struct blk_queue_tag *queue_tags; -unsigned int nr_sorted;unsigned int in_flight[2 ];
@@ -680,7 +667,6 @@ struct request_queue {u64 write_hints[BLK_MAX_WRITE_HINTS ]; }; -#define QUEUE_FLAG_QUEUED 0/* uses generic tag queueing */ #define QUEUE_FLAG_STOPPED 1/* queue is stopped */ #define QUEUE_FLAG_DYING 2/* queue being torn down */ #define QUEUE_FLAG_BYPASS 3/* act as dumb FIFO queue */
@@ -724,7 +710,6 @@ void blk_queue_flag_clear(unsigned int flag, struct request_queue *q);bool blk_queue_flag_test_and_set (unsigned int flag,struct request_queue *q);bool blk_queue_flag_test_and_clear (unsigned int flag,struct request_queue *q); -#define blk_queue_tagged (q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags)#define blk_queue_stopped (q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)#define blk_queue_dying (q) test_bit(QUEUE_FLAG_DYING, &(q)->queue_flags)#define blk_queue_dead (q) test_bit(QUEUE_FLAG_DEAD, &(q)->queue_flags)
@@ -1359,26 +1344,6 @@ static inline bool blk_needs_flush_plug(struct task_struct *tsk) !list_empty(&plug->cb_list)); } -/* -* tag stuff -*/ -extern int blk_queue_start_tag (struct request_queue *,struct request *); -extern struct request *blk_queue_find_tag (struct request_queue *,int ); -extern void blk_queue_end_tag (struct request_queue *,struct request *); -extern int blk_queue_init_tags (struct request_queue *,int ,struct blk_queue_tag *,int ); -extern void blk_queue_free_tags (struct request_queue *); -extern int blk_queue_resize_tags (struct request_queue *,int ); -extern struct blk_queue_tag *blk_init_tags (int ,int ); -extern void blk_free_tags (struct blk_queue_tag *); - -static inline struct request *blk_map_queue_find_tag (struct blk_queue_tag *bqt, -int tag) -{ -if (unlikely (bqt ==NULL || tag >= bqt->real_max_depth)) -return NULL ; -return bqt->tag_index[tag]; -} -extern int blkdev_issue_flush (struct block_device *,gfp_t ,sector_t *);extern int blkdev_issue_write_same (struct block_device *bdev,sector_t sector,sector_t nr_sects,gfp_t gfp_mask,struct page *page);
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 19/29 block: remove non mq parts from the flush code
In reply to Jens Axboe--- block/blk-flush.c | 154 +++++++++------------------------------------- block/blk.h | 4 +- 2 files changed, 31 insertions(+), 127 deletions(-)
block/blk-flush.c +30 -124
@@ -134,16 +134,8 @@ static void blk_flush_restore_request(struct request *rq)static bool blk_flush_queue_rq (struct request *rq,bool add_front) { -if (rq->q->mq_ops) { -blk_mq_add_to_requeue_list (rq, add_front, true); -return false; - }else { -if (add_front) -list_add (&rq->queuelist, &rq->q->queue_head); -else -list_add_tail (&rq->queuelist, &rq->q->queue_head); -return true; - } +blk_mq_add_to_requeue_list (rq, add_front, true); +return false; }/**
@@ -204,10 +196,7 @@ static bool blk_flush_complete_seq(struct request *rq,BUG_ON (!list_empty (&rq->queuelist));list_del_init (&rq->flush.list);blk_flush_restore_request (rq); -if (q->mq_ops) -blk_mq_end_request (rq, error); -else -__blk_end_request_all (rq, error); +blk_mq_end_request (rq, error);break ;default :
@@ -226,20 +215,17 @@ static void flush_end_io(struct request *flush_rq, blk_status_t error)struct request *rq, *n;unsigned long flags =0 ;struct blk_flush_queue *fq =blk_get_flush_queue (q, flush_rq->mq_ctx); +struct blk_mq_hw_ctx *hctx; -if (q->mq_ops) { -struct blk_mq_hw_ctx *hctx; - -/* release the tag's ownership to the req cloned from */ -spin_lock_irqsave (&fq->mq_flush_lock, flags); - hctx =blk_mq_map_queue (q, flush_rq->mq_ctx->cpu); -if (!q->elevator) { -blk_mq_tag_set_rq (hctx, flush_rq->tag, fq->orig_rq); - flush_rq->tag =-1 ; - }else { -blk_mq_put_driver_tag_hctx (hctx, flush_rq); - flush_rq->internal_tag =-1 ; - } +/* release the tag's ownership to the req cloned from */ +spin_lock_irqsave (&fq->mq_flush_lock, flags); + hctx =blk_mq_map_queue (q, flush_rq->mq_ctx->cpu); +if (!q->elevator) { +blk_mq_tag_set_rq (hctx, flush_rq->tag, fq->orig_rq); + flush_rq->tag =-1 ; + }else { +blk_mq_put_driver_tag_hctx (hctx, flush_rq); + flush_rq->internal_tag =-1 ; } running = &fq->flush_queue[fq->flush_running_idx];
@@ -248,9 +234,6 @@ static void flush_end_io(struct request *flush_rq, blk_status_t error)/* account completion of the flush request */ fq->flush_running_idx ^=1 ; -if (!q->mq_ops) -elv_completed_request (q, flush_rq); -/* and push the waiting requests to the next stage */ list_for_each_entry_safe (rq, n, running, flush.list) {unsigned int seq =blk_flush_cur_seq (rq);
@@ -259,24 +242,8 @@ static void flush_end_io(struct request *flush_rq, blk_status_t error) queued |=blk_flush_complete_seq (rq, fq, seq, error); } -/* -* Kick the queue to avoid stall for two cases: -* 1. Moving a request silently to empty queue_head may stall the -* queue. -* 2. When flush request is running in non-queueable queue, the -* queue is hold. Restart the queue after flush request is finished -* to avoid stall. -* This function is called from request completion path and calling -* directly into request_fn may confuse the driver. Always use -* kblockd. -*/ -if (queued || fq->flush_queue_delayed) { -WARN_ON (q->mq_ops); -blk_run_queue_async (q); - } fq->flush_queue_delayed =0 ; -if (q->mq_ops) -spin_unlock_irqrestore (&fq->mq_flush_lock, flags); +spin_unlock_irqrestore (&fq->mq_flush_lock, flags); }/**
@@ -301,6 +268,7 @@ static bool blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq,struct request *first_rq = list_first_entry(pending, struct request, flush.list);struct request *flush_rq = fq->flush_rq; +struct blk_mq_hw_ctx *hctx;/* C1 described at the top of this file */ if (fq->flush_pending_idx != fq->flush_running_idx ||list_empty (pending))
@@ -334,19 +302,15 @@ static bool blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq,* In case of IO scheduler, flush rq need to borrow scheduler tag * just for cheating put/get driver tag. */ -if (q->mq_ops) { -struct blk_mq_hw_ctx *hctx; - - flush_rq->mq_ctx = first_rq->mq_ctx; - -if (!q->elevator) { - fq->orig_rq = first_rq; - flush_rq->tag = first_rq->tag; - hctx =blk_mq_map_queue (q, first_rq->mq_ctx->cpu); -blk_mq_tag_set_rq (hctx, first_rq->tag, flush_rq); - }else { - flush_rq->internal_tag = first_rq->internal_tag; - } + flush_rq->mq_ctx = first_rq->mq_ctx; + +if (!q->elevator) { + fq->orig_rq = first_rq; + flush_rq->tag = first_rq->tag; + hctx =blk_mq_map_queue (q, first_rq->mq_ctx->cpu); +blk_mq_tag_set_rq (hctx, first_rq->tag, flush_rq); + }else { + flush_rq->internal_tag = first_rq->internal_tag; } flush_rq->cmd_flags =REQ_OP_FLUSH |REQ_PREFLUSH ;
@@ -358,49 +322,6 @@ static bool blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq,return blk_flush_queue_rq (flush_rq, false); } -static void flush_data_end_io (struct request *rq,blk_status_t error) -{ -struct request_queue *q = rq->q; -struct blk_flush_queue *fq =blk_get_flush_queue (q,NULL ); - -lockdep_assert_held (q->queue_lock); - -/* -* Updating q->in_flight[] here for making this tag usable -* early. Because in blk_queue_start_tag(), -* q->in_flight[BLK_RW_ASYNC] is used to limit async I/O and -* reserve tags for sync I/O. -* -* More importantly this way can avoid the following I/O -* deadlock: -* -* - suppose there are 40 fua requests comming to flush queue -* and queue depth is 31 -* - 30 rqs are scheduled then blk_queue_start_tag() can't alloc -* tag for async I/O any more -* - all the 30 rqs are completed before FLUSH_PENDING_TIMEOUT -* and flush_data_end_io() is called -* - the other rqs still can't go ahead if not updating -* q->in_flight[BLK_RW_ASYNC] here, meantime these rqs -* are held in flush data queue and make no progress of -* handling post flush rq -* - only after the post flush rq is handled, all these rqs -* can be completed -*/ - -elv_completed_request (q, rq); - -/* for avoiding double accounting */ - rq->rq_flags &= ~RQF_STARTED ; - -/* -* After populating an empty queue, kick it to avoid stall. Read -* the comment in flush_end_io(). -*/ -if (blk_flush_complete_seq (rq, fq,REQ_FSEQ_DATA , error)) -blk_run_queue_async (q); -} -static void mq_flush_data_end_io (struct request *rq,blk_status_t error) {struct request_queue *q = rq->q;
@@ -443,9 +364,6 @@ void blk_insert_flush(struct request *rq)unsigned int policy =blk_flush_policy (fflags, rq);struct blk_flush_queue *fq =blk_get_flush_queue (q, rq->mq_ctx); -if (!q->mq_ops) -lockdep_assert_held (q->queue_lock); -/* * @policy now records what operations need to be done. Adjust * REQ_PREFLUSH and FUA for the driver.
@@ -468,10 +386,7 @@ void blk_insert_flush(struct request *rq)* complete the request. */ if (!policy) { -if (q->mq_ops) -blk_mq_end_request (rq,0 ); -else -__blk_end_request (rq,0 ,0 ); +blk_mq_end_request (rq,0 );return ; }
@@ -484,10 +399,7 @@ void blk_insert_flush(struct request *rq)*/ if ((policy &REQ_FSEQ_DATA ) && !(policy & (REQ_FSEQ_PREFLUSH |REQ_FSEQ_POSTFLUSH ))) { -if (q->mq_ops) -blk_mq_request_bypass_insert (rq, false); -else -list_add_tail (&rq->queuelist, &q->queue_head); +blk_mq_request_bypass_insert (rq, false);return ; }
@@ -499,17 +411,12 @@ void blk_insert_flush(struct request *rq)INIT_LIST_HEAD (&rq->flush.list); rq->rq_flags |=RQF_FLUSH_SEQ ; rq->flush.saved_end_io = rq->end_io;/* Usually NULL */ -if (q->mq_ops) { - rq->end_io = mq_flush_data_end_io; -spin_lock_irq (&fq->mq_flush_lock); -blk_flush_complete_seq (rq, fq,REQ_FSEQ_ACTIONS & ~policy,0 ); -spin_unlock_irq (&fq->mq_flush_lock); -return ; - } - rq->end_io = flush_data_end_io; + rq->end_io = mq_flush_data_end_io; +spin_lock_irq (&fq->mq_flush_lock);blk_flush_complete_seq (rq, fq,REQ_FSEQ_ACTIONS & ~policy,0 ); +spin_unlock_irq (&fq->mq_flush_lock); }/**
@@ -575,8 +482,7 @@ struct blk_flush_queue *blk_alloc_flush_queue(struct request_queue *q,if (!fq) goto fail; -if (q->mq_ops) -spin_lock_init (&fq->mq_flush_lock); +spin_lock_init (&fq->mq_flush_lock); rq_sz =round_up (rq_sz + cmd_size,cache_line_size ()); fq->flush_rq =kzalloc_node (rq_sz, flags, node);
block/blk.h +1 -3
@@ -114,9 +114,7 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)static inline struct blk_flush_queue *blk_get_flush_queue (struct request_queue *q,struct blk_mq_ctx *ctx) { -if (q->mq_ops) -return blk_mq_map_queue (q, ctx->cpu)->fq; -return q->fq; +return blk_mq_map_queue (q, ctx->cpu)->fq; }static inline void __blk_get_queue (struct request_queue *q)
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 20/29 block: remove legacy IO schedulers
In reply to Jens AxboeRetain the deadline documentation, as that carries over to mq-deadline as well.
--- Documentation/block/cfq-iosched.txt | 291 -- block/Kconfig.iosched | 61 - block/Makefile | 3 - block/cfq-iosched.c | 4916 --------------------------- block/deadline-iosched.c | 560 --- block/elevator.c | 70 - block/noop-iosched.c | 124 - 7 files changed, 6025 deletions(-) delete mode 100644 Documentation/block/cfq-iosched.txt delete mode 100644 block/cfq-iosched.c delete mode 100644 block/deadline-iosched.c delete mode 100644 block/noop-iosched.c
Documentation/block/cfq-iosched.txt deleted +0 -291
@@ -1,291 +0,0 @@ -CFQ (Complete Fairness Queueing) -=============================== - -The main aim of CFQ scheduler is to provide a fair allocation of the disk -I/O bandwidth for all the processes which requests an I/O operation. - -CFQ maintains the per process queue for the processes which request I/O -operation(synchronous requests). In case of asynchronous requests, all the -requests from all the processes are batched together according to their -process's I/O priority. - -CFQ ioscheduler tunables -======================== - -slice_idle ----------- -This specifies how long CFQ should idle for next request on certain cfq queues -(for sequential workloads) and service trees (for random workloads) before -queue is expired and CFQ selects next queue to dispatch from. - -By default slice_idle is a non-zero value. That means by default we idle on -queues/service trees. This can be very helpful on highly seeky media like -single spindle SATA/SAS disks where we can cut down on overall number of -seeks and see improved throughput. - -Setting slice_idle to 0 will remove all the idling on queues/service tree -level and one should see an overall improved throughput on faster storage -devices like multiple SATA/SAS disks in hardware RAID configuration. The down -side is that isolation provided from WRITES also goes down and notion of -IO priority becomes weaker. - -So depending on storage and workload, it might be useful to set slice_idle=0. -In general I think for SATA/SAS disks and software RAID of SATA/SAS disks -keeping slice_idle enabled should be useful. For any configurations where -there are multiple spindles behind single LUN (Host based hardware RAID -controller or for storage arrays), setting slice_idle=0 might end up in better -throughput and acceptable latencies. - -back_seek_max -------------- -This specifies, given in Kbytes, the maximum "distance" for backward seeking. -The distance is the amount of space from the current head location to the -sectors that are backward in terms of distance. - -This parameter allows the scheduler to anticipate requests in the "backward" -direction and consider them as being the "next" if they are within this -distance from the current head location. - -back_seek_penalty ------------------ -This parameter is used to compute the cost of backward seeking. If the -backward distance of request is just 1/back_seek_penalty from a "front" -request, then the seeking cost of two requests is considered equivalent. - -So scheduler will not bias toward one or the other request (otherwise scheduler -will bias toward front request). Default value of back_seek_penalty is 2. - -fifo_expire_async ------------------ -This parameter is used to set the timeout of asynchronous requests. Default -value of this is 248ms. - -fifo_expire_sync ----------------- -This parameter is used to set the timeout of synchronous requests. Default -value of this is 124ms. In case to favor synchronous requests over asynchronous -one, this value should be decreased relative to fifo_expire_async. - -group_idle ------------ -This parameter forces idling at the CFQ group level instead of CFQ -queue level. This was introduced after a bottleneck was observed -in higher end storage due to idle on sequential queue and allow dispatch -from a single queue. The idea with this parameter is that it can be run with -slice_idle=0 and group_idle=8, so that idling does not happen on individual -queues in the group but happens overall on the group and thus still keeps the -IO controller working. -Not idling on individual queues in the group will dispatch requests from -multiple queues in the group at the same time and achieve higher throughput -on higher end storage. - -Default value for this parameter is 8ms. - -low_latency ------------ -This parameter is used to enable/disable the low latency mode of the CFQ -scheduler. If enabled, CFQ tries to recompute the slice time for each process -based on the target_latency set for the system. This favors fairness over -throughput. Disabling low latency (setting it to 0) ignores target latency, -allowing each process in the system to get a full time slice. - -By default low latency mode is enabled. - -target_latency --------------- -This parameter is used to calculate the time slice for a process if cfq's -latency mode is enabled. It will ensure that sync requests have an estimated -latency. But if sequential workload is higher(e.g. sequential read), -then to meet the latency constraints, throughput may decrease because of less -time for each process to issue I/O request before the cfq queue is switched. - -Though this can be overcome by disabling the latency_mode, it may increase -the read latency for some applications. This parameter allows for changing -target_latency through the sysfs interface which can provide the balanced -throughput and read latency. - -Default value for target_latency is 300ms. - -slice_async ------------ -This parameter is same as of slice_sync but for asynchronous queue. The -default value is 40ms. - -slice_async_rq --------------- -This parameter is used to limit the dispatching of asynchronous request to -device request queue in queue's slice time. The maximum number of request that -are allowed to be dispatched also depends upon the io priority. Default value -for this is 2. - -slice_sync ----------- -When a queue is selected for execution, the queues IO requests are only -executed for a certain amount of time(time_slice) before switching to another -queue. This parameter is used to calculate the time slice of synchronous -queue. - -time_slice is computed using the below equation:- -time_slice = slice_sync + (slice_sync/5 * (4 - prio)). To increase the -time_slice of synchronous queue, increase the value of slice_sync. Default -value is 100ms. - -quantum -------- -This specifies the number of request dispatched to the device queue. In a -queue's time slice, a request will not be dispatched if the number of request -in the device exceeds this parameter. This parameter is used for synchronous -request. - -In case of storage with several disk, this setting can limit the parallel -processing of request. Therefore, increasing the value can improve the -performance although this can cause the latency of some I/O to increase due -to more number of requests. - -CFQ Group scheduling -==================== - -CFQ supports blkio cgroup and has "blkio." prefixed files in each -blkio cgroup directory. It is weight-based and there are four knobs -for configuration - weight[_device] and leaf_weight[_device]. -Internal cgroup nodes (the ones with children) can also have tasks in -them, so the former two configure how much proportion the cgroup as a -whole is entitled to at its parent's level while the latter two -configure how much proportion the tasks in the cgroup have compared to -its direct children. - -Another way to think about it is assuming that each internal node has -an implicit leaf child node which hosts all the tasks whose weight is -configured by leaf_weight[_device]. Let's assume a blkio hierarchy -composed of five cgroups - root, A, B, AA and AB - with the following -weights where the names represent the hierarchy. - - weight leaf_weight - root : 125 125 - A : 500 750 - B : 250 500 - AA : 500 500 - AB : 1000 500 - -root never has a parent making its weight is meaningless. For backward -compatibility, weight is always kept in sync with leaf_weight. B, AA -and AB have no child and thus its tasks have no children cgroup to -compete with. They always get 100% of what the cgroup won at the -parent level. Considering only the weights which matter, the hierarchy -looks like the following. - - root - / | \ - A B leaf - 500 250 125 - / | \ - AA AB leaf - 500 1000 750 - -If all cgroups have active IOs and competing with each other, disk -time will be distributed like the following. - -Distribution below root. The total active weight at this level is -A:500 + B:250 + C:125 = 875. - - root-leaf : 125 / 875 =~ 14% - A : 500 / 875 =~ 57% - B(-leaf) : 250 / 875 =~ 28% - -A has children and further distributes its 57% among the children and -the implicit leaf node. The total active weight at this level is -AA:500 + AB:1000 + A-leaf:750 = 2250. - - A-leaf : ( 750 / 2250) * A =~ 19% - AA(-leaf) : ( 500 / 2250) * A =~ 12% - AB(-leaf) : (1000 / 2250) * A =~ 25% - -CFQ IOPS Mode for group scheduling -=================================== -Basic CFQ design is to provide priority based time slices. Higher priority -process gets bigger time slice and lower priority process gets smaller time -slice. Measuring time becomes harder if storage is fast and supports NCQ and -it would be better to dispatch multiple requests from multiple cfq queues in -request queue at a time. In such scenario, it is not possible to measure time -consumed by single queue accurately. - -What is possible though is to measure number of requests dispatched from a -single queue and also allow dispatch from multiple cfq queue at the same time. -This effectively becomes the fairness in terms of IOPS (IO operations per -second). - -If one sets slice_idle=0 and if storage supports NCQ, CFQ internally switches -to IOPS mode and starts providing fairness in terms of number of requests -dispatched. Note that this mode switching takes effect only for group -scheduling. For non-cgroup users nothing should change. - -CFQ IO scheduler Idling Theory -=============================== -Idling on a queue is primarily about waiting for the next request to come -on same queue after completion of a request. In this process CFQ will not -dispatch requests from other cfq queues even if requests are pending there. - -The rationale behind idling is that it can cut down on number of seeks -on rotational media. For example, if a process is doing dependent -sequential reads (next read will come on only after completion of previous -one), then not dispatching request from other queue should help as we -did not move the disk head and kept on dispatching sequential IO from -one queue. - -CFQ has following service trees and various queues are put on these trees. - - sync-idle sync-noidle async - -All cfq queues doing synchronous sequential IO go on to sync-idle tree. -On this tree we idle on each queue individually. - -All synchronous non-sequential queues go on sync-noidle tree. Also any -synchronous write request which is not marked with REQ_IDLE goes on this -service tree. On this tree we do not idle on individual queues instead idle -on the whole group of queues or the tree. So if there are 4 queues waiting -for IO to dispatch we will idle only once last queue has dispatched the IO -and there is no more IO on this service tree. - -All async writes go on async service tree. There is no idling on async -queues. - -CFQ has some optimizations for SSDs and if it detects a non-rotational -media which can support higher queue depth (multiple requests at in -flight at a time), then it cuts down on idling of individual queues and -all the queues move to sync-noidle tree and only tree idle remains. This -tree idling provides isolation with buffered write queues on async tree. - -FAQ -=== -Q1. Why to idle at all on queues not marked with REQ_IDLE. - -A1. We only do tree idle (all queues on sync-noidle tree) on queues not marked - with REQ_IDLE. This helps in providing isolation with all the sync-idle - queues. Otherwise in presence of many sequential readers, other - synchronous IO might not get fair share of disk. - - For example, if there are 10 sequential readers doing IO and they get - 100ms each. If a !REQ_IDLE request comes in, it will be scheduled - roughly after 1 second. If after completion of !REQ_IDLE request we - do not idle, and after a couple of milli seconds a another !REQ_IDLE - request comes in, again it will be scheduled after 1second. Repeat it - and notice how a workload can lose its disk share and suffer due to - multiple sequential readers. - - fsync can generate dependent IO where bunch of data is written in the - context of fsync, and later some journaling data is written. Journaling - data comes in only after fsync has finished its IO (atleast for ext4 - that seemed to be the case). Now if one decides not to idle on fsync - thread due to !REQ_IDLE, then next journaling write will not get - scheduled for another second. A process doing small fsync, will suffer - badly in presence of multiple sequential readers. - - Hence doing tree idling on threads using !REQ_IDLE flag on requests - provides isolation from multiple sequential readers and at the same - time we do not idle on individual threads. - -Q2. When to specify REQ_IDLE -A2. I would think whenever one is doing synchronous write and expecting - more writes to be dispatched from same context soon, should be able - to specify REQ_IDLE on writes and that probably should work well for - most of the cases.
block/Kconfig.iosched +0 -61
67 lines not on this page · raw message
block/Makefile +0 -3
@@ -18,9 +18,6 @@ obj-$(CONFIG_BLK_DEV_BSGLIB) += bsg-lib.o obj-$(CONFIG_BLK_CGROUP) += blk-cgroup.o obj-$(CONFIG_BLK_DEV_THROTTLING) += blk-throttle.o obj-$(CONFIG_BLK_CGROUP_IOLATENCY) += blk-iolatency.o -obj-$(CONFIG_IOSCHED_NOOP) += noop-iosched.o -obj-$(CONFIG_IOSCHED_DEADLINE) += deadline-iosched.o -obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o obj-$(CONFIG_MQ_IOSCHED_DEADLINE) += mq-deadline.o obj-$(CONFIG_MQ_IOSCHED_KYBER) += kyber-iosched.o bfq-y := bfq-iosched.o bfq-wf2q.o bfq-cgroup.o
block/cfq-iosched.c deleted +0 -4916
2,633 lines not on this page · raw message
block/deadline-iosched.c deleted +0 -560
560 lines not on this page · raw message
block/elevator.c +0 -70
70 lines not on this page · raw message
block/noop-iosched.c deleted +0 -124
124 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.17.1
Part of the diff is not shown here. View the raw message.
Jens Axboe
maintainerPATCH v2 21/29 block: remove dead elevator code
In reply to Jens AxboeThis removes a bunch of core and elevator related code. On the core front, we remove anything related to queue running, draining, initialization, plugging, and congestions. We also kill anything related to request allocation, merging, retrieval, and completion.
Remove any checking for single queue IO schedulers, as they no longer exist. This means we can also delete a bunch of code related to request issue, adding, completion, etc - and all the SQ related ops and helpers.
Also kill the load_default_modules(), as all that did was provide for a way to load the default single queue elevator.
--- block/bfq-iosched.c | 1 - block/blk-core.c | 1749 +------------------------------------- block/blk-exec.c | 20 +- block/blk-ioc.c | 33 +- block/blk-merge.c | 5 - block/blk-settings.c | 36 - block/blk-sysfs.c | 36 +- block/blk.h | 51 -- block/elevator.c | 377 +------- block/kyber-iosched.c | 1 - block/mq-deadline.c | 1 - include/linux/blkdev.h | 93 +- include/linux/elevator.h | 90 +- include/linux/init.h | 1 - init/do_mounts_initrd.c | 3 - init/initramfs.c | 6 - init/main.c | 12 - 17 files changed, 75 insertions(+), 2440 deletions(-)
block/bfq-iosched.c +0 -1
@@ -5745,7 +5745,6 @@ static struct elevator_type iosched_bfq_mq = { .exit_sched = bfq_exit_queue, }, - .uses_mq = true, .icq_size = sizeof(struct bfq_io_cq), .icq_align = __alignof__(struct bfq_io_cq), .elevator_attrs = bfq_attrs,
block/blk-core.c +34 -1715
1,905 lines not on this page · raw message
block/blk-exec.c +1 -19
@@ -48,8 +48,6 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk, struct request *rq, int at_head, rq_end_io_fn *done) { - int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK; -WARN_ON (irqs_disabled ());WARN_ON (!blk_rq_is_passthrough (rq));
@@ -60,23 +58,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,* don't check dying flag for MQ because the request won't * be reused after dying flag is set */ -if (q->mq_ops) { -blk_mq_sched_insert_request (rq, at_head, true, false); -return ; - } - -spin_lock_irq (q->queue_lock); - -if (unlikely (blk_queue_dying (q))) { - rq->rq_flags |=RQF_QUIET ; -__blk_end_request_all (rq,BLK_STS_IOERR ); -spin_unlock_irq (q->queue_lock); -return ; - } - -__elv_add_request (q, rq, where); -__blk_run_queue (q); -spin_unlock_irq (q->queue_lock); +blk_mq_sched_insert_request (rq, at_head, true, false); }EXPORT_SYMBOL_GPL (blk_execute_rq_nowait);
block/blk-ioc.c +6 -27
@@ -48,10 +48,8 @@ static void ioc_exit_icq(struct io_cq *icq)if (icq->flags &ICQ_EXITED )return ; -if (et->uses_mq && et->ops.mq.exit_icq) +if (et->ops.mq.exit_icq) et->ops.mq.exit_icq (icq); -else if (!et->uses_mq && et->ops.sq.elevator_exit_icq_fn) - et->ops.sq.elevator_exit_icq_fn (icq); icq->flags |=ICQ_EXITED ; }
@@ -187,25 +185,13 @@ void put_io_context_active(struct io_context *ioc)* reverse double locking. Read comment in ioc_release_fn() for * explanation on the nested locking annotation. */ -retry:spin_lock_irqsave_nested (&ioc->lock, flags,1 );hlist_for_each_entry (icq, &ioc->icq_list, ioc_node) {if (icq->flags &ICQ_EXITED )continue ; et = icq->q->elevator->type; -if (et->uses_mq) { -ioc_exit_icq (icq); - }else { -if (spin_trylock (icq->q->queue_lock)) { -ioc_exit_icq (icq); -spin_unlock (icq->q->queue_lock); - }else { -spin_unlock_irqrestore (&ioc->lock, flags); -cpu_relax (); - goto retry; - } - } +ioc_exit_icq (icq); }spin_unlock_irqrestore (&ioc->lock, flags);
@@ -232,7 +218,7 @@ static void __ioc_clear_queue(struct list_head *icq_list)while (!list_empty (icq_list)) {struct io_cq *icq =list_entry (icq_list->next, - struct io_cq, q_node); + struct io_cq, q_node);struct io_context *ioc = icq->ioc;spin_lock_irqsave (&ioc->lock, flags);
@@ -253,14 +239,9 @@ void ioc_clear_queue(struct request_queue *q)spin_lock_irq (q->queue_lock);list_splice_init (&q->icq_list, &icq_list); +spin_unlock_irq (q->queue_lock); -if (q->mq_ops) { -spin_unlock_irq (q->queue_lock); -__ioc_clear_queue (&icq_list); - }else { -__ioc_clear_queue (&icq_list); -spin_unlock_irq (q->queue_lock); - } +__ioc_clear_queue (&icq_list); }int create_task_io_context (struct task_struct *task,gfp_t gfp_flags,int node)
@@ -415,10 +396,8 @@ struct io_cq *ioc_create_icq(struct io_context *ioc, struct request_queue *q,if (likely (!radix_tree_insert (&ioc->icq_tree, q->id, icq))) {hlist_add_head (&icq->ioc_node, &ioc->icq_list);list_add (&icq->q_node, &q->icq_list); -if (et->uses_mq && et->ops.mq.init_icq) +if (et->ops.mq.init_icq) et->ops.mq.init_icq (icq); -else if (!et->uses_mq && et->ops.sq.elevator_init_icq_fn) - et->ops.sq.elevator_init_icq_fn (icq); }else {kmem_cache_free (et->icq_cache, icq); icq =ioc_lookup_icq (ioc, q);
block/blk-merge.c +0 -5
@@ -835,13 +835,8 @@ struct request *attempt_front_merge(struct request_queue *q, struct request *rq)int blk_attempt_req_merge (struct request_queue *q,struct request *rq,struct request *next) { -struct elevator_queue *e = q->elevator;struct request *free; -if (!e->uses_mq && e->type->ops.sq.elevator_allow_rq_merge_fn) -if (!e->type->ops.sq.elevator_allow_rq_merge_fn (q, rq, next)) -return 0 ; - free =attempt_merge (q, rq, next);if (free) {__blk_put_request (q, free);
block/blk-settings.c +0 -36
@@ -20,40 +20,6 @@ EXPORT_SYMBOL(blk_max_low_pfn);unsigned long blk_max_pfn; -/** -* blk_queue_prep_rq - set a prepare_request function for queue -* @q: queue -* @pfn: prepare_request function -* -* It's possible for a queue to register a prepare_request callback which -* is invoked before the request is handed to the request_fn. The goal of -* the function is to prepare a request for I/O, it can be used to build a -* cdb from the request data for instance. -* -*/ -void blk_queue_prep_rq (struct request_queue *q,prep_rq_fn *pfn) -{ - q->prep_rq_fn = pfn; -} -EXPORT_SYMBOL (blk_queue_prep_rq); - -/** -* blk_queue_unprep_rq - set an unprepare_request function for queue -* @q: queue -* @ufn: unprepare_request function -* -* It's possible for a queue to register an unprepare_request callback -* which is invoked before the request is finally completed. The goal -* of the function is to deallocate any data that was allocated in the -* prepare_request callback. -* -*/ -void blk_queue_unprep_rq (struct request_queue *q,unprep_rq_fn *ufn) -{ - q->unprep_rq_fn = ufn; -} -EXPORT_SYMBOL (blk_queue_unprep_rq); -void blk_queue_softirq_done (struct request_queue *q,softirq_done_fn *fn) { q->softirq_done_fn = fn;
@@ -163,8 +129,6 @@ void blk_queue_make_request(struct request_queue *q, make_request_fn *mfn) q->make_request_fn = mfn;blk_queue_dma_alignment (q,511 ); -blk_queue_congestion_threshold (q); - q->nr_batching =BLK_BATCH_REQ ;blk_set_default_limits (&q->limits); }
block/blk-sysfs.c +9 -27
@@ -68,7 +68,7 @@ queue_requests_store(struct request_queue *q, const char *page, size_t count)unsigned long nr;int ret, err; -if (!q->request_fn && !q->mq_ops) +if (!q->mq_ops)return -EINVAL ; ret =queue_var_store (&nr, page, count);
@@ -78,11 +78,7 @@ queue_requests_store(struct request_queue *q, const char *page, size_t count)if (nr <BLKDEV_MIN_RQ ) nr =BLKDEV_MIN_RQ ; -if (q->request_fn) - err =blk_update_nr_requests (q, nr); -else - err =blk_mq_update_nr_requests (q, nr); - + err =blk_mq_update_nr_requests (q, nr);if (err)return err;
@@ -463,20 +459,14 @@ static ssize_t queue_wb_lat_store(struct request_queue *q, const char *page,* ends up either enabling or disabling wbt completely. We can't * have IO inflight if that happens. */ -if (q->mq_ops) { -blk_mq_freeze_queue (q); -blk_mq_quiesce_queue (q); - }else -blk_queue_bypass_start (q); +blk_mq_freeze_queue (q); +blk_mq_quiesce_queue (q);wbt_set_min_lat (q, val);wbt_update_limits (q); -if (q->mq_ops) { -blk_mq_unquiesce_queue (q); -blk_mq_unfreeze_queue (q); - }else -blk_queue_bypass_end (q); +blk_mq_unquiesce_queue (q); +blk_mq_unfreeze_queue (q);return count; }
@@ -847,17 +837,10 @@ static void __blk_release_queue(struct work_struct *work)blk_free_queue_stats (q->stats); -blk_exit_rl (q, &q->root_rl); -blk_queue_free_zone_bitmaps (q); -if (!q->mq_ops) { -if (q->exit_rq_fn) - q->exit_rq_fn (q, q->fq->flush_rq); -blk_free_flush_queue (q->fq); - }else { +if (q->mq_ops)blk_mq_release (q); - }blk_trace_shutdown (q);
@@ -920,7 +903,6 @@ int blk_register_queue(struct gendisk *disk)if (!blk_queue_init_done (q)) {queue_flag_set_unlocked (QUEUE_FLAG_INIT_DONE , q);percpu_ref_switch_to_percpu (&q->q_usage_counter); -blk_queue_bypass_end (q); } ret =blk_trace_init_sysfs (dev);
@@ -947,7 +929,7 @@ int blk_register_queue(struct gendisk *disk)blk_throtl_register_queue (q); -if (q->request_fn || (q->mq_ops && q->elevator)) { +if ((q->mq_ops && q->elevator)) { ret =elv_register_queue (q);if (ret) {mutex_unlock (&q->sysfs_lock);
@@ -1007,7 +989,7 @@ void blk_unregister_queue(struct gendisk *disk)rq_qos_exit (q);mutex_lock (&q->sysfs_lock); -if (q->request_fn || (q->mq_ops && q->elevator)) +if (q->mq_ops && q->elevator)elv_unregister_queue (q);mutex_unlock (&q->sysfs_lock);
block/blk.h +0 -51
83 lines not on this page · raw message
block/elevator.c +22 -355
512 lines not on this page · raw message
block/kyber-iosched.c +0 -1
@@ -1032,7 +1032,6 @@ static struct elevator_type kyber_sched = { .dispatch_request = kyber_dispatch_request, .has_work = kyber_has_work, }, - .uses_mq = true,#ifdef CONFIG_BLK_DEBUG_FS .queue_debugfs_attrs = kyber_queue_debugfs_attrs, .hctx_debugfs_attrs = kyber_hctx_debugfs_attrs,
block/mq-deadline.c +0 -1
@@ -777,7 +777,6 @@ static struct elevator_type mq_deadline = { .exit_sched = dd_exit_queue, }, - .uses_mq = true,#ifdef CONFIG_BLK_DEBUG_FS .queue_debugfs_attrs = deadline_queue_debugfs_attrs,#endif
include/linux/blkdev.h +2 -91
222 lines not on this page · raw message
include/linux/elevator.h +1 -89
7 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.17.1
Part of the diff is not shown here. View the raw message.
Jens Axboe
maintainerPATCH v2 22/29 block: remove __blk_put_request()
In reply to Jens AxboeNow there's no difference between blk_put_request() and __blk_put_request() anymore, get rid of the underscore version and convert the few callers.
--- block/blk-core.c | 9 --------- block/blk-merge.c | 2 +- drivers/scsi/osd/osd_initiator.c | 4 ++-- drivers/scsi/osst.c | 2 +- drivers/scsi/scsi_error.c | 2 +- drivers/scsi/sg.c | 2 +- drivers/scsi/st.c | 2 +- drivers/target/target_core_pscsi.c | 2 +- include/linux/blkdev.h | 1 - 9 files changed, 8 insertions(+), 18 deletions(-)
block/blk-core.c +0 -9
@@ -800,15 +800,6 @@ void part_round_stats(struct request_queue *q, int cpu, struct hd_struct *part) }EXPORT_SYMBOL_GPL (part_round_stats); -void __blk_put_request (struct request_queue *q,struct request *req) -{ -if (unlikely (!q)) -return ; - -blk_mq_free_request (req); -} -EXPORT_SYMBOL_GPL (__blk_put_request); -void blk_put_request (struct request *req) {blk_mq_free_request (req);
block/blk-merge.c +1 -1
@@ -839,7 +839,7 @@ int blk_attempt_req_merge(struct request_queue *q, struct request *rq, free =attempt_merge (q, rq, next);if (free) { -__blk_put_request (q, free); +blk_put_request (free);return 1 ; }
drivers/scsi/osd/osd_initiator.c +2 -2
@@ -506,11 +506,11 @@ static void osd_request_async_done(struct request *req, blk_status_t error)_set_error_resid (or, req, error);if (req->next_rq) { -__blk_put_request (req->q, req->next_rq); +blk_put_request (req->next_rq); req->next_rq =NULL ; } -__blk_put_request (req->q, req); +blk_put_request (req); or->request =NULL ; or->in.req =NULL ; or->out.req =NULL ;
drivers/scsi/osst.c +1 -1
@@ -341,7 +341,7 @@ static void osst_end_async(struct request *req, blk_status_t status)blk_rq_unmap_user (SRpnt->bio); } -__blk_put_request (req->q, req); +blk_put_request (req); }/* osst_request memory management */
drivers/scsi/scsi_error.c +1 -1
@@ -1932,7 +1932,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)static void eh_lock_door_done (struct request *req,blk_status_t status) { -__blk_put_request (req->q, req); +blk_put_request (req); }/**
drivers/scsi/sg.c +1 -1
@@ -1390,7 +1390,7 @@ sg_rq_end_io(struct request *rq, blk_status_t status)*/ srp->rq =NULL ;scsi_req_free_cmd (scsi_req (rq)); -__blk_put_request (rq->q, rq); +blk_put_request (rq);write_lock_irqsave (&sfp->rq_list_lock, iflags);if (unlikely (srp->orphan)) {
drivers/scsi/st.c +1 -1
@@ -530,7 +530,7 @@ static void st_scsi_execute_end(struct request *req, blk_status_t status)complete (SRpnt->waiting);blk_rq_unmap_user (tmp); -__blk_put_request (req->q, req); +blk_put_request (req); } static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,
drivers/target/target_core_pscsi.c +1 -1
@@ -1094,7 +1094,7 @@ static void pscsi_req_done(struct request *req, blk_status_t status)break ; } -__blk_put_request (req->q, req); +blk_put_request (req);kfree (pt); }
include/linux/blkdev.h +0 -1
@@ -906,7 +906,6 @@ extern blk_qc_t direct_make_request(struct bio *bio);extern void blk_rq_init (struct request_queue *q,struct request *rq);extern void blk_init_request_from_bio (struct request *req,struct bio *bio);extern void blk_put_request (struct request *); -extern void __blk_put_request (struct request_queue *,struct request *);extern struct request *blk_get_request (struct request_queue *,unsigned int op,blk_mq_req_flags_t flags);extern int blk_lld_busy (struct request_queue *q);
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 23/29 block: kill legacy parts of timeout handling
In reply to Jens AxboeThe only user of legacy timing now is BSG, which is invoked from the mq timeout handler. Kill the legacy code, and rename the q->rq_timed_out_fn to q->bsg_job_timeout_fn.
--- block/blk-core.c | 1 - block/blk-settings.c | 7 --- block/blk-timeout.c | 99 +++--------------------------------------- block/blk.h | 1 - block/bsg-lib.c | 6 +-- include/linux/blkdev.h | 4 +- 6 files changed, 11 insertions(+), 107 deletions(-)
block/blk-core.c +0 -1
@@ -653,7 +653,6 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id, laptop_mode_timer_fn, 0);timer_setup (&q->timeout, blk_rq_timed_out_timer,0 );INIT_WORK (&q->timeout_work,NULL ); -INIT_LIST_HEAD (&q->timeout_list);INIT_LIST_HEAD (&q->icq_list);#ifdef CONFIG_BLK_CGROUP INIT_LIST_HEAD (&q->blkg_list);
block/blk-settings.c +0 -7
@@ -32,13 +32,6 @@ void blk_queue_rq_timeout(struct request_queue *q, unsigned int timeout) }EXPORT_SYMBOL_GPL (blk_queue_rq_timeout); -void blk_queue_rq_timed_out (struct request_queue *q,rq_timed_out_fn *fn) -{ -WARN_ON_ONCE (q->mq_ops); - q->rq_timed_out_fn = fn; -} -EXPORT_SYMBOL_GPL (blk_queue_rq_timed_out); -/** * blk_set_default_limits - reset limits to default values * @lim: the queue_limits structure to reset
block/blk-timeout.c +7 -92
123 lines not on this page · raw message
block/blk.h +0 -1
@@ -224,7 +224,6 @@ static inline bool bio_integrity_endio(struct bio *bio) }#endif /* CONFIG_BLK_DEV_INTEGRITY */ -void blk_timeout_work (struct work_struct *work);unsigned long blk_rq_timeout (unsigned long timeout);void blk_add_timer (struct request *req);void blk_delete_timer (struct request *);
block/bsg-lib.c +3 -3
@@ -307,8 +307,8 @@ static enum blk_eh_timer_return bsg_timeout(struct request *rq, bool reserved)enum blk_eh_timer_return ret =BLK_EH_DONE ;struct request_queue *q = rq->q; -if (q->rq_timed_out_fn) - ret = q->rq_timed_out_fn (rq); +if (q->bsg_job_timeout_fn) + ret = q->bsg_job_timeout_fn (rq);return ret; }
@@ -357,9 +357,9 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name, q->queuedata = dev; q->bsg_job_fn = job_fn; + q->bsg_job_timeout_fn = timeout;blk_queue_flag_set (QUEUE_FLAG_BIDI , q);blk_queue_rq_timeout (q,BLK_DEFAULT_SG_TIMEOUT ); - q->rq_timed_out_fn = timeout; ret =bsg_register_queue (q, dev, name, &bsg_transport_ops);if (ret) {
include/linux/blkdev.h +1 -3
@@ -441,7 +441,6 @@ struct request_queue {make_request_fn *make_request_fn;poll_q_fn *poll_fn;softirq_done_fn *softirq_done_fn; -rq_timed_out_fn *rq_timed_out_fn;dma_drain_needed_fn *dma_drain_needed;/* Called just after a request is allocated */ init_rq_fn *init_rq_fn;
@@ -541,7 +540,6 @@ struct request_queue {struct timer_list timeout;struct work_struct timeout_work; -struct list_head timeout_list;struct list_head icq_list;#ifdef CONFIG_BLK_CGROUP
@@ -601,6 +599,7 @@ struct request_queue {#if defined(CONFIG_BLK_DEV_BSG )bsg_job_fn *bsg_job_fn; +rq_timed_out_fn *bsg_job_timeout_fn;struct bsg_class_device bsg_dev;#endif
@@ -1156,7 +1155,6 @@ extern void blk_queue_virt_boundary(struct request_queue *, unsigned long);extern void blk_queue_dma_alignment (struct request_queue *,int );extern void blk_queue_update_dma_alignment (struct request_queue *,int );extern void blk_queue_softirq_done (struct request_queue *,softirq_done_fn *); -extern void blk_queue_rq_timed_out (struct request_queue *,rq_timed_out_fn *);extern void blk_queue_rq_timeout (struct request_queue *,unsigned int );extern void blk_queue_flush_queueable (struct request_queue *q,bool queueable);extern void blk_queue_write_cache (struct request_queue *q,bool enabled,bool fua);
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 24/29 bsg: move bsg-lib parts outside of request queue
In reply to Jens AxboeGet rid of the special bsg job fn and timeout handler, move them into a private bsg_set instead.
Mostly from Christoph, with fixes for error handling and cleanups.
--- block/bsg-lib.c | 43 ++++++++++++++++++++++++++--------------- include/linux/blkdev.h | 5 ----- include/linux/bsg-lib.h | 5 ++++- 3 files changed, 31 insertions(+), 22 deletions(-)
block/bsg-lib.c +27 -16
@@ -31,6 +31,12 @@#define uptr64 (val) ((void __user *)(uintptr_t)(val)) +struct bsg_set { +struct blk_mq_tag_set tag_set; +bsg_job_fn *job_fn; +bsg_timeout_fn *timeout_fn; +}; +static int bsg_transport_check_proto (struct sg_io_v4 *hdr) { if (hdr->protocol != BSG_PROTOCOL_SCSI ||
@@ -239,6 +245,8 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx,struct request_queue *q = hctx->queue;struct device *dev = q->queuedata;struct request *req = bd->rq; +struct bsg_set *bset = + container_of(q->tag_set, struct bsg_set, tag_set);int ret;blk_mq_start_request (req);
@@ -249,7 +257,7 @@ static blk_status_t bsg_queue_rq(struct blk_mq_hw_ctx *hctx,if (!bsg_prepare_job (dev, req))return BLK_STS_IOERR ; - ret = q->bsg_job_fn (blk_mq_rq_to_pdu (req)); + ret = bset->job_fn (blk_mq_rq_to_pdu (req));if (ret)return BLK_STS_IOERR ;
@@ -292,25 +300,25 @@ static void bsg_exit_rq(struct blk_mq_tag_set *set, struct request *req,void bsg_remove_queue (struct request_queue *q) {if (q) { -struct blk_mq_tag_set *set = q->tag_set; +struct bsg_set *bset = + container_of(q->tag_set, struct bsg_set, tag_set);bsg_unregister_queue (q);blk_cleanup_queue (q); -blk_mq_free_tag_set (set); -kfree (set); +blk_mq_free_tag_set (&bset->tag_set); +kfree (bset); } }EXPORT_SYMBOL_GPL (bsg_remove_queue);static enum blk_eh_timer_return bsg_timeout (struct request *rq,bool reserved) { -enum blk_eh_timer_return ret =BLK_EH_DONE ; -struct request_queue *q = rq->q; - -if (q->bsg_job_timeout_fn) - ret = q->bsg_job_timeout_fn (rq); +struct bsg_set *bset = + container_of(rq->q->tag_set, struct bsg_set, tag_set); -return ret; +if (!bset->timeout_fn) +return BLK_EH_DONE ; +return bset->timeout_fn (rq); }static const struct blk_mq_ops bsg_mq_ops = {
@@ -330,16 +338,21 @@ static const struct blk_mq_ops bsg_mq_ops = {* @dd_job_size: size of LLD data needed for each job */ struct request_queue *bsg_setup_queue (struct device *dev,const char *name, -bsg_job_fn *job_fn,rq_timed_out_fn *timeout,int dd_job_size) +bsg_job_fn *job_fn,bsg_timeout_fn *timeout,int dd_job_size) { +struct bsg_set *bset;struct blk_mq_tag_set *set;struct request_queue *q;int ret = -ENOMEM ; - set =kzalloc (sizeof (*set),GFP_KERNEL ); -if (!set) + bset =kzalloc (sizeof (*bset),GFP_KERNEL ); +if (!bset)return ERR_PTR (-ENOMEM ); + bset->job_fn = job_fn; + bset->timeout_fn = timeout; + + set = &bset->tag_set; set->ops = &bsg_mq_ops, set->nr_hw_queues =1 ; set->queue_depth =128 ;
@@ -356,8 +369,6 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name, } q->queuedata = dev; - q->bsg_job_fn = job_fn; - q->bsg_job_timeout_fn = timeout;blk_queue_flag_set (QUEUE_FLAG_BIDI , q);blk_queue_rq_timeout (q,BLK_DEFAULT_SG_TIMEOUT );
@@ -374,7 +385,7 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name, out_queue:blk_mq_free_tag_set (set); out_tag_set: -kfree (set); +kfree (bset);return ERR_PTR (ret); }EXPORT_SYMBOL_GPL (bsg_setup_queue);
include/linux/blkdev.h +0 -5
@@ -312,7 +312,6 @@ typedef bool (poll_q_fn) (struct request_queue *q, blk_qc_t);struct bio_vec ;typedef void (softirq_done_fn )(struct request *);typedef int (dma_drain_needed_fn )(struct request *); -typedef int (bsg_job_fn ) (struct bsg_job *);typedef int (init_rq_fn )(struct request_queue *,struct request *,gfp_t );typedef void (exit_rq_fn )(struct request_queue *,struct request *);
@@ -321,8 +320,6 @@ enum blk_eh_timer_return { BLK_EH_RESET_TIMER, /* reset timer and try again */ }; -typedef enum blk_eh_timer_return (rq_timed_out_fn )(struct request *); -enum blk_queue_state { Queue_down, Queue_up,
@@ -598,8 +595,6 @@ struct request_queue {atomic_t mq_freeze_depth;#if defined(CONFIG_BLK_DEV_BSG ) -bsg_job_fn *bsg_job_fn; -rq_timed_out_fn *bsg_job_timeout_fn;struct bsg_class_device bsg_dev;#endif
include/linux/bsg-lib.h +4 -1
@@ -31,6 +31,9 @@ struct device;struct scatterlist ;struct request_queue ; +typedef int (bsg_job_fn ) (struct bsg_job *); +typedef enum blk_eh_timer_return (bsg_timeout_fn )(struct request *); +struct bsg_buffer {unsigned int payload_len;int sg_cnt;
@@ -72,7 +75,7 @@ struct bsg_job {void bsg_job_done (struct bsg_job *job,int result,unsigned int reply_payload_rcv_len);struct request_queue *bsg_setup_queue (struct device *dev,const char *name, -bsg_job_fn *job_fn,rq_timed_out_fn *timeout,int dd_job_size); +bsg_job_fn *job_fn,bsg_timeout_fn *timeout,int dd_job_size);void bsg_remove_queue (struct request_queue *q);void bsg_job_put (struct bsg_job *job);int __must_check bsg_job_get (struct bsg_job *job);
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 25/29 block: remove request_list code
In reply to Jens AxboeIt's now dead code, nobody uses it.
--- block/blk-cgroup.c | 47 ---------------- block/blk-core.c | 75 -------------------------- block/blk-mq.c | 4 -- block/blk.h | 3 -- include/linux/blk-cgroup.h | 108 ------------------------------------- include/linux/blkdev.h | 34 ------------ 6 files changed, 271 deletions(-)
block/blk-cgroup.c +0 -47
@@ -76,9 +76,6 @@ static void blkg_free(struct blkcg_gq *blkg)if (blkg->pd[i]) blkcg_policy[i]->pd_free_fn (blkg->pd[i]); -if (blkg->blkcg != &blkcg_root) -blk_exit_rl (blkg->q, &blkg->rl); -blkg_rwstat_exit (&blkg->stat_ios);blkg_rwstat_exit (&blkg->stat_bytes);kfree (blkg);
@@ -142,13 +139,6 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q,INIT_LIST_HEAD (&blkg->q_node); blkg->blkcg = blkcg; -/* root blkg uses @q->root_rl, init rl only for !root blkgs */ -if (blkcg != &blkcg_root) { -if (blk_init_rl (&blkg->rl, q, gfp_mask)) - goto err_free; - blkg->rl.blkg = blkg; - } -for (i =0 ; i <BLKCG_MAX_POLS ; i++) {struct blkcg_policy *pol = blkcg_policy[i];struct blkg_policy_data *pd;
@@ -448,42 +438,6 @@ static void blkg_destroy_all(struct request_queue *q) } q->root_blkg =NULL ; - q->root_rl.blkg =NULL ; -} - -/* -* The next function used by blk_queue_for_each_rl(). It's a bit tricky -* because the root blkg uses @q->root_rl instead of its own rl. -*/ -struct request_list *__blk_queue_next_rl (struct request_list *rl, -struct request_queue *q) -{ -struct list_head *ent; -struct blkcg_gq *blkg; - -/* -* Determine the current blkg list_head. The first entry is -* root_rl which is off @q->blkg_list and mapped to the head. -*/ -if (rl == &q->root_rl) { - ent = &q->blkg_list; -/* There are no more block groups, hence no request lists */ -if (list_empty (ent)) -return NULL ; - }else { - blkg = container_of(rl, struct blkcg_gq, rl); - ent = &blkg->q_node; - } - -/* walk to the next list_head, skip root blkcg */ - ent = ent->next; -if (ent == &q->root_blkg->q_node) - ent = ent->next; -if (ent == &q->blkg_list) -return NULL ; - - blkg = container_of(ent, struct blkcg_gq, q_node); -return &blkg->rl; } static int blkcg_reset_stats(struct cgroup_subsys_state *css,
@@ -1278,7 +1232,6 @@ int blkcg_init_queue(struct request_queue *q)if (IS_ERR (blkg)) goto err_unlock; q->root_blkg = blkg; - q->root_rl.blkg = blkg;spin_unlock_irq (q->queue_lock);rcu_read_unlock ();
block/blk-core.c +0 -75
81 lines not on this page · raw message
block/blk-mq.c +0 -4
@@ -326,10 +326,6 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, rq->end_io_data =NULL ; rq->next_rq =NULL ; -#ifdef CONFIG_BLK_CGROUP - rq->rl =NULL ; -#endif - data->ctx->rq_dispatched[op_is_sync (op)]++;refcount_set (&rq->ref,1 );return rq;
block/blk.h +0 -3
@@ -120,9 +120,6 @@ struct blk_flush_queue *blk_alloc_flush_queue(struct request_queue *q, int node, int cmd_size, gfp_t flags);void blk_free_flush_queue (struct blk_flush_queue *q); -int blk_init_rl (struct request_list *rl,struct request_queue *q, -gfp_t gfp_mask); -void blk_exit_rl (struct request_queue *q,struct request_list *rl);void blk_exit_queue (struct request_queue *q);void blk_rq_bio_prep (struct request_queue *q,struct request *rq,struct bio *bio);
include/linux/blk-cgroup.h +0 -108
126 lines not on this page · raw message
include/linux/blkdev.h +0 -34
@@ -58,22 +58,6 @@ struct blk_stat_callback;typedef void (rq_end_io_fn )(struct request *,blk_status_t ); -struct request_list { -struct request_queue *q;/* the queue this rl belongs to */ -#ifdef CONFIG_BLK_CGROUP -struct blkcg_gq *blkg;/* blkg this request pool belongs to */ -#endif -/* -* count[], starved[], and wait[] are indexed by -* BLK_RW_SYNC/BLK_RW_ASYNC -*/ -int count[2 ]; -int starved[2 ]; -mempool_t *rq_pool; -wait_queue_head_t wait[2 ]; -unsigned int flags; -}; -/* * request flags */ typedef __u32 __bitwise req_flags_t ;
@@ -259,10 +243,6 @@ struct request {/* for bidi */ struct request *next_rq; - -#ifdef CONFIG_BLK_CGROUP -struct request_list *rl;/* rl this rq is alloced from */ -#endif };static inline bool blk_op_is_scsi (unsigned int op)
@@ -312,8 +292,6 @@ typedef bool (poll_q_fn) (struct request_queue *q, blk_qc_t);struct bio_vec ;typedef void (softirq_done_fn )(struct request *);typedef int (dma_drain_needed_fn )(struct request *); -typedef int (init_rq_fn )(struct request_queue *,struct request *,gfp_t ); -typedef void (exit_rq_fn )(struct request_queue *,struct request *);enum blk_eh_timer_return {BLK_EH_DONE ,/* drivers has completed the command */
@@ -427,22 +405,10 @@ struct request_queue {struct blk_queue_stats *stats;struct rq_qos *rq_qos; -/* -* If blkcg is not used, @q->root_rl serves all requests. If blkcg -* is used, root blkg allocates from @q->root_rl and all other -* blkgs from their own blkg->rl. Which one to use should be -* determined using bio_request_list(). -*/ -struct request_list root_rl; -make_request_fn *make_request_fn;poll_q_fn *poll_fn;softirq_done_fn *softirq_done_fn;dma_drain_needed_fn *dma_drain_needed; -/* Called just after a request is allocated */ -init_rq_fn *init_rq_fn; -/* Called just before a request is freed */ -exit_rq_fn *exit_rq_fn;const struct blk_mq_ops *mq_ops;
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 26/29 block: kill request slab cache
In reply to Jens Axboe--- block/blk-core.c | 8 -------- block/blk.h | 1 - 2 files changed, 9 deletions(-)
block/blk-core.c +0 -8
@@ -57,11 +57,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(block_unplug);DEFINE_IDA (blk_queue_ida); -/* -* For the allocated request tables -*/ -struct kmem_cache *request_cachep; -/* * For queue allocation */
@@ -1969,9 +1964,6 @@ int __init blk_dev_init(void)if (!kblockd_workqueue)panic ("Failed to create kblockd\n" ); - request_cachep =kmem_cache_create ("blkdev_requests" , -sizeof (struct request ),0 ,SLAB_PANIC ,NULL ); - blk_requestq_cachep =kmem_cache_create ("request_queue" ,sizeof (struct request_queue ),0 ,SLAB_PANIC ,NULL );
block/blk.h +0 -1
@@ -32,7 +32,6 @@ struct blk_flush_queue { };extern struct kmem_cache *blk_requestq_cachep; -extern struct kmem_cache *request_cachep;extern struct kobj_type blk_queue_ktype;extern struct ida blk_queue_ida;
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 27/29 block: remove req_no_special_merge() from merging code
In reply to Jens AxboeIt'll always be false at this point, just remove it.
--- block/blk-merge.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-)
block/blk-merge.c +3 -22
@@ -595,17 +595,6 @@ int ll_front_merge_fn(struct request_queue *q, struct request *req,return ll_new_hw_segment (q, req, bio); } -/* -* blk-mq uses req->special to carry normal driver per-request payload, it -* does not indicate a prepared command that we cannot merge with. -*/ -static bool req_no_special_merge (struct request *req) -{ -struct request_queue *q = req->q; - -return !q->mq_ops && req->special; -} -static bool req_attempt_discard_merge (struct request_queue *q,struct request *req,struct request *next) {
@@ -631,13 +620,6 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,unsigned int seg_size = req->biotail->bi_seg_back_size + next->bio->bi_seg_front_size; -/* -* First check if the either of the requests are re-queued -* requests. Can't merge them if they are. -*/ -if (req_no_special_merge (req) ||req_no_special_merge (next)) -return 0 ; -if (req_gap_back_merge (req, next->bio))return 0 ;
@@ -738,8 +720,7 @@ static struct request *attempt_merge(struct request_queue *q,return NULL ;if (rq_data_dir (req) !=rq_data_dir (next) - || req->rq_disk != next->rq_disk - ||req_no_special_merge (next)) + || req->rq_disk != next->rq_disk)return NULL ; if (req_op(req) == REQ_OP_WRITE_SAME &&
@@ -858,8 +839,8 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)if (bio_data_dir (bio) !=rq_data_dir (rq))return false; -/* must be same device and not a special request */ -if (rq->rq_disk != bio->bi_disk ||req_no_special_merge (rq)) +/* must be same device */ +if (rq->rq_disk != bio->bi_disk)return false;/* only merge integrity protected bio into ditto rq */
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 28/29 blk-merge: kill dead queue lock held check
In reply to Jens AxboeThis is dead code, any queue reaching this part has mq_ops attached.
--- block/blk-merge.c | 3 --- 1 file changed, 3 deletions(-)
block/blk-merge.c +0 -3
@@ -704,9 +704,6 @@ static void blk_account_io_merge(struct request *req)static struct request *attempt_merge (struct request_queue *q,struct request *req,struct request *next) { -if (!q->mq_ops) -lockdep_assert_held (q->queue_lock); -if (!rq_mergeable (req) || !rq_mergeable (next))return NULL ;
Signature · 1 line
2.17.1
Jens Axboe
maintainerPATCH v2 29/29 block: get rid of blk_queued_rq()
In reply to Jens AxboeNo point in hiding what this does, just open code it in the one spot where we are still using it.
--- block/blk-mq.c | 2 +- include/linux/blkdev.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-)
block/blk-mq.c +1 -1
@@ -692,7 +692,7 @@ void blk_mq_requeue_request(struct request *rq, bool kick_requeue_list)/* this request will be re-inserted to io scheduler queue */ blk_mq_sched_requeue_request (rq); -BUG_ON (blk_queued_rq (rq)); +BUG_ON (!list_empty (&rq->queuelist));blk_mq_add_to_requeue_list (rq, true, kick_requeue_list); }EXPORT_SYMBOL (blk_mq_requeue_request);
include/linux/blkdev.h +0 -2
@@ -673,8 +673,6 @@ static inline bool blk_account_rq(struct request *rq)#define blk_rq_cpu_valid (rq) ((rq)->cpu != -1)#define blk_bidi_rq (rq) ((rq)->next_rq != NULL) -/* rq->queuelist of dequeued request must be list_empty() */ -#define blk_queued_rq (rq) (!list_empty(&(rq)->queuelist))#define list_entry_rq (ptr) list_entry((ptr), struct request, queuelist)
Signature · 1 line
2.17.1
Re: [PATCH 07/29] blk-mq: provide mq_ops->busy() hook
In reply to Jens AxboeQuoted 10 lines · Jens Axboe
We'll hook into this from
blk_lld_busy(), allowing blk-mq to also return whether or not a given queue currently has requests in progress.Signed-off-by Jens Axboe <[email protected]>--- block/blk-core.c | 2 ++ include/linux/blk-mq.h | 6 ++++++ 2 files changed, 8 insertions(+)
Cheers,
Hannes
Re: [PATCH 08/29] scsi: provide mq_ops->busy() hook
In reply to Jens AxboeQuoted 9 lines · Jens Axboe
Only the SCSI legacy path provides a way to check if target is currently busy, provide the same for the MQ path.
Signed-off-by Jens Axboe <[email protected]>--- drivers/scsi/scsi_lib.c | 6 ++++++ 1 file changed, 6 insertions(+)
Cheers,
Hannes
Re: [PATCH 10/29] block: remove q->lld_busy_fn()
In reply to Jens AxboeQuoted 10 lines · Jens Axboe
Nobody is using the legacy path for
blk_lld_busy()anymore, remove it.Signed-off-by Jens Axboe <[email protected]>--- block/blk-core.c | 2 -- block/blk-settings.c | 6 ------ include/linux/blkdev.h | 3 --- 3 files changed, 11 deletions(-)
Cheers,
Hannes
Re: [PATCH 13/29] bsg: provide bsg_remove_queue() helper
In reply to Jens AxboeQuoted 7 lines · Jens Axboe
All drivers do unregister + cleanup, provide a helper for that.
Reviewed-by Johannes Thumshirn <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Tested-by Benjamin Block <[email protected]>Signed-off-by Jens Axboe <[email protected]>
Quoted 9 lines
--- block/bsg-lib.c | 9 +++++++++ drivers/scsi/scsi_transport_fc.c | 5 +---- drivers/scsi/scsi_transport_iscsi.c | 5 +---- drivers/scsi/scsi_transport_sas.c | 6 +----- drivers/scsi/ufs/ufs_bsg.c | 2 +- include/linux/bsg-lib.h | 1 + 6 files changed, 14 insertions(+), 14 deletions(-)
Cheers,
Hannes
Re: [PATCH 14/29] bsg: convert to use blk-mq
In reply to Jens AxboeQuoted 11 lines · Jens Axboe
Requires a few changes to the FC transport class as well.
Reviewed-by Johannes Thumshirn <[email protected]>Tested-by Benjamin Block <[email protected]>Signed-off-by Jens Axboe <[email protected]>--- block/bsg-lib.c | 123 +++++++++++++++++++------------ drivers/scsi/scsi_transport_fc.c | 59 +++++++++------ 2 files changed, 110 insertions(+), 72 deletions(-)
Cheers,
Hannes
Re: [PATCH 24/29] bsg: move bsg-lib parts outside of request queue
In reply to Jens AxboeQuoted 12 lines · Jens Axboe
Get rid of the special bsg job fn and timeout handler, move them into a private
bsg_setinstead.Mostly from Christoph, with fixes for error handling and cleanups.
Signed-off-by Jens Axboe <[email protected]>--- block/bsg-lib.c | 43 ++++++++++++++++++++++++++--------------- include/linux/blkdev.h | 5 ----- include/linux/bsg-lib.h | 5 ++++- 3 files changed, 31 insertions(+), 22 deletions(-)
Cheers,
Hannes