forked from Minki/linux
f2fs: move f2fs_force_buffered_io() into file.c
f2fs_force_buffered_io() is only used in file.c, so move it into there. No behavior change. This makes it easier to review later patches. Signed-off-by: Eric Biggers <ebiggers@google.com> Acked-by: Jaegeuk Kim <jaegeuk@kernel.org> Link: https://lore.kernel.org/r/20220827065851.135710-6-ebiggers@kernel.org
This commit is contained in:
parent
8434ef1d8a
commit
2db0487faa
@ -4471,17 +4471,6 @@ static inline void f2fs_i_compr_blocks_update(struct inode *inode,
|
||||
f2fs_mark_inode_dirty_sync(inode, true);
|
||||
}
|
||||
|
||||
static inline int block_unaligned_IO(struct inode *inode,
|
||||
struct kiocb *iocb, struct iov_iter *iter)
|
||||
{
|
||||
unsigned int i_blkbits = READ_ONCE(inode->i_blkbits);
|
||||
unsigned int blocksize_mask = (1 << i_blkbits) - 1;
|
||||
loff_t offset = iocb->ki_pos;
|
||||
unsigned long align = offset | iov_iter_alignment(iter);
|
||||
|
||||
return align & blocksize_mask;
|
||||
}
|
||||
|
||||
static inline bool f2fs_allow_multi_device_dio(struct f2fs_sb_info *sbi,
|
||||
int flag)
|
||||
{
|
||||
@ -4492,35 +4481,6 @@ static inline bool f2fs_allow_multi_device_dio(struct f2fs_sb_info *sbi,
|
||||
return sbi->aligned_blksize;
|
||||
}
|
||||
|
||||
static inline bool f2fs_force_buffered_io(struct inode *inode,
|
||||
struct kiocb *iocb, struct iov_iter *iter)
|
||||
{
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
||||
int rw = iov_iter_rw(iter);
|
||||
|
||||
if (!fscrypt_dio_supported(inode))
|
||||
return true;
|
||||
if (fsverity_active(inode))
|
||||
return true;
|
||||
if (f2fs_compressed_file(inode))
|
||||
return true;
|
||||
|
||||
/* disallow direct IO if any of devices has unaligned blksize */
|
||||
if (f2fs_is_multi_device(sbi) && !sbi->aligned_blksize)
|
||||
return true;
|
||||
|
||||
if (f2fs_lfs_mode(sbi) && (rw == WRITE)) {
|
||||
if (block_unaligned_IO(inode, iocb, iter))
|
||||
return true;
|
||||
if (F2FS_IO_ALIGNED(sbi))
|
||||
return true;
|
||||
}
|
||||
if (is_sbi_flag_set(F2FS_I_SB(inode), SBI_CP_DISABLED))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool f2fs_need_verity(const struct inode *inode, pgoff_t idx)
|
||||
{
|
||||
return fsverity_active(inode) &&
|
||||
|
@ -808,6 +808,46 @@ int f2fs_truncate(struct inode *inode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int block_unaligned_IO(struct inode *inode, struct kiocb *iocb,
|
||||
struct iov_iter *iter)
|
||||
{
|
||||
unsigned int i_blkbits = READ_ONCE(inode->i_blkbits);
|
||||
unsigned int blocksize_mask = (1 << i_blkbits) - 1;
|
||||
loff_t offset = iocb->ki_pos;
|
||||
unsigned long align = offset | iov_iter_alignment(iter);
|
||||
|
||||
return align & blocksize_mask;
|
||||
}
|
||||
|
||||
static bool f2fs_force_buffered_io(struct inode *inode,
|
||||
struct kiocb *iocb, struct iov_iter *iter)
|
||||
{
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
||||
int rw = iov_iter_rw(iter);
|
||||
|
||||
if (!fscrypt_dio_supported(inode))
|
||||
return true;
|
||||
if (fsverity_active(inode))
|
||||
return true;
|
||||
if (f2fs_compressed_file(inode))
|
||||
return true;
|
||||
|
||||
/* disallow direct IO if any of devices has unaligned blksize */
|
||||
if (f2fs_is_multi_device(sbi) && !sbi->aligned_blksize)
|
||||
return true;
|
||||
|
||||
if (f2fs_lfs_mode(sbi) && (rw == WRITE)) {
|
||||
if (block_unaligned_IO(inode, iocb, iter))
|
||||
return true;
|
||||
if (F2FS_IO_ALIGNED(sbi))
|
||||
return true;
|
||||
}
|
||||
if (is_sbi_flag_set(F2FS_I_SB(inode), SBI_CP_DISABLED))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int f2fs_getattr(struct user_namespace *mnt_userns, const struct path *path,
|
||||
struct kstat *stat, u32 request_mask, unsigned int query_flags)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user