diff options
Diffstat (limited to 'fs/ocfs2/journal.h')
-rw-r--r-- | fs/ocfs2/journal.h | 84 |
1 files changed, 69 insertions, 15 deletions
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h index 8203980fefed..ee08e9c1fc12 100644 --- a/fs/ocfs2/journal.h +++ b/fs/ocfs2/journal.h | |||
@@ -284,6 +284,37 @@ int ocfs2_journal_dirty(handle_t *handle, | |||
284 | /* extended attribute block update */ | 284 | /* extended attribute block update */ |
285 | #define OCFS2_XATTR_BLOCK_UPDATE_CREDITS 1 | 285 | #define OCFS2_XATTR_BLOCK_UPDATE_CREDITS 1 |
286 | 286 | ||
287 | /* global quotafile inode update, data block */ | ||
288 | #define OCFS2_QINFO_WRITE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1) | ||
289 | |||
290 | /* | ||
291 | * The two writes below can accidentally see global info dirty due | ||
292 | * to set_info() quotactl so make them prepared for the writes. | ||
293 | */ | ||
294 | /* quota data block, global info */ | ||
295 | /* Write to local quota file */ | ||
296 | #define OCFS2_QWRITE_CREDITS (OCFS2_QINFO_WRITE_CREDITS + 1) | ||
297 | |||
298 | /* global quota data block, local quota data block, global quota inode, | ||
299 | * global quota info */ | ||
300 | #define OCFS2_QSYNC_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 3) | ||
301 | |||
302 | static inline int ocfs2_quota_trans_credits(struct super_block *sb) | ||
303 | { | ||
304 | int credits = 0; | ||
305 | |||
306 | if (OCFS2_HAS_RO_COMPAT_FEATURE(sb, OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) | ||
307 | credits += OCFS2_QWRITE_CREDITS; | ||
308 | if (OCFS2_HAS_RO_COMPAT_FEATURE(sb, OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) | ||
309 | credits += OCFS2_QWRITE_CREDITS; | ||
310 | return credits; | ||
311 | } | ||
312 | |||
313 | /* Number of credits needed for removing quota structure from file */ | ||
314 | int ocfs2_calc_qdel_credits(struct super_block *sb, int type); | ||
315 | /* Number of credits needed for initialization of new quota structure */ | ||
316 | int ocfs2_calc_qinit_credits(struct super_block *sb, int type); | ||
317 | |||
287 | /* group extend. inode update and last group update. */ | 318 | /* group extend. inode update and last group update. */ |
288 | #define OCFS2_GROUP_EXTEND_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1) | 319 | #define OCFS2_GROUP_EXTEND_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1) |
289 | 320 | ||
@@ -294,8 +325,11 @@ int ocfs2_journal_dirty(handle_t *handle, | |||
294 | * prev. group desc. if we relink. */ | 325 | * prev. group desc. if we relink. */ |
295 | #define OCFS2_SUBALLOC_ALLOC (3) | 326 | #define OCFS2_SUBALLOC_ALLOC (3) |
296 | 327 | ||
297 | #define OCFS2_INLINE_TO_EXTENTS_CREDITS (OCFS2_SUBALLOC_ALLOC \ | 328 | static inline int ocfs2_inline_to_extents_credits(struct super_block *sb) |
298 | + OCFS2_INODE_UPDATE_CREDITS) | 329 | { |
330 | return OCFS2_SUBALLOC_ALLOC + OCFS2_INODE_UPDATE_CREDITS + | ||
331 | ocfs2_quota_trans_credits(sb); | ||
332 | } | ||
299 | 333 | ||
300 | /* dinode + group descriptor update. We don't relink on free yet. */ | 334 | /* dinode + group descriptor update. We don't relink on free yet. */ |
301 | #define OCFS2_SUBALLOC_FREE (2) | 335 | #define OCFS2_SUBALLOC_FREE (2) |
@@ -304,16 +338,23 @@ int ocfs2_journal_dirty(handle_t *handle, | |||
304 | #define OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC (OCFS2_SUBALLOC_FREE \ | 338 | #define OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC (OCFS2_SUBALLOC_FREE \ |
305 | + OCFS2_TRUNCATE_LOG_UPDATE) | 339 | + OCFS2_TRUNCATE_LOG_UPDATE) |
306 | 340 | ||
307 | #define OCFS2_REMOVE_EXTENT_CREDITS (OCFS2_TRUNCATE_LOG_UPDATE + OCFS2_INODE_UPDATE_CREDITS) | 341 | static inline int ocfs2_remove_extent_credits(struct super_block *sb) |
342 | { | ||
343 | return OCFS2_TRUNCATE_LOG_UPDATE + OCFS2_INODE_UPDATE_CREDITS + | ||
344 | ocfs2_quota_trans_credits(sb); | ||
345 | } | ||
308 | 346 | ||
309 | /* data block for new dir/symlink, 2 for bitmap updates (bitmap fe + | 347 | /* data block for new dir/symlink, 2 for bitmap updates (bitmap fe + |
310 | * bitmap block for the new bit) */ | 348 | * bitmap block for the new bit) */ |
311 | #define OCFS2_DIR_LINK_ADDITIONAL_CREDITS (1 + 2) | 349 | #define OCFS2_DIR_LINK_ADDITIONAL_CREDITS (1 + 2) |
312 | 350 | ||
313 | /* parent fe, parent block, new file entry, inode alloc fe, inode alloc | 351 | /* parent fe, parent block, new file entry, inode alloc fe, inode alloc |
314 | * group descriptor + mkdir/symlink blocks */ | 352 | * group descriptor + mkdir/symlink blocks + quota update */ |
315 | #define OCFS2_MKNOD_CREDITS (3 + OCFS2_SUBALLOC_ALLOC \ | 353 | static inline int ocfs2_mknod_credits(struct super_block *sb) |
316 | + OCFS2_DIR_LINK_ADDITIONAL_CREDITS) | 354 | { |
355 | return 3 + OCFS2_SUBALLOC_ALLOC + OCFS2_DIR_LINK_ADDITIONAL_CREDITS + | ||
356 | ocfs2_quota_trans_credits(sb); | ||
357 | } | ||
317 | 358 | ||
318 | /* local alloc metadata change + main bitmap updates */ | 359 | /* local alloc metadata change + main bitmap updates */ |
319 | #define OCFS2_WINDOW_MOVE_CREDITS (OCFS2_INODE_UPDATE_CREDITS \ | 360 | #define OCFS2_WINDOW_MOVE_CREDITS (OCFS2_INODE_UPDATE_CREDITS \ |
@@ -323,13 +364,21 @@ int ocfs2_journal_dirty(handle_t *handle, | |||
323 | * for the dinode, one for the new block. */ | 364 | * for the dinode, one for the new block. */ |
324 | #define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2) | 365 | #define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2) |
325 | 366 | ||
326 | /* file update (nlink, etc) + directory mtime/ctime + dir entry block */ | 367 | /* file update (nlink, etc) + directory mtime/ctime + dir entry block + quota |
327 | #define OCFS2_LINK_CREDITS (2*OCFS2_INODE_UPDATE_CREDITS + 1) | 368 | * update on dir */ |
369 | static inline int ocfs2_link_credits(struct super_block *sb) | ||
370 | { | ||
371 | return 2*OCFS2_INODE_UPDATE_CREDITS + 1 + | ||
372 | ocfs2_quota_trans_credits(sb); | ||
373 | } | ||
328 | 374 | ||
329 | /* inode + dir inode (if we unlink a dir), + dir entry block + orphan | 375 | /* inode + dir inode (if we unlink a dir), + dir entry block + orphan |
330 | * dir inode link */ | 376 | * dir inode link */ |
331 | #define OCFS2_UNLINK_CREDITS (2 * OCFS2_INODE_UPDATE_CREDITS + 1 \ | 377 | static inline int ocfs2_unlink_credits(struct super_block *sb) |
332 | + OCFS2_LINK_CREDITS) | 378 | { |
379 | /* The quota update from ocfs2_link_credits is unused here... */ | ||
380 | return 2 * OCFS2_INODE_UPDATE_CREDITS + 1 + ocfs2_link_credits(sb); | ||
381 | } | ||
333 | 382 | ||
334 | /* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry + | 383 | /* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry + |
335 | * inode alloc group descriptor */ | 384 | * inode alloc group descriptor */ |
@@ -338,8 +387,10 @@ int ocfs2_journal_dirty(handle_t *handle, | |||
338 | /* dinode update, old dir dinode update, new dir dinode update, old | 387 | /* dinode update, old dir dinode update, new dir dinode update, old |
339 | * dir dir entry, new dir dir entry, dir entry update for renaming | 388 | * dir dir entry, new dir dir entry, dir entry update for renaming |
340 | * directory + target unlink */ | 389 | * directory + target unlink */ |
341 | #define OCFS2_RENAME_CREDITS (3 * OCFS2_INODE_UPDATE_CREDITS + 3 \ | 390 | static inline int ocfs2_rename_credits(struct super_block *sb) |
342 | + OCFS2_UNLINK_CREDITS) | 391 | { |
392 | return 3 * OCFS2_INODE_UPDATE_CREDITS + 3 + ocfs2_unlink_credits(sb); | ||
393 | } | ||
343 | 394 | ||
344 | /* global bitmap dinode, group desc., relinked group, | 395 | /* global bitmap dinode, group desc., relinked group, |
345 | * suballocator dinode, group desc., relinked group, | 396 | * suballocator dinode, group desc., relinked group, |
@@ -377,18 +428,19 @@ static inline int ocfs2_calc_extend_credits(struct super_block *sb, | |||
377 | * credit for the dinode there. */ | 428 | * credit for the dinode there. */ |
378 | extent_blocks = 1 + 1 + le16_to_cpu(root_el->l_tree_depth); | 429 | extent_blocks = 1 + 1 + le16_to_cpu(root_el->l_tree_depth); |
379 | 430 | ||
380 | return bitmap_blocks + sysfile_bitmap_blocks + extent_blocks; | 431 | return bitmap_blocks + sysfile_bitmap_blocks + extent_blocks + |
432 | ocfs2_quota_trans_credits(sb); | ||
381 | } | 433 | } |
382 | 434 | ||
383 | static inline int ocfs2_calc_symlink_credits(struct super_block *sb) | 435 | static inline int ocfs2_calc_symlink_credits(struct super_block *sb) |
384 | { | 436 | { |
385 | int blocks = OCFS2_MKNOD_CREDITS; | 437 | int blocks = ocfs2_mknod_credits(sb); |
386 | 438 | ||
387 | /* links can be longer than one block so we may update many | 439 | /* links can be longer than one block so we may update many |
388 | * within our single allocated extent. */ | 440 | * within our single allocated extent. */ |
389 | blocks += ocfs2_clusters_to_blocks(sb, 1); | 441 | blocks += ocfs2_clusters_to_blocks(sb, 1); |
390 | 442 | ||
391 | return blocks; | 443 | return blocks + ocfs2_quota_trans_credits(sb); |
392 | } | 444 | } |
393 | 445 | ||
394 | static inline int ocfs2_calc_group_alloc_credits(struct super_block *sb, | 446 | static inline int ocfs2_calc_group_alloc_credits(struct super_block *sb, |
@@ -425,6 +477,8 @@ static inline int ocfs2_calc_tree_trunc_credits(struct super_block *sb, | |||
425 | /* update to the truncate log. */ | 477 | /* update to the truncate log. */ |
426 | credits += OCFS2_TRUNCATE_LOG_UPDATE; | 478 | credits += OCFS2_TRUNCATE_LOG_UPDATE; |
427 | 479 | ||
480 | credits += ocfs2_quota_trans_credits(sb); | ||
481 | |||
428 | return credits; | 482 | return credits; |
429 | } | 483 | } |
430 | 484 | ||