Message ID | 20220921180501.1539876-12-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/17] blk-cgroup: fix error unwinding in blkcg_init_queue | expand |
On Wed, Sep 21, 2022 at 08:04:55PM +0200, Christoph Hellwig wrote: > Use a local disk variable instead of retrieving the disk and > request_queue over and over by various means. > > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > block/blk-iocost.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) Reviewed-by: Andreas Herrmann <aherrmann@suse.de> > diff --git a/block/blk-iocost.c b/block/blk-iocost.c > index 1e7bf0d353227..b8e5f550aa5be 100644 > --- a/block/blk-iocost.c > +++ b/block/blk-iocost.c > @@ -3167,6 +3167,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, > size_t nbytes, loff_t off) > { > struct block_device *bdev; > + struct gendisk *disk; > struct ioc *ioc; > u32 qos[NR_QOS_PARAMS]; > bool enable, user; > @@ -3177,12 +3178,13 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, > if (IS_ERR(bdev)) > return PTR_ERR(bdev); > > - ioc = q_to_ioc(bdev_get_queue(bdev)); > + disk = bdev->bd_disk; > + ioc = q_to_ioc(disk->queue); > if (!ioc) { > - ret = blk_iocost_init(bdev->bd_disk); > + ret = blk_iocost_init(disk); > if (ret) > goto err; > - ioc = q_to_ioc(bdev_get_queue(bdev)); > + ioc = q_to_ioc(disk->queue); > } > > spin_lock_irq(&ioc->lock); > @@ -3259,11 +3261,11 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, > spin_lock_irq(&ioc->lock); > > if (enable) { > - blk_stat_enable_accounting(ioc->rqos.q); > - blk_queue_flag_set(QUEUE_FLAG_RQ_ALLOC_TIME, ioc->rqos.q); > + blk_stat_enable_accounting(disk->queue); > + blk_queue_flag_set(QUEUE_FLAG_RQ_ALLOC_TIME, disk->queue); > ioc->enabled = true; > } else { > - blk_queue_flag_clear(QUEUE_FLAG_RQ_ALLOC_TIME, ioc->rqos.q); > + blk_queue_flag_clear(QUEUE_FLAG_RQ_ALLOC_TIME, disk->queue); > ioc->enabled = false; > } > > -- > 2.30.2 >
diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 1e7bf0d353227..b8e5f550aa5be 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3167,6 +3167,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, size_t nbytes, loff_t off) { struct block_device *bdev; + struct gendisk *disk; struct ioc *ioc; u32 qos[NR_QOS_PARAMS]; bool enable, user; @@ -3177,12 +3178,13 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, if (IS_ERR(bdev)) return PTR_ERR(bdev); - ioc = q_to_ioc(bdev_get_queue(bdev)); + disk = bdev->bd_disk; + ioc = q_to_ioc(disk->queue); if (!ioc) { - ret = blk_iocost_init(bdev->bd_disk); + ret = blk_iocost_init(disk); if (ret) goto err; - ioc = q_to_ioc(bdev_get_queue(bdev)); + ioc = q_to_ioc(disk->queue); } spin_lock_irq(&ioc->lock); @@ -3259,11 +3261,11 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, spin_lock_irq(&ioc->lock); if (enable) { - blk_stat_enable_accounting(ioc->rqos.q); - blk_queue_flag_set(QUEUE_FLAG_RQ_ALLOC_TIME, ioc->rqos.q); + blk_stat_enable_accounting(disk->queue); + blk_queue_flag_set(QUEUE_FLAG_RQ_ALLOC_TIME, disk->queue); ioc->enabled = true; } else { - blk_queue_flag_clear(QUEUE_FLAG_RQ_ALLOC_TIME, ioc->rqos.q); + blk_queue_flag_clear(QUEUE_FLAG_RQ_ALLOC_TIME, disk->queue); ioc->enabled = false; }
Use a local disk variable instead of retrieving the disk and request_queue over and over by various means. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/blk-iocost.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)