shmem_fs.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef __SHMEM_FS_H
  2. #define __SHMEM_FS_H
  3. #include <linux/swap.h>
  4. #include <linux/mempolicy.h>
  5. #include <linux/pagemap.h>
  6. #include <linux/percpu_counter.h>
  7. #include <linux/xattr.h>
  8. /* inode in-kernel data */
  9. struct shmem_inode_info {
  10. spinlock_t lock;
  11. unsigned long flags;
  12. unsigned long alloced; /* data pages alloced to file */
  13. union {
  14. unsigned long swapped; /* subtotal assigned to swap */
  15. char *symlink; /* unswappable short symlink */
  16. };
  17. struct shared_policy policy; /* NUMA memory alloc policy */
  18. struct list_head swaplist; /* chain of maybes on swap */
  19. struct simple_xattrs xattrs; /* list of xattrs */
  20. struct inode vfs_inode;
  21. };
  22. struct shmem_sb_info {
  23. unsigned long max_blocks; /* How many blocks are allowed */
  24. struct percpu_counter used_blocks; /* How many are allocated */
  25. unsigned long max_inodes; /* How many inodes are allowed */
  26. unsigned long free_inodes; /* How many are left for allocation */
  27. spinlock_t stat_lock; /* Serialize shmem_sb_info changes */
  28. kuid_t uid; /* Mount uid for root directory */
  29. kgid_t gid; /* Mount gid for root directory */
  30. umode_t mode; /* Mount mode for root directory */
  31. struct mempolicy *mpol; /* default memory policy for mappings */
  32. };
  33. static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
  34. {
  35. return container_of(inode, struct shmem_inode_info, vfs_inode);
  36. }
  37. /*
  38. * Functions in mm/shmem.c called directly from elsewhere:
  39. */
  40. extern int shmem_init(void);
  41. extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
  42. extern struct file *shmem_file_setup(const char *name,
  43. loff_t size, unsigned long flags);
  44. extern int shmem_zero_setup(struct vm_area_struct *);
  45. extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
  46. extern void shmem_unlock_mapping(struct address_space *mapping);
  47. extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
  48. pgoff_t index, gfp_t gfp_mask);
  49. extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
  50. extern int shmem_unuse(swp_entry_t entry, struct page *page);
  51. static inline struct page *shmem_read_mapping_page(
  52. struct address_space *mapping, pgoff_t index)
  53. {
  54. return shmem_read_mapping_page_gfp(mapping, index,
  55. mapping_gfp_mask(mapping));
  56. }
  57. #endif