Commit 6530b6a3 authored by Li Nan's avatar Li Nan Committed by Zheng Zengkai
Browse files

blk-mq: fix kabi broken in struct request

hulk inclusion
category: bugfix
bugzilla: 187921, https://gitee.com/openeuler/kernel/issues/I66VDB


CVE: NA

--------------------------------

Enable CONFIG_BLK_RQ_ALLOC_TIME will cause kabi broken, use request
wrapper to fix it.

Signed-off-by: default avatarLi Nan <linan122@huawei.com>
Reviewed-by: default avatarHou Tao <houtao1@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent ee6d12f6
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -2747,8 +2747,13 @@ static void ioc_rqos_done(struct rq_qos *rqos, struct request *rq)
	struct ioc_pcpu_stat *ccs;
	u64 on_q_ns, rq_wait_ns, size_nsec;
	int pidx, rw;
	struct request_wrapper *rq_wrapper;

	if (!ioc->enabled || !rq->alloc_time_ns || !rq->start_time_ns)
	if (WARN_ON_ONCE(!(rq->rq_flags & RQF_FROM_BLOCK)))
		return;

	rq_wrapper = request_to_wrapper(rq);
	if (!ioc->enabled || !rq_wrapper->alloc_time_ns || !rq->start_time_ns)
		return;

	switch (req_op(rq) & REQ_OP_MASK) {
@@ -2764,8 +2769,8 @@ static void ioc_rqos_done(struct rq_qos *rqos, struct request *rq)
		return;
	}

	on_q_ns = ktime_get_ns() - rq->alloc_time_ns;
	rq_wait_ns = rq->start_time_ns - rq->alloc_time_ns;
	on_q_ns = ktime_get_ns() - rq_wrapper->alloc_time_ns;
	rq_wait_ns = rq->start_time_ns - rq_wrapper->alloc_time_ns;
	size_nsec = div64_u64(calc_size_vtime_cost(rq, ioc), VTIME_PER_NSEC);

	ccs = get_cpu_ptr(ioc->pcpu_stat);
+1 −1
Original line number Diff line number Diff line
@@ -386,7 +386,7 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
	rq->rq_disk = NULL;
	rq->part = NULL;
#ifdef CONFIG_BLK_RQ_ALLOC_TIME
	rq->alloc_time_ns = alloc_time_ns;
	request_to_wrapper(rq)->alloc_time_ns = alloc_time_ns;
#endif
	request_to_wrapper(rq)->stat_time_ns = 0;
	if (blk_mq_need_time_stamp(rq))
+4 −0
Original line number Diff line number Diff line
@@ -40,6 +40,10 @@ struct blk_mq_ctx {
struct request_wrapper {
	/* Time that I/O was counted in part_get_stat_info(). */
	u64 stat_time_ns;
#ifdef CONFIG_BLK_RQ_ALLOC_TIME
	/* Time that the first bio started allocating this request. */
	u64 alloc_time_ns;
#endif
} ____cacheline_aligned;

static inline struct request_wrapper *request_to_wrapper(void *rq)
+0 −4
Original line number Diff line number Diff line
@@ -202,10 +202,6 @@ struct request {

	struct gendisk *rq_disk;
	struct hd_struct *part;
#ifdef CONFIG_BLK_RQ_ALLOC_TIME
	/* Time that the first bio started allocating this request. */
	u64 alloc_time_ns;
#endif
	/* Time that this request was allocated for this IO. */
	u64 start_time_ns;
	/* Time that I/O was submitted to the device. */