f2fs: relocate inline conversion from mmap() to mkwrite()
authorChao Yu <yuchao0@huawei.com>
Tue, 2 Feb 2021 08:03:11 +0000 (16:03 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 2 Feb 2021 17:14:27 +0000 (09:14 -0800)
If there is page fault only for read case on inline inode, we don't need
to convert inline inode, instead, let's do conversion for write case.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index 00b2ce47fa3776d2e61c0859d51fbf6b96c2a392..8e53f8898688fcad97150d41a2e0fcbbae946ce9 100644 (file)
@@ -72,6 +72,10 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
                goto err;
        }
 
+       err = f2fs_convert_inline_inode(inode);
+       if (err)
+               goto err;
+
 #ifdef CONFIG_F2FS_FS_COMPRESSION
        if (f2fs_compressed_file(inode)) {
                int ret = f2fs_is_compressed_cluster(inode, page->index);
@@ -506,7 +510,6 @@ static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
 static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
 {
        struct inode *inode = file_inode(file);
-       int err;
 
        if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
                return -EIO;
@@ -514,11 +517,6 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
        if (!f2fs_is_compress_backend_ready(inode))
                return -EOPNOTSUPP;
 
-       /* we don't need to use inline_data strictly */
-       err = f2fs_convert_inline_inode(inode);
-       if (err)
-               return err;
-
        file_accessed(file);
        vma->vm_ops = &f2fs_file_vm_ops;
        set_inode_flag(inode, FI_MMAP_FILE);