22 #define EXT4_JOURNAL(inode) (EXT4_SB((inode)->i_sb)->s_journal)
34 #define EXT4_SINGLEDATA_TRANS_BLOCKS(sb) \
35 (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS) \
42 #define EXT4_XATTR_TRANS_BLOCKS 6U
50 #define EXT4_DATA_TRANS_BLOCKS(sb) (EXT4_SINGLEDATA_TRANS_BLOCKS(sb) + \
51 EXT4_XATTR_TRANS_BLOCKS - 2 + \
52 EXT4_MAXQUOTAS_TRANS_BLOCKS(sb))
59 #define EXT4_META_TRANS_BLOCKS(sb) (EXT4_XATTR_TRANS_BLOCKS + \
60 EXT4_MAXQUOTAS_TRANS_BLOCKS(sb))
66 #define EXT4_DELETE_TRANS_BLOCKS(sb) (2 * EXT4_DATA_TRANS_BLOCKS(sb) + 64)
74 #define EXT4_MAX_TRANS_DATA 64U
83 #define EXT4_RESERVE_TRANS_BLOCKS 12U
85 #define EXT4_INDEX_EXTRA_TRANS_BLOCKS 8
90 #define EXT4_QUOTA_TRANS_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\
91 EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\
95 #define EXT4_QUOTA_INIT_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\
96 EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\
97 (DQUOT_INIT_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\
98 +3+DQUOT_INIT_REWRITE) : 0)
100 #define EXT4_QUOTA_DEL_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\
101 EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\
102 (DQUOT_DEL_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\
103 +3+DQUOT_DEL_REWRITE) : 0)
105 #define EXT4_QUOTA_TRANS_BLOCKS(sb) 0
106 #define EXT4_QUOTA_INIT_BLOCKS(sb) 0
107 #define EXT4_QUOTA_DEL_BLOCKS(sb) 0
109 #define EXT4_MAXQUOTAS_TRANS_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_TRANS_BLOCKS(sb))
110 #define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb))
111 #define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb))
153 static inline void ext4_journal_callback_add(handle_t *
handle,
159 struct ext4_sb_info *sbi =
160 EXT4_SB(handle->h_transaction->t_journal->j_private);
164 spin_lock(&sbi->s_md_lock);
166 spin_unlock(&sbi->s_md_lock);
174 static inline void ext4_journal_callback_del(handle_t *handle,
177 struct ext4_sb_info *sbi =
178 EXT4_SB(handle->h_transaction->t_journal->j_private);
180 spin_lock(&sbi->s_md_lock);
182 spin_unlock(&sbi->s_md_lock);
188 struct ext4_iloc *iloc);
196 struct ext4_iloc *iloc);
205 struct buffer_head *bh, handle_t *handle,
int err);
208 handle_t *handle,
struct buffer_head *bh);
215 handle_t *handle,
struct buffer_head *bh);
219 struct buffer_head *bh);
224 #define ext4_journal_get_write_access(handle, bh) \
225 __ext4_journal_get_write_access(__func__, __LINE__, (handle), (bh))
226 #define ext4_forget(handle, is_metadata, inode, bh, block_nr) \
227 __ext4_forget(__func__, __LINE__, (handle), (is_metadata), (inode), \
229 #define ext4_journal_get_create_access(handle, bh) \
230 __ext4_journal_get_create_access(__func__, __LINE__, (handle), (bh))
231 #define ext4_handle_dirty_metadata(handle, inode, bh) \
232 __ext4_handle_dirty_metadata(__func__, __LINE__, (handle), (inode), \
234 #define ext4_handle_dirty_super(handle, sb) \
235 __ext4_handle_dirty_super(__func__, __LINE__, (handle), (sb))
240 #define EXT4_NOJOURNAL_MAX_REF_COUNT ((unsigned long) 4096)
244 static inline int ext4_handle_valid(handle_t *handle)
251 static inline void ext4_handle_sync(handle_t *handle)
253 if (ext4_handle_valid(handle))
257 static inline void ext4_handle_release_buffer(handle_t *handle,
258 struct buffer_head *bh)
260 if (ext4_handle_valid(handle))
264 static inline int ext4_handle_is_aborted(handle_t *handle)
266 if (ext4_handle_valid(handle))
267 return is_handle_aborted(handle);
271 static inline int ext4_handle_has_enough_credits(handle_t *handle,
int needed)
273 if (ext4_handle_valid(handle) && handle->h_buffer_credits < needed)
278 static inline handle_t *ext4_journal_start(
struct inode *
inode,
int nblocks)
283 #define ext4_journal_stop(handle) \
284 __ext4_journal_stop(__func__, __LINE__, (handle))
286 static inline handle_t *ext4_journal_current_handle(
void)
288 return journal_current_handle();
291 static inline int ext4_journal_extend(handle_t *handle,
int nblocks)
293 if (ext4_handle_valid(handle))
298 static inline int ext4_journal_restart(handle_t *handle,
int nblocks)
300 if (ext4_handle_valid(handle))
305 static inline int ext4_journal_blocks_per_page(
struct inode *
inode)
312 static inline int ext4_journal_force_commit(journal_t *journal)
319 static inline int ext4_jbd2_file_inode(handle_t *handle,
struct inode *inode)
321 if (ext4_handle_valid(handle))
326 static inline void ext4_update_inode_fsync_trans(handle_t *handle,
332 if (ext4_handle_valid(handle)) {
333 ei->
i_sync_tid = handle->h_transaction->t_tid;
345 #define EXT4_INODE_JOURNAL_DATA_MODE 0x01
346 #define EXT4_INODE_ORDERED_DATA_MODE 0x02
347 #define EXT4_INODE_WRITEBACK_DATA_MODE 0x04
349 static inline int ext4_inode_journal_mode(
struct inode *inode)
368 static inline int ext4_should_journal_data(
struct inode *inode)
373 static inline int ext4_should_order_data(
struct inode *inode)
378 static inline int ext4_should_writeback_data(
struct inode *inode)
392 static inline int ext4_should_dioread_nolock(
struct inode *inode)
400 if (ext4_should_journal_data(inode))