OK6410A 开发板 (八) 106 linux-5.11 OK6410A tmpfs 文件系统

tmpfs 是 内存文件系统(不对应磁盘文件),却有 page cache
tmpfs 和 shmem  有什么关系

CONFIG_SHMEM 是 CONFIG_TMPFS 的基础,当 CONFIG_SHMEM 选择了 , CONFIG_TMPFS 才可以选
CONFIG_TMPFS 是 CONFIG_SHMEM 的前端,CONFIG_TMPFS呈现给用户空间的接口
CONFIG_TMPFS 和 "tmpfs" 是 两个东西,tmpfs 不必依赖 CONFIG_TMPFS  而 存在.
CONFIG_TMPFS 只有 在 CONFIG_SHMEM 存在时才存在,"tmpfs" 可以 在 CONFIG_SHMEM 不存在时而存在
"tmpfs" 一定要实现,可简单可复杂,总共有三种配置
	CONFIG_SHMEM=n & CONFIG_TMPFS=n
	CONFIG_SHMEM=y & CONFIG_TMPFS=n
	CONFIG_SHMEM=y & CONFIG_TMPFS=y


  | CONFIG_TMPFS:                                                                                                                                         |   
  |                                                                                                                                                       |   
  | Tmpfs is a file system which keeps all files in virtual memory.                                                                                       |   
  |                                                                                                                                                       |   
  | Everything in tmpfs is temporary in the sense that no files will be                                                                                   |   
  | created on your hard drive. The files live in memory and swap                                                                                         |   
  | space. If you unmount a tmpfs instance, everything stored therein is                                                                                  |   
  | lost.                                                                                                                                                 |   
  |                                                                                                                                                       |   
  | See <file:Documentation/filesystems/tmpfs.rst> for details.                                                                                           |   
  |                                                                                                                                                       |   
  | Symbol: TMPFS [=y]                                                                                                                                    |   
  | Type  : bool                                                                                                                                          |   
  | Defined at fs/Kconfig:158                                                                                                                             |   
  |   Prompt: Tmpfs virtual memory file system support (former shm fs)                                                                                    |   
  |   Depends on: SHMEM [=y]                                                                                                                              |   
  |   Location:                                                                                                                                           |   
  |     -> File systems                                                                                                                                   |   
  |       -> Pseudo filesystems 


  | CONFIG_SHMEM:                                                                                                                                         |   
  |                                                                                                                                                       |   
  | The shmem is an internal filesystem used to manage shared memory.                                                                                     |   
  | It is backed by swap and manages resource limits. It is also exported                                                                                 |   
  | to userspace as tmpfs if TMPFS is enabled. Disabling this                                                                                             |   
  | option replaces shmem and tmpfs with the much simpler ramfs code,                                                                                     |   
  | which may be appropriate on small systems without swap.                                                                                               |   
  |                                                                                                                                                       |   
  | Symbol: SHMEM [=y]                                                                                                                                    |   
  | Type  : bool                                                                                                                                          |   
  | Defined at init/Kconfig:1581                                                                                                                          |   
  |   Prompt: Use full shmem filesystem                                                                                                                   |   
  |   Depends on: MMU [=y]                                                                                                                                |   
  |   Visible if: MMU [=y] && EXPERT [=y]                                                                                                                 |   
  |   Location:                                                                                                                                           |   
  |     -> General setup                                                                                                                                  |   
  |       -> Configure standard kernel features (expert users) (EXPERT [=y])


Documentation/translations/zh_CN/filesystems/tmpfs.rst

tmpfs具有以下用途:

1) 内核总有一个无法看到的内部挂载,用于共享匿名映射和SYSV共享内存。

   挂载不依赖于CONFIG_TMPFS。如果CONFIG_TMPFS未设置,tmpfs对用户不可见。
   但是内部机制始终存在。

2) glibc 2.2及更高版本期望将tmpfs挂载在/dev/shm上以用于POSIX共享内存
   (shm_open,shm_unlink)。添加内容到/etc/fstab应注意如下:

 tmpfs /dev/shm tmpfs defaults 0 0

   使用时需要记住创建挂载tmpfs的目录。

   SYSV共享内存无需挂载,内部已默认支持。(2.3内核版本中,必须挂载
   tmpfs的前身(shm fs)才能使用SYSV共享内存)

// 在 不定义 CONFIG_TMPFS,不定义 CONFIG_SHMEM 的时候,不支持挂载,可以支持 共享匿名映射和SYSV共享内存,不支持 posix共享内存
// 在 不定义 CONFIG_TMPFS ,定义 CONFIG_SHMEM 的时候,不支持挂载,可以支持 共享匿名映射和SYSV共享内存,不支持 posix共享内存
// 在 定义 CONFIG_TMPFS  的时候 , 支持挂载, 必须挂载了才支持 posix共享内存 . 不管挂不挂载 都支持 共享匿名映射和SYSV共享内存

在这里插入图片描述

mm/shmem.c

shmem.c 一定会被编入内核
shmem.c 分为两种实现
	1. 没有定义 CONFIG_SHMEM
	2. 定义了   CONFIG_SHMEM
两种实现(其实为三种)
  • 没有定义 CONFIG_SHMEM
	没定义 CONFIG_SHMEM

	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,
		.fs_flags	= FS_USERNS_MOUNT,
	};

	#define shmem_file_operations           ramfs_file_operations
	const struct file_operations ramfs_file_operations = {                              
	    .read_iter  = generic_file_read_iter,                                           
	    .write_iter = generic_file_write_iter,                                          
	    .mmap       = generic_file_mmap,                                                
	    .fsync      = noop_fsync,                                                       
	    .splice_read    = generic_file_splice_read,                                     
	    .splice_write   = iter_file_splice_write,                                       
	    .llseek     = generic_file_llseek,                                              
	    .get_unmapped_area  = ramfs_mmu_get_unmapped_area,                              
	};
  • 定义了 CONFIG_SHMEM
// 这里包含了 CONFIG_SHMEM=n 和 CONFIG_SHMEM=y 的情况
	static struct file_system_type shmem_fs_type = {
		.owner		= THIS_MODULE,
		.name		= "tmpfs",
		.init_fs_context = shmem_init_fs_context,
	#ifdef CONFIG_TMPFS
		.parameters	= shmem_fs_parameters,
	#endif
		.kill_sb	= kill_litter_super,
		.fs_flags	= FS_USERNS_MOUNT | FS_THP_SUPPORT,
	};

static const struct file_operations shmem_file_operations = {                    
    .mmap       = shmem_mmap,                                                        
    .get_unmapped_area = shmem_get_unmapped_area,                                    
#ifdef CONFIG_TMPFS                                                                  
    .llseek     = shmem_file_llseek,                                                 
    .read_iter  = shmem_file_read_iter,                                              
    .write_iter = generic_file_write_iter,                                           
    .fsync      = noop_fsync,                                                        
    .splice_read    = generic_file_splice_read,                                      
    .splice_write   = iter_file_splice_write,                                        
    .fallocate  = shmem_fallocate,                                                   
#endif                                                                               
}; 
  • tmpfs 的 三种配置
tmpfs 共三个配置,不管怎么配置,都提供tmpfs

CONFIG_SHMEM=n & CONFIG_TMPFS=n
CONFIG_SHMEM=y & CONFIG_TMPFS=n
CONFIG_SHMEM=y & CONFIG_TMPFS=y


====================================================================================
三种配置有一组共用的函数和结构变量,我们以此为base讨论问题
▼ variables
   -shm_mnt

▼ functions
   -__shmem_file_setup(struct vfsmount *mnt, const char *name, loff_t size, unsigned long flags, unsigned int i_flags)
    shmem_file_setup(const char *name, loff_t size, unsigned long flags)
    shmem_file_setup_with_mnt(struct vfsmount *mnt, const char *name, loff_t size, unsigned long flags)
    shmem_kernel_file_setup(const char *name, loff_t size, unsigned long flags)
    shmem_read_mapping_page_gfp(struct address_space *mapping, pgoff_t index, gfp_t gfp)
    shmem_zero_setup(struct vm_area_struct *vma)


====================================================================================
CONFIG_SHMEM=n & CONFIG_TMPFS=n , tmpfs 多提供了 

▼ macros
   -shmem_acct_size
   -shmem_file_operations
   -shmem_get_inode
   -shmem_unacct_size
   -shmem_vm_ops
▼ variables
    -shmem_fs_type
     shmem_truncate_range
▼ functions
     shmem_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
     shmem_init(void)
     shmem_lock(struct file *file, int lock, struct user_struct *user)
     shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
     shmem_unlock_mapping(struct address_space *mapping)
     shmem_unuse(unsigned int type, bool frontswap, unsigned long *fs_pages_to_unuse)

====================================================================================
CONFIG_SHMEM=y & CONFIG_TMPFS=n, tmpfs 多提供了 



> ▼ macros
>    -BLOCKS_PER_PAGE
>    -BOGO_DIRENT_SIZE
>    -SHMEM_HUGE_ADVISE
>    -SHMEM_HUGE_ALWAYS
>    -SHMEM_HUGE_DENY
>    -SHMEM_HUGE_FORCE
>    -SHMEM_HUGE_NEVER
>    -SHMEM_HUGE_WITHIN_SIZE
>    -SHMEM_INO_BATCH
>    -SHMEM_SEEN_BLOCKS
>    -SHMEM_SEEN_HUGE
>    -SHMEM_SEEN_INODES
>    -SHMEM_SEEN_INUMS
>    -SHORT_SYMLINK_LEN
>    -VM_ACCT
>    -shmem_huge
>    -vm_policy
>
> ▼ prototypes
>    -DEFINE_MUTEX
>    -LIST_HEAD
>    -shmem_getpage_gfp(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, struct vm_fault *vmf, vm_fault_t *fault_type)
>    -shmem_replace_page(struct page **pagep, gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_should_replace_page(struct page *page, gfp_t gfp)
>    -shmem_swapin_page(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, vm_fault_t *fault_type)
>
>-shmem_falloc : struct
>     [members]
>    +next
>    +nr_falloced
>    +nr_unswapped
>    +start
>    +waitq
>
>-shmem_options : struct
>     [members]
>    +blocks
>    +full_inums
>    +gid
>    +huge
>    +inodes
>    +mode
>    +mpol
>    +seen
>    +uid

▼ variables
>    -__read_mostly
3a51,58
>     shmem_aops
>     shmem_aops
>     shmem_aops
>    -shmem_dir_inode_operations
>    -shmem_dir_inode_operations
>     shmem_enabled_attr
>    -shmem_file_operations
>    -shmem_file_operations
5a61,68
>    -shmem_fs_context_ops
>    -shmem_fs_type
>    -shmem_fs_type
>    -shmem_inode_cachep
>    -shmem_inode_operations
>    -shmem_inode_operations
>    -shmem_ops
>    -shmem_ops
6a70,74
>    -shmem_special_inode_operations
>    -shmem_special_inode_operations
>     shmem_truncate_range
>    -shmem_vm_ops
>    -shmem_vm_ops

▼ functions
8a77
>    -SHMEM_SB(struct super_block *sb)
9a79,95
>    -is_huge_enabled(struct shmem_sb_info *sbinfo)
>    -shmem_acct_block(unsigned long flags, long pages)
>    -shmem_acct_size(unsigned long flags, loff_t size)
>    -shmem_add_to_page_cache(struct page *page, struct address_space *mapping, pgoff_t index, void *expected, gfp_t gfp, struct mm_struct *charge_mm)
>    -shmem_alloc_and_acct_page(gfp_t gfp, struct inode *inode, pgoff_t index, bool huge)
>    -shmem_alloc_hugepage(gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_alloc_inode(struct super_block *sb)
>    -shmem_alloc_page(gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>     shmem_charge(struct inode *inode, long pages)
>    -shmem_confirm_swap(struct address_space *mapping, pgoff_t index, swp_entry_t swap)
>    -shmem_delete_from_page_cache(struct page *page, void *radswap)
>    -shmem_destroy_inode(struct inode *inode)
>    -shmem_destroy_inodecache(void)
>    -shmem_enabled_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>    -shmem_enabled_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count)
>    -shmem_evict_inode(struct inode *inode)
>    -shmem_fault(struct vm_fault *vmf)
11a98,119
>    -shmem_fill_super(struct super_block *sb, struct fs_context *fc)
>    -shmem_find_swap_entries(struct address_space *mapping, pgoff_t start, unsigned int nr_entries, struct page **entries, pgoff_t *indices, unsigned int type, bool frontswap)
>    -shmem_format_huge(int huge)
>    -shmem_free_fc(struct fs_context *fc)
>    -shmem_free_in_core_inode(struct inode *inode)
>    -shmem_free_inode(struct super_block *sb)
>    -shmem_free_swap(struct address_space *mapping, pgoff_t index, void *radswap)
>    -shmem_get_inode(struct super_block *sb, const struct inode *dir, umode_t mode, dev_t dev, unsigned long flags)
>    -shmem_get_policy(struct vm_area_struct *vma, unsigned long addr)
>    -shmem_get_sbmpol(struct shmem_sb_info *sbinfo)
>    -shmem_get_tree(struct fs_context *fc)
>     shmem_get_unmapped_area(struct file *file, unsigned long uaddr, unsigned long len, unsigned long pgoff, unsigned long flags)
>    -shmem_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags)
>     shmem_getpage(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp)
>    -shmem_getpage_gfp(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, struct vm_fault *vmf, vm_fault_t *fault_type)
>     shmem_huge_enabled(struct vm_area_struct *vma)
>     shmem_init(void)
>     shmem_init_fs_context(struct fs_context *fc)
>    -shmem_init_inode(void *foo)
>    -shmem_init_inodecache(void)
>    -shmem_inode_acct_block(struct inode *inode, long pages)
>    -shmem_inode_unacct_blocks(struct inode *inode, long pages)
12a121,132
>     shmem_lock(struct file *file, int lock, struct user_struct *user)
>     shmem_mcopy_atomic_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, struct vm_area_struct *dst_vma, unsigned long dst_addr, unsigned long src_addr, struct page **pagep)
>    -shmem_mfill_atomic_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, struct vm_area_struct *dst_vma, unsigned long dst_addr, unsigned long src_addr, bool zeropage, struct page **pagep)
>     shmem_mfill_zeropage_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, struct vm_area_struct *dst_vma, unsigned long dst_addr)
>    -shmem_mmap(struct file *file, struct vm_area_struct *vma)
>    -shmem_parse_huge(const char *str)
>     shmem_partial_swap_usage(struct address_space *mapping, pgoff_t start, pgoff_t end)
>    -shmem_pseudo_vma_destroy(struct vm_area_struct *vma)
>    -shmem_pseudo_vma_init(struct vm_area_struct *vma, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_punch_compound(struct page *page, pgoff_t start, pgoff_t end)
>    -shmem_put_super(struct super_block *sb)
>    -shmem_reacct_size(unsigned long flags, loff_t oldsize, loff_t newsize)
13a134,158
>    -shmem_recalc_inode(struct inode *inode)
>    -shmem_replace_entry(struct address_space *mapping, pgoff_t index, void *expected, void *replacement)
>    -shmem_replace_page(struct page **pagep, gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_reserve_inode(struct super_block *sb, ino_t *inop)
>    -shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *mpol)
>    -shmem_setattr(struct dentry *dentry, struct iattr *attr)
>    -shmem_should_replace_page(struct page *page, gfp_t gfp)
>    -shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
>     shmem_swap_usage(struct vm_area_struct *vma)
>    -shmem_swapin(swp_entry_t swap, gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_swapin_page(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, vm_fault_t *fault_type)
>     shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
>    -shmem_unacct_blocks(unsigned long flags, long pages)
>    -shmem_unacct_size(unsigned long flags, loff_t size)
>     shmem_uncharge(struct inode *inode, long pages)
>    -shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, bool unfalloc)
>     shmem_unlock_mapping(struct address_space *mapping)
>     shmem_unuse(unsigned int type, bool frontswap, unsigned long *fs_pages_to_unuse)
>    -shmem_unuse_inode(struct inode *inode, unsigned int type, bool frontswap, unsigned long *fs_pages_to_unuse)
>    -shmem_unuse_swap_entries(struct inode *inode, struct pagevec pvec, pgoff_t *indices)
>    -shmem_unused_huge_count(struct super_block *sb, struct shrink_control *sc)
>    -shmem_unused_huge_scan(struct super_block *sb, struct shrink_control *sc)
>    -shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, struct shrink_control *sc, unsigned long nr_to_split)
>    -shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, struct shrink_control *sc, unsigned long nr_to_split)
>    -shmem_writepage(struct page *page, struct writeback_control *wbc)
14a160,161
>    -synchronous_wake_function(wait_queue_entry_t *wait, unsigned mode, int sync, void *key)
>     vma_is_shmem(struct vm_area_struct *vma)


====================================================================================
CONFIG_SHMEM=y & CONFIG_TMPFS=y, tmpfs 多提供了 


0a1,68
> " Press <F1>, ? for help
> 
> ▼ macros
>    -BLOCKS_PER_PAGE
>    -BOGO_DIRENT_SIZE
>    -SHMEM_HUGE_ADVISE
>    -SHMEM_HUGE_ALWAYS
>    -SHMEM_HUGE_DENY
>    -SHMEM_HUGE_FORCE
>    -SHMEM_HUGE_NEVER
>    -SHMEM_HUGE_WITHIN_SIZE
>    -SHMEM_INO_BATCH
>    -SHMEM_SEEN_BLOCKS
>    -SHMEM_SEEN_HUGE
>    -SHMEM_SEEN_INODES
>    -SHMEM_SEEN_INUMS
>    -SHORT_SYMLINK_LEN
>    -VM_ACCT
>    -shmem_acct_size
>    -shmem_file_operations
>    -shmem_get_inode
>    -shmem_huge
>    -shmem_initxattrs
>    -shmem_unacct_size
>    -shmem_vm_ops
>    -vm_policy
> 
> ▼ prototypes
>    -DEFINE_MUTEX
>    -LIST_HEAD
>    -shmem_getpage_gfp(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, struct vm_fault *vmf, vm_fault_t *fault_type)
>    -shmem_initxattrs(struct inode *, const struct xattr *, void *)
>    -shmem_replace_page(struct page **pagep, gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_should_replace_page(struct page *page, gfp_t gfp)
>    -shmem_swapin_page(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, vm_fault_t *fault_type)
> 
>-shmem_param : enum
>     [enumerators]
>    -Opt_gid
>    -Opt_huge
>    -Opt_inode32
>    -Opt_inode64
>    -Opt_mode
>    -Opt_mpol
>    -Opt_nr_blocks
>    -Opt_nr_inodes
>    -Opt_size
>    -Opt_uid
> 
>-shmem_falloc : struct
>     [members]
>    +next
>    +nr_falloced
>    +nr_unswapped
>    +start
>    +waitq
> 
>-shmem_options : struct
>     [members]
>    +blocks
>    +full_inums
>    +gid
>    +huge
>    +inodes
>    +mode
>    +mpol
>    +seen
>    +uid
▼ variables
2a71
>    -__read_mostly
3a73,81
>     shmem_aops
>     shmem_aops
>     shmem_aops
>    -shmem_dir_inode_operations
>    -shmem_dir_inode_operations
>     shmem_enabled_attr
>    -shmem_export_ops
>    -shmem_file_operations
>    -shmem_file_operations
5a84,94
>    -shmem_fs_context_ops
>     shmem_fs_parameters
>    -shmem_fs_type
>    -shmem_fs_type
>    -shmem_fs_type
>    -shmem_inode_cachep
>    -shmem_inode_operations
>    -shmem_inode_operations
>    -shmem_ops
>    -shmem_ops
>    -shmem_param_enums_huge
6a96,108
>    -shmem_security_xattr_handler
>    -shmem_short_symlink_operations
>    -shmem_short_symlink_operations
>    -shmem_special_inode_operations
>    -shmem_special_inode_operations
>    -shmem_symlink_inode_operations
>    -shmem_symlink_inode_operations
>     shmem_truncate_range
>     shmem_truncate_range
>    -shmem_trusted_xattr_handler
>    -shmem_vm_ops
>    -shmem_vm_ops
>    -shmem_xattr_handlers
▼ functions
8a111
>    -SHMEM_SB(struct super_block *sb)
9a113,138
>    -is_huge_enabled(struct shmem_sb_info *sbinfo)
>    -shmem_acct_block(unsigned long flags, long pages)
>    -shmem_acct_size(unsigned long flags, loff_t size)
>    -shmem_add_to_page_cache(struct page *page, struct address_space *mapping, pgoff_t index, void *expected, gfp_t gfp, struct mm_struct *charge_mm)
>    -shmem_alloc_and_acct_page(gfp_t gfp, struct inode *inode, pgoff_t index, bool huge)
>    -shmem_alloc_hugepage(gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_alloc_inode(struct super_block *sb)
>    -shmem_alloc_page(gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>     shmem_charge(struct inode *inode, long pages)
>    -shmem_confirm_swap(struct address_space *mapping, pgoff_t index, swp_entry_t swap)
>    -shmem_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl)
>    -shmem_default_max_blocks(void)
>    -shmem_default_max_inodes(void)
>    -shmem_delete_from_page_cache(struct page *page, void *radswap)
>    -shmem_destroy_inode(struct inode *inode)
>    -shmem_destroy_inodecache(void)
>    -shmem_enabled_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>    -shmem_enabled_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count)
>    -shmem_encode_fh(struct inode *inode, __u32 *fh, int *len, struct inode *parent)
>    -shmem_evict_inode(struct inode *inode)
>    -shmem_exchange(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry)
>    -shmem_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
>    -shmem_fault(struct vm_fault *vmf)
>    -shmem_fh_to_dentry(struct super_block *sb, struct fid *fid, int fh_len, int fh_type)
>    -shmem_file_llseek(struct file *file, loff_t offset, int whence)
>    -shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
11a141,168
>    -shmem_fill_super(struct super_block *sb, struct fs_context *fc)
>    -shmem_find_alias(struct inode *inode)
>    -shmem_find_swap_entries(struct address_space *mapping, pgoff_t start, unsigned int nr_entries, struct page **entries, pgoff_t *indices, unsigned int type, bool frontswap)
>    -shmem_format_huge(int huge)
>    -shmem_free_fc(struct fs_context *fc)
>    -shmem_free_in_core_inode(struct inode *inode)
>    -shmem_free_inode(struct super_block *sb)
>    -shmem_free_swap(struct address_space *mapping, pgoff_t index, void *radswap)
>    -shmem_get_inode(struct super_block *sb, const struct inode *dir, umode_t mode, dev_t dev, unsigned long flags)
>    -shmem_get_link(struct dentry *dentry, struct inode *inode, struct delayed_call *done)
>    -shmem_get_parent(struct dentry *child)
>    -shmem_get_policy(struct vm_area_struct *vma, unsigned long addr)
>    -shmem_get_sbmpol(struct shmem_sb_info *sbinfo)
>    -shmem_get_tree(struct fs_context *fc)
>     shmem_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
>     shmem_get_unmapped_area(struct file *file, unsigned long uaddr, unsigned long len, unsigned long pgoff, unsigned long flags)
>    -shmem_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags)
>     shmem_getpage(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp)
>    -shmem_getpage_gfp(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, struct vm_fault *vmf, vm_fault_t *fault_type)
>     shmem_huge_enabled(struct vm_area_struct *vma)
>     shmem_init(void)
>     shmem_init(void)
>     shmem_init_fs_context(struct fs_context *fc)
>    -shmem_init_inode(void *foo)
>    -shmem_init_inodecache(void)
>    -shmem_initxattrs(struct inode *inode, const struct xattr *xattr_array, void *fs_info)
>    -shmem_inode_acct_block(struct inode *inode, long pages)
>    -shmem_inode_unacct_blocks(struct inode *inode, long pages)
12a170,190
>    -shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
>    -shmem_listxattr(struct dentry *dentry, char *buffer, size_t size)
>     shmem_lock(struct file *file, int lock, struct user_struct *user)
>     shmem_lock(struct file *file, int lock, struct user_struct *user)
>    -shmem_match(struct inode *ino, void *vfh)
>     shmem_mcopy_atomic_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, struct vm_area_struct *dst_vma, unsigned long dst_addr, unsigned long src_addr, struct page **pagep)
>    -shmem_mfill_atomic_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, struct vm_area_struct *dst_vma, unsigned long dst_addr, unsigned long src_addr, bool zeropage, struct page **pagep)
>     shmem_mfill_zeropage_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, struct vm_area_struct *dst_vma, unsigned long dst_addr)
>    -shmem_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>    -shmem_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
>    -shmem_mmap(struct file *file, struct vm_area_struct *vma)
>    -shmem_parse_huge(const char *str)
>    -shmem_parse_one(struct fs_context *fc, struct fs_parameter *param)
>    -shmem_parse_options(struct fs_context *fc, void *data)
>     shmem_partial_swap_usage(struct address_space *mapping, pgoff_t start, pgoff_t end)
>    -shmem_pseudo_vma_destroy(struct vm_area_struct *vma)
>    -shmem_pseudo_vma_init(struct vm_area_struct *vma, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_punch_compound(struct page *page, pgoff_t start, pgoff_t end)
>    -shmem_put_link(void *arg)
>    -shmem_put_super(struct super_block *sb)
>    -shmem_reacct_size(unsigned long flags, loff_t oldsize, loff_t newsize)
13a192,233
>    -shmem_recalc_inode(struct inode *inode)
>    -shmem_reconfigure(struct fs_context *fc)
>    -shmem_rename2(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags)
>    -shmem_replace_entry(struct address_space *mapping, pgoff_t index, void *expected, void *replacement)
>    -shmem_replace_page(struct page **pagep, gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_reserve_inode(struct super_block *sb, ino_t *inop)
>    -shmem_rmdir(struct inode *dir, struct dentry *dentry)
>    -shmem_seek_hole_data(struct address_space *mapping, pgoff_t index, pgoff_t end, int whence)
>    -shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *mpol)
>    -shmem_setattr(struct dentry *dentry, struct iattr *attr)
>    -shmem_should_replace_page(struct page *page, gfp_t gfp)
>    -shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
>    -shmem_show_options(struct seq_file *seq, struct dentry *root)
>    -shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
>     shmem_swap_usage(struct vm_area_struct *vma)
>    -shmem_swapin(swp_entry_t swap, gfp_t gfp, struct shmem_inode_info *info, pgoff_t index)
>    -shmem_swapin_page(struct inode *inode, pgoff_t index, struct page **pagep, enum sgp_type sgp, gfp_t gfp, struct vm_area_struct *vma, vm_fault_t *fault_type)
>    -shmem_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
>    -shmem_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
>     shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
>     shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
>    -shmem_unacct_blocks(unsigned long flags, long pages)
>    -shmem_unacct_size(unsigned long flags, loff_t size)
>     shmem_uncharge(struct inode *inode, long pages)
>    -shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, bool unfalloc)
>    -shmem_unlink(struct inode *dir, struct dentry *dentry)
>     shmem_unlock_mapping(struct address_space *mapping)
>     shmem_unlock_mapping(struct address_space *mapping)
>     shmem_unuse(unsigned int type, bool frontswap, unsigned long *fs_pages_to_unuse)
>     shmem_unuse(unsigned int type, bool frontswap, unsigned long *fs_pages_to_unuse)
>    -shmem_unuse_inode(struct inode *inode, unsigned int type, bool frontswap, unsigned long *fs_pages_to_unuse)
>    -shmem_unuse_swap_entries(struct inode *inode, struct pagevec pvec, pgoff_t *indices)
>    -shmem_unused_huge_count(struct super_block *sb, struct shrink_control *sc)
>    -shmem_unused_huge_scan(struct super_block *sb, struct shrink_control *sc)
>    -shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, struct shrink_control *sc, unsigned long nr_to_split)
>    -shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, struct shrink_control *sc, unsigned long nr_to_split)
>    -shmem_whiteout(struct inode *old_dir, struct dentry *old_dentry)
>    -shmem_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata)
>    -shmem_write_end(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned copied, struct page *page, void *fsdata)
>    -shmem_writepage(struct page *page, struct writeback_control *wbc)
>    -shmem_xattr_handler_get(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *buffer, size_t size)
>    -shmem_xattr_handler_set(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, const void *value, size_t size, int flags)
14a235,236
>    -synchronous_wake_function(wait_queue_entry_t *wait, unsigned mode, int sync, void *key)
>     vma_is_shmem(struct vm_area_struct *vma)



====================================================================================
"CONFIG_SHMEM=y & CONFIG_TMPFS=y" 相较于 "CONFIG_SHMEM=y & CONFIG_TMPFS=n" 多了

0a1,2
> " Press <F1>, ? for help
> 
16a19,21
>    -shmem_acct_size
>    -shmem_file_operations
>    -shmem_get_inode
17a23,25
>    -shmem_initxattrs
>    -shmem_unacct_size
>    -shmem_vm_ops
23a32
>    -shmem_initxattrs(struct inode *, const struct xattr *, void *)
27a37,49
>-shmem_param : enum
>     [enumerators]
>    -Opt_gid
>    -Opt_huge
>    -Opt_inode32
>    -Opt_inode64
>    -Opt_mode
>    -Opt_mpol
>    -Opt_nr_blocks
>    -Opt_nr_inodes
>    -Opt_size
>    -Opt_uid
> 

▼ variables
56a79
>    -shmem_export_ops
61a85,86
>     shmem_fs_parameters
>    -shmem_fs_type
68a94
>    -shmem_param_enums_huge
69a96,98
>    -shmem_security_xattr_handler
>    -shmem_short_symlink_operations
>    -shmem_short_symlink_operations
71a101,103
>    -shmem_symlink_inode_operations
>    -shmem_symlink_inode_operations
>     shmem_truncate_range
72a105
>    -shmem_trusted_xattr_handler
74a108
>    -shmem_xattr_handlers

▼ functions
88a123,125
>    -shmem_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl)
>    -shmem_default_max_blocks(void)
>    -shmem_default_max_inodes(void)
93a131
>    -shmem_encode_fh(struct inode *inode, __u32 *fh, int *len, struct inode *parent)
94a133,134
>    -shmem_exchange(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry)
>    -shmem_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
95a136,138
>    -shmem_fh_to_dentry(struct super_block *sb, struct fid *fid, int fh_len, int fh_type)
>    -shmem_file_llseek(struct file *file, loff_t offset, int whence)
>    -shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
98a142
>    -shmem_find_alias(struct inode *inode)
105a150,151
>    -shmem_get_link(struct dentry *dentry, struct inode *inode, struct delayed_call *done)
>    -shmem_get_parent(struct dentry *child)
108a155
>     shmem_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
114a162
>     shmem_init(void)
117a166
>    -shmem_initxattrs(struct inode *inode, const struct xattr *xattr_array, void *fs_info)
120a170,172
>    -shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
>    -shmem_listxattr(struct dentry *dentry, char *buffer, size_t size)
>     shmem_lock(struct file *file, int lock, struct user_struct *user)
121a174
>    -shmem_match(struct inode *ino, void *vfh)
124a178,179
>    -shmem_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
>    -shmem_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
126a182,183
>    -shmem_parse_one(struct fs_context *fc, struct fs_parameter *param)
>    -shmem_parse_options(struct fs_context *fc, void *data)
130a188
>    -shmem_put_link(void *arg)
134a193,194
>    -shmem_reconfigure(struct fs_context *fc)
>    -shmem_rename2(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags)
137a198,199
>    -shmem_rmdir(struct inode *dir, struct dentry *dentry)
>    -shmem_seek_hole_data(struct address_space *mapping, pgoff_t index, pgoff_t end, int whence)
141a204,205
>    -shmem_show_options(struct seq_file *seq, struct dentry *root)
>    -shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
144a209,211
>    -shmem_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
>    -shmem_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
>     shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
149a217
>    -shmem_unlink(struct inode *dir, struct dentry *dentry)
150a219,220
>     shmem_unlock_mapping(struct address_space *mapping)
>     shmem_unuse(unsigned int type, bool frontswap, unsigned long *fs_pages_to_unuse)
157a228,230
>    -shmem_whiteout(struct inode *old_dir, struct dentry *old_dentry)
>    -shmem_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata)
>    -shmem_write_end(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned copied, struct page *page, void *fsdata)
158a232,233
>    -shmem_xattr_handler_get(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *buffer, size_t size)
>    -shmem_xattr_handler_set(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, const void *value, size_t size, int flags)


真实文件系统的四个问题
TODO
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值