Loading fs/f2fs/data.c +5 −1 Original line number Diff line number Diff line Loading @@ -840,6 +840,9 @@ int f2fs_preallocate_blocks(struct inode *inode, loff_t pos, return err; } if (is_inode_flag_set(inode, FI_NO_PREALLOC)) return 0; map.m_lblk = F2FS_BLK_ALIGN(pos); map.m_len = F2FS_BYTES_TO_BLK(pos + count); if (map.m_len > map.m_lblk) Loading Loading @@ -1865,7 +1868,8 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, * we already allocated all the blocks, so we don't need to get * the block addresses when there is no need to fill the page. */ if (!f2fs_has_inline_data(inode) && len == PAGE_SIZE) if (!f2fs_has_inline_data(inode) && len == PAGE_SIZE && !is_inode_flag_set(inode, FI_NO_PREALLOC)) return 0; if (f2fs_has_inline_data(inode) || Loading fs/f2fs/f2fs.h +1 −0 Original line number Diff line number Diff line Loading @@ -2200,6 +2200,7 @@ enum { FI_INLINE_DOTS, /* indicate inline dot dentries */ FI_DO_DEFRAG, /* indicate defragment is running */ FI_DIRTY_FILE, /* indicate regular/symlink has dirty pages */ FI_NO_PREALLOC, /* indicate skipped preallocated blocks */ FI_HOT_DATA, /* indicate file is hot */ FI_EXTRA_ATTR, /* indicate file has extra attribute */ FI_PROJ_INHERIT, /* indicate file inherits projectid */ Loading fs/f2fs/file.c +9 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <linux/uaccess.h> #include <linux/mount.h> #include <linux/pagevec.h> #include <linux/uio.h> #include <linux/random.h> #include <linux/aio.h> #include <linux/uuid.h> Loading Loading @@ -2536,15 +2537,22 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) inode_lock(inode); ret = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); if (!ret) { int err = f2fs_preallocate_blocks(inode, pos, count, int err; if (iov_iter_fault_in_readable(from, iov_iter_count(from))) set_inode_flag(inode, FI_NO_PREALLOC); err = f2fs_preallocate_blocks(inode, pos, count, file->f_flags & O_DIRECT); if (err) { clear_inode_flag(inode, FI_NO_PREALLOC); inode_unlock(inode); return err; } blk_start_plug(&plug); ret = __generic_file_write_iter(iocb, from); blk_finish_plug(&plug); clear_inode_flag(inode, FI_NO_PREALLOC); if (ret > 0) f2fs_update_iostat(F2FS_I_SB(inode), APP_WRITE_IO, ret); Loading Loading
fs/f2fs/data.c +5 −1 Original line number Diff line number Diff line Loading @@ -840,6 +840,9 @@ int f2fs_preallocate_blocks(struct inode *inode, loff_t pos, return err; } if (is_inode_flag_set(inode, FI_NO_PREALLOC)) return 0; map.m_lblk = F2FS_BLK_ALIGN(pos); map.m_len = F2FS_BYTES_TO_BLK(pos + count); if (map.m_len > map.m_lblk) Loading Loading @@ -1865,7 +1868,8 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi, * we already allocated all the blocks, so we don't need to get * the block addresses when there is no need to fill the page. */ if (!f2fs_has_inline_data(inode) && len == PAGE_SIZE) if (!f2fs_has_inline_data(inode) && len == PAGE_SIZE && !is_inode_flag_set(inode, FI_NO_PREALLOC)) return 0; if (f2fs_has_inline_data(inode) || Loading
fs/f2fs/f2fs.h +1 −0 Original line number Diff line number Diff line Loading @@ -2200,6 +2200,7 @@ enum { FI_INLINE_DOTS, /* indicate inline dot dentries */ FI_DO_DEFRAG, /* indicate defragment is running */ FI_DIRTY_FILE, /* indicate regular/symlink has dirty pages */ FI_NO_PREALLOC, /* indicate skipped preallocated blocks */ FI_HOT_DATA, /* indicate file is hot */ FI_EXTRA_ATTR, /* indicate file has extra attribute */ FI_PROJ_INHERIT, /* indicate file inherits projectid */ Loading
fs/f2fs/file.c +9 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <linux/uaccess.h> #include <linux/mount.h> #include <linux/pagevec.h> #include <linux/uio.h> #include <linux/random.h> #include <linux/aio.h> #include <linux/uuid.h> Loading Loading @@ -2536,15 +2537,22 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) inode_lock(inode); ret = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode)); if (!ret) { int err = f2fs_preallocate_blocks(inode, pos, count, int err; if (iov_iter_fault_in_readable(from, iov_iter_count(from))) set_inode_flag(inode, FI_NO_PREALLOC); err = f2fs_preallocate_blocks(inode, pos, count, file->f_flags & O_DIRECT); if (err) { clear_inode_flag(inode, FI_NO_PREALLOC); inode_unlock(inode); return err; } blk_start_plug(&plug); ret = __generic_file_write_iter(iocb, from); blk_finish_plug(&plug); clear_inode_flag(inode, FI_NO_PREALLOC); if (ret > 0) f2fs_update_iostat(F2FS_I_SB(inode), APP_WRITE_IO, ret); Loading