diff options
Diffstat (limited to 'include/linux/quotaops.h')
-rw-r--r-- | include/linux/quotaops.h | 208 |
1 files changed, 58 insertions, 150 deletions
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index e1cae204b5d9..47e85682e118 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
@@ -33,14 +33,13 @@ int dquot_scan_active(struct super_block *sb, | |||
33 | struct dquot *dquot_alloc(struct super_block *sb, int type); | 33 | struct dquot *dquot_alloc(struct super_block *sb, int type); |
34 | void dquot_destroy(struct dquot *dquot); | 34 | void dquot_destroy(struct dquot *dquot); |
35 | 35 | ||
36 | int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); | 36 | int __dquot_alloc_space(struct inode *inode, qsize_t number, |
37 | int dquot_alloc_inode(const struct inode *inode, qsize_t number); | 37 | int warn, int reserve); |
38 | void __dquot_free_space(struct inode *inode, qsize_t number, int reserve); | ||
38 | 39 | ||
39 | int dquot_reserve_space(struct inode *inode, qsize_t number, int prealloc); | 40 | int dquot_alloc_inode(const struct inode *inode, qsize_t number); |
40 | int dquot_claim_space(struct inode *inode, qsize_t number); | ||
41 | void dquot_release_reserved_space(struct inode *inode, qsize_t number); | ||
42 | 41 | ||
43 | int dquot_free_space(struct inode *inode, qsize_t number); | 42 | int dquot_claim_space_nodirty(struct inode *inode, qsize_t number); |
44 | int dquot_free_inode(const struct inode *inode, qsize_t number); | 43 | int dquot_free_inode(const struct inode *inode, qsize_t number); |
45 | 44 | ||
46 | int dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask); | 45 | int dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask); |
@@ -149,60 +148,6 @@ static inline void vfs_dq_init(struct inode *inode) | |||
149 | inode->i_sb->dq_op->initialize(inode, -1); | 148 | inode->i_sb->dq_op->initialize(inode, -1); |
150 | } | 149 | } |
151 | 150 | ||
152 | /* The following allocation/freeing/transfer functions *must* be called inside | ||
153 | * a transaction (deadlocks possible otherwise) */ | ||
154 | static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) | ||
155 | { | ||
156 | if (sb_any_quota_active(inode->i_sb)) { | ||
157 | /* Used space is updated in alloc_space() */ | ||
158 | if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA) | ||
159 | return 1; | ||
160 | } | ||
161 | else | ||
162 | inode_add_bytes(inode, nr); | ||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) | ||
167 | { | ||
168 | int ret; | ||
169 | if (!(ret = vfs_dq_prealloc_space_nodirty(inode, nr))) | ||
170 | mark_inode_dirty(inode); | ||
171 | return ret; | ||
172 | } | ||
173 | |||
174 | static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) | ||
175 | { | ||
176 | if (sb_any_quota_active(inode->i_sb)) { | ||
177 | /* Used space is updated in alloc_space() */ | ||
178 | if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA) | ||
179 | return 1; | ||
180 | } | ||
181 | else | ||
182 | inode_add_bytes(inode, nr); | ||
183 | return 0; | ||
184 | } | ||
185 | |||
186 | static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) | ||
187 | { | ||
188 | int ret; | ||
189 | if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr))) | ||
190 | mark_inode_dirty(inode); | ||
191 | return ret; | ||
192 | } | ||
193 | |||
194 | static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) | ||
195 | { | ||
196 | if (sb_any_quota_active(inode->i_sb)) { | ||
197 | /* Used space is updated in alloc_space() */ | ||
198 | if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA) | ||
199 | return 1; | ||
200 | } | ||
201 | else | ||
202 | inode_add_rsv_space(inode, nr); | ||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | static inline int vfs_dq_alloc_inode(struct inode *inode) | 151 | static inline int vfs_dq_alloc_inode(struct inode *inode) |
207 | { | 152 | { |
208 | if (sb_any_quota_active(inode->i_sb)) { | 153 | if (sb_any_quota_active(inode->i_sb)) { |
@@ -213,47 +158,6 @@ static inline int vfs_dq_alloc_inode(struct inode *inode) | |||
213 | return 0; | 158 | return 0; |
214 | } | 159 | } |
215 | 160 | ||
216 | /* | ||
217 | * Convert in-memory reserved quotas to real consumed quotas | ||
218 | */ | ||
219 | static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr) | ||
220 | { | ||
221 | if (sb_any_quota_active(inode->i_sb)) { | ||
222 | if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA) | ||
223 | return 1; | ||
224 | } else | ||
225 | inode_claim_rsv_space(inode, nr); | ||
226 | |||
227 | mark_inode_dirty(inode); | ||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | /* | ||
232 | * Release reserved (in-memory) quotas | ||
233 | */ | ||
234 | static inline | ||
235 | void vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr) | ||
236 | { | ||
237 | if (sb_any_quota_active(inode->i_sb)) | ||
238 | inode->i_sb->dq_op->release_rsv(inode, nr); | ||
239 | else | ||
240 | inode_sub_rsv_space(inode, nr); | ||
241 | } | ||
242 | |||
243 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) | ||
244 | { | ||
245 | if (sb_any_quota_active(inode->i_sb)) | ||
246 | inode->i_sb->dq_op->free_space(inode, nr); | ||
247 | else | ||
248 | inode_sub_bytes(inode, nr); | ||
249 | } | ||
250 | |||
251 | static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) | ||
252 | { | ||
253 | vfs_dq_free_space_nodirty(inode, nr); | ||
254 | mark_inode_dirty(inode); | ||
255 | } | ||
256 | |||
257 | static inline void vfs_dq_free_inode(struct inode *inode) | 161 | static inline void vfs_dq_free_inode(struct inode *inode) |
258 | { | 162 | { |
259 | if (sb_any_quota_active(inode->i_sb)) | 163 | if (sb_any_quota_active(inode->i_sb)) |
@@ -351,105 +255,109 @@ static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) | |||
351 | return 0; | 255 | return 0; |
352 | } | 256 | } |
353 | 257 | ||
354 | static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) | 258 | static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, |
259 | int warn, int reserve) | ||
355 | { | 260 | { |
356 | inode_add_bytes(inode, nr); | 261 | if (!reserve) |
262 | inode_add_bytes(inode, number); | ||
357 | return 0; | 263 | return 0; |
358 | } | 264 | } |
359 | 265 | ||
360 | static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) | 266 | static inline void __dquot_free_space(struct inode *inode, qsize_t number, |
267 | int reserve) | ||
361 | { | 268 | { |
362 | vfs_dq_prealloc_space_nodirty(inode, nr); | 269 | if (!reserve) |
363 | mark_inode_dirty(inode); | 270 | inode_sub_bytes(inode, number); |
364 | return 0; | ||
365 | } | 271 | } |
366 | 272 | ||
367 | static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) | 273 | static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) |
368 | { | 274 | { |
369 | inode_add_bytes(inode, nr); | 275 | inode_add_bytes(inode, number); |
370 | return 0; | 276 | return 0; |
371 | } | 277 | } |
372 | 278 | ||
373 | static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) | 279 | #endif /* CONFIG_QUOTA */ |
280 | |||
281 | static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) | ||
374 | { | 282 | { |
375 | vfs_dq_alloc_space_nodirty(inode, nr); | 283 | return __dquot_alloc_space(inode, nr, 1, 0); |
376 | mark_inode_dirty(inode); | ||
377 | return 0; | ||
378 | } | 284 | } |
379 | 285 | ||
380 | static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) | 286 | static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) |
381 | { | 287 | { |
382 | return 0; | 288 | int ret; |
289 | |||
290 | ret = dquot_alloc_space_nodirty(inode, nr); | ||
291 | if (!ret) | ||
292 | mark_inode_dirty(inode); | ||
293 | return ret; | ||
383 | } | 294 | } |
384 | 295 | ||
385 | static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr) | 296 | static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr) |
386 | { | 297 | { |
387 | return vfs_dq_alloc_space(inode, nr); | 298 | return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits); |
388 | } | 299 | } |
389 | 300 | ||
390 | static inline | 301 | static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) |
391 | int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr) | ||
392 | { | 302 | { |
393 | return 0; | 303 | return dquot_alloc_space(inode, nr << inode->i_blkbits); |
394 | } | 304 | } |
395 | 305 | ||
396 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) | 306 | static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) |
397 | { | 307 | { |
398 | inode_sub_bytes(inode, nr); | 308 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0, 0); |
399 | } | 309 | } |
400 | 310 | ||
401 | static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) | 311 | static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) |
402 | { | 312 | { |
403 | vfs_dq_free_space_nodirty(inode, nr); | 313 | int ret; |
404 | mark_inode_dirty(inode); | ||
405 | } | ||
406 | |||
407 | #endif /* CONFIG_QUOTA */ | ||
408 | 314 | ||
409 | static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr) | 315 | ret = dquot_prealloc_block_nodirty(inode, nr); |
410 | { | 316 | if (!ret) |
411 | return vfs_dq_prealloc_space_nodirty(inode, nr << inode->i_blkbits); | 317 | mark_inode_dirty(inode); |
318 | return ret; | ||
412 | } | 319 | } |
413 | 320 | ||
414 | static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr) | 321 | static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) |
415 | { | 322 | { |
416 | return vfs_dq_prealloc_space(inode, nr << inode->i_blkbits); | 323 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, 1, 1); |
417 | } | 324 | } |
418 | 325 | ||
419 | static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr) | 326 | static inline int dquot_claim_block(struct inode *inode, qsize_t nr) |
420 | { | 327 | { |
421 | return vfs_dq_alloc_space_nodirty(inode, nr << inode->i_blkbits); | 328 | int ret; |
422 | } | ||
423 | 329 | ||
424 | static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr) | 330 | ret = dquot_claim_space_nodirty(inode, nr << inode->i_blkbits); |
425 | { | 331 | if (!ret) |
426 | return vfs_dq_alloc_space(inode, nr << inode->i_blkbits); | 332 | mark_inode_dirty(inode); |
333 | return ret; | ||
427 | } | 334 | } |
428 | 335 | ||
429 | static inline int vfs_dq_reserve_block(struct inode *inode, qsize_t nr) | 336 | static inline void dquot_free_space_nodirty(struct inode *inode, qsize_t nr) |
430 | { | 337 | { |
431 | return vfs_dq_reserve_space(inode, nr << inode->i_blkbits); | 338 | __dquot_free_space(inode, nr, 0); |
432 | } | 339 | } |
433 | 340 | ||
434 | static inline int vfs_dq_claim_block(struct inode *inode, qsize_t nr) | 341 | static inline void dquot_free_space(struct inode *inode, qsize_t nr) |
435 | { | 342 | { |
436 | return vfs_dq_claim_space(inode, nr << inode->i_blkbits); | 343 | dquot_free_space_nodirty(inode, nr); |
344 | mark_inode_dirty(inode); | ||
437 | } | 345 | } |
438 | 346 | ||
439 | static inline | 347 | static inline void dquot_free_block_nodirty(struct inode *inode, qsize_t nr) |
440 | void vfs_dq_release_reservation_block(struct inode *inode, qsize_t nr) | ||
441 | { | 348 | { |
442 | vfs_dq_release_reservation_space(inode, nr << inode->i_blkbits); | 349 | dquot_free_space_nodirty(inode, nr << inode->i_blkbits); |
443 | } | 350 | } |
444 | 351 | ||
445 | static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) | 352 | static inline void dquot_free_block(struct inode *inode, qsize_t nr) |
446 | { | 353 | { |
447 | vfs_dq_free_space_nodirty(inode, nr << inode->i_blkbits); | 354 | dquot_free_space(inode, nr << inode->i_blkbits); |
448 | } | 355 | } |
449 | 356 | ||
450 | static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr) | 357 | static inline void dquot_release_reservation_block(struct inode *inode, |
358 | qsize_t nr) | ||
451 | { | 359 | { |
452 | vfs_dq_free_space(inode, nr << inode->i_blkbits); | 360 | __dquot_free_space(inode, nr << inode->i_blkbits, 1); |
453 | } | 361 | } |
454 | 362 | ||
455 | #endif /* _LINUX_QUOTAOPS_ */ | 363 | #endif /* _LINUX_QUOTAOPS_ */ |