* [PATCH] bfq-iosched: Ensure bio->bi_blkg is valid before using it
@ 2019-12-05 12:53 Hou Tao
2019-12-05 14:31 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Hou Tao @ 2019-12-05 12:53 UTC (permalink / raw)
To: linux-block, tj; +Cc: paolo.valente, axboe, cgroups, houtao1
bio->bi_blkg will be NULL when the issue of the request
has bypassed the block layer as shown in the following oops:
Internal error: Oops: 96000005 [#1] SMP
CPU: 17 PID: 2996 Comm: scsi_id Not tainted 5.4.0 #4
Call trace:
percpu_counter_add_batch+0x38/0x4c8
bfqg_stats_update_legacy_io+0x9c/0x280
bfq_insert_requests+0xbac/0x2190
blk_mq_sched_insert_request+0x288/0x670
blk_execute_rq_nowait+0x140/0x178
blk_execute_rq+0x8c/0x140
sg_io+0x604/0x9c0
scsi_cmd_ioctl+0xe38/0x10a8
scsi_cmd_blk_ioctl+0xac/0xe8
sd_ioctl+0xe4/0x238
blkdev_ioctl+0x590/0x20e0
block_ioctl+0x60/0x98
do_vfs_ioctl+0xe0/0x1b58
ksys_ioctl+0x80/0xd8
__arm64_sys_ioctl+0x40/0x78
el0_svc_handler+0xc4/0x270
so ensure its validity before using it.
Fixes: fd41e60331b1 ("bfq-iosched: stop using blkg->stat_bytes and ->stat_ios")
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
block/bfq-cgroup.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
index cea0ae12f937..e1419edde2ec 100644
--- a/block/bfq-cgroup.c
+++ b/block/bfq-cgroup.c
@@ -351,6 +351,9 @@ void bfqg_stats_update_legacy_io(struct request_queue *q, struct request *rq)
{
struct bfq_group *bfqg = blkg_to_bfqg(rq->bio->bi_blkg);
+ if (!bfqg)
+ return;
+
blkg_rwstat_add(&bfqg->stats.bytes, rq->cmd_flags, blk_rq_bytes(rq));
blkg_rwstat_add(&bfqg->stats.ios, rq->cmd_flags, 1);
}
--
2.22.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bfq-iosched: Ensure bio->bi_blkg is valid before using it
2019-12-05 12:53 [PATCH] bfq-iosched: Ensure bio->bi_blkg is valid before using it Hou Tao
@ 2019-12-05 14:31 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2019-12-05 14:31 UTC (permalink / raw)
To: Hou Tao, linux-block, tj; +Cc: paolo.valente, cgroups
On 12/5/19 5:53 AM, Hou Tao wrote:
> bio->bi_blkg will be NULL when the issue of the request
> has bypassed the block layer as shown in the following oops:
>
> Internal error: Oops: 96000005 [#1] SMP
> CPU: 17 PID: 2996 Comm: scsi_id Not tainted 5.4.0 #4
> Call trace:
> percpu_counter_add_batch+0x38/0x4c8
> bfqg_stats_update_legacy_io+0x9c/0x280
> bfq_insert_requests+0xbac/0x2190
> blk_mq_sched_insert_request+0x288/0x670
> blk_execute_rq_nowait+0x140/0x178
> blk_execute_rq+0x8c/0x140
> sg_io+0x604/0x9c0
> scsi_cmd_ioctl+0xe38/0x10a8
> scsi_cmd_blk_ioctl+0xac/0xe8
> sd_ioctl+0xe4/0x238
> blkdev_ioctl+0x590/0x20e0
> block_ioctl+0x60/0x98
> do_vfs_ioctl+0xe0/0x1b58
> ksys_ioctl+0x80/0xd8
> __arm64_sys_ioctl+0x40/0x78
> el0_svc_handler+0xc4/0x270
>
> so ensure its validity before using it.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-12-05 14:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-05 12:53 [PATCH] bfq-iosched: Ensure bio->bi_blkg is valid before using it Hou Tao
2019-12-05 14:31 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.