Commit 2ed9d17c authored by Yu Kuai's avatar Yu Kuai Committed by Zheng Zengkai
Browse files

block: don't use cmpxchg64() on 32-bit platform



hulk inclusion
category: bugfix
bugzilla: 186921
CVE: NA

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

Some 32-bit platform doesn't support cmpxchg64(), using it in generic
code will cause compile error.

Fixes: 4c8f034bf1e6 ("[Huawei] block: update nsecs[] in part_stat_show() and diskstats_show()")
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 ae7eb31e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1292,13 +1292,16 @@ void blk_account_io_done(struct request *req, u64 now)
	    !(req->rq_flags & RQF_FLUSH_SEQ)) {
		const int sgrp = op_stat_group(req_op(req));
		struct hd_struct *part;
#ifdef CONFIG_64BIT
		u64 stat_time;
		struct request_wrapper *rq_wrapper = request_to_wrapper(req);
#endif

		part_stat_lock();
		part = req->part;
		update_io_ticks(part, jiffies, true);
		part_stat_inc(part, ios[sgrp]);
#ifdef CONFIG_64BIT
		stat_time = READ_ONCE(rq_wrapper->stat_time_ns);
		/*
		 * This might fail if 'stat_time_ns' is updated
@@ -1312,6 +1315,9 @@ void blk_account_io_done(struct request *req, u64 now)

			part_stat_add(req->part, nsecs[sgrp], duation);
		}
#else
		part_stat_add(part, nsecs[sgrp], now - req->start_time_ns);
#endif
		part_stat_unlock();

		hd_struct_put(part);
+2 −1
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ struct mq_inflight {
	unsigned int inflight[2];
};

#ifdef CONFIG_64BIT
static bool blk_mq_check_inflight_with_stat(struct blk_mq_hw_ctx *hctx,
					    struct request *rq, void *priv,
					    bool reserved)
@@ -154,7 +155,7 @@ unsigned int blk_mq_in_flight_with_stat(struct request_queue *q,

	return mi.inflight[0] + mi.inflight[1];
}

#endif

static bool blk_mq_check_inflight(struct blk_mq_hw_ctx *hctx,
				  struct request *rq, void *priv,
+2 −0
Original line number Diff line number Diff line
@@ -187,8 +187,10 @@ static inline bool blk_mq_hw_queue_mapped(struct blk_mq_hw_ctx *hctx)
unsigned int blk_mq_in_flight(struct request_queue *q, struct hd_struct *part);
void blk_mq_in_flight_rw(struct request_queue *q, struct hd_struct *part,
			 unsigned int inflight[2]);
#ifdef CONFIG_64BIT
unsigned int blk_mq_in_flight_with_stat(struct request_queue *q,
					struct hd_struct *part);
#endif

static inline void blk_mq_put_dispatch_budget(struct request_queue *q)
{
+6 −2
Original line number Diff line number Diff line
@@ -1293,6 +1293,7 @@ ssize_t part_size_show(struct device *dev,
		(unsigned long long)part_nr_sects_read(p));
}

#ifdef CONFIG_64BIT
static void part_set_stat_time(struct hd_struct *hd)
{
	u64 now = ktime_get_ns();
@@ -1304,12 +1305,13 @@ static void part_set_stat_time(struct hd_struct *hd)
		goto again;
	}
}
#endif

static void part_get_stat_info(struct hd_struct *hd, struct disk_stats *stat,
			       unsigned int *inflight)
{
#ifdef CONFIG_64BIT
	struct request_queue *q = part_to_disk(hd)->queue;

	if (queue_is_mq(q)) {
		mutex_lock(&part_to_dev(hd)->mutex);
		part_stat_lock();
@@ -1320,7 +1322,9 @@ static void part_get_stat_info(struct hd_struct *hd, struct disk_stats *stat,
	} else {
		*inflight = part_in_flight(hd);
	}

#else
	*inflight = part_in_flight(hd);
#endif
	if (*inflight) {
		part_stat_lock();
		update_io_ticks(hd, jiffies, true);