shmem.c (15520a3f046998e3f57e695743e99b0875e2dae7) | shmem.c (d09e8ca6cb93bb4b97517a18fbbf7eccb0e9ff43) |
---|---|
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. --- 223 unchanged lines hidden (view full) --- 232 233static const struct super_operations shmem_ops; 234const struct address_space_operations shmem_aops; 235static const struct file_operations shmem_file_operations; 236static const struct inode_operations shmem_inode_operations; 237static const struct inode_operations shmem_dir_inode_operations; 238static const struct inode_operations shmem_special_inode_operations; 239static const struct vm_operations_struct shmem_vm_ops; | 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. --- 223 unchanged lines hidden (view full) --- 232 233static const struct super_operations shmem_ops; 234const struct address_space_operations shmem_aops; 235static const struct file_operations shmem_file_operations; 236static const struct inode_operations shmem_inode_operations; 237static const struct inode_operations shmem_dir_inode_operations; 238static const struct inode_operations shmem_special_inode_operations; 239static const struct vm_operations_struct shmem_vm_ops; |
240static const struct vm_operations_struct shmem_anon_vm_ops; |
|
240static struct file_system_type shmem_fs_type; 241 | 241static struct file_system_type shmem_fs_type; 242 |
243bool vma_is_anon_shmem(struct vm_area_struct *vma) 244{ 245 return vma->vm_ops == &shmem_anon_vm_ops; 246} 247 |
|
242bool vma_is_shmem(struct vm_area_struct *vma) 243{ | 248bool vma_is_shmem(struct vm_area_struct *vma) 249{ |
244 return vma->vm_ops == &shmem_vm_ops; | 250 return vma_is_anon_shmem(vma) || vma->vm_ops == &shmem_vm_ops; |
245} 246 247static LIST_HEAD(shmem_swaplist); 248static DEFINE_MUTEX(shmem_swaplist_mutex); 249 250/* 251 * shmem_reserve_inode() performs bookkeeping to reserve a shmem inode, and 252 * produces a novel ino for the newly allocated inode. --- 2005 unchanged lines hidden (view full) --- 2258 retval = 0; 2259 2260out_nomem: 2261 return retval; 2262} 2263 2264static int shmem_mmap(struct file *file, struct vm_area_struct *vma) 2265{ | 251} 252 253static LIST_HEAD(shmem_swaplist); 254static DEFINE_MUTEX(shmem_swaplist_mutex); 255 256/* 257 * shmem_reserve_inode() performs bookkeeping to reserve a shmem inode, and 258 * produces a novel ino for the newly allocated inode. --- 2005 unchanged lines hidden (view full) --- 2264 retval = 0; 2265 2266out_nomem: 2267 return retval; 2268} 2269 2270static int shmem_mmap(struct file *file, struct vm_area_struct *vma) 2271{ |
2266 struct shmem_inode_info *info = SHMEM_I(file_inode(file)); | 2272 struct inode *inode = file_inode(file); 2273 struct shmem_inode_info *info = SHMEM_I(inode); |
2267 int ret; 2268 2269 ret = seal_check_future_write(info->seals, vma); 2270 if (ret) 2271 return ret; 2272 2273 /* arm64 - allow memory tagging on RAM-based files */ 2274 vma->vm_flags |= VM_MTE_ALLOWED; 2275 2276 file_accessed(file); | 2274 int ret; 2275 2276 ret = seal_check_future_write(info->seals, vma); 2277 if (ret) 2278 return ret; 2279 2280 /* arm64 - allow memory tagging on RAM-based files */ 2281 vma->vm_flags |= VM_MTE_ALLOWED; 2282 2283 file_accessed(file); |
2277 vma->vm_ops = &shmem_vm_ops; | 2284 /* This is anonymous shared memory if it is unlinked at the time of mmap */ 2285 if (inode->i_nlink) 2286 vma->vm_ops = &shmem_vm_ops; 2287 else 2288 vma->vm_ops = &shmem_anon_vm_ops; |
2278 return 0; 2279} 2280 2281#ifdef CONFIG_TMPFS_XATTR 2282static int shmem_initxattrs(struct inode *, const struct xattr *, void *); 2283 2284/* 2285 * chattr's fsflags are unrelated to extended attributes, --- 1697 unchanged lines hidden (view full) --- 3983 .fault = shmem_fault, 3984 .map_pages = filemap_map_pages, 3985#ifdef CONFIG_NUMA 3986 .set_policy = shmem_set_policy, 3987 .get_policy = shmem_get_policy, 3988#endif 3989}; 3990 | 2289 return 0; 2290} 2291 2292#ifdef CONFIG_TMPFS_XATTR 2293static int shmem_initxattrs(struct inode *, const struct xattr *, void *); 2294 2295/* 2296 * chattr's fsflags are unrelated to extended attributes, --- 1697 unchanged lines hidden (view full) --- 3994 .fault = shmem_fault, 3995 .map_pages = filemap_map_pages, 3996#ifdef CONFIG_NUMA 3997 .set_policy = shmem_set_policy, 3998 .get_policy = shmem_get_policy, 3999#endif 4000}; 4001 |
4002static const struct vm_operations_struct shmem_anon_vm_ops = { 4003 .fault = shmem_fault, 4004 .map_pages = filemap_map_pages, 4005#ifdef CONFIG_NUMA 4006 .set_policy = shmem_set_policy, 4007 .get_policy = shmem_get_policy, 4008#endif 4009}; 4010 |
|
3991int shmem_init_fs_context(struct fs_context *fc) 3992{ 3993 struct shmem_options *ctx; 3994 3995 ctx = kzalloc(sizeof(struct shmem_options), GFP_KERNEL); 3996 if (!ctx) 3997 return -ENOMEM; 3998 --- 159 unchanged lines hidden (view full) --- 4158 4159void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) 4160{ 4161 truncate_inode_pages_range(inode->i_mapping, lstart, lend); 4162} 4163EXPORT_SYMBOL_GPL(shmem_truncate_range); 4164 4165#define shmem_vm_ops generic_file_vm_ops | 4011int shmem_init_fs_context(struct fs_context *fc) 4012{ 4013 struct shmem_options *ctx; 4014 4015 ctx = kzalloc(sizeof(struct shmem_options), GFP_KERNEL); 4016 if (!ctx) 4017 return -ENOMEM; 4018 --- 159 unchanged lines hidden (view full) --- 4178 4179void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) 4180{ 4181 truncate_inode_pages_range(inode->i_mapping, lstart, lend); 4182} 4183EXPORT_SYMBOL_GPL(shmem_truncate_range); 4184 4185#define shmem_vm_ops generic_file_vm_ops |
4186#define shmem_anon_vm_ops generic_file_vm_ops |
|
4166#define shmem_file_operations ramfs_file_operations 4167#define shmem_get_inode(sb, dir, mode, dev, flags) ramfs_get_inode(sb, dir, mode, dev) 4168#define shmem_acct_size(flags, size) 0 4169#define shmem_unacct_size(flags, size) do {} while (0) 4170 4171#endif /* CONFIG_SHMEM */ 4172 4173/* common code */ --- 89 unchanged lines hidden (view full) --- 4263 */ 4264 file = shmem_kernel_file_setup("dev/zero", size, vma->vm_flags); 4265 if (IS_ERR(file)) 4266 return PTR_ERR(file); 4267 4268 if (vma->vm_file) 4269 fput(vma->vm_file); 4270 vma->vm_file = file; | 4187#define shmem_file_operations ramfs_file_operations 4188#define shmem_get_inode(sb, dir, mode, dev, flags) ramfs_get_inode(sb, dir, mode, dev) 4189#define shmem_acct_size(flags, size) 0 4190#define shmem_unacct_size(flags, size) do {} while (0) 4191 4192#endif /* CONFIG_SHMEM */ 4193 4194/* common code */ --- 89 unchanged lines hidden (view full) --- 4284 */ 4285 file = shmem_kernel_file_setup("dev/zero", size, vma->vm_flags); 4286 if (IS_ERR(file)) 4287 return PTR_ERR(file); 4288 4289 if (vma->vm_file) 4290 fput(vma->vm_file); 4291 vma->vm_file = file; |
4271 vma->vm_ops = &shmem_vm_ops; | 4292 vma->vm_ops = &shmem_anon_vm_ops; |
4272 4273 return 0; 4274} 4275 4276/** 4277 * shmem_read_mapping_page_gfp - read into page cache, using specified page allocation flags. 4278 * @mapping: the page's address_space 4279 * @index: the page index --- 42 unchanged lines hidden --- | 4293 4294 return 0; 4295} 4296 4297/** 4298 * shmem_read_mapping_page_gfp - read into page cache, using specified page allocation flags. 4299 * @mapping: the page's address_space 4300 * @index: the page index --- 42 unchanged lines hidden --- |