shmem_fs.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. /* inode in-kernel data */
  8. #define SHMEM_NR_DIRECT 16
  9. #define SHMEM_SYMLINK_INLINE_LEN (SHMEM_NR_DIRECT * sizeof(swp_entry_t))
  10. struct shmem_inode_info {
  11. spinlock_t lock;
  12. unsigned long flags;
  13. unsigned long alloced; /* data pages alloced to file */
  14. unsigned long swapped; /* subtotal assigned to swap */
  15. unsigned long next_index; /* highest alloced index + 1 */
  16. struct shared_policy policy; /* NUMA memory alloc policy */
  17. struct page *i_indirect; /* top indirect blocks page */
  18. union {
  19. swp_entry_t i_direct[SHMEM_NR_DIRECT]; /* first blocks */
  20. char inline_symlink[SHMEM_SYMLINK_INLINE_LEN];
  21. };
  22. struct list_head swaplist; /* chain of maybes on swap */
  23. struct list_head xattr_list; /* list of shmem_xattr */
  24. struct inode vfs_inode;
  25. };
  26. struct shmem_sb_info {
  27. unsigned long max_blocks; /* How many blocks are allowed */
  28. struct percpu_counter used_blocks; /* How many are allocated */
  29. unsigned long max_inodes; /* How many inodes are allowed */
  30. unsigned long free_inodes; /* How many are left for allocation */
  31. spinlock_t stat_lock; /* Serialize shmem_sb_info changes */
  32. uid_t uid; /* Mount uid for root directory */
  33. gid_t gid; /* Mount gid for root directory */
  34. mode_t mode; /* Mount mode for root directory */
  35. struct mempolicy *mpol; /* default memory policy for mappings */
  36. };
  37. static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
  38. {
  39. return container_of(inode, struct shmem_inode_info, vfs_inode);
  40. }
  41. /*
  42. * Functions in mm/shmem.c called directly from elsewhere:
  43. */
  44. extern int init_tmpfs(void);
  45. extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
  46. extern struct file *shmem_file_setup(const char *name,
  47. loff_t size, unsigned long flags);
  48. extern int shmem_zero_setup(struct vm_area_struct *);
  49. extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
  50. extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping,
  51. pgoff_t index, gfp_t gfp_mask);
  52. extern void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end);
  53. extern int shmem_unuse(swp_entry_t entry, struct page *page);
  54. extern void mem_cgroup_get_shmem_target(struct inode *inode, pgoff_t pgoff,
  55. struct page **pagep, swp_entry_t *ent);
  56. static inline struct page *shmem_read_mapping_page(
  57. struct address_space *mapping, pgoff_t index)
  58. {
  59. return shmem_read_mapping_page_gfp(mapping, index,
  60. mapping_gfp_mask(mapping));
  61. }
  62. #endif