Skip to content

Commit 6d85ebf

Browse files
YuKuai-huaweiaxboe
authored andcommitted
blk-sysfs: add a new attr_group for blk_mq
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 <hch@lst.de> Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20230527010644.647900-6-yukuai1@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent eebc21d commit 6d85ebf

1 file changed

Lines changed: 31 additions & 11 deletions

File tree

block/blk-sysfs.c

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -621,15 +621,13 @@ QUEUE_RW_ENTRY(queue_wb_lat, "wbt_lat_usec");
621621
#endif
622622

623623
static struct attribute *queue_attrs[] = {
624-
&queue_requests_entry.attr,
625624
&queue_ra_entry.attr,
626625
&queue_max_hw_sectors_entry.attr,
627626
&queue_max_sectors_entry.attr,
628627
&queue_max_segments_entry.attr,
629628
&queue_max_discard_segments_entry.attr,
630629
&queue_max_integrity_segments_entry.attr,
631630
&queue_max_segment_size_entry.attr,
632-
&elv_iosched_entry.attr,
633631
&queue_hw_sector_size_entry.attr,
634632
&queue_logical_block_size_entry.attr,
635633
&queue_physical_block_size_entry.attr,
@@ -650,19 +648,14 @@ static struct attribute *queue_attrs[] = {
650648
&queue_max_open_zones_entry.attr,
651649
&queue_max_active_zones_entry.attr,
652650
&queue_nomerges_entry.attr,
653-
&queue_rq_affinity_entry.attr,
654651
&queue_iostats_entry.attr,
655652
&queue_stable_writes_entry.attr,
656653
&queue_random_entry.attr,
657654
&queue_poll_entry.attr,
658655
&queue_wc_entry.attr,
659656
&queue_fua_entry.attr,
660657
&queue_dax_entry.attr,
661-
#ifdef CONFIG_BLK_WBT
662-
&queue_wb_lat_entry.attr,
663-
#endif
664658
&queue_poll_delay_entry.attr,
665-
&queue_io_timeout_entry.attr,
666659
#ifdef CONFIG_BLK_DEV_THROTTLING_LOW
667660
&blk_throtl_sample_time_entry.attr,
668661
#endif
@@ -671,16 +664,23 @@ static struct attribute *queue_attrs[] = {
671664
NULL,
672665
};
673666

667+
static struct attribute *blk_mq_queue_attrs[] = {
668+
&queue_requests_entry.attr,
669+
&elv_iosched_entry.attr,
670+
&queue_rq_affinity_entry.attr,
671+
&queue_io_timeout_entry.attr,
672+
#ifdef CONFIG_BLK_WBT
673+
&queue_wb_lat_entry.attr,
674+
#endif
675+
NULL,
676+
};
677+
674678
static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
675679
int n)
676680
{
677681
struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj);
678682
struct request_queue *q = disk->queue;
679683

680-
if (attr == &queue_io_timeout_entry.attr &&
681-
(!q->mq_ops || !q->mq_ops->timeout))
682-
return 0;
683-
684684
if ((attr == &queue_max_open_zones_entry.attr ||
685685
attr == &queue_max_active_zones_entry.attr) &&
686686
!blk_queue_is_zoned(q))
@@ -689,11 +689,30 @@ static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
689689
return attr->mode;
690690
}
691691

692+
static umode_t blk_mq_queue_attr_visible(struct kobject *kobj,
693+
struct attribute *attr, int n)
694+
{
695+
struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj);
696+
struct request_queue *q = disk->queue;
697+
698+
if (!queue_is_mq(q))
699+
return 0;
700+
701+
if (attr == &queue_io_timeout_entry.attr && !q->mq_ops->timeout)
702+
return 0;
703+
704+
return attr->mode;
705+
}
706+
692707
static struct attribute_group queue_attr_group = {
693708
.attrs = queue_attrs,
694709
.is_visible = queue_attr_visible,
695710
};
696711

712+
static struct attribute_group blk_mq_queue_attr_group = {
713+
.attrs = blk_mq_queue_attrs,
714+
.is_visible = blk_mq_queue_attr_visible,
715+
};
697716

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

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

739758
static const struct attribute_group *blk_queue_attr_groups[] = {
740759
&queue_attr_group,
760+
&blk_mq_queue_attr_group,
741761
NULL
742762
};
743763

0 commit comments

Comments
 (0)