WIP: update tizen_qemu_defconfig
[platform/kernel/linux-starfive.git] / mm / shmem.c
index c1d8b8a..aba041a 100644 (file)
@@ -472,12 +472,10 @@ bool shmem_is_huge(struct vm_area_struct *vma, struct inode *inode,
        if (vma && ((vma->vm_flags & VM_NOHUGEPAGE) ||
            test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags)))
                return false;
-       if (shmem_huge_force)
-               return true;
-       if (shmem_huge == SHMEM_HUGE_FORCE)
-               return true;
        if (shmem_huge == SHMEM_HUGE_DENY)
                return false;
+       if (shmem_huge_force || shmem_huge == SHMEM_HUGE_FORCE)
+               return true;
 
        switch (SHMEM_SB(inode->i_sb)->huge) {
        case SHMEM_HUGE_ALWAYS:
@@ -948,6 +946,15 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
                index++;
        }
 
+       /*
+        * When undoing a failed fallocate, we want none of the partial folio
+        * zeroing and splitting below, but shall want to truncate the whole
+        * folio when !uptodate indicates that it was added by this fallocate,
+        * even when [lstart, lend] covers only a part of the folio.
+        */
+       if (unfalloc)
+               goto whole_folios;
+
        same_folio = (lstart >> PAGE_SHIFT) == (lend >> PAGE_SHIFT);
        folio = shmem_get_partial_folio(inode, lstart >> PAGE_SHIFT);
        if (folio) {
@@ -973,6 +980,8 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend,
                folio_put(folio);
        }
 
+whole_folios:
+
        index = start;
        while (index < end) {
                cond_resched();
@@ -4128,7 +4137,7 @@ static struct file_system_type shmem_fs_type = {
        .name           = "tmpfs",
        .init_fs_context = ramfs_init_fs_context,
        .parameters     = ramfs_fs_parameters,
-       .kill_sb        = kill_litter_super,
+       .kill_sb        = ramfs_kill_sb,
        .fs_flags       = FS_USERNS_MOUNT,
 };