blob: fd83f2584b157b5e76b593344c55f3381f149014 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __SHMEM_FS_H
2#define __SHMEM_FS_H
3
4#include <linux/swap.h>
5#include <linux/mempolicy.h>
6
7/* inode in-kernel data */
8
9#define SHMEM_NR_DIRECT 16
10
11struct shmem_inode_info {
12 spinlock_t lock;
13 unsigned long flags;
14 unsigned long alloced; /* data pages alloced to file */
15 unsigned long swapped; /* subtotal assigned to swap */
16 unsigned long next_index; /* highest alloced index + 1 */
17 struct shared_policy policy; /* NUMA memory alloc policy */
18 struct page *i_indirect; /* top indirect blocks page */
19 swp_entry_t i_direct[SHMEM_NR_DIRECT]; /* first blocks */
20 struct list_head swaplist; /* chain of maybes on swap */
21 struct inode vfs_inode;
Andreas Gruenbacher39f02472006-09-29 02:01:35 -070022#ifdef CONFIG_TMPFS_POSIX_ACL
23 struct posix_acl *i_acl;
24 struct posix_acl *i_default_acl;
25#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070026};
27
28struct shmem_sb_info {
29 unsigned long max_blocks; /* How many blocks are allowed */
30 unsigned long free_blocks; /* How many are left for allocation */
31 unsigned long max_inodes; /* How many inodes are allowed */
32 unsigned long free_inodes; /* How many are left for allocation */
akpm@linux-foundation.org680d7942008-02-08 04:21:48 -080033 spinlock_t stat_lock; /* Serialize shmem_sb_info changes */
34 uid_t uid; /* Mount uid for root directory */
35 gid_t gid; /* Mount gid for root directory */
36 mode_t mode; /* Mount mode for root directory */
Lee Schermerhorn71fe8042008-04-28 02:13:26 -070037 struct mempolicy *mpol; /* default memory policy for mappings */
Linus Torvalds1da177e2005-04-16 15:20:36 -070038};
39
40static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
41{
42 return container_of(inode, struct shmem_inode_info, vfs_inode);
43}
44
Andreas Gruenbacher39f02472006-09-29 02:01:35 -070045#ifdef CONFIG_TMPFS_POSIX_ACL
Al Viroe6305c42008-07-15 21:03:57 -040046int shmem_permission(struct inode *, int);
Andreas Gruenbacher39f02472006-09-29 02:01:35 -070047int shmem_acl_init(struct inode *, struct inode *);
48void shmem_acl_destroy_inode(struct inode *);
49
50extern struct xattr_handler shmem_xattr_acl_access_handler;
51extern struct xattr_handler shmem_xattr_acl_default_handler;
52
53extern struct generic_acl_operations shmem_acl_ops;
54
55#else
56static inline int shmem_acl_init(struct inode *inode, struct inode *dir)
57{
58 return 0;
59}
60static inline void shmem_acl_destroy_inode(struct inode *inode)
61{
62}
63#endif /* CONFIG_TMPFS_POSIX_ACL */
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065#endif