Commit 5c250d55 authored by Yu Kuai's avatar Yu Kuai Committed by Zheng Zengkai
Browse files

blk-mq: fix kabi broken in struct request

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I57S8D


CVE: NA

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

Since there are no reserved fields, declare a wrapper to fix kabi
broken.

Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarJason Yan <yanaijie@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent badcb143
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1293,17 +1293,18 @@ void blk_account_io_done(struct request *req, u64 now)
		const int sgrp = op_stat_group(req_op(req));
		struct hd_struct *part;
		u64 stat_time;
		struct request_wrapper *rq_wrapper = request_to_wrapper(req);

		part_stat_lock();
		part = req->part;
		update_io_ticks(part, jiffies, true);
		part_stat_inc(part, ios[sgrp]);
		stat_time = READ_ONCE(req->stat_time_ns);
		stat_time = READ_ONCE(rq_wrapper->stat_time_ns);
		/*
		 * This might fail if 'req->stat_time_ns' is updated
		 * This might fail if 'stat_time_ns' is updated
		 * in blk_mq_check_inflight_with_stat().
		 */
		if (likely(cmpxchg64(&req->stat_time_ns, stat_time, now)
		if (likely(cmpxchg64(&rq_wrapper->stat_time_ns, stat_time, now)
			   == stat_time)) {
			u64 duation = stat_time ? now - stat_time :
				now - req->start_time_ns;
+7 −5
Original line number Diff line number Diff line
@@ -111,17 +111,19 @@ static bool blk_mq_check_inflight_with_stat(struct blk_mq_hw_ctx *hctx,
	if ((!mi->part->partno || rq->part == mi->part) &&
	    blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT) {
		u64 stat_time;
		struct request_wrapper *rq_wrapper;

		mi->inflight[rq_data_dir(rq)]++;
		if (!rq->part)
			return true;

		stat_time = READ_ONCE(rq->stat_time_ns);
		rq_wrapper = request_to_wrapper(rq);
		stat_time = READ_ONCE(rq_wrapper->stat_time_ns);
		/*
		 * This might fail if 'req->stat_time_ns' is updated in
		 * This might fail if 'stat_time_ns' is updated in
		 * blk_account_io_done().
		 */
		if (likely(cmpxchg64(&rq->stat_time_ns, stat_time,
		if (likely(cmpxchg64(&rq_wrapper->stat_time_ns, stat_time,
				   rq->part->stat_time) == stat_time)) {
			int sgrp = op_stat_group(req_op(rq));
			u64 duation = stat_time ?
@@ -368,11 +370,11 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
#ifdef CONFIG_BLK_RQ_ALLOC_TIME
	rq->alloc_time_ns = alloc_time_ns;
#endif
	request_to_wrapper(rq)->stat_time_ns = 0;
	if (blk_mq_need_time_stamp(rq))
		rq->start_time_ns = ktime_get_ns();
	else
		rq->start_time_ns = 0;
	rq->stat_time_ns = 0;
	rq->io_start_time_ns = 0;
	rq->stats_sectors = 0;
	rq->nr_phys_segments = 0;
@@ -2555,7 +2557,7 @@ int blk_mq_alloc_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,
	 * rq_size is the size of the request plus driver payload, rounded
	 * to the cacheline size
	 */
	rq_size = round_up(sizeof(struct request) + set->cmd_size,
	rq_size = round_up(sizeof(struct request_wrapper) + set->cmd_size,
				cache_line_size());
	left = rq_size * depth;

+11 −2
Original line number Diff line number Diff line
@@ -304,6 +304,15 @@ struct blk_mq_queue_data {
	KABI_RESERVE(1)
};

struct request_wrapper {
	struct request rq;

	/* Time that I/O was counted in part_get_stat_info(). */
	u64 stat_time_ns;
};

#define request_to_wrapper(_rq) container_of(_rq, struct request_wrapper, rq)

typedef bool (busy_iter_fn)(struct blk_mq_hw_ctx *, struct request *, void *,
		bool);
typedef bool (busy_tag_iter_fn)(struct request *, void *, bool);
@@ -595,7 +604,7 @@ static inline bool blk_should_fake_timeout(struct request_queue *q)
 */
static inline struct request *blk_mq_rq_from_pdu(void *pdu)
{
	return pdu - sizeof(struct request);
	return pdu - sizeof(struct request_wrapper);
}

/**
@@ -609,7 +618,7 @@ static inline struct request *blk_mq_rq_from_pdu(void *pdu)
 */
static inline void *blk_mq_rq_to_pdu(struct request *rq)
{
	return rq + 1;
	return request_to_wrapper(rq) + 1;
}

static inline struct blk_mq_hw_ctx *queue_hctx(struct request_queue *q, int id)
+0 −2
Original line number Diff line number Diff line
@@ -207,8 +207,6 @@ struct request {
	u64 start_time_ns;
	/* Time that I/O was submitted to the device. */
	u64 io_start_time_ns;
	/* Time that I/O was counted in part_get_stat_info(). */
	u64 stat_time_ns;
#ifdef CONFIG_BLK_WBT
	unsigned short wbt_flags;
#endif