提交 73f23755 编写于 作者: Y Yu Kuai 提交者: Zheng Zengkai

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

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I57S8D
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: NYu Kuai <yukuai3@huawei.com>
Reviewed-by: NJason Yan <yanaijie@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 d518f3fd
......@@ -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);
......
......@@ -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,
......
......@@ -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)
{
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册