From: Yu Kuai yukuai3@huawei.com
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: Yu Kuai yukuai3@huawei.com Reviewed-by: Jason Yan yanaijie@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- block/blk-core.c | 6 ++++++ block/blk-mq.c | 3 ++- block/blk-mq.h | 2 ++ block/genhd.c | 8 ++++++-- 4 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c index 715b61c239ea..109fb2750453 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -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); diff --git a/block/blk-mq.c b/block/blk-mq.c index 5031c4fc4412..1941ffc4db85 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -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, diff --git a/block/blk-mq.h b/block/blk-mq.h index 6897b4c09b7c..ad2d74f887f2 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -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) { diff --git a/block/genhd.c b/block/genhd.c index fcd6210417bc..8b37fcfa10d1 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -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);