26 #ifndef OCFS2_JOURNAL_H
27 #define OCFS2_JOURNAL_H
83 static inline unsigned long ocfs2_inc_trans_id(
struct ocfs2_journal *
j)
86 spin_lock(&trans_inc_lock);
90 spin_unlock(&trans_inc_lock);
94 static inline void ocfs2_set_ci_lock_trans(
struct ocfs2_journal *journal,
97 spin_lock(&trans_inc_lock);
99 spin_unlock(&trans_inc_lock);
113 spin_lock(&trans_inc_lock);
115 spin_unlock(&trans_inc_lock);
129 spin_lock(&trans_inc_lock);
133 spin_unlock(&trans_inc_lock);
138 static inline int ocfs2_inode_is_new(
struct inode *
inode)
146 return ocfs2_ci_is_new(INODE_CACHE(inode));
149 static inline void ocfs2_ci_set_new(
struct ocfs2_super *osb,
152 spin_lock(&trans_inc_lock);
154 spin_unlock(&trans_inc_lock);
201 static inline void ocfs2_start_checkpoint(
struct ocfs2_super *osb)
207 static inline void ocfs2_checkpoint_inode(
struct inode *inode)
211 if (ocfs2_mount_local(osb))
214 if (!ocfs2_ci_fully_checkpointed(INODE_CACHE(inode))) {
221 ocfs2_start_checkpoint(osb);
224 ocfs2_ci_fully_checkpointed(INODE_CACHE(inode)));
274 #define OCFS2_JOURNAL_ACCESS_CREATE 0
275 #define OCFS2_JOURNAL_ACCESS_WRITE 1
276 #define OCFS2_JOURNAL_ACCESS_UNDO 2
281 struct buffer_head *bh,
int type);
284 struct buffer_head *bh,
int type);
287 struct buffer_head *bh,
int type);
290 struct buffer_head *bh,
int type);
293 struct buffer_head *bh,
int type);
296 struct buffer_head *bh,
int type);
299 struct buffer_head *bh,
int type);
302 struct buffer_head *bh,
int type);
305 struct buffer_head *bh,
int type);
308 struct buffer_head *bh,
int type);
341 #define OCFS2_INODE_UPDATE_CREDITS 1
344 #define OCFS2_XATTR_BLOCK_UPDATE_CREDITS 1
347 #define OCFS2_QUOTA_BLOCK_UPDATE_CREDITS 1
350 #define OCFS2_QINFO_WRITE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + \
351 OCFS2_QUOTA_BLOCK_UPDATE_CREDITS)
353 #define OCFS2_LOCAL_QINFO_WRITE_CREDITS OCFS2_QUOTA_BLOCK_UPDATE_CREDITS
360 #define OCFS2_QWRITE_CREDITS (OCFS2_QINFO_WRITE_CREDITS + \
361 OCFS2_QUOTA_BLOCK_UPDATE_CREDITS)
365 #define OCFS2_QSYNC_CREDITS (OCFS2_QINFO_WRITE_CREDITS + \
366 2 * OCFS2_QUOTA_BLOCK_UPDATE_CREDITS)
368 static inline int ocfs2_quota_trans_credits(
struct super_block *
sb)
380 #define OCFS2_GROUP_EXTEND_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1)
383 #define OCFS2_GROUP_ADD_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1)
387 #define OCFS2_SUBALLOC_ALLOC (3)
389 static inline int ocfs2_inline_to_extents_credits(
struct super_block *
sb)
392 ocfs2_quota_trans_credits(sb);
396 #define OCFS2_SUBALLOC_FREE (2)
398 #define OCFS2_TRUNCATE_LOG_UPDATE OCFS2_INODE_UPDATE_CREDITS
399 #define OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC (OCFS2_SUBALLOC_FREE \
400 + OCFS2_TRUNCATE_LOG_UPDATE)
402 static inline int ocfs2_remove_extent_credits(
struct super_block *
sb)
405 ocfs2_quota_trans_credits(sb);
410 #define OCFS2_DIR_LINK_ADDITIONAL_CREDITS (1 + OCFS2_SUBALLOC_ALLOC + 1)
412 static inline int ocfs2_add_dir_index_credits(
struct super_block *
sb)
417 ocfs2_clusters_to_blocks(sb, 1);
423 static inline int ocfs2_mknod_credits(
struct super_block *
sb,
int is_dir,
429 dir_credits += ocfs2_add_dir_index_credits(sb);
432 ocfs2_quota_trans_credits(sb);
436 #define OCFS2_WINDOW_MOVE_CREDITS (OCFS2_INODE_UPDATE_CREDITS \
437 + OCFS2_SUBALLOC_ALLOC + OCFS2_SUBALLOC_FREE)
441 #define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2)
446 static inline int ocfs2_link_credits(
struct super_block *sb)
449 ocfs2_quota_trans_credits(sb);
454 static inline int ocfs2_unlink_credits(
struct super_block *sb)
463 #define OCFS2_DELETE_INODE_CREDITS (3 * OCFS2_INODE_UPDATE_CREDITS + 4)
468 static inline int ocfs2_rename_credits(
struct super_block *sb)
476 #define OCFS2_XATTR_BLOCK_CREATE_CREDITS (OCFS2_SUBALLOC_ALLOC * 2 + \
477 + OCFS2_INODE_UPDATE_CREDITS \
478 + OCFS2_XATTR_BLOCK_UPDATE_CREDITS)
481 #define OCFS2_DX_ROOT_REMOVE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + \
484 static inline int ocfs2_calc_dxi_expand_credits(
struct super_block *sb)
488 credits += ocfs2_clusters_to_blocks(sb, 1);
489 credits += ocfs2_quota_trans_credits(sb);
495 #define OCFS2_REFCOUNT_TREE_CREATE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1 \
496 + OCFS2_SUBALLOC_ALLOC)
499 #define OCFS2_REFCOUNT_TREE_SET_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1)
506 #define OCFS2_REFCOUNT_TREE_REMOVE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1)
509 #define OCFS2_EXPAND_REFCOUNT_TREE_CREDITS (OCFS2_SUBALLOC_ALLOC * 2 + 3)
516 static inline int ocfs2_calc_extend_credits(
struct super_block *sb,
520 int bitmap_blocks, sysfile_bitmap_blocks, extent_blocks;
530 sysfile_bitmap_blocks = 1 +
540 return bitmap_blocks + sysfile_bitmap_blocks + extent_blocks +
541 ocfs2_quota_trans_credits(sb);
544 static inline int ocfs2_calc_symlink_credits(
struct super_block *sb)
546 int blocks = ocfs2_mknod_credits(sb, 0, 0);
550 blocks += ocfs2_clusters_to_blocks(sb, 1);
552 return blocks + ocfs2_quota_trans_credits(sb);
555 static inline int ocfs2_calc_group_alloc_credits(
struct super_block *sb,
562 blocks = 1 + 1 + 1 + bitmap_blocks;
573 static inline int ocfs2_calc_bg_discontig_credits(
struct super_block *sb)
575 return ocfs2_extent_recs_per_gd(sb);
578 static inline int ocfs2_calc_tree_trunc_credits(
struct super_block *sb,
579 unsigned int clusters_to_del,
586 int credits = 1 + tree_depth + 1;
594 if (tree_depth && next_free == 1 &&
595 ocfs2_rec_clusters(last_el, &last_el->
l_recs[i]) == clusters_to_del)
596 credits += 1 + tree_depth;
601 credits += ocfs2_quota_trans_credits(sb);
606 static inline int ocfs2_jbd2_file_inode(handle_t *
handle,
struct inode *inode)
611 static inline int ocfs2_begin_ordered_truncate(
struct inode *inode,
616 &OCFS2_I(inode)->ip_jinode,