Unverified Commit ea496bf9 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!1295 blk-wbt: don't show valid wbt_lat_usec in

Merge Pull Request from: @ci-robot 
 
PR sync from: Li Lingfeng <lilingfeng3@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/OFH6G7EUCRF236P635HQ5LEDXVZ4AEJJ/ 
Yu Kuai (2):
  blk-wbt: make enable_state more accurate
  blk-wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled


-- 
2.31.1
 
 
Link:https://gitee.com/openeuler/kernel/pulls/1295

 

Reviewed-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 6a69749f 18e44529
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -461,6 +461,9 @@ static ssize_t queue_wb_lat_show(struct request_queue *q, char *page)
	if (!wbt_rq_qos(q))
		return -EINVAL;

	if (wbt_disabled(q))
		return sprintf(page, "0\n");

	return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000));
}

+14 −1
Original line number Diff line number Diff line
@@ -419,6 +419,14 @@ static void wbt_update_limits(struct rq_wb *rwb)
	rwb_wake_all(rwb);
}

bool wbt_disabled(struct request_queue *q)
{
	struct rq_qos *rqos = wbt_rq_qos(q);

	return !rqos || RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT ||
	       RQWB(rqos)->enable_state == WBT_STATE_OFF_MANUAL;
}

u64 wbt_get_min_lat(struct request_queue *q)
{
	struct rq_qos *rqos = wbt_rq_qos(q);
@@ -432,8 +440,13 @@ void wbt_set_min_lat(struct request_queue *q, u64 val)
	struct rq_qos *rqos = wbt_rq_qos(q);
	if (!rqos)
		return;

	RQWB(rqos)->min_lat_nsec = val;
	if (val)
		RQWB(rqos)->enable_state = WBT_STATE_ON_MANUAL;
	else
		RQWB(rqos)->enable_state = WBT_STATE_OFF_MANUAL;

	wbt_update_limits(RQWB(rqos));
}

+12 −5
Original line number Diff line number Diff line
@@ -28,13 +28,15 @@ enum {
};

/*
 * Enable states. Either off, or on by default (done at init time),
 * or on through manual setup in sysfs.
 * If current state is WBT_STATE_ON/OFF_DEFAULT, it can be covered to any other
 * state, if current state is WBT_STATE_ON/OFF_MANUAL, it can only be covered
 * to WBT_STATE_OFF/ON_MANUAL.
 */
enum {
	WBT_STATE_ON_DEFAULT	= 1,
	WBT_STATE_ON_MANUAL	= 2,
	WBT_STATE_OFF_DEFAULT
	WBT_STATE_ON_DEFAULT	= 1,	/* on by default */
	WBT_STATE_ON_MANUAL	= 2,	/* on manually by sysfs */
	WBT_STATE_OFF_DEFAULT	= 3,	/* off by default */
	WBT_STATE_OFF_MANUAL	= 4,	/* off manually by sysfs */
};

struct rq_wb {
@@ -94,6 +96,7 @@ void wbt_enable_default(struct request_queue *);

u64 wbt_get_min_lat(struct request_queue *q);
void wbt_set_min_lat(struct request_queue *q, u64 val);
bool wbt_disabled(struct request_queue *);

void wbt_set_write_cache(struct request_queue *, bool);

@@ -128,6 +131,10 @@ static inline u64 wbt_default_latency_nsec(struct request_queue *q)
{
	return 0;
}
static inline bool wbt_disabled(struct request_queue *q)
{
	return true;
}

#endif /* CONFIG_BLK_WBT */