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