From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 09/10] block: reduce ifdef CONFIG_BLOCK madness in headers
Date: Sat, 20 Jun 2020 09:16:43 +0200 [thread overview]
Message-ID: <20200620071644.463185-10-hch@lst.de> (raw)
In-Reply-To: <20200620071644.463185-1-hch@lst.de>
Large part of bio.h, blkdev.h and genhd.h are under ifdef CONFIG_BLOCK
for no good reason. Only stub out function that are called from
code that is not dependent on CONFIG_BLOCK and leave the harmless
other declarations around.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/bio.h | 3 --
include/linux/blkdev.h | 92 ++++++++++++++++++------------------------
include/linux/genhd.h | 14 +++----
3 files changed, 46 insertions(+), 63 deletions(-)
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 91676d4b2dfe77..0282f8aa85935c 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -8,8 +8,6 @@
#include <linux/highmem.h>
#include <linux/mempool.h>
#include <linux/ioprio.h>
-
-#ifdef CONFIG_BLOCK
/* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */
#include <linux/blk_types.h>
@@ -824,5 +822,4 @@ static inline void bio_set_polled(struct bio *bio, struct kiocb *kiocb)
bio->bi_opf |= REQ_NOWAIT;
}
-#endif /* CONFIG_BLOCK */
#endif /* __LINUX_BIO_H */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 973253ce202d87..0f021ee2ce1c3b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -4,9 +4,6 @@
#include <linux/sched.h>
#include <linux/sched/clock.h>
-
-#ifdef CONFIG_BLOCK
-
#include <linux/major.h>
#include <linux/genhd.h>
#include <linux/list.h>
@@ -1165,13 +1162,13 @@ static inline int blk_rq_map_sg(struct request_queue *q, struct request *rq,
return __blk_rq_map_sg(q, rq, sglist, &last_sg);
}
extern void blk_dump_rq_flags(struct request *, char *);
-extern long nr_blockdev_pages(void);
bool __must_check blk_get_queue(struct request_queue *);
struct request_queue *blk_alloc_queue(make_request_fn make_request, int node_id);
extern void blk_put_queue(struct request_queue *);
extern void blk_set_queue_dying(struct request_queue *);
+#ifdef CONFIG_BLOCK
/*
* blk_plug permits building a queue of related requests by holding the I/O
* fragments for a short period. This allows merging of sequential requests
@@ -1231,9 +1228,47 @@ static inline bool blk_needs_flush_plug(struct task_struct *tsk)
!list_empty(&plug->cb_list));
}
+int blkdev_issue_flush(struct block_device *, gfp_t);
+long nr_blockdev_pages(void);
+#else /* CONFIG_BLOCK */
+struct blk_plug {
+};
+
+static inline void blk_start_plug(struct blk_plug *plug)
+{
+}
+
+static inline void blk_finish_plug(struct blk_plug *plug)
+{
+}
+
+static inline void blk_flush_plug(struct task_struct *task)
+{
+}
+
+static inline void blk_schedule_flush_plug(struct task_struct *task)
+{
+}
+
+
+static inline bool blk_needs_flush_plug(struct task_struct *tsk)
+{
+ return false;
+}
+
+static inline int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask)
+{
+ return 0;
+}
+
+static inline long nr_blockdev_pages(void)
+{
+ return 0;
+}
+#endif /* CONFIG_BLOCK */
+
extern void blk_io_schedule(void);
-int blkdev_issue_flush(struct block_device *, gfp_t);
extern int blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
sector_t nr_sects, gfp_t gfp_mask, struct page *page);
@@ -1833,51 +1868,6 @@ static inline bool blk_req_can_dispatch_to_zone(struct request *rq)
}
#endif /* CONFIG_BLK_DEV_ZONED */
-#else /* CONFIG_BLOCK */
-
-struct block_device;
-
-/*
- * stubs for when the block layer is configured out
- */
-
-static inline long nr_blockdev_pages(void)
-{
- return 0;
-}
-
-struct blk_plug {
-};
-
-static inline void blk_start_plug(struct blk_plug *plug)
-{
-}
-
-static inline void blk_finish_plug(struct blk_plug *plug)
-{
-}
-
-static inline void blk_flush_plug(struct task_struct *task)
-{
-}
-
-static inline void blk_schedule_flush_plug(struct task_struct *task)
-{
-}
-
-
-static inline bool blk_needs_flush_plug(struct task_struct *tsk)
-{
- return false;
-}
-
-static inline int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask)
-{
- return 0;
-}
-
-#endif /* CONFIG_BLOCK */
-
static inline void blk_wake_io_task(struct task_struct *waiter)
{
/*
@@ -1891,7 +1881,6 @@ static inline void blk_wake_io_task(struct task_struct *waiter)
wake_up_process(waiter);
}
-#ifdef CONFIG_BLOCK
unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors,
unsigned int op);
void disk_end_io_acct(struct gendisk *disk, unsigned int op,
@@ -1917,7 +1906,6 @@ static inline void bio_end_io_acct(struct bio *bio, unsigned long start_time)
{
return disk_end_io_acct(bio->bi_disk, bio_op(bio), start_time);
}
-#endif /* CONFIG_BLOCK */
int bdev_read_only(struct block_device *bdev);
int set_blocksize(struct block_device *bdev, int size);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 83f8e0d8322836..31a54072ffd653 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -19,8 +19,6 @@
#include <linux/blk_types.h>
#include <asm/local.h>
-#ifdef CONFIG_BLOCK
-
#define dev_to_disk(device) container_of((device), struct gendisk, part0.__dev)
#define dev_to_part(device) container_of((device), struct hd_struct, __dev)
#define disk_to_dev(disk) (&(disk)->part0.__dev)
@@ -337,12 +335,9 @@ static inline void set_capacity(struct gendisk *disk, sector_t size)
disk->part0.nr_sects = size;
}
-extern dev_t blk_lookup_devt(const char *name, int partno);
-
int bdev_disk_changed(struct block_device *bdev, bool invalidate);
int blk_add_partitions(struct gendisk *disk, struct block_device *bdev);
int blk_drop_partitions(struct block_device *bdev);
-extern void printk_all_partitions(void);
extern struct gendisk *__alloc_disk_node(int minors, int node_id);
extern struct kobject *get_disk_and_module(struct gendisk *disk);
@@ -400,10 +395,13 @@ static inline void bd_unlink_disk_holder(struct block_device *bdev,
}
#endif /* CONFIG_SYSFS */
+#ifdef CONFIG_BLOCK
+void printk_all_partitions(void);
+dev_t blk_lookup_devt(const char *name, int partno);
#else /* CONFIG_BLOCK */
-
-static inline void printk_all_partitions(void) { }
-
+static inline void printk_all_partitions(void)
+{
+}
static inline dev_t blk_lookup_devt(const char *name, int partno)
{
dev_t devt = MKDEV(0, 0);
--
2.26.2
next prev parent reply other threads:[~2020-06-20 7:17 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-20 7:16 move block bits out of fs.h Christoph Hellwig
2020-06-20 7:16 ` [PATCH 01/10] tty/sysrq: emergency_thaw_all does not depend on CONFIG_BLOCK Christoph Hellwig
2020-06-20 7:21 ` Greg Kroah-Hartman
2020-06-21 2:54 ` Bart Van Assche
2020-06-22 8:48 ` Johannes Thumshirn
2020-06-20 7:16 ` [PATCH 02/10] block: mark bd_finish_claiming static Christoph Hellwig
2020-06-21 2:54 ` Bart Van Assche
2020-06-22 8:47 ` Johannes Thumshirn
2020-06-20 7:16 ` [PATCH 03/10] fs: remove an unused block_device_operations forward declaration Christoph Hellwig
2020-06-21 2:55 ` Bart Van Assche
2020-06-22 9:12 ` Johannes Thumshirn
2020-06-20 7:16 ` [PATCH 04/10] fs: remove the HAVE_UNLOCKED_IOCTL and HAVE_COMPAT_IOCTL defines Christoph Hellwig
2020-06-21 2:56 ` Bart Van Assche
2020-06-22 9:13 ` Johannes Thumshirn
2020-06-20 7:16 ` [PATCH 05/10] fs: remove the mount_bdev and kill_block_super stubs Christoph Hellwig
2020-06-22 9:26 ` Johannes Thumshirn
2020-06-20 7:16 ` [PATCH 06/10] block: simplify sb_is_blkdev_sb Christoph Hellwig
2020-06-21 2:57 ` Bart Van Assche
2020-06-22 9:27 ` Johannes Thumshirn
2020-06-20 7:16 ` [PATCH 07/10] block: move block-related definitions out of fs.h Christoph Hellwig
2020-06-22 9:33 ` Johannes Thumshirn
2020-06-20 7:16 ` [PATCH 08/10] fs: move the buffer_heads_over_limit stub to buffer_head.h Christoph Hellwig
2020-06-21 3:03 ` Bart Van Assche
2020-06-22 9:36 ` Johannes Thumshirn
2020-06-20 7:16 ` Christoph Hellwig [this message]
2020-06-20 7:16 ` [PATCH 10/10] block: move struct block_device to blk_types.h Christoph Hellwig
2020-06-22 9:42 ` Johannes Thumshirn
2020-06-24 15:09 ` move block bits out of fs.h Jens Axboe
2020-06-24 15:12 ` Christoph Hellwig
2020-06-24 15:14 ` Jens Axboe
2020-06-24 15:14 ` Christoph Hellwig
2020-06-24 15:16 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200620071644.463185-10-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).