Skip to contentSkip to conversation

untangle the block headers

PATCH In review Christoph Hellwig 2 participants 25 messages Sep 15, 2021

Subsystems (46)
lore
Share & tools
lore

Christoph Hellwig

author maintainer
#0 lore raw

Hi Jens,

this series untangles the worst of the block header maze. It removes various includes from blkdev.h and genhd.h, and also ensures the writeback code doesn't pull in blkdev.h leading to huge rebuilds whenever they change. Finally it moves various bits out of blkdev.h which shouldn't be in the general block layer header.

It has surived various randomconfig builds from me and the buildbot, but I suspect there are a few more conditionally missing headers that will emerge later for more oscure configs, so it would be great to get this out early.

Diffstat:

 arch/mips/rb532/prom.c                     |    1 
 arch/mips/sibyte/common/cfe.c              |    1 
 arch/mips/sibyte/swarm/setup.c             |    1 
 arch/openrisc/mm/init.c                    |    1 
 arch/um/drivers/ubd_kern.c                 |    1 
 block/bdev.c                               |    1 
 block/bfq-cgroup.c                         |    2 
 block/bfq-iosched.c                        |    2 
 block/bio-integrity.c                      |    2 
 block/blk-core.c                           |    1 
 block/blk-crypto-fallback.c                |    1 
 block/blk-crypto-internal.h                |    2 
 block/blk-integrity.c                      |    2 
 block/blk-iolatency.c                      |    1 
 block/blk-merge.c                          |   25 
 block/blk-mq-sched.h                       |    1 
 block/blk-mq-tag.h                         |    2 
 block/blk-mq.c                             |    2 
 block/blk.h                                |   40 +
 block/bounce.c                             |    1 
 block/elevator.c                           |    2 
 block/elevator.h                           |   21 
 block/genhd.c                              |    1 
 block/holder.c                             |    1 
 block/keyslot-manager.c                    |    1 
 block/kyber-iosched.c                      |    2 
 block/mq-deadline.c                        |    2 
 block/partitions/core.c                    |    1 
 block/t10-pi.c                             |    2 
 drivers/block/amiflop.c                    |    2 
 drivers/block/ataflop.c                    |    1 
 drivers/block/floppy.c                     |    1 
 drivers/block/rnbd/rnbd-proto.h            |    2 
 drivers/block/swim.c                       |    1 
 drivers/block/xen-blkfront.c               |    1 
 drivers/gpu/drm/i915/i915_utils.h          |    1 
 drivers/md/dm-bio-record.h                 |    1 
 drivers/md/dm-crypt.c                      |    1 
 drivers/md/dm-ps-historical-service-time.c |    1 
 drivers/md/dm-rq.c                         |    1 
 drivers/md/dm-table.c                      |    1 
 drivers/md/dm-verity-target.c              |    1 
 drivers/md/md.c                            |    2 
 drivers/mmc/core/sd.c                      |    1 
 drivers/mtd/mtdsuper.c                     |    1 
 drivers/nvdimm/core.c                      |    1 
 drivers/nvme/host/core.c                   |    1 
 drivers/nvme/host/pci.c                    |    1 
 drivers/nvme/host/rdma.c                   |    1 
 drivers/nvme/target/io-cmd-bdev.c          |    1 
 drivers/nvme/target/rdma.c                 |    1 
 drivers/s390/block/dasd_genhd.c            |    1 
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c     |    1 
 drivers/scsi/lpfc/lpfc.h                   |    1 
 drivers/scsi/scsi_lib.c                    |    1 
 drivers/scsi/sd.c                          |    1 
 drivers/scsi/sd_dif.c                      |    2 
 drivers/scsi/sg.c                          |    1 
 drivers/scsi/sr.c                          |    1 
 drivers/scsi/st.c                          |    1 
 drivers/scsi/virtio_scsi.c                 |    1 
 drivers/target/target_core_file.c          |    1 
 drivers/target/target_core_iblock.c        |    2 
 fs/btrfs/compression.c                     |    1 
 fs/btrfs/ctree.c                           |    1 
 fs/btrfs/inode.c                           |    1 
 fs/f2fs/compress.c                         |    1 
 fs/ntfs/file.c                             |    1 
 fs/ntfs3/file.c                            |    1 
 fs/orangefs/inode.c                        |    2 
 fs/orangefs/super.c                        |    1 
 fs/quota/quota.c                           |    1 
 fs/ramfs/inode.c                           |    1 
 include/linux/backing-dev.h                |   19 
 include/linux/blk-integrity.h              |  183 +++++++
 include/linux/blk-mq.h                     |  465 ++++++++++++++++++
 include/linux/blk_types.h                  |    2 
 include/linux/blkdev.h                     |  743 -----------------------------
 include/linux/blktrace_api.h               |    2 
 include/linux/genhd.h                      |   14 
 include/linux/part_stat.h                  |    1 
 include/linux/t10-pi.h                     |    2 
 include/linux/writeback.h                  |   14 
 include/scsi/scsi_device.h                 |    2 
 init/main.c                                |    1 
 kernel/acct.c                              |    1 
 kernel/exit.c                              |    1 
 kernel/fork.c                              |    1 
 kernel/sched/core.c                        |    2 
 kernel/sched/sched.h                       |    1 
 lib/random32.c                             |    1 
 mm/backing-dev.c                           |   19 
 mm/filemap.c                               |    1 
 mm/highmem.c                               |    1 
 mm/mempool.c                               |    1 
 mm/nommu.c                                 |    1 
 mm/readahead.c                             |    1 
 mm/shmem.c                                 |    1 
 mm/swapfile.c                              |    2 
 99 files changed, 830 insertions(+), 825 deletions(-)
author maintainer
#1 lore raw

PATCH 1/17 mm: don't include <linux/blk-cgroup.h> in <linux/writeback.h>

blk-cgroup.h pulls in blkdev.h and thus pretty much all the block headers. Break this dependency chain by turning wbc_blkcg_css into a macro and dropping the blk-cgroup.h include.

---
 drivers/gpu/drm/i915/i915_utils.h |  1 +
 fs/btrfs/inode.c                  |  1 +
 fs/quota/quota.c                  |  1 +
 include/linux/writeback.h         | 14 +++++---------
 lib/random32.c                    |  1 +
 5 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_utils.h +1 -0
index 5259edacde380..066a9118c3748 100644
@@ -30,6 +30,7 @@
 #include <linux/sched.h>
 #include <linux/types.h>
 #include <linux/workqueue.h>
+#include <linux/sched/clock.h>
 
 struct drm_i915_private;
 struct timer_list;
fs/btrfs/inode.c +1 -0
index 487533c35ddb6..4a9077c524448 100644
@@ -6,6 +6,7 @@
 #include <crypto/hash.h>
 #include <linux/kernel.h>
 #include <linux/bio.h>
+#include <linux/blk-cgroup.h>
 #include <linux/file.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
fs/quota/quota.c +1 -0
index 2bcc9a6f1bfc0..052f143e2e0e1 100644
@@ -10,6 +10,7 @@
 #include <linux/namei.h>
 #include <linux/slab.h>
 #include <asm/current.h>
+#include <linux/blkdev.h>
 #include <linux/uaccess.h>
 #include <linux/kernel.h>
 #include <linux/security.h>
include/linux/writeback.h +5 -9
index d1f65adf6a266..8eb165760752b 100644
@@ -11,7 +11,6 @@
 #include <linux/flex_proportions.h>
 #include <linux/backing-dev-defs.h>
 #include <linux/blk_types.h>
-#include <linux/blk-cgroup.h>
 
 struct bio;
 
@@ -109,15 +108,12 @@ static inline int wbc_to_write_flags(struct writeback_control *wbc)
 	return flags;
 }
 
-static inline struct cgroup_subsys_state *
-wbc_blkcg_css(struct writeback_control *wbc)
-{
 #ifdef CONFIG_CGROUP_WRITEBACK
-	if (wbc->wb)
-		return wbc->wb->blkcg_css;
-#endif
-	return blkcg_root_css;
-}
+#define wbc_blkcg_css(wbc) \
+	((wbc)->wb ? (wbc)->wb->blkcg_css : blkcg_root_css)
+#else
+#define wbc_blkcg_css(wbc)		(blkcg_root_css)
+#endif /* CONFIG_CGROUP_WRITEBACK */
 
 /*
  * A wb_domain represents a domain that wb's (bdi_writeback's) belong to
lib/random32.c +1 -0
index 4d0e05e471d72..a57a0e18819d0 100644
@@ -39,6 +39,7 @@
 #include <linux/random.h>
 #include <linux/sched.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include <trace/events/random.h>
 
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH 01/17] mm: don't include <linux/blk-cgroup.h> in <linux/writeback.h>

drivers/gpu/drm/i915/i915_utils.h line 36

Quoted 12 lines · Christoph Hellwig
drivers/gpu/drm/i915/i915_utils.h +1 -0
index 5259edacde380..066a9118c3748 100644
@@ -30,6 +30,7 @@
 #include <linux/sched.h>
 #include <linux/types.h>
 #include <linux/workqueue.h>
+#include <linux/sched/clock.h>
 
 struct drm_i915_private;
 struct timer_list;

This one

lib/random32.c line 45

Quoted 13 lines
lib/random32.c +1 -0
index 4d0e05e471d72..a57a0e18819d0 100644
@@ -39,6 +39,7 @@
 #include <linux/random.h>
 #include <linux/sched.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include <trace/events/random.h>
 

and this one look unrelated.

author maintainer
#3 lore raw

Re: [PATCH 01/17] mm: don't include <linux/blk-cgroup.h> in <linux/writeback.h>

Quoted 14 lines · Johannes Thumshirn

drivers/gpu/drm/i915/i915_utils.h line 36

Quoted 11 lines

index 5259edacde380..066a9118c3748 100644

drivers/gpu/drm/i915/i915_utils.h +1 -0
@@ -30,6 +30,7 @@
 #include <linux/sched.h>
 #include <linux/types.h>
 #include <linux/workqueue.h>
+#include <linux/sched/clock.h>
 
 struct drm_i915_private;
 struct timer_list;

This one

Quoted 15 lines

lib/random32.c line 45

Quoted 13 lines
lib/random32.c +1 -0
index 4d0e05e471d72..a57a0e18819d0 100644
@@ -39,6 +39,7 @@
 #include <linux/random.h>
 #include <linux/sched.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <asm/unaligned.h>
 #include <trace/events/random.h>
 

and this one look unrelated.

.. but they aren't. All these headers indirectl pulled these headers in before and now don't.

random32.c pulls in writeback.h through trace/events/random.h, which pulls in blk-cgroup.h, which pull in blkdev.h, which pulls in slab.h through some other weird twist of fate.

The drm code also somehow manages to pull in writeback.h

#4 lore raw

Re: [PATCH 01/17] mm: don't include <linux/blk-cgroup.h> in <linux/writeback.h>

Quoted 10 lines · Christoph Hellwig

.. but they aren't. All these headers indirectl pulled these headers in before and now don't.

random32.c pulls in writeback.h through trace/events/random.h, which pulls in blk-cgroup.h, which pull in blkdev.h, which pulls in slab.h through some other weird twist of fate.

The drm code also somehow manages to pull in writeback.h

Sh*t didn't notice that. But this doesn't sound healthy.

author maintainer
#5 lore raw

PATCH 2/17 mm: don't include <linux/blk-cgroup.h> in <linux/backing-dev.h>

In reply to Christoph Hellwig

There is no need to pull blk-cgroup.h and thus blkdev.h in here, so break the include chain.

---
 block/blk-iolatency.c       | 1 +
 block/blk-mq.c              | 1 +
 block/bounce.c              | 1 +
 fs/btrfs/compression.c      | 1 +
 fs/btrfs/ctree.c            | 1 +
 fs/f2fs/compress.c          | 1 +
 fs/orangefs/super.c         | 1 +
 fs/ramfs/inode.c            | 1 +
 include/linux/backing-dev.h | 3 ++-
 mm/backing-dev.c            | 3 ++-
 mm/swapfile.c               | 2 +-
 11 files changed, 13 insertions(+), 3 deletions(-)
block/blk-iolatency.c +1 -0
index c0545f9da549c..6593c7123b97e 100644
@@ -74,6 +74,7 @@
 #include <linux/sched/signal.h>
 #include <trace/events/block.h>
 #include <linux/blk-mq.h>
+#include <linux/blk-cgroup.h>
 #include "blk-rq-qos.h"
 #include "blk-stat.h"
 #include "blk.h"
block/blk-mq.c +1 -0
index 108a352051be5..61264bff6103a 100644
@@ -16,6 +16,7 @@
 #include <linux/slab.h>
 #include <linux/workqueue.h>
 #include <linux/smp.h>
+#include <linux/interrupt.h>
 #include <linux/llist.h>
 #include <linux/list_sort.h>
 #include <linux/cpu.h>
block/bounce.c +1 -0
index 05fc7148489d7..7af1a72835b99 100644
@@ -14,6 +14,7 @@
 #include <linux/pagemap.h>
 #include <linux/mempool.h>
 #include <linux/blkdev.h>
+#include <linux/blk-cgroup.h>
 #include <linux/backing-dev.h>
 #include <linux/init.h>
 #include <linux/hash.h>
fs/btrfs/compression.c +1 -0
index 7869ad12bc6e1..ddc4f5436cc91 100644
@@ -9,6 +9,7 @@
 #include <linux/fs.h>
 #include <linux/pagemap.h>
 #include <linux/highmem.h>
+#include <linux/kthread.h>
 #include <linux/time.h>
 #include <linux/init.h>
 #include <linux/string.h>
fs/btrfs/ctree.c +1 -0
index 84627cbd5b5b5..66290b214f2bc 100644
@@ -7,6 +7,7 @@
 #include <linux/slab.h>
 #include <linux/rbtree.h>
 #include <linux/mm.h>
+#include <linux/error-injection.h>
 #include "ctree.h"
 #include "disk-io.h"
 #include "transaction.h"
fs/f2fs/compress.c +1 -0
index c1bf9ad4c2207..20a083dc90423 100644
@@ -7,6 +7,7 @@
 
 #include <linux/fs.h>
 #include <linux/f2fs_fs.h>
+#include <linux/moduleparam.h>
 #include <linux/writeback.h>
 #include <linux/backing-dev.h>
 #include <linux/lzo.h>
fs/orangefs/super.c +1 -0
index 2f2e430461b21..8bb0a53a658b0 100644
@@ -11,6 +11,7 @@
 
 #include <linux/parser.h>
 #include <linux/hashtable.h>
+#include <linux/seq_file.h>
 
 /* a cache for orangefs-inode objects (i.e. orangefs inode private data) */
 static struct kmem_cache *orangefs_inode_cache;
fs/ramfs/inode.c +1 -0
index 65e7e56005b8f..e2302342a67f4 100644
@@ -38,6 +38,7 @@
 #include <linux/uaccess.h>
 #include <linux/fs_context.h>
 #include <linux/fs_parser.h>
+#include <linux/seq_file.h>
 #include "internal.h"
 
 struct ramfs_mount_opts {
include/linux/backing-dev.h +2 -1
index ac7f231b88258..843bf4be675f3 100644
@@ -15,10 +15,11 @@
 #include <linux/blkdev.h>
 #include <linux/device.h>
 #include <linux/writeback.h>
-#include <linux/blk-cgroup.h>
 #include <linux/backing-dev-defs.h>
 #include <linux/slab.h>
 
+struct blkcg;
+
 static inline struct backing_dev_info *bdi_get(struct backing_dev_info *bdi)
 {
 	kref_get(&bdi->refcnt);
mm/backing-dev.c +2 -1
index 4a9d4e27d0d9b..5245744437dc9 100644
@@ -2,8 +2,9 @@
 
 #include <linux/wait.h>
 #include <linux/rbtree.h>
-#include <linux/backing-dev.h>
 #include <linux/kthread.h>
+#include <linux/backing-dev.h>
+#include <linux/blk-cgroup.h>
 #include <linux/freezer.h>
 #include <linux/fs.h>
 #include <linux/pagemap.h>
mm/swapfile.c +1 -1
index 22d10f7138487..30db362749c06 100644
@@ -18,7 +18,7 @@
 #include <linux/pagemap.h>
 #include <linux/namei.h>
 #include <linux/shmem_fs.h>
-#include <linux/blkdev.h>
+#include <linux/blk-cgroup.h>
 #include <linux/random.h>
 #include <linux/writeback.h>
 #include <linux/proc_fs.h>
Signature · 1 line
2.30.2
author maintainer
#7 lore raw

PATCH 3/17 mm: don't include <linux/blkdev.h> in <linux/backing-dev.h>

In reply to Christoph Hellwig

Move inode_to_bdi out of line to avoid having to include blkdev.h.

---
 drivers/mtd/mtdsuper.c      |  1 +
 fs/ntfs/file.c              |  1 +
 fs/ntfs3/file.c             |  1 +
 fs/orangefs/inode.c         |  2 +-
 include/linux/backing-dev.h | 16 +---------------
 mm/backing-dev.c            | 16 ++++++++++++++++
 6 files changed, 21 insertions(+), 16 deletions(-)
drivers/mtd/mtdsuper.c +1 -0
index 38b6aa849c638..5ff001140ef4a 100644
@@ -15,6 +15,7 @@
 #include <linux/slab.h>
 #include <linux/major.h>
 #include <linux/backing-dev.h>
+#include <linux/blkdev.h>
 #include <linux/fs_context.h>
 #include "mtdcore.h"
 
fs/ntfs/file.c +1 -0
index ab4f3362466d0..373dbb6276570 100644
@@ -5,6 +5,7 @@
  * Copyright (c) 2001-2015 Anton Altaparmakov and Tuxera Inc.
  */
 
+#include <linux/blkdev.h>
 #include <linux/backing-dev.h>
 #include <linux/buffer_head.h>
 #include <linux/gfp.h>
fs/ntfs3/file.c +1 -0
index 424450e77ad52..7592ba8944572 100644
@@ -8,6 +8,7 @@
  */
 
 #include <linux/backing-dev.h>
+#include <linux/blkdev.h>
 #include <linux/buffer_head.h>
 #include <linux/compat.h>
 #include <linux/falloc.h>
fs/orangefs/inode.c +1 -1
index c1bb4c4b5d672..e5e3e500ed462 100644
@@ -10,7 +10,7 @@
  *  Linux VFS inode operations.
  */
 
-#include <linux/bvec.h>
+#include <linux/blkdev.h>
 #include <linux/fileattr.h>
 #include "protocol.h"
 #include "orangefs-kernel.h"
include/linux/backing-dev.h +1 -15
index 843bf4be675f3..4ac7ce0960139 100644
@@ -12,7 +12,6 @@
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/sched.h>
-#include <linux/blkdev.h>
 #include <linux/device.h>
 #include <linux/writeback.h>
 #include <linux/backing-dev-defs.h>
@@ -134,20 +133,7 @@ static inline bool writeback_in_progress(struct bdi_writeback *wb)
 	return test_bit(WB_writeback_running, &wb->state);
 }
 
-static inline struct backing_dev_info *inode_to_bdi(struct inode *inode)
-{
-	struct super_block *sb;
-
-	if (!inode)
-		return &noop_backing_dev_info;
-
-	sb = inode->i_sb;
-#ifdef CONFIG_BLOCK
-	if (sb_is_blkdev_sb(sb))
-		return I_BDEV(inode)->bd_disk->bdi;
-#endif
-	return sb->s_bdi;
-}
+struct backing_dev_info *inode_to_bdi(struct inode *inode);
 
 static inline int wb_congested(struct bdi_writeback *wb, int cong_bits)
 {
mm/backing-dev.c +16 -0
index 5245744437dc9..c878d995af06e 100644
@@ -978,6 +978,22 @@ void bdi_put(struct backing_dev_info *bdi)
 }
 EXPORT_SYMBOL(bdi_put);
 
+struct backing_dev_info *inode_to_bdi(struct inode *inode)
+{
+	struct super_block *sb;
+
+	if (!inode)
+		return &noop_backing_dev_info;
+
+	sb = inode->i_sb;
+#ifdef CONFIG_BLOCK
+	if (sb_is_blkdev_sb(sb))
+		return I_BDEV(inode)->bd_disk->bdi;
+#endif
+	return sb->s_bdi;
+}
+EXPORT_SYMBOL(inode_to_bdi);
+
 const char *bdi_dev_name(struct backing_dev_info *bdi)
 {
 	if (!bdi || !bdi->dev)
Signature · 1 line
2.30.2
author maintainer
#8 lore raw

PATCH 4/17 mm: remove spurious blkdev.h includes

In reply to Christoph Hellwig

Various files have acquired spurious includes of <linux/blkdev.h> over time. Remove them.

---
 mm/filemap.c   | 1 -
 mm/highmem.c   | 1 -
 mm/mempool.c   | 1 -
 mm/nommu.c     | 1 -
 mm/readahead.c | 1 -
 mm/shmem.c     | 1 -
 6 files changed, 6 deletions(-)
mm/filemap.c +0 -1
index dae481293b5d9..44b4b551e430f 100644
@@ -30,7 +30,6 @@
 #include <linux/writeback.h>
 #include <linux/backing-dev.h>
 #include <linux/pagevec.h>
-#include <linux/blkdev.h>
 #include <linux/security.h>
 #include <linux/cpuset.h>
 #include <linux/hugetlb.h>
mm/highmem.c +0 -1
index 4212ad0e4a195..471d9779a7f47 100644
@@ -23,7 +23,6 @@
 #include <linux/bio.h>
 #include <linux/pagemap.h>
 #include <linux/mempool.h>
-#include <linux/blkdev.h>
 #include <linux/init.h>
 #include <linux/hash.h>
 #include <linux/highmem.h>
mm/mempool.c +0 -1
index 0b8afbec3e358..b933d0fc21b8b 100644
@@ -17,7 +17,6 @@
 #include <linux/kmemleak.h>
 #include <linux/export.h>
 #include <linux/mempool.h>
-#include <linux/blkdev.h>
 #include <linux/writeback.h>
 #include "slab.h"
 
mm/nommu.c +0 -1
index 02d2427b8f9e8..41ef204e74820 100644
@@ -27,7 +27,6 @@
 #include <linux/pagemap.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
-#include <linux/blkdev.h>
 #include <linux/backing-dev.h>
 #include <linux/compiler.h>
 #include <linux/mount.h>
mm/readahead.c +0 -1
index 41b75d76d36e1..e71e719e36c90 100644
@@ -12,7 +12,6 @@
 #include <linux/dax.h>
 #include <linux/gfp.h>
 #include <linux/export.h>
-#include <linux/blkdev.h>
 #include <linux/backing-dev.h>
 #include <linux/task_io_accounting_ops.h>
 #include <linux/pagevec.h>
mm/shmem.c +0 -1
index 88742953532cc..b9d22ab32a770 100644
@@ -59,7 +59,6 @@ static struct vfsmount *shm_mnt;
 #include <linux/backing-dev.h>
 #include <linux/shmem_fs.h>
 #include <linux/writeback.h>
-#include <linux/blkdev.h>
 #include <linux/pagevec.h>
 #include <linux/percpu_counter.h>
 #include <linux/falloc.h>
Signature · 1 line
2.30.2
author maintainer
#10 lore raw

PATCH 5/17 arch: remove spurious blkdev.h includes

In reply to Christoph Hellwig

Various files have acquired spurious includes of <linux/blkdev.h> over time. Remove them.

---
 arch/mips/rb532/prom.c         | 1 -
 arch/mips/sibyte/common/cfe.c  | 1 -
 arch/mips/sibyte/swarm/setup.c | 1 -
 arch/openrisc/mm/init.c        | 1 -
 4 files changed, 4 deletions(-)
arch/mips/rb532/prom.c +0 -1
index 23ad8dd9aa5e0..b116937155474 100644
@@ -16,7 +16,6 @@
 #include <linux/console.h>
 #include <linux/memblock.h>
 #include <linux/ioport.h>
-#include <linux/blkdev.h>
 
 #include <asm/bootinfo.h>
 #include <asm/mach-rc32434/ddr.h>
arch/mips/sibyte/common/cfe.c +0 -1
index a3323f8dcc1b8..1a504294d85f8 100644
@@ -7,7 +7,6 @@
 #include <linux/kernel.h>
 #include <linux/linkage.h>
 #include <linux/mm.h>
-#include <linux/blkdev.h>
 #include <linux/memblock.h>
 #include <linux/pm.h>
 #include <linux/smp.h>
arch/mips/sibyte/swarm/setup.c +0 -1
index 538a2791b48ca..f07b15dd1c1a3 100644
@@ -11,7 +11,6 @@
 #include <linux/spinlock.h>
 #include <linux/mm.h>
 #include <linux/memblock.h>
-#include <linux/blkdev.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/screen_info.h>
arch/openrisc/mm/init.c +0 -1
index cfef61a7b6c2a..97305bde1b169 100644
@@ -25,7 +25,6 @@
 #include <linux/memblock.h>
 #include <linux/init.h>
 #include <linux/delay.h>
-#include <linux/blkdev.h>	/* for initrd_* */
 #include <linux/pagemap.h>
 
 #include <asm/pgalloc.h>
Signature · 1 line
2.30.2
author maintainer
#11 lore raw

PATCH 6/17 kernel: remove spurious blkdev.h includes

In reply to Christoph Hellwig

Various files have acquired spurious includes of <linux/blkdev.h> over time. Remove them.

---
 kernel/acct.c | 1 -
 kernel/exit.c | 1 -
 kernel/fork.c | 1 -
 3 files changed, 3 deletions(-)
kernel/acct.c +0 -1
index 23a7ab8e6cbc8..3df53cf1dcd5e 100644
@@ -60,7 +60,6 @@
 #include <linux/sched/cputime.h>
 
 #include <asm/div64.h>
-#include <linux/blkdev.h> /* sector_div */
 #include <linux/pid_namespace.h>
 #include <linux/fs_pin.h>
 
kernel/exit.c +0 -1
index 91a43e57a32eb..a53863dafb3d7 100644
@@ -48,7 +48,6 @@
 #include <linux/pipe_fs_i.h>
 #include <linux/audit.h> /* for audit_free() */
 #include <linux/resource.h>
-#include <linux/blkdev.h>
 #include <linux/task_io_accounting_ops.h>
 #include <linux/tracehook.h>
 #include <linux/fs_struct.h>
kernel/fork.c +0 -1
index 38681ad44c76b..67679e3933f2f 100644
@@ -76,7 +76,6 @@
 #include <linux/taskstats_kern.h>
 #include <linux/random.h>
 #include <linux/tty.h>
-#include <linux/blkdev.h>
 #include <linux/fs_struct.h>
 #include <linux/magic.h>
 #include <linux/perf_event.h>
Signature · 1 line
2.30.2
author maintainer
#12 lore raw

PATCH 7/17 sched: move the <linux/blkdev.h> include out of kernel/sched/sched.h

In reply to Christoph Hellwig

Only core.c needs blkdev.h, so move the #include statement there.

---
 kernel/sched/core.c  | 2 +-
 kernel/sched/sched.h | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
kernel/sched/core.c +1 -1
index 1bba4128a3e68..92ef7b68198c4 100644
@@ -13,7 +13,7 @@
 #include "sched.h"
 
 #include <linux/nospec.h>
-
+#include <linux/blkdev.h>
 #include <linux/kcov.h>
 #include <linux/scs.h>
 
kernel/sched/sched.h +0 -1
index 3d3e5793e1172..66128dfc05fb3 100644
@@ -37,7 +37,6 @@
 
 #include <linux/binfmts.h>
 #include <linux/bitops.h>
-#include <linux/blkdev.h>
 #include <linux/compat.h>
 #include <linux/context_tracking.h>
 #include <linux/cpufreq.h>
Signature · 1 line
2.30.2
author maintainer
#13 lore raw

PATCH 8/17 block: remove the unused rq_end_sector macro

In reply to Christoph Hellwig
---
 drivers/md/dm-rq.c       | 1 -
 include/linux/elevator.h | 1 -
 2 files changed, 2 deletions(-)
drivers/md/dm-rq.c +0 -1
index 5b95eea517d1b..79974bb0d250f 100644
@@ -7,7 +7,6 @@
 #include "dm-core.h"
 #include "dm-rq.h"
 
-#include <linux/elevator.h> /* for rq_end_sector() */
 #include <linux/blk-mq.h>
 
 #define DM_MSG_PREFIX "core-rq"
include/linux/elevator.h +0 -1
index ef9ceead3db13..80633f3b600c2 100644
@@ -162,7 +162,6 @@ extern struct request *elv_rb_find(struct rb_root *, sector_t);
 #define ELEVATOR_INSERT_FLUSH	5
 #define ELEVATOR_INSERT_SORT_MERGE	6
 
-#define rq_end_sector(rq)	(blk_rq_pos(rq) + blk_rq_sectors(rq))
 #define rb_entry_rq(node)	rb_entry((node), struct request, rb_node)
 
 #define rq_entry_fifo(ptr)	list_entry((ptr), struct request, queuelist)
Signature · 1 line
2.30.2
author maintainer
#14 lore raw

PATCH 9/17 block: remove the unused blk_queue_state enum

In reply to Christoph Hellwig
---
 include/linux/blkdev.h | 5 -----
 1 file changed, 5 deletions(-)
include/linux/blkdev.h +0 -5
index 12b9dbcc980ee..9e367509bea10 100644
@@ -262,11 +262,6 @@ enum blk_eh_timer_return {
 	BLK_EH_RESET_TIMER,	/* reset timer and try again */
 };
 
-enum blk_queue_state {
-	Queue_down,
-	Queue_up,
-};
-
 #define BLK_TAG_ALLOC_FIFO 0 /* allocate starting from 0 */
 #define BLK_TAG_ALLOC_RR 1 /* allocate starting from last allocated tag */
 
Signature · 1 line
2.30.2
author maintainer
#15 lore raw

PATCH 10/17 block: remove the cmd_size field from struct request_queue

In reply to Christoph Hellwig

Entirely unused.

---
 include/linux/blkdev.h | 2 --
 1 file changed, 2 deletions(-)
include/linux/blkdev.h +0 -2
index 9e367509bea10..6737e484280d3 100644
@@ -544,8 +544,6 @@ struct request_queue {
 
 	bool			mq_sysfs_init_done;
 
-	size_t			cmd_size;
-
 #define BLK_MAX_WRITE_HINTS	5
 	u64			write_hints[BLK_MAX_WRITE_HINTS];
 };
Signature · 1 line
2.30.2
author maintainer
#16 lore raw

PATCH 11/17 block: remove the struct blk_queue_ctx forward declaration

In reply to Christoph Hellwig

This type doesn't exist at all, so no need to forward declare it.

---
 include/linux/blkdev.h | 2 --
 1 file changed, 2 deletions(-)
include/linux/blkdev.h +0 -2
index 6737e484280d3..4bcbb1ae2d66a 100644
@@ -253,8 +253,6 @@ static inline unsigned short req_get_ioprio(struct request *req)
 
 #include <linux/elevator.h>
 
-struct blk_queue_ctx;
-
 struct bio_vec;
 
 enum blk_eh_timer_return {
Signature · 1 line
2.30.2
author maintainer
#17 lore raw

PATCH 12/17 block: move elevator.h to block/

In reply to Christoph Hellwig

Except for the features passed to blk_queue_required_elevator_features, elevator.h is only needed internally to the block layer. Move the ELEVATOR_F_* definitions to blkdev.h, and the move elevator.h to block/, dropping all the spurious includes outside of that.

---
 block/bfq-cgroup.c                  |  2 +-
 block/bfq-iosched.c                 |  2 +-
 block/blk-mq-sched.h                |  1 +
 block/blk-mq-tag.h                  |  2 ++
 block/blk.h                         |  2 ++
 block/elevator.c                    |  2 +-
 {include/linux => block}/elevator.h | 20 +++-----------------
 block/kyber-iosched.c               |  2 +-
 block/mq-deadline.c                 |  2 +-
 drivers/block/amiflop.c             |  1 -
 drivers/scsi/lpfc/lpfc.h            |  1 +
 include/linux/blkdev.h              | 11 +++++++++--
 init/main.c                         |  1 -
 13 files changed, 23 insertions(+), 26 deletions(-)
 rename {include/linux => block}/elevator.h (93%)
block/bfq-cgroup.c +1 -1
index e2f14508f2d6e..8826daedd61c1 100644
@@ -6,13 +6,13 @@
 #include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/cgroup.h>
-#include <linux/elevator.h>
 #include <linux/ktime.h>
 #include <linux/rbtree.h>
 #include <linux/ioprio.h>
 #include <linux/sbitmap.h>
 #include <linux/delay.h>
 
+#include "elevator.h"
 #include "bfq-iosched.h"
 
 #ifdef CONFIG_BFQ_CGROUP_DEBUG
block/bfq-iosched.c +1 -1
index dd13c2bbc29c1..f045ac8f07adf 100644
@@ -117,7 +117,6 @@
 #include <linux/slab.h>
 #include <linux/blkdev.h>
 #include <linux/cgroup.h>
-#include <linux/elevator.h>
 #include <linux/ktime.h>
 #include <linux/rbtree.h>
 #include <linux/ioprio.h>
@@ -127,6 +126,7 @@
 
 #include <trace/events/block.h>
 
+#include "elevator.h"
 #include "blk.h"
 #include "blk-mq.h"
 #include "blk-mq-tag.h"
block/blk-mq-sched.h +1 -0
index 5246ae0407047..5181487db7923 100644
@@ -2,6 +2,7 @@
 #ifndef BLK_MQ_SCHED_H
 #define BLK_MQ_SCHED_H
 
+#include "elevator.h"
 #include "blk-mq.h"
 #include "blk-mq-tag.h"
 
block/blk-mq-tag.h +2 -0
index 8ed55af084273..f0a0ee758a556 100644
@@ -2,6 +2,8 @@
 #ifndef INT_BLK_MQ_TAG_H
 #define INT_BLK_MQ_TAG_H
 
+struct blk_mq_alloc_data;
+
 /*
  * Tag address space map.
  */
block/blk.h +2 -0
index 7d2a0ba7ed21d..82ab26add08df 100644
@@ -12,6 +12,8 @@
 #include "blk-mq.h"
 #include "blk-mq-sched.h"
 
+struct elevator_type;
+
 /* Max future timer expiry for timeouts */
 #define BLK_MAX_TIMEOUT		(5 * HZ)
 
block/elevator.c +1 -1
index ff45d8388f487..57be09cd7f6dd 100644
@@ -26,7 +26,6 @@
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/blkdev.h>
-#include <linux/elevator.h>
 #include <linux/bio.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -40,6 +39,7 @@
 
 #include <trace/events/block.h>
 
+#include "elevator.h"
 #include "blk.h"
 #include "blk-mq-sched.h"
 #include "blk-pm.h"
block/elevator.h renamed from include/linux/elevator.h +3 -17
similarity index 93%
rename from include/linux/elevator.h
rename to block/elevator.h
index 80633f3b600c2..16cd8bdedb7ea 100644
@@ -1,17 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _LINUX_ELEVATOR_H
-#define _LINUX_ELEVATOR_H
+#ifndef _ELEVATOR_H
+#define _ELEVATOR_H
 
 #include <linux/percpu.h>
 #include <linux/hashtable.h>
 
-#ifdef CONFIG_BLOCK
-
 struct io_cq;
 struct elevator_type;
-#ifdef CONFIG_BLK_DEBUG_FS
 struct blk_mq_debugfs_attr;
-#endif
 
 /*
  * Return values from elevator merger
@@ -167,14 +163,4 @@ extern struct request *elv_rb_find(struct rb_root *, sector_t);
 #define rq_entry_fifo(ptr)	list_entry((ptr), struct request, queuelist)
 #define rq_fifo_clear(rq)	list_del_init(&(rq)->queuelist)
 
-/*
- * Elevator features.
- */
-
-/* Supports zoned block devices sequential write constraint */
-#define ELEVATOR_F_ZBD_SEQ_WRITE	(1U << 0)
-/* Supports scheduling on multiple hardware queues */
-#define ELEVATOR_F_MQ_AWARE		(1U << 1)
-
-#endif /* CONFIG_BLOCK */
-#endif
+#endif /* _ELEVATOR_H */
block/kyber-iosched.c +1 -1
index 15a8be57203d6..5808f0ea0b79f 100644
@@ -9,12 +9,12 @@
 #include <linux/kernel.h>
 #include <linux/blkdev.h>
 #include <linux/blk-mq.h>
-#include <linux/elevator.h>
 #include <linux/module.h>
 #include <linux/sbitmap.h>
 
 #include <trace/events/block.h>
 
+#include "elevator.h"
 #include "blk.h"
 #include "blk-mq.h"
 #include "blk-mq-debugfs.h"
block/mq-deadline.c +1 -1
index 7f3c3932b723e..47f042fa6a688 100644
@@ -9,7 +9,6 @@
 #include <linux/fs.h>
 #include <linux/blkdev.h>
 #include <linux/blk-mq.h>
-#include <linux/elevator.h>
 #include <linux/bio.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -20,6 +19,7 @@
 
 #include <trace/events/block.h>
 
+#include "elevator.h"
 #include "blk.h"
 #include "blk-mq.h"
 #include "blk-mq-debugfs.h"
drivers/block/amiflop.c +0 -1
index 8b1714021498c..b892e5185d6fa 100644
@@ -64,7 +64,6 @@
 #include <linux/mutex.h>
 #include <linux/fs.h>
 #include <linux/blk-mq.h>
-#include <linux/elevator.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 
drivers/scsi/lpfc/lpfc.h +1 -0
index befeb7c342903..337e6ed248218 100644
@@ -22,6 +22,7 @@
  *******************************************************************/
 
 #include <scsi/scsi_host.h>
+#include <linux/hashtable.h>
 #include <linux/ktime.h>
 #include <linux/workqueue.h>
 
include/linux/blkdev.h +9 -2
index 4bcbb1ae2d66a..d815238f61ed9 100644
@@ -251,8 +251,6 @@ static inline unsigned short req_get_ioprio(struct request *req)
 	return req->ioprio;
 }
 
-#include <linux/elevator.h>
-
 struct bio_vec;
 
 enum blk_eh_timer_return {
@@ -1124,6 +1122,15 @@ extern void blk_queue_dma_alignment(struct request_queue *, int);
 extern void blk_queue_update_dma_alignment(struct request_queue *, int);
 extern void blk_queue_rq_timeout(struct request_queue *, unsigned int);
 extern void blk_queue_write_cache(struct request_queue *q, bool enabled, bool fua);
+
+/*
+ * Elevator features for blk_queue_required_elevator_features:
+ */
+/* Supports zoned block devices sequential write constraint */
+#define ELEVATOR_F_ZBD_SEQ_WRITE	(1U << 0)
+/* Supports scheduling on multiple hardware queues */
+#define ELEVATOR_F_MQ_AWARE		(1U << 1)
+
 extern void blk_queue_required_elevator_features(struct request_queue *q,
 						 unsigned int features);
 extern bool blk_queue_can_use_dma_map_merging(struct request_queue *q,
init/main.c +0 -1
index 3f72169344412..330aae01e728c 100644
@@ -83,7 +83,6 @@
 #include <linux/ptrace.h>
 #include <linux/pti.h>
 #include <linux/blkdev.h>
-#include <linux/elevator.h>
 #include <linux/sched/clock.h>
 #include <linux/sched/task.h>
 #include <linux/sched/task_stack.h>
Signature · 1 line
2.30.2
author maintainer
#18 lore raw

PATCH 13/17 block: drop unused includes in <linux/blkdev.h>

In reply to Christoph Hellwig

Drop various include not actually used in blkdev.h itself.

---
 drivers/md/dm-ps-historical-service-time.c | 1 +
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c     | 1 +
 include/linux/blkdev.h                     | 7 -------
 3 files changed, 2 insertions(+), 7 deletions(-)
drivers/md/dm-ps-historical-service-time.c +1 -0
index 1856a1b125cc1..875bca30a0dd5 100644
@@ -27,6 +27,7 @@
 #include <linux/blkdev.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/sched/clock.h>
 
 
 #define DM_MSG_PREFIX	"multipath historical-service-time"
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +1 -0
index 3ab669dc806f6..27884f3106ab8 100644
@@ -3,6 +3,7 @@
  * Copyright (c) 2017 Hisilicon Limited.
  */
 
+#include <linux/sched/clock.h>
 #include "hisi_sas.h"
 #define DRV_NAME "hisi_sas_v3_hw"
 
include/linux/blkdev.h +0 -7
index d815238f61ed9..46a703394f7f4 100644
@@ -3,8 +3,6 @@
 #define _LINUX_BLKDEV_H
 
 #include <linux/sched.h>
-#include <linux/sched/clock.h>
-#include <linux/major.h>
 #include <linux/genhd.h>
 #include <linux/list.h>
 #include <linux/llist.h>
@@ -12,17 +10,12 @@
 #include <linux/timer.h>
 #include <linux/workqueue.h>
 #include <linux/wait.h>
-#include <linux/mempool.h>
-#include <linux/pfn.h>
 #include <linux/bio.h>
-#include <linux/stringify.h>
 #include <linux/gfp.h>
-#include <linux/smp.h>
 #include <linux/rcupdate.h>
 #include <linux/percpu-refcount.h>
 #include <linux/scatterlist.h>
 #include <linux/blkzoned.h>
-#include <linux/pm.h>
 #include <linux/sbitmap.h>
 
 struct module;
Signature · 1 line
2.30.2
author maintainer
#19 lore raw

PATCH 14/17 block: drop unused includes in <linux/genhd.h>

In reply to Christoph Hellwig

Drop various include not actually used in genhd.h itself, and move the remaning includes closer together.

---
 arch/um/drivers/ubd_kern.c      |  1 +
 block/genhd.c                   |  1 +
 block/holder.c                  |  1 +
 block/partitions/core.c         |  1 +
 drivers/block/amiflop.c         |  1 +
 drivers/block/ataflop.c         |  1 +
 drivers/block/floppy.c          |  1 +
 drivers/block/swim.c            |  1 +
 drivers/block/xen-blkfront.c    |  1 +
 drivers/md/md.c                 |  1 +
 drivers/s390/block/dasd_genhd.c |  1 +
 drivers/scsi/sd.c               |  1 +
 drivers/scsi/sg.c               |  1 +
 drivers/scsi/sr.c               |  1 +
 drivers/scsi/st.c               |  1 +
 include/linux/genhd.h           | 14 ++------------
 include/linux/part_stat.h       |  1 +
 17 files changed, 18 insertions(+), 12 deletions(-)
arch/um/drivers/ubd_kern.c +1 -0
index cd9dc0556e913..4352ef3ea7e04 100644
@@ -27,6 +27,7 @@
 #include <linux/blk-mq.h>
 #include <linux/ata.h>
 #include <linux/hdreg.h>
+#include <linux/kernel.h>
 #include <linux/cdrom.h>
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
block/genhd.c +1 -0
index 7b6e5e1cf9564..5e8aa0ab66c2a 100644
@@ -19,6 +19,7 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/kmod.h>
+#include <linux/major.h>
 #include <linux/mutex.h>
 #include <linux/idr.h>
 #include <linux/log2.h>
block/holder.c +1 -0
index 9dc084182337f..27cddce1b4461 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 #include <linux/genhd.h>
+#include <linux/slab.h>
 
 struct bd_holder_disk {
 	struct list_head	list;
block/partitions/core.c +1 -0
index 58c4c362c94f9..3a4898433c434 100644
@@ -5,6 +5,7 @@
  * Copyright (C) 2020 Christoph Hellwig
  */
 #include <linux/fs.h>
+#include <linux/major.h>
 #include <linux/slab.h>
 #include <linux/ctype.h>
 #include <linux/genhd.h>
drivers/block/amiflop.c +1 -0
index b892e5185d6fa..2909fd9e72fb8 100644
@@ -61,6 +61,7 @@
 #include <linux/hdreg.h>
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/major.h>
 #include <linux/mutex.h>
 #include <linux/fs.h>
 #include <linux/blk-mq.h>
drivers/block/ataflop.c +1 -0
index a093644ac39fb..58e921ab57298 100644
@@ -68,6 +68,7 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/blk-mq.h>
+#include <linux/major.h>
 #include <linux/mutex.h>
 #include <linux/completion.h>
 #include <linux/wait.h>
drivers/block/floppy.c +1 -0
index fef79ea52e3ed..6288ce8884147 100644
@@ -184,6 +184,7 @@ static int print_unex = 1;
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/major.h>
 #include <linux/platform_device.h>
 #include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
drivers/block/swim.c +1 -0
index 7ccc8d2a41bc6..3911d0833e1b9 100644
@@ -16,6 +16,7 @@
 #include <linux/fd.h>
 #include <linux/slab.h>
 #include <linux/blk-mq.h>
+#include <linux/major.h>
 #include <linux/mutex.h>
 #include <linux/hdreg.h>
 #include <linux/kernel.h>
drivers/block/xen-blkfront.c +1 -0
index 72902104f1112..df0deb9277601 100644
@@ -42,6 +42,7 @@
 #include <linux/cdrom.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/major.h>
 #include <linux/mutex.h>
 #include <linux/scatterlist.h>
 #include <linux/bitmap.h>
drivers/md/md.c +1 -0
index ae8fe54ea3581..0c7018462eaee 100644
@@ -51,6 +51,7 @@
 #include <linux/hdreg.h>
 #include <linux/proc_fs.h>
 #include <linux/random.h>
+#include <linux/major.h>
 #include <linux/module.h>
 #include <linux/reboot.h>
 #include <linux/file.h>
drivers/s390/block/dasd_genhd.c +1 -0
index fa966e0db6ca9..3a6f3af240fa7 100644
@@ -14,6 +14,7 @@
 #define KMSG_COMPONENT "dasd"
 
 #include <linux/interrupt.h>
+#include <linux/major.h>
 #include <linux/fs.h>
 #include <linux/blkpg.h>
 
drivers/scsi/sd.c +1 -0
index cbd9999f93a6b..a18ae0950c491 100644
@@ -48,6 +48,7 @@
 #include <linux/blkpg.h>
 #include <linux/blk-pm.h>
 #include <linux/delay.h>
+#include <linux/major.h>
 #include <linux/mutex.h>
 #include <linux/string_helpers.h>
 #include <linux/async.h>
drivers/scsi/sg.c +1 -0
index 8f05248920e8e..3c98f08dc25d9 100644
@@ -31,6 +31,7 @@ static int sg_version_num = 30536;	/* 2 digits for each component */
 #include <linux/errno.h>
 #include <linux/mtio.h>
 #include <linux/ioctl.h>
+#include <linux/major.h>
 #include <linux/slab.h>
 #include <linux/fcntl.h>
 #include <linux/init.h>
drivers/scsi/sr.c +1 -0
index 8b17b35283aa5..115f7ef7a5def 100644
@@ -44,6 +44,7 @@
 #include <linux/cdrom.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
+#include <linux/major.h>
 #include <linux/blkdev.h>
 #include <linux/blk-pm.h>
 #include <linux/mutex.h>
drivers/scsi/st.c +1 -0
index 9d04929f03a10..8cc02f5264ba7 100644
@@ -32,6 +32,7 @@ static const char *verstr = "20160209";
 #include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/mtio.h>
+#include <linux/major.h>
 #include <linux/cdrom.h>
 #include <linux/ioctl.h>
 #include <linux/fcntl.h>
include/linux/genhd.h +2 -12
index c68d83c87f83f..c1639c16b74c3 100644
@@ -12,12 +12,10 @@
 
 #include <linux/types.h>
 #include <linux/kdev_t.h>
-#include <linux/rcupdate.h>
-#include <linux/slab.h>
-#include <linux/percpu-refcount.h>
 #include <linux/uuid.h>
 #include <linux/blk_types.h>
-#include <asm/local.h>
+#include <linux/device.h>
+#include <linux/xarray.h>
 
 extern const struct device_type disk_type;
 extern struct device_type part_type;
@@ -26,14 +24,6 @@ extern struct class block_class;
 #define DISK_MAX_PARTS			256
 #define DISK_NAME_LEN			32
 
-#include <linux/major.h>
-#include <linux/device.h>
-#include <linux/smp.h>
-#include <linux/string.h>
-#include <linux/fs.h>
-#include <linux/workqueue.h>
-#include <linux/xarray.h>
-
 #define PARTITION_META_INFO_VOLNAMELTH	64
 /*
  * Enough for the string representation of any kind of UUID plus NULL.
include/linux/part_stat.h +1 -0
index d2558121d48c0..6f7949b2fd8dc 100644
@@ -3,6 +3,7 @@
 #define _LINUX_PART_STAT_H
 
 #include <linux/genhd.h>
+#include <asm/local.h>
 
 struct disk_stats {
 	u64 nsecs[NR_STAT_GROUPS];
Signature · 1 line
2.30.2
author maintainer
#20 lore raw

PATCH 15/17 block: move a few merge helpers out of <linux/blkdev.h>

In reply to Christoph Hellwig

These are lock-layer internal helper, so move them to block/blk.h and block/blk-mergec. Also update a comment a bit to use better grammar.

---
 block/blk-merge.c      | 24 ++++++++++++++++
 block/blk.h            | 38 +++++++++++++++++++++++++
 include/linux/blkdev.h | 64 ------------------------------------------
 3 files changed, 62 insertions(+), 64 deletions(-)
block/blk-merge.c +24 -0
index 7a5c81c02c800..39f210da399a6 100644
@@ -558,6 +558,23 @@ static inline unsigned int blk_rq_get_max_segments(struct request *rq)
 	return queue_max_segments(rq->q);
 }
 
+static inline unsigned int blk_rq_get_max_sectors(struct request *rq,
+						  sector_t offset)
+{
+	struct request_queue *q = rq->q;
+
+	if (blk_rq_is_passthrough(rq))
+		return q->limits.max_hw_sectors;
+
+	if (!q->limits.chunk_sectors ||
+	    req_op(rq) == REQ_OP_DISCARD ||
+	    req_op(rq) == REQ_OP_SECURE_ERASE)
+		return blk_queue_get_max_sectors(q, req_op(rq));
+
+	return min(blk_max_size_offset(q, offset, 0),
+			blk_queue_get_max_sectors(q, req_op(rq)));
+}
+
 static inline int ll_new_hw_segment(struct request *req, struct bio *bio,
 		unsigned int nr_phys_segs)
 {
@@ -718,6 +735,13 @@ static enum elv_merge blk_try_req_merge(struct request *req,
 	return ELEVATOR_NO_MERGE;
 }
 
+static inline bool blk_write_same_mergeable(struct bio *a, struct bio *b)
+{
+	if (bio_page(a) == bio_page(b) && bio_offset(a) == bio_offset(b))
+		return true;
+	return false;
+}
+
 /*
  * For non-mq, this has to be called with the request spinlock acquired.
  * For mq with scheduling, the appropriate queue wide lock should be held.
block/blk.h +38 -0
index 82ab26add08df..deb8393e34eec 100644
@@ -94,6 +94,44 @@ static inline bool bvec_gap_to_prev(struct request_queue *q,
 	return __bvec_gap_to_prev(q, bprv, offset);
 }
 
+static inline bool rq_mergeable(struct request *rq)
+{
+	if (blk_rq_is_passthrough(rq))
+		return false;
+
+	if (req_op(rq) == REQ_OP_FLUSH)
+		return false;
+
+	if (req_op(rq) == REQ_OP_WRITE_ZEROES)
+		return false;
+
+	if (req_op(rq) == REQ_OP_ZONE_APPEND)
+		return false;
+
+	if (rq->cmd_flags & REQ_NOMERGE_FLAGS)
+		return false;
+	if (rq->rq_flags & RQF_NOMERGE_FLAGS)
+		return false;
+
+	return true;
+}
+
+/*
+ * There are two different ways to handle DISCARD merges:
+ *  1) If max_discard_segments > 1, the driver treats every bio as a range and
+ *     send the bios to controller together. The ranges don't need to be
+ *     contiguous.
+ *  2) Otherwise, the request will be normal read/write requests.  The ranges
+ *     need to be contiguous.
+ */
+static inline bool blk_discard_mergable(struct request *req)
+{
+	if (req_op(req) == REQ_OP_DISCARD &&
+	    queue_max_discard_segments(req->q) > 1)
+		return true;
+	return false;
+}
+
 #ifdef CONFIG_BLK_DEV_INTEGRITY
 void blk_flush_integrity(void);
 bool __bio_integrity_endio(struct bio *);
include/linux/blkdev.h +0 -64

82 lines not on this page · raw message

Signature · 1 line
2.30.2
Reviewed-by on v1 15/17
#21 lore raw

Re: [PATCH 15/17] block: move a few merge helpers out of <linux/blkdev.h>

Quoted 1 line · Christoph Hellwig

These are lock-layer internal helper, so move them to block/blk.h and

block-layer ~^ helpers ~^

Quoted 1 line

block/blk-mergec. Also update a comment a bit to use better grammar.

block/blk-merge.c

Otherwise looks good,

author maintainer
#22 lore raw

PATCH 16/17 block: move integrity handling out of <linux/blkdev.h>

In reply to Christoph Hellwig

Split the integrity/metadata handling definitions out into a new header.

---
 block/bdev.c                        |   1 +
 block/bio-integrity.c               |   2 +-
 block/blk-core.c                    |   1 +
 block/blk-integrity.c               |   2 +-
 block/blk-merge.c                   |   1 +
 block/blk-mq.c                      |   1 +
 block/keyslot-manager.c             |   1 +
 block/t10-pi.c                      |   2 +-
 drivers/md/dm-bio-record.h          |   1 +
 drivers/md/dm-crypt.c               |   1 +
 drivers/md/dm-table.c               |   1 +
 drivers/md/md.c                     |   1 +
 drivers/nvdimm/core.c               |   1 +
 drivers/nvme/host/core.c            |   1 +
 drivers/nvme/host/pci.c             |   1 +
 drivers/nvme/host/rdma.c            |   1 +
 drivers/nvme/target/io-cmd-bdev.c   |   1 +
 drivers/nvme/target/rdma.c          |   1 +
 drivers/scsi/scsi_lib.c             |   1 +
 drivers/scsi/sd_dif.c               |   2 +-
 drivers/scsi/virtio_scsi.c          |   1 +
 drivers/target/target_core_iblock.c |   1 +
 include/linux/blk-integrity.h       | 183 ++++++++++++++++++++++++++++
 include/linux/blkdev.h              | 183 ----------------------------
 24 files changed, 205 insertions(+), 187 deletions(-)
 create mode 100644 include/linux/blk-integrity.h
block/bdev.c +1 -0
index cf2780cb44a74..567534c63f3d5 100644
@@ -12,6 +12,7 @@
 #include <linux/major.h>
 #include <linux/device_cgroup.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/backing-dev.h>
 #include <linux/module.h>
 #include <linux/blkpg.h>
block/bio-integrity.c +1 -1
index 6b47cddbbca17..21234ff966d9b 100644
@@ -6,7 +6,7 @@
  * Written by: Martin K. Petersen <[email protected]>
  */
 
-#include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/mempool.h>
 #include <linux/export.h>
 #include <linux/bio.h>
block/blk-core.c +1 -0
index 5454db2fa263b..22c2982bb0bdf 100644
@@ -18,6 +18,7 @@
 #include <linux/blkdev.h>
 #include <linux/blk-mq.h>
 #include <linux/blk-pm.h>
+#include <linux/blk-integrity.h>
 #include <linux/highmem.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
block/blk-integrity.c +1 -1
index 69a12177dfb62..35e948ea7e625 100644
@@ -6,7 +6,7 @@
  * Written by: Martin K. Petersen <[email protected]>
  */
 
-#include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/backing-dev.h>
 #include <linux/mempool.h>
 #include <linux/bio.h>
block/blk-merge.c +1 -0
index 39f210da399a6..5b4f23014df8a 100644
@@ -6,6 +6,7 @@
 #include <linux/module.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/scatterlist.h>
 
 #include <trace/events/block.h>
block/blk-mq.c +1 -0
index 61264bff6103a..21bf4c3f08259 100644
@@ -10,6 +10,7 @@
 #include <linux/backing-dev.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/kmemleak.h>
 #include <linux/mm.h>
 #include <linux/init.h>
block/keyslot-manager.c +1 -0
index 2c4a55bea6ca1..1792159d12d18 100644
@@ -35,6 +35,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/wait.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 
 struct blk_ksm_keyslot {
 	atomic_t slot_refs;
block/t10-pi.c +1 -1
index 00c203b2a921e..25a52a2a09a88 100644
@@ -5,7 +5,7 @@
  */
 
 #include <linux/t10-pi.h>
-#include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/crc-t10dif.h>
 #include <linux/module.h>
 #include <net/checksum.h>
drivers/md/dm-bio-record.h +1 -0
index a3b71350eec84..745e3ab4aa0af 100644
@@ -8,6 +8,7 @@
 #define DM_BIO_RECORD_H
 
 #include <linux/bio.h>
+#include <linux/blk-integrity.h>
 
 /*
  * There are lots of mutable fields in the bio struct that get
drivers/md/dm-crypt.c +1 -0
index 916b7da16de25..292f7896f7333 100644
@@ -15,6 +15,7 @@
 #include <linux/key.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/mempool.h>
 #include <linux/slab.h>
 #include <linux/crypto.h>
drivers/md/dm-table.c +1 -0
index 2111daaacabaf..1fa4d5582dca5 100644
@@ -10,6 +10,7 @@
 #include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/namei.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
drivers/md/md.c +1 -0
index 0c7018462eaee..5e6232386b0ce 100644
@@ -41,6 +41,7 @@
 #include <linux/sched/signal.h>
 #include <linux/kthread.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/badblocks.h>
 #include <linux/sysctl.h>
 #include <linux/seq_file.h>
drivers/nvdimm/core.c +1 -0
index 7de592d7eff45..6a45fa91e8a3e 100644
@@ -7,6 +7,7 @@
 #include <linux/export.h>
 #include <linux/module.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/device.h>
 #include <linux/ctype.h>
 #include <linux/ndctl.h>
drivers/nvme/host/core.c +1 -0
index 7efb31b87f37a..408392ec4600c 100644
@@ -6,6 +6,7 @@
 
 #include <linux/blkdev.h>
 #include <linux/blk-mq.h>
+#include <linux/blk-integrity.h>
 #include <linux/compat.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
drivers/nvme/host/pci.c +1 -0
index b82492cd75033..ca5bda26226ae 100644
@@ -10,6 +10,7 @@
 #include <linux/blkdev.h>
 #include <linux/blk-mq.h>
 #include <linux/blk-mq-pci.h>
+#include <linux/blk-integrity.h>
 #include <linux/dmi.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
drivers/nvme/host/rdma.c +1 -0
index a68704e39084e..61e22c7c28025 100644
@@ -13,6 +13,7 @@
 #include <linux/atomic.h>
 #include <linux/blk-mq.h>
 #include <linux/blk-mq-rdma.h>
+#include <linux/blk-integrity.h>
 #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
drivers/nvme/target/io-cmd-bdev.c +1 -0
index 0fc2781ab9708..6139e1de50a66 100644
@@ -5,6 +5,7 @@
  */
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/module.h>
 #include "nvmet.h"
 
drivers/nvme/target/rdma.c +1 -0
index 891174ccd44bb..38d1f292ecc20 100644
@@ -5,6 +5,7 @@
  */
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 #include <linux/atomic.h>
+#include <linux/blk-integrity.h>
 #include <linux/ctype.h>
 #include <linux/delay.h>
 #include <linux/err.h>
drivers/scsi/scsi_lib.c +1 -0
index 572673873ddf8..33fd9a01330ce 100644
@@ -21,6 +21,7 @@
 #include <linux/hardirq.h>
 #include <linux/scatterlist.h>
 #include <linux/blk-mq.h>
+#include <linux/blk-integrity.h>
 #include <linux/ratelimit.h>
 #include <asm/unaligned.h>
 
drivers/scsi/sd_dif.c +1 -1
index 4cadb26070a8f..349950616adc5 100644
@@ -6,7 +6,7 @@
  * Written by: Martin K. Petersen <[email protected]>
  */
 
-#include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/t10-pi.h>
 
 #include <scsi/scsi.h>
drivers/scsi/virtio_scsi.c +1 -0
index c25ce8f0e0afc..b7c69b97f43ab 100644
@@ -22,6 +22,7 @@
 #include <linux/virtio_scsi.h>
 #include <linux/cpu.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_cmnd.h>
drivers/target/target_core_iblock.c +1 -0
index 4069a1edcfa34..d39b87e2ed100 100644
@@ -16,6 +16,7 @@
 #include <linux/timer.h>
 #include <linux/fs.h>
 #include <linux/blkdev.h>
+#include <linux/blk-integrity.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/bio.h>
include/linux/blk-integrity.h new file +183 -0

183 lines not on this page · raw message

include/linux/blkdev.h +0 -183

189 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#23 lore raw

PATCH 17/17 block: move struct request to blk-mq.h

In reply to Christoph Hellwig

struct request is only used by blk-mq drivers, so move it and all related declarations to blk-mq.h.

---
 block/blk-crypto-fallback.c         |   1 +
 block/blk-crypto-internal.h         |   2 +-
 drivers/block/rnbd/rnbd-proto.h     |   2 +-
 drivers/md/dm-verity-target.c       |   1 +
 drivers/mmc/core/sd.c               |   1 +
 drivers/target/target_core_file.c   |   1 +
 drivers/target/target_core_iblock.c |   1 +
 include/linux/blk-mq.h              | 465 +++++++++++++++++++++++++++
 include/linux/blk_types.h           |   2 -
 include/linux/blkdev.h              | 469 +---------------------------
 include/linux/blktrace_api.h        |   2 +-
 include/linux/t10-pi.h              |   2 +-
 include/scsi/scsi_device.h          |   2 +-
 13 files changed, 476 insertions(+), 475 deletions(-)
block/blk-crypto-fallback.c +1 -0
index c322176a1e099..ec4c7823541c8 100644
@@ -18,6 +18,7 @@
 #include <linux/mempool.h>
 #include <linux/module.h>
 #include <linux/random.h>
+#include <linux/scatterlist.h>
 
 #include "blk-crypto-internal.h"
 
block/blk-crypto-internal.h +1 -1
index 0d36aae538d7b..2fb0d65a464ca 100644
@@ -7,7 +7,7 @@
 #define __LINUX_BLK_CRYPTO_INTERNAL_H
 
 #include <linux/bio.h>
-#include <linux/blkdev.h>
+#include <linux/blk-mq.h>
 
 /* Represents a crypto mode supported by blk-crypto  */
 struct blk_crypto_mode {
drivers/block/rnbd/rnbd-proto.h +1 -1
index c1bc5c0fef71d..de5d5a8df81d7 100644
@@ -10,7 +10,7 @@
 #define RNBD_PROTO_H
 
 #include <linux/types.h>
-#include <linux/blkdev.h>
+#include <linux/blk-mq.h>
 #include <linux/limits.h>
 #include <linux/inet.h>
 #include <linux/in.h>
drivers/md/dm-verity-target.c +1 -0
index 22a5ac82446a6..88e2702b473b0 100644
@@ -18,6 +18,7 @@
 #include "dm-verity-verify-sig.h"
 #include <linux/module.h>
 #include <linux/reboot.h>
+#include <linux/scatterlist.h>
 
 #define DM_MSG_PREFIX			"verity"
 
drivers/mmc/core/sd.c +1 -0
index 4646b7a03db6b..c9db24e16af13 100644
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/stat.h>
 #include <linux/pm_runtime.h>
+#include <linux/scatterlist.h>
 
 #include <linux/mmc/host.h>
 #include <linux/mmc/card.h>
drivers/target/target_core_file.c +1 -0
index ef4a8e189fba0..02f64453b4c5f 100644
@@ -20,6 +20,7 @@
 #include <linux/vmalloc.h>
 #include <linux/falloc.h>
 #include <linux/uio.h>
+#include <linux/scatterlist.h>
 #include <scsi/scsi_proto.h>
 #include <asm/unaligned.h>
 
drivers/target/target_core_iblock.c +1 -0
index d39b87e2ed100..31df20abe141f 100644
@@ -23,6 +23,7 @@
 #include <linux/genhd.h>
 #include <linux/file.h>
 #include <linux/module.h>
+#include <linux/scatterlist.h>
 #include <scsi/scsi_proto.h>
 #include <asm/unaligned.h>
 
include/linux/blk-mq.h +465 -0

479 lines not on this page · raw message

include/linux/blk_types.h +0 -2
index be622b5a21ed5..3b967053e9f5a 100644
@@ -431,8 +431,6 @@ enum stat_group {
 
 #define bio_op(bio) \
 	((bio)->bi_opf & REQ_OP_MASK)
-#define req_op(req) \
-	((req)->cmd_flags & REQ_OP_MASK)
 
 /* obsolete, don't use in new code */
 static inline void bio_set_op_attrs(struct bio *bio, unsigned op,
include/linux/blkdev.h +1 -468

556 lines not on this page · raw message

include/linux/blktrace_api.h +1 -1
index a083e15df6087..22501a293fa54 100644
@@ -2,7 +2,7 @@
 #ifndef BLKTRACE_H
 #define BLKTRACE_H
 
-#include <linux/blkdev.h>
+#include <linux/blk-mq.h>
 #include <linux/relay.h>
 #include <linux/compat.h>
 #include <uapi/linux/blktrace_api.h>
include/linux/t10-pi.h +1 -1
index 96305a64a5a7b..c635c2e014e3d 100644
@@ -3,7 +3,7 @@
 #define _LINUX_T10_PI_H
 
 #include <linux/types.h>
-#include <linux/blkdev.h>
+#include <linux/blk-mq.h>
 
 /*
  * A T10 PI-capable target device can be formatted with different
include/scsi/scsi_device.h +1 -1
index 09a17f6e93a79..76d9ee98f6c15 100644
@@ -5,7 +5,7 @@
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
-#include <linux/blkdev.h>
+#include <linux/blk-mq.h>
 #include <scsi/scsi.h>
 #include <linux/atomic.h>
 #include <linux/sbitmap.h>
Signature · 1 line
2.30.2