shmem.c (46de8b979492e1377947700ecb1e3169088668b2) | shmem.c (f7cd16a55837f37b4c3835a2c646023e4d0f0e04) |
---|---|
1/* 2 * Resizable virtual memory filesystem for Linux. 3 * 4 * Copyright (C) 2000 Linus Torvalds. 5 * 2000 Transmeta Corp. 6 * 2000-2001 Christoph Rohland 7 * 2000-2001 SAP AG 8 * 2002 Red Hat Inc. --- 462 unchanged lines hidden (view full) --- 471 472static int shmem_huge __read_mostly = SHMEM_HUGE_NEVER; 473 474bool shmem_is_huge(struct vm_area_struct *vma, 475 struct inode *inode, pgoff_t index) 476{ 477 loff_t i_size; 478 | 1/* 2 * Resizable virtual memory filesystem for Linux. 3 * 4 * Copyright (C) 2000 Linus Torvalds. 5 * 2000 Transmeta Corp. 6 * 2000-2001 Christoph Rohland 7 * 2000-2001 SAP AG 8 * 2002 Red Hat Inc. --- 462 unchanged lines hidden (view full) --- 471 472static int shmem_huge __read_mostly = SHMEM_HUGE_NEVER; 473 474bool shmem_is_huge(struct vm_area_struct *vma, 475 struct inode *inode, pgoff_t index) 476{ 477 loff_t i_size; 478 |
479 if (!S_ISREG(inode->i_mode)) 480 return false; |
|
479 if (shmem_huge == SHMEM_HUGE_DENY) 480 return false; 481 if (vma && ((vma->vm_flags & VM_NOHUGEPAGE) || 482 test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags))) 483 return false; 484 if (shmem_huge == SHMEM_HUGE_FORCE) 485 return true; 486 --- 569 unchanged lines hidden (view full) --- 1056 shmem_recalc_inode(inode); 1057 spin_unlock_irq(&info->lock); 1058 } 1059 generic_fillattr(&init_user_ns, inode, stat); 1060 1061 if (shmem_is_huge(NULL, inode, 0)) 1062 stat->blksize = HPAGE_PMD_SIZE; 1063 | 481 if (shmem_huge == SHMEM_HUGE_DENY) 482 return false; 483 if (vma && ((vma->vm_flags & VM_NOHUGEPAGE) || 484 test_bit(MMF_DISABLE_THP, &vma->vm_mm->flags))) 485 return false; 486 if (shmem_huge == SHMEM_HUGE_FORCE) 487 return true; 488 --- 569 unchanged lines hidden (view full) --- 1058 shmem_recalc_inode(inode); 1059 spin_unlock_irq(&info->lock); 1060 } 1061 generic_fillattr(&init_user_ns, inode, stat); 1062 1063 if (shmem_is_huge(NULL, inode, 0)) 1064 stat->blksize = HPAGE_PMD_SIZE; 1065 |
1066 if (request_mask & STATX_BTIME) { 1067 stat->result_mask |= STATX_BTIME; 1068 stat->btime.tv_sec = info->i_crtime.tv_sec; 1069 stat->btime.tv_nsec = info->i_crtime.tv_nsec; 1070 } 1071 |
|
1064 return 0; 1065} 1066 1067static int shmem_setattr(struct user_namespace *mnt_userns, 1068 struct dentry *dentry, struct iattr *attr) 1069{ 1070 struct inode *inode = d_inode(dentry); 1071 struct shmem_inode_info *info = SHMEM_I(inode); --- 777 unchanged lines hidden (view full) --- 1849 * Fast cache lookup and swap lookup did not find it: allocate. 1850 */ 1851 1852 if (vma && userfaultfd_missing(vma)) { 1853 *fault_type = handle_userfault(vmf, VM_UFFD_MISSING); 1854 return 0; 1855 } 1856 | 1072 return 0; 1073} 1074 1075static int shmem_setattr(struct user_namespace *mnt_userns, 1076 struct dentry *dentry, struct iattr *attr) 1077{ 1078 struct inode *inode = d_inode(dentry); 1079 struct shmem_inode_info *info = SHMEM_I(inode); --- 777 unchanged lines hidden (view full) --- 1857 * Fast cache lookup and swap lookup did not find it: allocate. 1858 */ 1859 1860 if (vma && userfaultfd_missing(vma)) { 1861 *fault_type = handle_userfault(vmf, VM_UFFD_MISSING); 1862 return 0; 1863 } 1864 |
1857 /* Never use a huge page for shmem_symlink() */ 1858 if (S_ISLNK(inode->i_mode)) 1859 goto alloc_nohuge; | |
1860 if (!shmem_is_huge(vma, inode, index)) 1861 goto alloc_nohuge; 1862 1863 huge_gfp = vma_thp_gfp_mask(vma); 1864 huge_gfp = limit_gfp_mask(huge_gfp, gfp); 1865 page = shmem_alloc_and_acct_page(huge_gfp, inode, index, true); 1866 if (IS_ERR(page)) { 1867alloc_nohuge: --- 392 unchanged lines hidden (view full) --- 2260 inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); 2261 inode->i_generation = prandom_u32(); 2262 info = SHMEM_I(inode); 2263 memset(info, 0, (char *)inode - (char *)info); 2264 spin_lock_init(&info->lock); 2265 atomic_set(&info->stop_eviction, 0); 2266 info->seals = F_SEAL_SEAL; 2267 info->flags = flags & VM_NORESERVE; | 1865 if (!shmem_is_huge(vma, inode, index)) 1866 goto alloc_nohuge; 1867 1868 huge_gfp = vma_thp_gfp_mask(vma); 1869 huge_gfp = limit_gfp_mask(huge_gfp, gfp); 1870 page = shmem_alloc_and_acct_page(huge_gfp, inode, index, true); 1871 if (IS_ERR(page)) { 1872alloc_nohuge: --- 392 unchanged lines hidden (view full) --- 2265 inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); 2266 inode->i_generation = prandom_u32(); 2267 info = SHMEM_I(inode); 2268 memset(info, 0, (char *)inode - (char *)info); 2269 spin_lock_init(&info->lock); 2270 atomic_set(&info->stop_eviction, 0); 2271 info->seals = F_SEAL_SEAL; 2272 info->flags = flags & VM_NORESERVE; |
2273 info->i_crtime = inode->i_mtime; |
|
2268 INIT_LIST_HEAD(&info->shrinklist); 2269 INIT_LIST_HEAD(&info->swaplist); 2270 simple_xattrs_init(&info->xattrs); 2271 cache_no_acl(inode); 2272 mapping_set_large_folios(inode->i_mapping); 2273 2274 switch (mode & S_IFMT) { 2275 default: --- 915 unchanged lines hidden (view full) --- 3191static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer, size_t size) 3192{ 3193 struct shmem_inode_info *info = SHMEM_I(d_inode(dentry)); 3194 return simple_xattr_list(d_inode(dentry), &info->xattrs, buffer, size); 3195} 3196#endif /* CONFIG_TMPFS_XATTR */ 3197 3198static const struct inode_operations shmem_short_symlink_operations = { | 2274 INIT_LIST_HEAD(&info->shrinklist); 2275 INIT_LIST_HEAD(&info->swaplist); 2276 simple_xattrs_init(&info->xattrs); 2277 cache_no_acl(inode); 2278 mapping_set_large_folios(inode->i_mapping); 2279 2280 switch (mode & S_IFMT) { 2281 default: --- 915 unchanged lines hidden (view full) --- 3197static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer, size_t size) 3198{ 3199 struct shmem_inode_info *info = SHMEM_I(d_inode(dentry)); 3200 return simple_xattr_list(d_inode(dentry), &info->xattrs, buffer, size); 3201} 3202#endif /* CONFIG_TMPFS_XATTR */ 3203 3204static const struct inode_operations shmem_short_symlink_operations = { |
3205 .getattr = shmem_getattr, |
|
3199 .get_link = simple_get_link, 3200#ifdef CONFIG_TMPFS_XATTR 3201 .listxattr = shmem_listxattr, 3202#endif 3203}; 3204 3205static const struct inode_operations shmem_symlink_inode_operations = { | 3206 .get_link = simple_get_link, 3207#ifdef CONFIG_TMPFS_XATTR 3208 .listxattr = shmem_listxattr, 3209#endif 3210}; 3211 3212static const struct inode_operations shmem_symlink_inode_operations = { |
3213 .getattr = shmem_getattr, |
|
3206 .get_link = shmem_get_link, 3207#ifdef CONFIG_TMPFS_XATTR 3208 .listxattr = shmem_listxattr, 3209#endif 3210}; 3211 3212static struct dentry *shmem_get_parent(struct dentry *child) 3213{ --- 534 unchanged lines hidden (view full) --- 3748static int shmem_error_remove_page(struct address_space *mapping, 3749 struct page *page) 3750{ 3751 return 0; 3752} 3753 3754const struct address_space_operations shmem_aops = { 3755 .writepage = shmem_writepage, | 3214 .get_link = shmem_get_link, 3215#ifdef CONFIG_TMPFS_XATTR 3216 .listxattr = shmem_listxattr, 3217#endif 3218}; 3219 3220static struct dentry *shmem_get_parent(struct dentry *child) 3221{ --- 534 unchanged lines hidden (view full) --- 3756static int shmem_error_remove_page(struct address_space *mapping, 3757 struct page *page) 3758{ 3759 return 0; 3760} 3761 3762const struct address_space_operations shmem_aops = { 3763 .writepage = shmem_writepage, |
3756 .dirty_folio = noop_dirty_folio, | 3764 .set_page_dirty = __set_page_dirty_no_writeback, |
3757#ifdef CONFIG_TMPFS 3758 .write_begin = shmem_write_begin, 3759 .write_end = shmem_write_end, 3760#endif 3761#ifdef CONFIG_MIGRATION 3762 .migratepage = migrate_page, 3763#endif 3764 .error_remove_page = shmem_error_remove_page, --- 20 unchanged lines hidden (view full) --- 3785#ifdef CONFIG_TMPFS_XATTR 3786 .listxattr = shmem_listxattr, 3787 .set_acl = simple_set_acl, 3788#endif 3789}; 3790 3791static const struct inode_operations shmem_dir_inode_operations = { 3792#ifdef CONFIG_TMPFS | 3765#ifdef CONFIG_TMPFS 3766 .write_begin = shmem_write_begin, 3767 .write_end = shmem_write_end, 3768#endif 3769#ifdef CONFIG_MIGRATION 3770 .migratepage = migrate_page, 3771#endif 3772 .error_remove_page = shmem_error_remove_page, --- 20 unchanged lines hidden (view full) --- 3793#ifdef CONFIG_TMPFS_XATTR 3794 .listxattr = shmem_listxattr, 3795 .set_acl = simple_set_acl, 3796#endif 3797}; 3798 3799static const struct inode_operations shmem_dir_inode_operations = { 3800#ifdef CONFIG_TMPFS |
3801 .getattr = shmem_getattr, |
|
3793 .create = shmem_create, 3794 .lookup = simple_lookup, 3795 .link = shmem_link, 3796 .unlink = shmem_unlink, 3797 .symlink = shmem_symlink, 3798 .mkdir = shmem_mkdir, 3799 .rmdir = shmem_rmdir, 3800 .mknod = shmem_mknod, --- 5 unchanged lines hidden (view full) --- 3806#endif 3807#ifdef CONFIG_TMPFS_POSIX_ACL 3808 .setattr = shmem_setattr, 3809 .set_acl = simple_set_acl, 3810#endif 3811}; 3812 3813static const struct inode_operations shmem_special_inode_operations = { | 3802 .create = shmem_create, 3803 .lookup = simple_lookup, 3804 .link = shmem_link, 3805 .unlink = shmem_unlink, 3806 .symlink = shmem_symlink, 3807 .mkdir = shmem_mkdir, 3808 .rmdir = shmem_rmdir, 3809 .mknod = shmem_mknod, --- 5 unchanged lines hidden (view full) --- 3815#endif 3816#ifdef CONFIG_TMPFS_POSIX_ACL 3817 .setattr = shmem_setattr, 3818 .set_acl = simple_set_acl, 3819#endif 3820}; 3821 3822static const struct inode_operations shmem_special_inode_operations = { |
3823 .getattr = shmem_getattr, |
|
3814#ifdef CONFIG_TMPFS_XATTR 3815 .listxattr = shmem_listxattr, 3816#endif 3817#ifdef CONFIG_TMPFS_POSIX_ACL 3818 .setattr = shmem_setattr, 3819 .set_acl = simple_set_acl, 3820#endif 3821}; --- 366 unchanged lines hidden --- | 3824#ifdef CONFIG_TMPFS_XATTR 3825 .listxattr = shmem_listxattr, 3826#endif 3827#ifdef CONFIG_TMPFS_POSIX_ACL 3828 .setattr = shmem_setattr, 3829 .set_acl = simple_set_acl, 3830#endif 3831}; --- 366 unchanged lines hidden --- |