diff options
Diffstat (limited to 'include/linux/quotaops.h')
-rw-r--r-- | include/linux/quotaops.h | 137 |
1 files changed, 106 insertions, 31 deletions
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 5110201a4159..f86702053853 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
@@ -37,11 +37,11 @@ extern int dquot_release(struct dquot *dquot); | |||
37 | extern int dquot_commit_info(struct super_block *sb, int type); | 37 | extern int dquot_commit_info(struct super_block *sb, int type); |
38 | extern int dquot_mark_dquot_dirty(struct dquot *dquot); | 38 | extern int dquot_mark_dquot_dirty(struct dquot *dquot); |
39 | 39 | ||
40 | extern int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path); | 40 | extern int vfs_quota_on(struct super_block *sb, int type, int format_id, |
41 | char *path, int remount); | ||
41 | extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name, | 42 | extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name, |
42 | int format_id, int type); | 43 | int format_id, int type); |
43 | extern int vfs_quota_off(struct super_block *sb, int type); | 44 | extern int vfs_quota_off(struct super_block *sb, int type, int remount); |
44 | #define vfs_quota_off_mount(sb, type) vfs_quota_off(sb, type) | ||
45 | extern int vfs_quota_sync(struct super_block *sb, int type); | 45 | extern int vfs_quota_sync(struct super_block *sb, int type); |
46 | extern int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 46 | extern int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
47 | extern int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); | 47 | extern int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); |
@@ -59,7 +59,7 @@ extern struct quotactl_ops vfs_quotactl_ops; | |||
59 | 59 | ||
60 | /* It is better to call this function outside of any transaction as it might | 60 | /* It is better to call this function outside of any transaction as it might |
61 | * need a lot of space in journal for dquot structure allocation. */ | 61 | * need a lot of space in journal for dquot structure allocation. */ |
62 | static __inline__ void DQUOT_INIT(struct inode *inode) | 62 | static inline void DQUOT_INIT(struct inode *inode) |
63 | { | 63 | { |
64 | BUG_ON(!inode->i_sb); | 64 | BUG_ON(!inode->i_sb); |
65 | if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) | 65 | if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) |
@@ -67,7 +67,7 @@ static __inline__ void DQUOT_INIT(struct inode *inode) | |||
67 | } | 67 | } |
68 | 68 | ||
69 | /* The same as with DQUOT_INIT */ | 69 | /* The same as with DQUOT_INIT */ |
70 | static __inline__ void DQUOT_DROP(struct inode *inode) | 70 | static inline void DQUOT_DROP(struct inode *inode) |
71 | { | 71 | { |
72 | /* Here we can get arbitrary inode from clear_inode() so we have | 72 | /* Here we can get arbitrary inode from clear_inode() so we have |
73 | * to be careful. OTOH we don't need locking as quota operations | 73 | * to be careful. OTOH we don't need locking as quota operations |
@@ -90,7 +90,7 @@ static __inline__ void DQUOT_DROP(struct inode *inode) | |||
90 | 90 | ||
91 | /* The following allocation/freeing/transfer functions *must* be called inside | 91 | /* The following allocation/freeing/transfer functions *must* be called inside |
92 | * a transaction (deadlocks possible otherwise) */ | 92 | * a transaction (deadlocks possible otherwise) */ |
93 | static __inline__ int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) | 93 | static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) |
94 | { | 94 | { |
95 | if (sb_any_quota_enabled(inode->i_sb)) { | 95 | if (sb_any_quota_enabled(inode->i_sb)) { |
96 | /* Used space is updated in alloc_space() */ | 96 | /* Used space is updated in alloc_space() */ |
@@ -102,7 +102,7 @@ static __inline__ int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t | |||
102 | return 0; | 102 | return 0; |
103 | } | 103 | } |
104 | 104 | ||
105 | static __inline__ int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr) | 105 | static inline int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr) |
106 | { | 106 | { |
107 | int ret; | 107 | int ret; |
108 | if (!(ret = DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr))) | 108 | if (!(ret = DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr))) |
@@ -110,7 +110,7 @@ static __inline__ int DQUOT_PREALLOC_SPACE(struct inode *inode, qsize_t nr) | |||
110 | return ret; | 110 | return ret; |
111 | } | 111 | } |
112 | 112 | ||
113 | static __inline__ int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) | 113 | static inline int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) |
114 | { | 114 | { |
115 | if (sb_any_quota_enabled(inode->i_sb)) { | 115 | if (sb_any_quota_enabled(inode->i_sb)) { |
116 | /* Used space is updated in alloc_space() */ | 116 | /* Used space is updated in alloc_space() */ |
@@ -122,7 +122,7 @@ static __inline__ int DQUOT_ALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) | |||
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | 124 | ||
125 | static __inline__ int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr) | 125 | static inline int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr) |
126 | { | 126 | { |
127 | int ret; | 127 | int ret; |
128 | if (!(ret = DQUOT_ALLOC_SPACE_NODIRTY(inode, nr))) | 128 | if (!(ret = DQUOT_ALLOC_SPACE_NODIRTY(inode, nr))) |
@@ -130,7 +130,7 @@ static __inline__ int DQUOT_ALLOC_SPACE(struct inode *inode, qsize_t nr) | |||
130 | return ret; | 130 | return ret; |
131 | } | 131 | } |
132 | 132 | ||
133 | static __inline__ int DQUOT_ALLOC_INODE(struct inode *inode) | 133 | static inline int DQUOT_ALLOC_INODE(struct inode *inode) |
134 | { | 134 | { |
135 | if (sb_any_quota_enabled(inode->i_sb)) { | 135 | if (sb_any_quota_enabled(inode->i_sb)) { |
136 | DQUOT_INIT(inode); | 136 | DQUOT_INIT(inode); |
@@ -140,7 +140,7 @@ static __inline__ int DQUOT_ALLOC_INODE(struct inode *inode) | |||
140 | return 0; | 140 | return 0; |
141 | } | 141 | } |
142 | 142 | ||
143 | static __inline__ void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr) | 143 | static inline void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr) |
144 | { | 144 | { |
145 | if (sb_any_quota_enabled(inode->i_sb)) | 145 | if (sb_any_quota_enabled(inode->i_sb)) |
146 | inode->i_sb->dq_op->free_space(inode, nr); | 146 | inode->i_sb->dq_op->free_space(inode, nr); |
@@ -148,19 +148,19 @@ static __inline__ void DQUOT_FREE_SPACE_NODIRTY(struct inode *inode, qsize_t nr) | |||
148 | inode_sub_bytes(inode, nr); | 148 | inode_sub_bytes(inode, nr); |
149 | } | 149 | } |
150 | 150 | ||
151 | static __inline__ void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr) | 151 | static inline void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr) |
152 | { | 152 | { |
153 | DQUOT_FREE_SPACE_NODIRTY(inode, nr); | 153 | DQUOT_FREE_SPACE_NODIRTY(inode, nr); |
154 | mark_inode_dirty(inode); | 154 | mark_inode_dirty(inode); |
155 | } | 155 | } |
156 | 156 | ||
157 | static __inline__ void DQUOT_FREE_INODE(struct inode *inode) | 157 | static inline void DQUOT_FREE_INODE(struct inode *inode) |
158 | { | 158 | { |
159 | if (sb_any_quota_enabled(inode->i_sb)) | 159 | if (sb_any_quota_enabled(inode->i_sb)) |
160 | inode->i_sb->dq_op->free_inode(inode, 1); | 160 | inode->i_sb->dq_op->free_inode(inode, 1); |
161 | } | 161 | } |
162 | 162 | ||
163 | static __inline__ int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr) | 163 | static inline int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr) |
164 | { | 164 | { |
165 | if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) { | 165 | if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) { |
166 | DQUOT_INIT(inode); | 166 | DQUOT_INIT(inode); |
@@ -171,14 +171,32 @@ static __inline__ int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr) | |||
171 | } | 171 | } |
172 | 172 | ||
173 | /* The following two functions cannot be called inside a transaction */ | 173 | /* The following two functions cannot be called inside a transaction */ |
174 | #define DQUOT_SYNC(sb) sync_dquots(sb, -1) | 174 | static inline void DQUOT_SYNC(struct super_block *sb) |
175 | { | ||
176 | sync_dquots(sb, -1); | ||
177 | } | ||
175 | 178 | ||
176 | static __inline__ int DQUOT_OFF(struct super_block *sb) | 179 | static inline int DQUOT_OFF(struct super_block *sb, int remount) |
177 | { | 180 | { |
178 | int ret = -ENOSYS; | 181 | int ret = -ENOSYS; |
179 | 182 | ||
180 | if (sb_any_quota_enabled(sb) && sb->s_qcop && sb->s_qcop->quota_off) | 183 | if (sb->s_qcop && sb->s_qcop->quota_off) |
181 | ret = sb->s_qcop->quota_off(sb, -1); | 184 | ret = sb->s_qcop->quota_off(sb, -1, remount); |
185 | return ret; | ||
186 | } | ||
187 | |||
188 | static inline int DQUOT_ON_REMOUNT(struct super_block *sb) | ||
189 | { | ||
190 | int cnt; | ||
191 | int ret = 0, err; | ||
192 | |||
193 | if (!sb->s_qcop || !sb->s_qcop->quota_on) | ||
194 | return -ENOSYS; | ||
195 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | ||
196 | err = sb->s_qcop->quota_on(sb, cnt, 0, NULL, 1); | ||
197 | if (err < 0 && !ret) | ||
198 | ret = err; | ||
199 | } | ||
182 | return ret; | 200 | return ret; |
183 | } | 201 | } |
184 | 202 | ||
@@ -189,13 +207,43 @@ static __inline__ int DQUOT_OFF(struct super_block *sb) | |||
189 | */ | 207 | */ |
190 | #define sb_dquot_ops (NULL) | 208 | #define sb_dquot_ops (NULL) |
191 | #define sb_quotactl_ops (NULL) | 209 | #define sb_quotactl_ops (NULL) |
192 | #define DQUOT_INIT(inode) do { } while(0) | 210 | |
193 | #define DQUOT_DROP(inode) do { } while(0) | 211 | static inline void DQUOT_INIT(struct inode *inode) |
194 | #define DQUOT_ALLOC_INODE(inode) (0) | 212 | { |
195 | #define DQUOT_FREE_INODE(inode) do { } while(0) | 213 | } |
196 | #define DQUOT_SYNC(sb) do { } while(0) | 214 | |
197 | #define DQUOT_OFF(sb) do { } while(0) | 215 | static inline void DQUOT_DROP(struct inode *inode) |
198 | #define DQUOT_TRANSFER(inode, iattr) (0) | 216 | { |
217 | } | ||
218 | |||
219 | static inline int DQUOT_ALLOC_INODE(struct inode *inode) | ||
220 | { | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static inline void DQUOT_FREE_INODE(struct inode *inode) | ||
225 | { | ||
226 | } | ||
227 | |||
228 | static inline void DQUOT_SYNC(struct super_block *sb) | ||
229 | { | ||
230 | } | ||
231 | |||
232 | static inline int DQUOT_OFF(struct super_block *sb, int remount) | ||
233 | { | ||
234 | return 0; | ||
235 | } | ||
236 | |||
237 | static inline int DQUOT_ON_REMOUNT(struct super_block *sb) | ||
238 | { | ||
239 | return 0; | ||
240 | } | ||
241 | |||
242 | static inline int DQUOT_TRANSFER(struct inode *inode, struct iattr *iattr) | ||
243 | { | ||
244 | return 0; | ||
245 | } | ||
246 | |||
199 | static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) | 247 | static inline int DQUOT_PREALLOC_SPACE_NODIRTY(struct inode *inode, qsize_t nr) |
200 | { | 248 | { |
201 | inode_add_bytes(inode, nr); | 249 | inode_add_bytes(inode, nr); |
@@ -235,11 +283,38 @@ static inline void DQUOT_FREE_SPACE(struct inode *inode, qsize_t nr) | |||
235 | 283 | ||
236 | #endif /* CONFIG_QUOTA */ | 284 | #endif /* CONFIG_QUOTA */ |
237 | 285 | ||
238 | #define DQUOT_PREALLOC_BLOCK_NODIRTY(inode, nr) DQUOT_PREALLOC_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) | 286 | static inline int DQUOT_PREALLOC_BLOCK_NODIRTY(struct inode *inode, qsize_t nr) |
239 | #define DQUOT_PREALLOC_BLOCK(inode, nr) DQUOT_PREALLOC_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) | 287 | { |
240 | #define DQUOT_ALLOC_BLOCK_NODIRTY(inode, nr) DQUOT_ALLOC_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) | 288 | return DQUOT_PREALLOC_SPACE_NODIRTY(inode, |
241 | #define DQUOT_ALLOC_BLOCK(inode, nr) DQUOT_ALLOC_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) | 289 | nr << inode->i_sb->s_blocksize_bits); |
242 | #define DQUOT_FREE_BLOCK_NODIRTY(inode, nr) DQUOT_FREE_SPACE_NODIRTY(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) | 290 | } |
243 | #define DQUOT_FREE_BLOCK(inode, nr) DQUOT_FREE_SPACE(inode, ((qsize_t)(nr)) << (inode)->i_sb->s_blocksize_bits) | 291 | |
292 | static inline int DQUOT_PREALLOC_BLOCK(struct inode *inode, qsize_t nr) | ||
293 | { | ||
294 | return DQUOT_PREALLOC_SPACE(inode, | ||
295 | nr << inode->i_sb->s_blocksize_bits); | ||
296 | } | ||
297 | |||
298 | static inline int DQUOT_ALLOC_BLOCK_NODIRTY(struct inode *inode, qsize_t nr) | ||
299 | { | ||
300 | return DQUOT_ALLOC_SPACE_NODIRTY(inode, | ||
301 | nr << inode->i_sb->s_blocksize_bits); | ||
302 | } | ||
303 | |||
304 | static inline int DQUOT_ALLOC_BLOCK(struct inode *inode, qsize_t nr) | ||
305 | { | ||
306 | return DQUOT_ALLOC_SPACE(inode, | ||
307 | nr << inode->i_sb->s_blocksize_bits); | ||
308 | } | ||
309 | |||
310 | static inline void DQUOT_FREE_BLOCK_NODIRTY(struct inode *inode, qsize_t nr) | ||
311 | { | ||
312 | DQUOT_FREE_SPACE_NODIRTY(inode, nr << inode->i_sb->s_blocksize_bits); | ||
313 | } | ||
314 | |||
315 | static inline void DQUOT_FREE_BLOCK(struct inode *inode, qsize_t nr) | ||
316 | { | ||
317 | DQUOT_FREE_SPACE(inode, nr << inode->i_sb->s_blocksize_bits); | ||
318 | } | ||
244 | 319 | ||
245 | #endif /* _LINUX_QUOTAOPS_ */ | 320 | #endif /* _LINUX_QUOTAOPS_ */ |