From 439bc39b3cf0014b1b75075812f7ef0f8baa9674 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 25 Jan 2023 07:58:38 +0100 Subject: [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. Signed-off-by: Christoph Hellwig Reviewed-by: Eric Biggers Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/20230125065839.191256-2-hch@lst.de Signed-off-by: Jens Axboe --- fs/direct-io.c | 24 ------------------------ fs/internal.h | 4 +--- fs/super.c | 24 ++++++++++++++++++++++++ 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index 03d381377ae1..ab0d7ea89813 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -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; diff --git a/fs/internal.h b/fs/internal.h index a803cc3cf716..cb0c0749661a 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -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: */ diff --git a/fs/super.c b/fs/super.c index 12c08cb20405..904adfbacdcf 100644 --- a/fs/super.c +++ b/fs/super.c @@ -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; +} From 9636e650e16f6b01f0044f7662074958c23e4707 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 25 Jan 2023 07:58:39 +0100 Subject: [PATCH 2/2] fs: build the legacy direct I/O code conditionally 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. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Reviewed-by: Eric Biggers Link: https://lore.kernel.org/r/20230125065839.191256-3-hch@lst.de Signed-off-by: Jens Axboe --- 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(-) diff --git a/fs/Kconfig b/fs/Kconfig index 2685a4d0d353..e99830c65033 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -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" diff --git a/fs/Makefile b/fs/Makefile index 4dea17840761..606c029e1c9b 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -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 diff --git a/fs/affs/Kconfig b/fs/affs/Kconfig index eb9d0ab850cb..962b86374e1c 100644 --- a/fs/affs/Kconfig +++ b/fs/affs/Kconfig @@ -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 diff --git a/fs/exfat/Kconfig b/fs/exfat/Kconfig index 5a65071b5ecf..147edeb04469 100644 --- a/fs/exfat/Kconfig +++ b/fs/exfat/Kconfig @@ -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. diff --git a/fs/ext2/Kconfig b/fs/ext2/Kconfig index 1248ff4ef562..77393fda99af 100644 --- a/fs/ext2/Kconfig +++ b/fs/ext2/Kconfig @@ -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. diff --git a/fs/fat/Kconfig b/fs/fat/Kconfig index 238cc55f84c4..afe83b4e7172 100644 --- a/fs/fat/Kconfig +++ b/fs/fat/Kconfig @@ -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 diff --git a/fs/hfs/Kconfig b/fs/hfs/Kconfig index 129926b5142d..d985066006d5 100644 --- a/fs/hfs/Kconfig +++ b/fs/hfs/Kconfig @@ -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. diff --git a/fs/hfsplus/Kconfig b/fs/hfsplus/Kconfig index 7d4229aecec0..8034e7827a69 100644 --- a/fs/hfsplus/Kconfig +++ b/fs/hfsplus/Kconfig @@ -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. diff --git a/fs/jfs/Kconfig b/fs/jfs/Kconfig index 05cb0e8e4382..51e856f0e4b8 100644 --- a/fs/jfs/Kconfig +++ b/fs/jfs/Kconfig @@ -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 . diff --git a/fs/nilfs2/Kconfig b/fs/nilfs2/Kconfig index 254d102e79c9..7d59567465e1 100644 --- a/fs/nilfs2/Kconfig +++ b/fs/nilfs2/Kconfig @@ -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 diff --git a/fs/ntfs3/Kconfig b/fs/ntfs3/Kconfig index 6e4cbc48ab8e..96cc236f7f7b 100644 --- a/fs/ntfs3/Kconfig +++ b/fs/ntfs3/Kconfig @@ -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. diff --git a/fs/ocfs2/Kconfig b/fs/ocfs2/Kconfig index 5d11380d8724..304d12186ccd 100644 --- a/fs/ocfs2/Kconfig +++ b/fs/ocfs2/Kconfig @@ -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 diff --git a/fs/reiserfs/Kconfig b/fs/reiserfs/Kconfig index 33c8b0dd07a2..4d22ecfe0fab 100644 --- a/fs/reiserfs/Kconfig +++ b/fs/reiserfs/Kconfig @@ -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 diff --git a/fs/udf/Kconfig b/fs/udf/Kconfig index 26e1a49f3ba7..82e8bfa2dfd9 100644 --- a/fs/udf/Kconfig +++ b/fs/udf/Kconfig @@ -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