2023-05-27 01:18:29

by Yu Kuai

[permalink] [raw]
Subject: [PATCH -next v3 0/5] blk-wbt: minor fix and cleanup

From: Yu Kuai <[email protected]>

Changes in v3:
- patch 1 from v2 is sent separately, and it's removd from this series.
- add review tag for all the patches.

Changes in v2:
- make the code more readable for patch 1
- add a new attr_group that is only visible for rq based device
- explain in detail for patch 4
- add review tag for patch 2,3,5

Yu Kuai (5):
blk-wbt: don't create wbt sysfs entry if CONFIG_BLK_WBT is disabled
blk-wbt: remove dead code to handle wbt enable/disable with io
inflight
blk-wbt: cleanup rwb_enabled() and wbt_disabled()
blk-iocost: move wbt_enable/disable_default() out of spinlock
blk-sysfs: add a new attr_group for blk_mq

block/blk-iocost.c | 7 +-
block/blk-sysfs.c | 181 ++++++++++++++++++++++++++-------------------
block/blk-wbt.c | 21 +-----
block/blk-wbt.h | 19 -----
4 files changed, 110 insertions(+), 118 deletions(-)

--
2.39.2



2023-05-27 01:44:08

by Yu Kuai

[permalink] [raw]
Subject: [PATCH -next v3 5/5] blk-sysfs: add a new attr_group for blk_mq

From: Yu Kuai <[email protected]>

Currently wbt sysfs entry is created for bio based device, and wbt can
be enabled for such device through sysfs while it doesn't make sense
because wbt can only work for rq based device. In the meantime, there
are other similar sysfs entries.

Fix this by adding a new attr_group for blk_mq, and sysfs entries will
only be created when the device is rq based.

Suggested-by: Christoph Hellwig <[email protected]>
Signed-off-by: Yu Kuai <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
---
block/blk-sysfs.c | 42 +++++++++++++++++++++++++++++++-----------
1 file changed, 31 insertions(+), 11 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 6c1c4ba66bc0..afc797fb0dfc 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -621,7 +621,6 @@ QUEUE_RW_ENTRY(queue_wb_lat, "wbt_lat_usec");
#endif

static struct attribute *queue_attrs[] = {
- &queue_requests_entry.attr,
&queue_ra_entry.attr,
&queue_max_hw_sectors_entry.attr,
&queue_max_sectors_entry.attr,
@@ -629,7 +628,6 @@ static struct attribute *queue_attrs[] = {
&queue_max_discard_segments_entry.attr,
&queue_max_integrity_segments_entry.attr,
&queue_max_segment_size_entry.attr,
- &elv_iosched_entry.attr,
&queue_hw_sector_size_entry.attr,
&queue_logical_block_size_entry.attr,
&queue_physical_block_size_entry.attr,
@@ -650,7 +648,6 @@ static struct attribute *queue_attrs[] = {
&queue_max_open_zones_entry.attr,
&queue_max_active_zones_entry.attr,
&queue_nomerges_entry.attr,
- &queue_rq_affinity_entry.attr,
&queue_iostats_entry.attr,
&queue_stable_writes_entry.attr,
&queue_random_entry.attr,
@@ -658,11 +655,7 @@ static struct attribute *queue_attrs[] = {
&queue_wc_entry.attr,
&queue_fua_entry.attr,
&queue_dax_entry.attr,
-#ifdef CONFIG_BLK_WBT
- &queue_wb_lat_entry.attr,
-#endif
&queue_poll_delay_entry.attr,
- &queue_io_timeout_entry.attr,
#ifdef CONFIG_BLK_DEV_THROTTLING_LOW
&blk_throtl_sample_time_entry.attr,
#endif
@@ -671,16 +664,23 @@ static struct attribute *queue_attrs[] = {
NULL,
};

+static struct attribute *blk_mq_queue_attrs[] = {
+ &queue_requests_entry.attr,
+ &elv_iosched_entry.attr,
+ &queue_rq_affinity_entry.attr,
+ &queue_io_timeout_entry.attr,
+#ifdef CONFIG_BLK_WBT
+ &queue_wb_lat_entry.attr,
+#endif
+ NULL,
+};
+
static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
int n)
{
struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj);
struct request_queue *q = disk->queue;

- if (attr == &queue_io_timeout_entry.attr &&
- (!q->mq_ops || !q->mq_ops->timeout))
- return 0;
-
if ((attr == &queue_max_open_zones_entry.attr ||
attr == &queue_max_active_zones_entry.attr) &&
!blk_queue_is_zoned(q))
@@ -689,11 +689,30 @@ static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
return attr->mode;
}

+static umode_t blk_mq_queue_attr_visible(struct kobject *kobj,
+ struct attribute *attr, int n)
+{
+ struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj);
+ struct request_queue *q = disk->queue;
+
+ if (!queue_is_mq(q))
+ return 0;
+
+ if (attr == &queue_io_timeout_entry.attr && !q->mq_ops->timeout)
+ return 0;
+
+ return attr->mode;
+}
+
static struct attribute_group queue_attr_group = {
.attrs = queue_attrs,
.is_visible = queue_attr_visible,
};

+static struct attribute_group blk_mq_queue_attr_group = {
+ .attrs = blk_mq_queue_attrs,
+ .is_visible = blk_mq_queue_attr_visible,
+};

#define to_queue(atr) container_of((atr), struct queue_sysfs_entry, attr)

@@ -738,6 +757,7 @@ static const struct sysfs_ops queue_sysfs_ops = {

static const struct attribute_group *blk_queue_attr_groups[] = {
&queue_attr_group,
+ &blk_mq_queue_attr_group,
NULL
};

--
2.39.2


2023-06-08 03:08:58

by Yu Kuai

[permalink] [raw]
Subject: Re: [PATCH -next v3 0/5] blk-wbt: minor fix and cleanup

Hi, Jens

Can you apply this patchset?

Thanks,
Kuai

?? 2023/05/27 9:06, Yu Kuai д??:
> From: Yu Kuai <[email protected]>
>
> Changes in v3:
> - patch 1 from v2 is sent separately, and it's removd from this series.
> - add review tag for all the patches.
>
> Changes in v2:
> - make the code more readable for patch 1
> - add a new attr_group that is only visible for rq based device
> - explain in detail for patch 4
> - add review tag for patch 2,3,5
>
> Yu Kuai (5):
> blk-wbt: don't create wbt sysfs entry if CONFIG_BLK_WBT is disabled
> blk-wbt: remove dead code to handle wbt enable/disable with io
> inflight
> blk-wbt: cleanup rwb_enabled() and wbt_disabled()
> blk-iocost: move wbt_enable/disable_default() out of spinlock
> blk-sysfs: add a new attr_group for blk_mq
>
> block/blk-iocost.c | 7 +-
> block/blk-sysfs.c | 181 ++++++++++++++++++++++++++-------------------
> block/blk-wbt.c | 21 +-----
> block/blk-wbt.h | 19 -----
> 4 files changed, 110 insertions(+), 118 deletions(-)
>


2023-06-26 03:08:46

by Yu Kuai

[permalink] [raw]
Subject: Re: [PATCH -next v3 0/5] blk-wbt: minor fix and cleanup

Hi, Jens

在 2023/06/08 10:36, Yu Kuai 写道:
> Hi, Jens
>
> Can you apply this patchset?

The only fix from this patchset is applied separately, so this patchset
is just simple cleanups now, can you please consider this for the next
merge window?

Thanks,
Kuai
>
> Thanks,
> Kuai
>
> 在 2023/05/27 9:06, Yu Kuai 写道:
>> From: Yu Kuai <[email protected]>
>>
>> Changes in v3:
>>   - patch 1 from v2 is sent separately, and it's removd from this series.
>>   - add review tag for all the patches.
>>
>> Changes in v2:
>>   - make the code more readable for patch 1
>>   - add a new attr_group that is only visible for rq based device
>>   - explain in detail for patch 4
>>   - add review tag for patch 2,3,5
>>
>> Yu Kuai (5):
>>    blk-wbt: don't create wbt sysfs entry if CONFIG_BLK_WBT is disabled
>>    blk-wbt: remove dead code to handle wbt enable/disable with io
>>      inflight
>>    blk-wbt: cleanup rwb_enabled() and wbt_disabled()
>>    blk-iocost: move wbt_enable/disable_default() out of spinlock
>>    blk-sysfs: add a new attr_group for blk_mq
>>
>>   block/blk-iocost.c |   7 +-
>>   block/blk-sysfs.c  | 181 ++++++++++++++++++++++++++-------------------
>>   block/blk-wbt.c    |  21 +-----
>>   block/blk-wbt.h    |  19 -----
>>   4 files changed, 110 insertions(+), 118 deletions(-)
>>
>
> .
>


2023-06-26 16:25:58

by Jens Axboe

[permalink] [raw]
Subject: Re: [PATCH -next v3 0/5] blk-wbt: minor fix and cleanup


On Sat, 27 May 2023 09:06:39 +0800, Yu Kuai wrote:
> Changes in v3:
> - patch 1 from v2 is sent separately, and it's removd from this series.
> - add review tag for all the patches.
>
> Changes in v2:
> - make the code more readable for patch 1
> - add a new attr_group that is only visible for rq based device
> - explain in detail for patch 4
> - add review tag for patch 2,3,5
>
> [...]

Applied, thanks!

[1/5] blk-wbt: don't create wbt sysfs entry if CONFIG_BLK_WBT is disabled
commit: 645a829e03384a235b3760959d4ebe420a0f2027
[2/5] blk-wbt: remove dead code to handle wbt enable/disable with io inflight
commit: 71b8642e79f277459555629f2bea1a8d1fed307e
[3/5] blk-wbt: cleanup rwb_enabled() and wbt_disabled()
commit: 06257fda83ebfd1c33fb992e41dba7be4e1184d4
[4/5] blk-iocost: move wbt_enable/disable_default() out of spinlock
commit: eebc21d12f56c1e09a163abf91e351fa2a55a938
[5/5] blk-sysfs: add a new attr_group for blk_mq
commit: 6d85ebf95c44e52337ca1d07f0db4b435d1e6762

Best regards,
--
Jens Axboe