Skip to contentSkip to conversation

build direct-io.c conditionally

PATCH In review Christoph Hellwig 5 participants 10 messages Jan 25, 2023 – Jan 27, 2023

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

Hi all,

this series makes the build of direct-io.c conditional as only about a dozen file systems actually use it.

Diffstat:

 Kconfig          |    4 ++++
 Makefile         |    3 ++-
 affs/Kconfig     |    1 +
 direct-io.c      |   24 ------------------------
 exfat/Kconfig    |    1 +
 ext2/Kconfig     |    1 +
 fat/Kconfig      |    1 +
 hfs/Kconfig      |    1 +
 hfsplus/Kconfig  |    1 +
 internal.h       |    4 +---
 jfs/Kconfig      |    1 +
 nilfs2/Kconfig   |    1 +
 ntfs3/Kconfig    |    1 +
 ocfs2/Kconfig    |    1 +
 reiserfs/Kconfig |    1 +
 super.c          |   24 ++++++++++++++++++++++++
 udf/Kconfig      |    1 +
 17 files changed, 43 insertions(+), 28 deletions(-)
#1 lore raw

PATCH 1/2 fs: move sb_init_dio_done_wq out of direct-io.c

sb_init_dio_done_wq is also used by the iomap code, so move it to super.c in preparation for building direct-io.c conditionally.

---
 fs/direct-io.c | 24 ------------------------
 fs/internal.h  |  4 +---
 fs/super.c     | 24 ++++++++++++++++++++++++
 3 files changed, 25 insertions(+), 27 deletions(-)
fs/direct-io.c +0 -24
index 03d381377ae10a..ab0d7ea89813a6 100644
@@ -558,30 +558,6 @@ static inline int dio_bio_reap(struct dio *dio, struct dio_submit *sdio)
 	return ret;
 }
 
-/*
- * Create workqueue for deferred direct IO completions. We allocate the
- * workqueue when it's first needed. This avoids creating workqueue for
- * filesystems that don't need it and also allows us to create the workqueue
- * late enough so the we can include s_id in the name of the workqueue.
- */
-int sb_init_dio_done_wq(struct super_block *sb)
-{
-	struct workqueue_struct *old;
-	struct workqueue_struct *wq = alloc_workqueue("dio/%s",
-						      WQ_MEM_RECLAIM, 0,
-						      sb->s_id);
-	if (!wq)
-		return -ENOMEM;
-	/*
-	 * This has to be atomic as more DIOs can race to create the workqueue
-	 */
-	old = cmpxchg(&sb->s_dio_done_wq, NULL, wq);
-	/* Someone created workqueue before us? Free ours... */
-	if (old)
-		destroy_workqueue(wq);
-	return 0;
-}
-
 static int dio_set_defer_completion(struct dio *dio)
 {
 	struct super_block *sb = dio->inode->i_sb;
fs/internal.h +1 -3
index a803cc3cf716ab..cb0c0749661aae 100644
@@ -120,6 +120,7 @@ extern bool trylock_super(struct super_block *sb);
 struct super_block *user_get_super(dev_t, bool excl);
 void put_super(struct super_block *sb);
 extern bool mount_capable(struct fs_context *);
+int sb_init_dio_done_wq(struct super_block *sb);
 
 /*
  * open.c
@@ -187,9 +188,6 @@ extern void mnt_pin_kill(struct mount *m);
  */
 extern const struct dentry_operations ns_dentry_operations;
 
-/* direct-io.c: */
-int sb_init_dio_done_wq(struct super_block *sb);
-
 /*
  * fs/stat.c:
  */
fs/super.c +24 -0
index 12c08cb20405d5..904adfbacdcf3c 100644
@@ -1764,3 +1764,27 @@ int thaw_super(struct super_block *sb)
 	return thaw_super_locked(sb);
 }
 EXPORT_SYMBOL(thaw_super);
+
+/*
+ * Create workqueue for deferred direct IO completions. We allocate the
+ * workqueue when it's first needed. This avoids creating workqueue for
+ * filesystems that don't need it and also allows us to create the workqueue
+ * late enough so the we can include s_id in the name of the workqueue.
+ */
+int sb_init_dio_done_wq(struct super_block *sb)
+{
+	struct workqueue_struct *old;
+	struct workqueue_struct *wq = alloc_workqueue("dio/%s",
+						      WQ_MEM_RECLAIM, 0,
+						      sb->s_id);
+	if (!wq)
+		return -ENOMEM;
+	/*
+	 * This has to be atomic as more DIOs can race to create the workqueue
+	 */
+	old = cmpxchg(&sb->s_dio_done_wq, NULL, wq);
+	/* Someone created workqueue before us? Free ours... */
+	if (old)
+		destroy_workqueue(wq);
+	return 0;
+}
Signature · 1 line
2.39.0
reviewer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] fs: move sb_init_dio_done_wq out of direct-io.c

Quoted 4 lines · Christoph Hellwig

sb_init_dio_done_wq is also used by the iomap code, so move it to super.c in preparation for building direct-io.c conditionally.

Looks good. Feel free to add:

Honza

Quoted 98 lines
---
 fs/direct-io.c | 24 ------------------------
 fs/internal.h  |  4 +---
 fs/super.c     | 24 ++++++++++++++++++++++++
 3 files changed, 25 insertions(+), 27 deletions(-)
fs/direct-io.c +0 -24
index 03d381377ae10a..ab0d7ea89813a6 100644
@@ -558,30 +558,6 @@ static inline int dio_bio_reap(struct dio *dio, struct dio_submit *sdio)
 	return ret;
 }
 
-/*
- * Create workqueue for deferred direct IO completions. We allocate the
- * workqueue when it's first needed. This avoids creating workqueue for
- * filesystems that don't need it and also allows us to create the workqueue
- * late enough so the we can include s_id in the name of the workqueue.
- */
-int sb_init_dio_done_wq(struct super_block *sb)
-{
-	struct workqueue_struct *old;
-	struct workqueue_struct *wq = alloc_workqueue("dio/%s",
-						      WQ_MEM_RECLAIM, 0,
-						      sb->s_id);
-	if (!wq)
-		return -ENOMEM;
-	/*
-	 * This has to be atomic as more DIOs can race to create the workqueue
-	 */
-	old = cmpxchg(&sb->s_dio_done_wq, NULL, wq);
-	/* Someone created workqueue before us? Free ours... */
-	if (old)
-		destroy_workqueue(wq);
-	return 0;
-}
-
 static int dio_set_defer_completion(struct dio *dio)
 {
 	struct super_block *sb = dio->inode->i_sb;
fs/internal.h +1 -3
index a803cc3cf716ab..cb0c0749661aae 100644
@@ -120,6 +120,7 @@ extern bool trylock_super(struct super_block *sb);
 struct super_block *user_get_super(dev_t, bool excl);
 void put_super(struct super_block *sb);
 extern bool mount_capable(struct fs_context *);
+int sb_init_dio_done_wq(struct super_block *sb);
 
 /*
  * open.c
@@ -187,9 +188,6 @@ extern void mnt_pin_kill(struct mount *m);
  */
 extern const struct dentry_operations ns_dentry_operations;
 
-/* direct-io.c: */
-int sb_init_dio_done_wq(struct super_block *sb);
-
 /*
  * fs/stat.c:
  */
fs/super.c +24 -0
index 12c08cb20405d5..904adfbacdcf3c 100644
@@ -1764,3 +1764,27 @@ int thaw_super(struct super_block *sb)
 	return thaw_super_locked(sb);
 }
 EXPORT_SYMBOL(thaw_super);
+
+/*
+ * Create workqueue for deferred direct IO completions. We allocate the
+ * workqueue when it's first needed. This avoids creating workqueue for
+ * filesystems that don't need it and also allows us to create the workqueue
+ * late enough so the we can include s_id in the name of the workqueue.
+ */
+int sb_init_dio_done_wq(struct super_block *sb)
+{
+	struct workqueue_struct *old;
+	struct workqueue_struct *wq = alloc_workqueue("dio/%s",
+						      WQ_MEM_RECLAIM, 0,
+						      sb->s_id);
+	if (!wq)
+		return -ENOMEM;
+	/*
+	 * This has to be atomic as more DIOs can race to create the workqueue
+	 */
+	old = cmpxchg(&sb->s_dio_done_wq, NULL, wq);
+	/* Someone created workqueue before us? Free ours... */
+	if (old)
+		destroy_workqueue(wq);
+	return 0;
+}
Signature · 1 line
2.39.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] fs: move sb_init_dio_done_wq out of direct-io.c

In reply to Christoph Hellwig
Quoted 10 lines · Christoph Hellwig

sb_init_dio_done_wq is also used by the iomap code, so move it to super.c in preparation for building direct-io.c conditionally.

---
 fs/direct-io.c | 24 ------------------------
 fs/internal.h  |  4 +---
 fs/super.c     | 24 ++++++++++++++++++++++++
 3 files changed, 25 insertions(+), 27 deletions(-)

- Eric

#4 lore raw

PATCH 2/2 fs: build the legacy direct I/O code conditionally

In reply to Christoph Hellwig

Add a new LEGACY_DIRECT_IO config symbol that is only selected by the file systems that still use the legacy blockdev_direct_IO code, so that kernels without support for those file systems don't need to build the code.

---
 fs/Kconfig          | 4 ++++
 fs/Makefile         | 3 ++-
 fs/affs/Kconfig     | 1 +
 fs/exfat/Kconfig    | 1 +
 fs/ext2/Kconfig     | 1 +
 fs/fat/Kconfig      | 1 +
 fs/hfs/Kconfig      | 1 +
 fs/hfsplus/Kconfig  | 1 +
 fs/jfs/Kconfig      | 1 +
 fs/nilfs2/Kconfig   | 1 +
 fs/ntfs3/Kconfig    | 1 +
 fs/ocfs2/Kconfig    | 1 +
 fs/reiserfs/Kconfig | 1 +
 fs/udf/Kconfig      | 1 +
 14 files changed, 18 insertions(+), 1 deletion(-)
fs/Kconfig +4 -0
index 2685a4d0d35318..e99830c650336a 100644
@@ -18,6 +18,10 @@ config VALIDATE_FS_PARSER
 config FS_IOMAP
 	bool
 
+# old blockdev_direct_IO implementation.  Use iomap for new code instead
+config LEGACY_DIRECT_IO
+	bool
+
 if BLOCK
 
 source "fs/ext2/Kconfig"
fs/Makefile +2 -1
index 4dea17840761a0..606c029e1c9bc3 100644
@@ -19,13 +19,14 @@ obj-y :=	open.o read_write.o file_table.o super.o \
 		kernel_read_file.o remap_range.o
 
 ifeq ($(CONFIG_BLOCK),y)
-obj-y +=	buffer.o direct-io.o mpage.o
+obj-y +=	buffer.o mpage.o
 else
 obj-y +=	no-block.o
 endif
 
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
+obj-$(CONFIG_LEGACY_DIRECT_IO)	+= direct-io.o
 obj-y				+= notify/
 obj-$(CONFIG_EPOLL)		+= eventpoll.o
 obj-y				+= anon_inodes.o
fs/affs/Kconfig +1 -0
index eb9d0ab850cb1d..962b86374e1c15 100644
@@ -2,6 +2,7 @@
 config AFFS_FS
 	tristate "Amiga FFS file system support"
 	depends on BLOCK
+	select LEGACY_DIRECT_IO
 	help
 	  The Fast File System (FFS) is the common file system used on hard
 	  disks by Amiga(tm) systems since AmigaOS Version 1.3 (34.20).  Say Y
fs/exfat/Kconfig +1 -0
index 5a65071b5ecf10..147edeb044691d 100644
@@ -3,6 +3,7 @@
 config EXFAT_FS
 	tristate "exFAT filesystem support"
 	select NLS
+	select LEGACY_DIRECT_IO
 	help
 	  This allows you to mount devices formatted with the exFAT file system.
 	  exFAT is typically used on SD-Cards or USB sticks.
fs/ext2/Kconfig +1 -0
index 1248ff4ef56254..77393fda99af09 100644
@@ -2,6 +2,7 @@
 config EXT2_FS
 	tristate "Second extended fs support"
 	select FS_IOMAP
+	select LEGACY_DIRECT_IO
 	help
 	  Ext2 is a standard Linux file system for hard disks.
 
fs/fat/Kconfig +1 -0
index 238cc55f84c429..afe83b4e717280 100644
@@ -2,6 +2,7 @@
 config FAT_FS
 	tristate
 	select NLS
+	select LEGACY_DIRECT_IO
 	help
 	  If you want to use one of the FAT-based file systems (the MS-DOS and
 	  VFAT (Windows 95) file systems), then you must say Y or M here
fs/hfs/Kconfig +1 -0
index 129926b5142d8f..d985066006d588 100644
@@ -3,6 +3,7 @@ config HFS_FS
 	tristate "Apple Macintosh file system support"
 	depends on BLOCK
 	select NLS
+	select LEGACY_DIRECT_IO
 	help
 	  If you say Y here, you will be able to mount Macintosh-formatted
 	  floppy disks and hard drive partitions with full read-write access.
fs/hfsplus/Kconfig +1 -0
index 7d4229aecec05b..8034e7827a690b 100644
@@ -4,6 +4,7 @@ config HFSPLUS_FS
 	depends on BLOCK
 	select NLS
 	select NLS_UTF8
+	select LEGACY_DIRECT_IO
 	help
 	  If you say Y here, you will be able to mount extended format
 	  Macintosh-formatted hard drive partitions with full read-write access.
fs/jfs/Kconfig +1 -0
index 05cb0e8e4382ee..51e856f0e4b8d6 100644
@@ -3,6 +3,7 @@ config JFS_FS
 	tristate "JFS filesystem support"
 	select NLS
 	select CRC32
+	select LEGACY_DIRECT_IO
 	help
 	  This is a port of IBM's Journaled Filesystem .  More information is
 	  available in the file <file:Documentation/admin-guide/jfs.rst>.
fs/nilfs2/Kconfig +1 -0
index 254d102e79c99b..7d59567465e121 100644
@@ -2,6 +2,7 @@
 config NILFS2_FS
 	tristate "NILFS2 file system support"
 	select CRC32
+	select LEGACY_DIRECT_IO
 	help
 	  NILFS2 is a log-structured file system (LFS) supporting continuous
 	  snapshotting.  In addition to versioning capability of the entire
fs/ntfs3/Kconfig +1 -0
index 6e4cbc48ab8e43..96cc236f7f7bd3 100644
@@ -2,6 +2,7 @@
 config NTFS3_FS
 	tristate "NTFS Read-Write file system support"
 	select NLS
+	select LEGACY_DIRECT_IO
 	help
 	  Windows OS native file system (NTFS) support up to NTFS version 3.1.
 
fs/ocfs2/Kconfig +1 -0
index 5d11380d872417..304d12186ccd38 100644
@@ -7,6 +7,7 @@ config OCFS2_FS
 	select QUOTA
 	select QUOTA_TREE
 	select FS_POSIX_ACL
+	select LEGACY_DIRECT_IO
 	help
 	  OCFS2 is a general purpose extent based shared disk cluster file
 	  system with many similarities to ext3. It supports 64 bit inode
fs/reiserfs/Kconfig +1 -0
index 33c8b0dd07a2e7..4d22ecfe0fab65 100644
@@ -2,6 +2,7 @@
 config REISERFS_FS
 	tristate "Reiserfs support (deprecated)"
 	select CRC32
+	select LEGACY_DIRECT_IO
 	help
 	  Reiserfs is deprecated and scheduled to be removed from the kernel
 	  in 2025. If you are still using it, please migrate to another
fs/udf/Kconfig +1 -0
index 26e1a49f3ba795..82e8bfa2dfd989 100644
@@ -3,6 +3,7 @@ config UDF_FS
 	tristate "UDF file system support"
 	select CRC_ITU_T
 	select NLS
+	select LEGACY_DIRECT_IO
 	help
 	  This is a file system used on some CD-ROMs and DVDs. Since the
 	  file system is supported by multiple operating systems and is more
Signature · 1 line
2.39.0
reviewer Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] fs: build the legacy direct I/O code conditionally

Quoted 6 lines · Christoph Hellwig

Add a new LEGACY_DIRECT_IO config symbol that is only selected by the file systems that still use the legacy blockdev_direct_IO code, so that kernels without support for those file systems don't need to build the code.

Looks good to me. Feel free to add:

Honza

Quoted 199 lines
---
 fs/Kconfig          | 4 ++++
 fs/Makefile         | 3 ++-
 fs/affs/Kconfig     | 1 +
 fs/exfat/Kconfig    | 1 +
 fs/ext2/Kconfig     | 1 +
 fs/fat/Kconfig      | 1 +
 fs/hfs/Kconfig      | 1 +
 fs/hfsplus/Kconfig  | 1 +
 fs/jfs/Kconfig      | 1 +
 fs/nilfs2/Kconfig   | 1 +
 fs/ntfs3/Kconfig    | 1 +
 fs/ocfs2/Kconfig    | 1 +
 fs/reiserfs/Kconfig | 1 +
 fs/udf/Kconfig      | 1 +
 14 files changed, 18 insertions(+), 1 deletion(-)
fs/Kconfig +4 -0
index 2685a4d0d35318..e99830c650336a 100644
@@ -18,6 +18,10 @@ config VALIDATE_FS_PARSER
 config FS_IOMAP
 	bool
 
+# old blockdev_direct_IO implementation.  Use iomap for new code instead
+config LEGACY_DIRECT_IO
+	bool
+
 if BLOCK
 
 source "fs/ext2/Kconfig"
fs/Makefile +2 -1
index 4dea17840761a0..606c029e1c9bc3 100644
@@ -19,13 +19,14 @@ obj-y :=	open.o read_write.o file_table.o super.o \
 		kernel_read_file.o remap_range.o
 
 ifeq ($(CONFIG_BLOCK),y)
-obj-y +=	buffer.o direct-io.o mpage.o
+obj-y +=	buffer.o mpage.o
 else
 obj-y +=	no-block.o
 endif
 
 obj-$(CONFIG_PROC_FS) += proc_namespace.o
 
+obj-$(CONFIG_LEGACY_DIRECT_IO)	+= direct-io.o
 obj-y				+= notify/
 obj-$(CONFIG_EPOLL)		+= eventpoll.o
 obj-y				+= anon_inodes.o
fs/affs/Kconfig +1 -0
index eb9d0ab850cb1d..962b86374e1c15 100644
@@ -2,6 +2,7 @@
 config AFFS_FS
 	tristate "Amiga FFS file system support"
 	depends on BLOCK
+	select LEGACY_DIRECT_IO
 	help
 	  The Fast File System (FFS) is the common file system used on hard
 	  disks by Amiga(tm) systems since AmigaOS Version 1.3 (34.20).  Say Y
fs/exfat/Kconfig +1 -0
index 5a65071b5ecf10..147edeb044691d 100644
@@ -3,6 +3,7 @@
 config EXFAT_FS
 	tristate "exFAT filesystem support"
 	select NLS
+	select LEGACY_DIRECT_IO
 	help
 	  This allows you to mount devices formatted with the exFAT file system.
 	  exFAT is typically used on SD-Cards or USB sticks.
fs/ext2/Kconfig +1 -0
index 1248ff4ef56254..77393fda99af09 100644
@@ -2,6 +2,7 @@
 config EXT2_FS
 	tristate "Second extended fs support"
 	select FS_IOMAP
+	select LEGACY_DIRECT_IO
 	help
 	  Ext2 is a standard Linux file system for hard disks.
 
fs/fat/Kconfig +1 -0
index 238cc55f84c429..afe83b4e717280 100644
@@ -2,6 +2,7 @@
 config FAT_FS
 	tristate
 	select NLS
+	select LEGACY_DIRECT_IO
 	help
 	  If you want to use one of the FAT-based file systems (the MS-DOS and
 	  VFAT (Windows 95) file systems), then you must say Y or M here
fs/hfs/Kconfig +1 -0
index 129926b5142d8f..d985066006d588 100644
@@ -3,6 +3,7 @@ config HFS_FS
 	tristate "Apple Macintosh file system support"
 	depends on BLOCK
 	select NLS
+	select LEGACY_DIRECT_IO
 	help
 	  If you say Y here, you will be able to mount Macintosh-formatted
 	  floppy disks and hard drive partitions with full read-write access.
fs/hfsplus/Kconfig +1 -0
index 7d4229aecec05b..8034e7827a690b 100644
@@ -4,6 +4,7 @@ config HFSPLUS_FS
 	depends on BLOCK
 	select NLS
 	select NLS_UTF8
+	select LEGACY_DIRECT_IO
 	help
 	  If you say Y here, you will be able to mount extended format
 	  Macintosh-formatted hard drive partitions with full read-write access.
fs/jfs/Kconfig +1 -0
index 05cb0e8e4382ee..51e856f0e4b8d6 100644
@@ -3,6 +3,7 @@ config JFS_FS
 	tristate "JFS filesystem support"
 	select NLS
 	select CRC32
+	select LEGACY_DIRECT_IO
 	help
 	  This is a port of IBM's Journaled Filesystem .  More information is
 	  available in the file <file:Documentation/admin-guide/jfs.rst>.
fs/nilfs2/Kconfig +1 -0
index 254d102e79c99b..7d59567465e121 100644
@@ -2,6 +2,7 @@
 config NILFS2_FS
 	tristate "NILFS2 file system support"
 	select CRC32
+	select LEGACY_DIRECT_IO
 	help
 	  NILFS2 is a log-structured file system (LFS) supporting continuous
 	  snapshotting.  In addition to versioning capability of the entire
fs/ntfs3/Kconfig +1 -0
index 6e4cbc48ab8e43..96cc236f7f7bd3 100644
@@ -2,6 +2,7 @@
 config NTFS3_FS
 	tristate "NTFS Read-Write file system support"
 	select NLS
+	select LEGACY_DIRECT_IO
 	help
 	  Windows OS native file system (NTFS) support up to NTFS version 3.1.
 
fs/ocfs2/Kconfig +1 -0
index 5d11380d872417..304d12186ccd38 100644
@@ -7,6 +7,7 @@ config OCFS2_FS
 	select QUOTA
 	select QUOTA_TREE
 	select FS_POSIX_ACL
+	select LEGACY_DIRECT_IO
 	help
 	  OCFS2 is a general purpose extent based shared disk cluster file
 	  system with many similarities to ext3. It supports 64 bit inode
fs/reiserfs/Kconfig +1 -0
index 33c8b0dd07a2e7..4d22ecfe0fab65 100644
@@ -2,6 +2,7 @@
 config REISERFS_FS
 	tristate "Reiserfs support (deprecated)"
 	select CRC32
+	select LEGACY_DIRECT_IO
 	help
 	  Reiserfs is deprecated and scheduled to be removed from the kernel
 	  in 2025. If you are still using it, please migrate to another
fs/udf/Kconfig +1 -0
index 26e1a49f3ba795..82e8bfa2dfd989 100644
@@ -3,6 +3,7 @@ config UDF_FS
 	tristate "UDF file system support"
 	select CRC_ITU_T
 	select NLS
+	select LEGACY_DIRECT_IO
 	help
 	  This is a file system used on some CD-ROMs and DVDs. Since the
 	  file system is supported by multiple operating systems and is more
Signature · 1 line
2.39.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] fs: build the legacy direct I/O code conditionally

In reply to Christoph Hellwig
Quoted 28 lines · Christoph Hellwig

Add a new LEGACY_DIRECT_IO config symbol that is only selected by the file systems that still use the legacy blockdev_direct_IO code, so that kernels without support for those file systems don't need to build the code.

---
 fs/Kconfig          | 4 ++++
 fs/Makefile         | 3 ++-
 fs/affs/Kconfig     | 1 +
 fs/exfat/Kconfig    | 1 +
 fs/ext2/Kconfig     | 1 +
 fs/fat/Kconfig      | 1 +
 fs/hfs/Kconfig      | 1 +
 fs/hfsplus/Kconfig  | 1 +
 fs/jfs/Kconfig      | 1 +
 fs/nilfs2/Kconfig   | 1 +
 fs/ntfs3/Kconfig    | 1 +
 fs/ocfs2/Kconfig    | 1 +
 fs/reiserfs/Kconfig | 1 +
 fs/udf/Kconfig      | 1 +
 14 files changed, 18 insertions(+), 1 deletion(-)
fs/Kconfig +0 -0
index 2685a4d0d35318..e99830c650336a 100644

fs/Kconfig config VALIDATE_FS_PARSER · line 26

Quoted 9 lines
fs/Kconfig +4 -0
@@ -18,6 +18,10 @@ config VALIDATE_FS_PARSER
 config FS_IOMAP
 	bool
 
+# old blockdev_direct_IO implementation.  Use iomap for new code instead
+config LEGACY_DIRECT_IO
+	bool
+
 if BLOCK
 

- Eric

maintainer
#7 lore raw

Re: [PATCH 2/2] fs: build the legacy direct I/O code conditionally

In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

Add a new LEGACY_DIRECT_IO config symbol that is only selected by the file systems that still use the legacy blockdev_direct_IO code, so that kernels without support for those file systems don't need to build the code.

Looks sane... FWIW, I've got this in the misc pile; doesn't seem to conflict anything in your series, thankfully...

commit 193010cdc86da0126c58f58bbeacfcb5a15e6cee

Author: Al Viro <[email protected]>
Date:   Thu Jan 19 19:22:22 2023 -0500

__blockdev_direct_IO(): get rid of submit_io callback

always NULL...

fs/direct-io.c +2 -7
index 03d381377ae1..c2736da875cc 100644
@@ -86,7 +86,6 @@ struct dio_submit {
 	sector_t final_block_in_request;/* doesn't change */
 	int boundary;			/* prev block is at a boundary */
 	get_block_t *get_block;		/* block mapping function */
-	dio_submit_t *submit_io;	/* IO submition function */
 
 	loff_t logical_offset_in_bio;	/* current first logical block in bio */
 	sector_t final_block_in_bio;	/* current final block in bio + 1 */
@@ -431,10 +430,7 @@ static inline void dio_bio_submit(struct dio *dio, struct dio_submit *sdio)
 
 	dio->bio_disk = bio->bi_bdev->bd_disk;
 
-	if (sdio->submit_io)
-		sdio->submit_io(bio, dio->inode, sdio->logical_offset_in_bio);
-	else
-		submit_bio(bio);
+	submit_bio(bio);
 
 	sdio->bio = NULL;
 	sdio->boundary = 0;
@@ -1122,7 +1118,7 @@ static inline int drop_refcount(struct dio *dio)
 ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
 		struct block_device *bdev, struct iov_iter *iter,
 		get_block_t get_block, dio_iodone_t end_io,
-		dio_submit_t submit_io, int flags)
+		int flags)
 {
 	unsigned i_blkbits = READ_ONCE(inode->i_blkbits);
 	unsigned blkbits = i_blkbits;
@@ -1239,7 +1235,6 @@ ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
 
 	sdio.get_block = get_block;
 	dio->end_io = end_io;
-	sdio.submit_io = submit_io;
 	sdio.final_block_in_bio = -1;
 	sdio.next_block_for_io = -1;
 
fs/ocfs2/aops.c +1 -1
index 1d65f6ef00ca..50448ba5fda8 100644
@@ -2448,7 +2448,7 @@ static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 
 	return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev,
 				    iter, get_block,
-				    ocfs2_dio_end_io, NULL, 0);
+				    ocfs2_dio_end_io, 0);
 }
 
 const struct address_space_operations ocfs2_aops = {
include/linux/fs.h +2 -2
index c1769a2c5d70..544b29a96fb0 100644
@@ -3205,7 +3205,7 @@ enum {
 ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
 			     struct block_device *bdev, struct iov_iter *iter,
 			     get_block_t get_block,
-			     dio_iodone_t end_io, dio_submit_t submit_io,
+			     dio_iodone_t end_io,
 			     int flags);
 
 static inline ssize_t blockdev_direct_IO(struct kiocb *iocb,
@@ -3214,7 +3214,7 @@ static inline ssize_t blockdev_direct_IO(struct kiocb *iocb,
 					 get_block_t get_block)
 {
 	return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
-			get_block, NULL, NULL, DIO_LOCKING | DIO_SKIP_HOLES);
+			get_block, NULL, DIO_LOCKING | DIO_SKIP_HOLES);
 }
 #endif
 
author Reviewed-by
#8 lore raw

Re: [PATCH 2/2] fs: build the legacy direct I/O code conditionally

Quoted 8 lines · Al Viro
Quoted 4 lines · Christoph Hellwig

Add a new LEGACY_DIRECT_IO config symbol that is only selected by the file systems that still use the legacy blockdev_direct_IO code, so that kernels without support for those file systems don't need to build the code.

Looks sane... FWIW, I've got this in the misc pile; doesn't seem to conflict anything in your series, thankfully...

Yes, this looks good:

If someone had time to convert ocfs2 to iomap we could also kill the entire __blockdev_direct_IO variant.

Applied
#9 lore raw
In reply to Christoph Hellwig
Quoted 23 lines · Christoph Hellwig

this series makes the build of direct-io.c conditional as only about a dozen file systems actually use it.

Diffstat:

 Kconfig          |    4 ++++
 Makefile         |    3 ++-
 affs/Kconfig     |    1 +
 direct-io.c      |   24 ------------------------
 exfat/Kconfig    |    1 +
 ext2/Kconfig     |    1 +
 fat/Kconfig      |    1 +
 hfs/Kconfig      |    1 +
 hfsplus/Kconfig  |    1 +
 internal.h       |    4 +---
 jfs/Kconfig      |    1 +
 nilfs2/Kconfig   |    1 +
 ntfs3/Kconfig    |    1 +
 ocfs2/Kconfig    |    1 +
 reiserfs/Kconfig |    1 +
 super.c          |   24 ++++++++++++++++++++++++
 udf/Kconfig      |    1 +
 17 files changed, 43 insertions(+), 28 deletions(-)
Quoted 1 line

[...]

Applied, thanks!

[1/2] fs: move sb_init_dio_done_wq out of direct-io.c

      commit: 439bc39b3cf0014b1b75075812f7ef0f8baa9674
[2/2] fs: build the legacy direct I/O code conditionally
      commit: 9636e650e16f6b01f0044f7662074958c23e4707

Best regards,

Signature · 1 line
Jens Axboe