summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@wdc.com>2018-06-15 17:55:21 -0400
committerJens Axboe <axboe@kernel.dk>2018-07-09 11:07:52 -0400
commit6a5ac9846508ad7d1d23881d9d5add35f2e6ae71 (patch)
treec0386ecdda510c941829913bba55aa68085a92b3
parent7c8542b7982264226cf94102950343185869b584 (diff)
block: Make struct request_queue smaller for CONFIG_BLK_DEV_ZONED=n
Exclude zoned block device members from struct request_queue for CONFIG_BLK_DEV_ZONED == n. Avoid breaking the build by only building the code that uses these struct request_queue members if CONFIG_BLK_DEV_ZONED != n. Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Cc: Matias Bjorling <mb@lightnvm.io> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/Kconfig4
-rw-r--r--block/Makefile1
-rw-r--r--block/blk-mq-debugfs-zoned.c24
-rw-r--r--block/blk-mq-debugfs.c15
-rw-r--r--block/blk-mq-debugfs.h9
-rw-r--r--include/linux/blkdev.h6
6 files changed, 44 insertions, 15 deletions
diff --git a/block/Kconfig b/block/Kconfig
index eb50fd4977c2..dfe7bc770fc9 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -177,6 +177,10 @@ config BLK_DEBUG_FS
177 Unless you are building a kernel for a tiny system, you should 177 Unless you are building a kernel for a tiny system, you should
178 say Y here. 178 say Y here.
179 179
180config BLK_DEBUG_FS_ZONED
181 bool
182 default BLK_DEBUG_FS && BLK_DEV_ZONED
183
180config BLK_SED_OPAL 184config BLK_SED_OPAL
181 bool "Logic for interfacing with Opal enabled SEDs" 185 bool "Logic for interfacing with Opal enabled SEDs"
182 ---help--- 186 ---help---
diff --git a/block/Makefile b/block/Makefile
index 6a56303b9925..a8f94cdb75c3 100644
--- a/block/Makefile
+++ b/block/Makefile
@@ -34,4 +34,5 @@ obj-$(CONFIG_BLK_MQ_RDMA) += blk-mq-rdma.o
34obj-$(CONFIG_BLK_DEV_ZONED) += blk-zoned.o 34obj-$(CONFIG_BLK_DEV_ZONED) += blk-zoned.o
35obj-$(CONFIG_BLK_WBT) += blk-wbt.o 35obj-$(CONFIG_BLK_WBT) += blk-wbt.o
36obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-debugfs.o 36obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-debugfs.o
37obj-$(CONFIG_BLK_DEBUG_FS_ZONED)+= blk-mq-debugfs-zoned.o
37obj-$(CONFIG_BLK_SED_OPAL) += sed-opal.o 38obj-$(CONFIG_BLK_SED_OPAL) += sed-opal.o
diff --git a/block/blk-mq-debugfs-zoned.c b/block/blk-mq-debugfs-zoned.c
new file mode 100644
index 000000000000..fb2c82c351e4
--- /dev/null
+++ b/block/blk-mq-debugfs-zoned.c
@@ -0,0 +1,24 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2017 Western Digital Corporation or its affiliates.
4 *
5 * This file is released under the GPL.
6 */
7
8#include <linux/blkdev.h>
9#include "blk-mq-debugfs.h"
10
11int queue_zone_wlock_show(void *data, struct seq_file *m)
12{
13 struct request_queue *q = data;
14 unsigned int i;
15
16 if (!q->seq_zones_wlock)
17 return 0;
18
19 for (i = 0; i < q->nr_zones; i++)
20 if (test_bit(i, q->seq_zones_wlock))
21 seq_printf(m, "%u\n", i);
22
23 return 0;
24}
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 26e1f8e425a8..7efe268e4447 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -206,21 +206,6 @@ static ssize_t queue_write_hint_store(void *data, const char __user *buf,
206 return count; 206 return count;
207} 207}
208 208
209static int queue_zone_wlock_show(void *data, struct seq_file *m)
210{
211 struct request_queue *q = data;
212 unsigned int i;
213
214 if (!q->seq_zones_wlock)
215 return 0;
216
217 for (i = 0; i < q->nr_zones; i++)
218 if (test_bit(i, q->seq_zones_wlock))
219 seq_printf(m, "%u\n", i);
220
221 return 0;
222}
223
224static const struct blk_mq_debugfs_attr blk_mq_debugfs_queue_attrs[] = { 209static const struct blk_mq_debugfs_attr blk_mq_debugfs_queue_attrs[] = {
225 { "poll_stat", 0400, queue_poll_stat_show }, 210 { "poll_stat", 0400, queue_poll_stat_show },
226 { "requeue_list", 0400, .seq_ops = &queue_requeue_list_seq_ops }, 211 { "requeue_list", 0400, .seq_ops = &queue_requeue_list_seq_ops },
diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h
index b9d366e57097..a9160be12be0 100644
--- a/block/blk-mq-debugfs.h
+++ b/block/blk-mq-debugfs.h
@@ -80,4 +80,13 @@ static inline void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hc
80} 80}
81#endif 81#endif
82 82
83#ifdef CONFIG_BLK_DEBUG_FS_ZONED
84int queue_zone_wlock_show(void *data, struct seq_file *m);
85#else
86static inline int queue_zone_wlock_show(void *data, struct seq_file *m)
87{
88 return 0;
89}
90#endif
91
83#endif 92#endif
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 905daa7c647e..ca5a8b046894 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -592,6 +592,7 @@ struct request_queue {
592 592
593 struct queue_limits limits; 593 struct queue_limits limits;
594 594
595#ifdef CONFIG_BLK_DEV_ZONED
595 /* 596 /*
596 * Zoned block device information for request dispatch control. 597 * Zoned block device information for request dispatch control.
597 * nr_zones is the total number of zones of the device. This is always 598 * nr_zones is the total number of zones of the device. This is always
@@ -612,6 +613,7 @@ struct request_queue {
612 unsigned int nr_zones; 613 unsigned int nr_zones;
613 unsigned long *seq_zones_bitmap; 614 unsigned long *seq_zones_bitmap;
614 unsigned long *seq_zones_wlock; 615 unsigned long *seq_zones_wlock;
616#endif /* CONFIG_BLK_DEV_ZONED */
615 617
616 /* 618 /*
617 * sg stuff 619 * sg stuff
@@ -800,6 +802,7 @@ static inline unsigned int blk_queue_zone_sectors(struct request_queue *q)
800 return blk_queue_is_zoned(q) ? q->limits.chunk_sectors : 0; 802 return blk_queue_is_zoned(q) ? q->limits.chunk_sectors : 0;
801} 803}
802 804
805#ifdef CONFIG_BLK_DEV_ZONED
803static inline unsigned int blk_queue_zone_no(struct request_queue *q, 806static inline unsigned int blk_queue_zone_no(struct request_queue *q,
804 sector_t sector) 807 sector_t sector)
805{ 808{
@@ -815,6 +818,7 @@ static inline bool blk_queue_zone_is_seq(struct request_queue *q,
815 return false; 818 return false;
816 return test_bit(blk_queue_zone_no(q, sector), q->seq_zones_bitmap); 819 return test_bit(blk_queue_zone_no(q, sector), q->seq_zones_bitmap);
817} 820}
821#endif /* CONFIG_BLK_DEV_ZONED */
818 822
819static inline bool rq_is_sync(struct request *rq) 823static inline bool rq_is_sync(struct request *rq)
820{ 824{
@@ -1065,6 +1069,7 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
1065 return blk_rq_cur_bytes(rq) >> SECTOR_SHIFT; 1069 return blk_rq_cur_bytes(rq) >> SECTOR_SHIFT;
1066} 1070}
1067 1071
1072#ifdef CONFIG_BLK_DEV_ZONED
1068static inline unsigned int blk_rq_zone_no(struct request *rq) 1073static inline unsigned int blk_rq_zone_no(struct request *rq)
1069{ 1074{
1070 return blk_queue_zone_no(rq->q, blk_rq_pos(rq)); 1075 return blk_queue_zone_no(rq->q, blk_rq_pos(rq));
@@ -1074,6 +1079,7 @@ static inline unsigned int blk_rq_zone_is_seq(struct request *rq)
1074{ 1079{
1075 return blk_queue_zone_is_seq(rq->q, blk_rq_pos(rq)); 1080 return blk_queue_zone_is_seq(rq->q, blk_rq_pos(rq));
1076} 1081}
1082#endif /* CONFIG_BLK_DEV_ZONED */
1077 1083
1078/* 1084/*
1079 * Some commands like WRITE SAME have a payload or data transfer size which 1085 * Some commands like WRITE SAME have a payload or data transfer size which