shmem_fs.h 2.3 KB

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