diff options
author | Ingo Molnar <mingo@kernel.org> | 2021-11-30 17:23:45 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2022-03-15 12:57:37 +0100 |
commit | 7da726cf808763bb624c0094de698848ba5a3ce1 (patch) | |
tree | ea2d7ebc11f1b1fe096088579b3a9acb4641fa3c | |
parent | cd71c0f7d2025ad3e903d19157740f4b1b834618 (diff) | |
download | tip-7da726cf808763bb624c0094de698848ba5a3ce1.tar.gz |
headers/deps: fs: Introduce <linux/fs_api_dio.h> for Direct IO related APIs
<linux/fs_api.h> is used in over 4,100 files, while the Direct IO
related functions are only used by ~47 files.
So move them over into their new <linux/fs_api_dio.h> header.
The motivation is to allow the reduction of <linux/fs_api.h>
header dependencies.
Note: we also move inode_drain_writes(), which uses inode_dio_wait().
It's only used by mm/swapfile.c.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | include/linux/fs_api.h | 70 | ||||
-rw-r--r-- | include/linux/fs_api_dio.h | 79 |
2 files changed, 78 insertions, 71 deletions
diff --git a/include/linux/fs_api.h b/include/linux/fs_api.h index b2d51c13fd15b7..f4cfa09f13c310 100644 --- a/include/linux/fs_api.h +++ b/include/linux/fs_api.h @@ -1501,66 +1501,6 @@ extern int generic_file_open(struct inode * inode, struct file * filp); extern int nonseekable_open(struct inode * inode, struct file * filp); extern int stream_open(struct inode * inode, struct file * filp); -#ifdef CONFIG_BLOCK -typedef void (dio_submit_t)(struct bio *bio, struct inode *inode, - loff_t file_offset); - -enum { - /* need locking between buffered and direct access */ - DIO_LOCKING = 0x01, - - /* filesystem does not support filling holes */ - DIO_SKIP_HOLES = 0x02, -}; - -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); - -static inline ssize_t blockdev_direct_IO(struct kiocb *iocb, - struct inode *inode, - struct iov_iter *iter, - 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); -} -#endif - -void inode_dio_wait(struct inode *inode); - -/** - * inode_dio_begin - signal start of a direct I/O requests - * @inode: inode the direct I/O happens on - * - * This is called once we've finished processing a direct I/O request, - * and is used to wake up callers waiting for direct I/O to be quiesced. - */ -static inline void inode_dio_begin(struct inode *inode) -{ - atomic_inc(&inode->i_dio_count); -} - -/** - * inode_dio_end - signal finish of a direct I/O requests - * @inode: inode the direct I/O happens on - * - * This is called once we've finished processing a direct I/O request, - * and is used to wake up callers waiting for direct I/O to be quiesced. - */ -static inline void inode_dio_end(struct inode *inode) -{ - if (atomic_dec_and_test(&inode->i_dio_count)) - wake_up_bit(&inode->i_state, __I_DIO_WAKEUP); -} - -/* - * Warn about a page cache invalidation failure diring a direct I/O write. - */ -void dio_warn_stale_pagecache(struct file *filp); - extern void inode_set_flags(struct inode *inode, unsigned int flags, unsigned int mask); @@ -1871,14 +1811,4 @@ extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len, extern int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice); -/* - * Flush file data before changing attributes. Caller must hold any locks - * required to prevent further writes to this file until we're done setting - * flags. - */ -static inline int inode_drain_writes(struct inode *inode) -{ - inode_dio_wait(inode); - return filemap_write_and_wait(inode->i_mapping); -} #endif /* _LINUX_FS_API_H */ diff --git a/include/linux/fs_api_dio.h b/include/linux/fs_api_dio.h index 83be38d6d4132c..b5e24c723516cd 100644 --- a/include/linux/fs_api_dio.h +++ b/include/linux/fs_api_dio.h @@ -1 +1,78 @@ -#include <linux/fs.h> +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_FS_API_DIO_H +#define _LINUX_FS_API_DIO_H + +#include <linux/fs_api.h> + +#ifdef CONFIG_BLOCK +typedef void (dio_submit_t)(struct bio *bio, struct inode *inode, + loff_t file_offset); + +enum { + /* need locking between buffered and direct access */ + DIO_LOCKING = 0x01, + + /* filesystem does not support filling holes */ + DIO_SKIP_HOLES = 0x02, +}; + +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); + +static inline ssize_t blockdev_direct_IO(struct kiocb *iocb, + struct inode *inode, + struct iov_iter *iter, + 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); +} +#endif + +void inode_dio_wait(struct inode *inode); + +/** + * inode_dio_begin - signal start of a direct I/O requests + * @inode: inode the direct I/O happens on + * + * This is called once we've finished processing a direct I/O request, + * and is used to wake up callers waiting for direct I/O to be quiesced. + */ +static inline void inode_dio_begin(struct inode *inode) +{ + atomic_inc(&inode->i_dio_count); +} + +/** + * inode_dio_end - signal finish of a direct I/O requests + * @inode: inode the direct I/O happens on + * + * This is called once we've finished processing a direct I/O request, + * and is used to wake up callers waiting for direct I/O to be quiesced. + */ +static inline void inode_dio_end(struct inode *inode) +{ + if (atomic_dec_and_test(&inode->i_dio_count)) + wake_up_bit(&inode->i_state, __I_DIO_WAKEUP); +} + +/* + * Warn about a page cache invalidation failure diring a direct I/O write. + */ +void dio_warn_stale_pagecache(struct file *filp); + +/* + * Flush file data before changing attributes. Caller must hold any locks + * required to prevent further writes to this file until we're done setting + * flags. + */ +static inline int inode_drain_writes(struct inode *inode) +{ + inode_dio_wait(inode); + return filemap_write_and_wait(inode->i_mapping); +} + +#endif /* _LINUX_FS_API_DIO_H */ |