Commit 0390131b authored by Frank Mayhar's avatar Frank Mayhar Committed by Theodore Ts'o

ext4: Allow ext4 to run without a journal

A few weeks ago I posted a patch for discussion that allowed ext4 to run
without a journal.  Since that time I've integrated the excellent
comments from Andreas and fixed several serious bugs.  We're currently
running with this patch and generating some performance numbers against
both ext2 (with backported reservations code) and ext4 with and without
a journal.  It just so happens that running without a journal is
slightly faster for most everything.

We did
	iozone -T -t 4 s 2g -r 256k -T -I -i0 -i1 -i2

which creates 4 threads, each of which create and do reads and writes on
a 2G file, with a buffer size of 256K, using O_DIRECT for all file opens
to bypass the page cache.  Results:

                     ext2        ext4, default   ext4, no journal
  initial writes   13.0 MB/s        15.4 MB/s          15.7 MB/s
  rewrites         13.1 MB/s        15.6 MB/s          15.9 MB/s
  reads            15.2 MB/s        16.9 MB/s          17.2 MB/s
  re-reads         15.3 MB/s        16.9 MB/s          17.2 MB/s
  random readers    5.6 MB/s         5.6 MB/s           5.7 MB/s
  random writers    5.1 MB/s         5.3 MB/s           5.4 MB/s 

So it seems that, so far, this was a useful exercise.
Signed-off-by: default avatarFrank Mayhar <fmayhar@google.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent ff7ef329
...@@ -531,11 +531,11 @@ void ext4_free_blocks_sb(handle_t *handle, struct super_block *sb, ...@@ -531,11 +531,11 @@ void ext4_free_blocks_sb(handle_t *handle, struct super_block *sb,
/* We dirtied the bitmap block */ /* We dirtied the bitmap block */
BUFFER_TRACE(bitmap_bh, "dirtied bitmap block"); BUFFER_TRACE(bitmap_bh, "dirtied bitmap block");
err = ext4_journal_dirty_metadata(handle, bitmap_bh); err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);
/* And the group descriptor block */ /* And the group descriptor block */
BUFFER_TRACE(gd_bh, "dirtied group descriptor block"); BUFFER_TRACE(gd_bh, "dirtied group descriptor block");
ret = ext4_journal_dirty_metadata(handle, gd_bh); ret = ext4_handle_dirty_metadata(handle, NULL, gd_bh);
if (!err) err = ret; if (!err) err = ret;
*pdquot_freed_blocks += group_freed; *pdquot_freed_blocks += group_freed;
......
...@@ -7,53 +7,96 @@ ...@@ -7,53 +7,96 @@
int __ext4_journal_get_undo_access(const char *where, handle_t *handle, int __ext4_journal_get_undo_access(const char *where, handle_t *handle,
struct buffer_head *bh) struct buffer_head *bh)
{ {
int err = jbd2_journal_get_undo_access(handle, bh); int err = 0;
if (err)
ext4_journal_abort_handle(where, __func__, bh, handle, err); if (ext4_handle_valid(handle)) {
err = jbd2_journal_get_undo_access(handle, bh);
if (err)
ext4_journal_abort_handle(where, __func__, bh,
handle, err);
}
return err; return err;
} }
int __ext4_journal_get_write_access(const char *where, handle_t *handle, int __ext4_journal_get_write_access(const char *where, handle_t *handle,
struct buffer_head *bh) struct buffer_head *bh)
{ {
int err = jbd2_journal_get_write_access(handle, bh); int err = 0;
if (err)
ext4_journal_abort_handle(where, __func__, bh, handle, err); if (ext4_handle_valid(handle)) {
err = jbd2_journal_get_write_access(handle, bh);
if (err)
ext4_journal_abort_handle(where, __func__, bh,
handle, err);
}
return err; return err;
} }
int __ext4_journal_forget(const char *where, handle_t *handle, int __ext4_journal_forget(const char *where, handle_t *handle,
struct buffer_head *bh) struct buffer_head *bh)
{ {
int err = jbd2_journal_forget(handle, bh); int err = 0;
if (err)
ext4_journal_abort_handle(where, __func__, bh, handle, err); if (ext4_handle_valid(handle)) {
err = jbd2_journal_forget(handle, bh);
if (err)
ext4_journal_abort_handle(where, __func__, bh,
handle, err);
}
return err; return err;
} }
int __ext4_journal_revoke(const char *where, handle_t *handle, int __ext4_journal_revoke(const char *where, handle_t *handle,
ext4_fsblk_t blocknr, struct buffer_head *bh) ext4_fsblk_t blocknr, struct buffer_head *bh)
{ {
int err = jbd2_journal_revoke(handle, blocknr, bh); int err = 0;
if (err)
ext4_journal_abort_handle(where, __func__, bh, handle, err); if (ext4_handle_valid(handle)) {
err = jbd2_journal_revoke(handle, blocknr, bh);
if (err)
ext4_journal_abort_handle(where, __func__, bh,
handle, err);
}
return err; return err;
} }
int __ext4_journal_get_create_access(const char *where, int __ext4_journal_get_create_access(const char *where,
handle_t *handle, struct buffer_head *bh) handle_t *handle, struct buffer_head *bh)
{ {
int err = jbd2_journal_get_create_access(handle, bh); int err = 0;
if (err)
ext4_journal_abort_handle(where, __func__, bh, handle, err); if (ext4_handle_valid(handle)) {
err = jbd2_journal_get_create_access(handle, bh);
if (err)
ext4_journal_abort_handle(where, __func__, bh,
handle, err);
}
return err; return err;
} }
int __ext4_journal_dirty_metadata(const char *where, int __ext4_handle_dirty_metadata(const char *where, handle_t *handle,
handle_t *handle, struct buffer_head *bh) struct inode *inode, struct buffer_head *bh)
{ {
int err = jbd2_journal_dirty_metadata(handle, bh); int err = 0;
if (err)
ext4_journal_abort_handle(where, __func__, bh, handle, err); if (ext4_handle_valid(handle)) {
err = jbd2_journal_dirty_metadata(handle, bh);
if (err)
ext4_journal_abort_handle(where, __func__, bh,
handle, err);
} else {
mark_buffer_dirty(bh);
if (inode && inode_needs_sync(inode)) {
sync_dirty_buffer(bh);
if (buffer_req(bh) && !buffer_uptodate(bh)) {
ext4_error(inode->i_sb, __func__,
"IO error syncing inode, "
"inode=%lu, block=%llu",
inode->i_ino,
(unsigned long long) bh->b_blocknr);
err = -EIO;
}
}
}
return err; return err;
} }
...@@ -122,12 +122,6 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode); ...@@ -122,12 +122,6 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode);
* been done yet. * been done yet.
*/ */
static inline void ext4_journal_release_buffer(handle_t *handle,
struct buffer_head *bh)
{
jbd2_journal_release_buffer(handle, bh);
}
void ext4_journal_abort_handle(const char *caller, const char *err_fn, void ext4_journal_abort_handle(const char *caller, const char *err_fn,
struct buffer_head *bh, handle_t *handle, int err); struct buffer_head *bh, handle_t *handle, int err);
...@@ -146,8 +140,8 @@ int __ext4_journal_revoke(const char *where, handle_t *handle, ...@@ -146,8 +140,8 @@ int __ext4_journal_revoke(const char *where, handle_t *handle,
int __ext4_journal_get_create_access(const char *where, int __ext4_journal_get_create_access(const char *where,
handle_t *handle, struct buffer_head *bh); handle_t *handle, struct buffer_head *bh);
int __ext4_journal_dirty_metadata(const char *where, int __ext4_handle_dirty_metadata(const char *where, handle_t *handle,
handle_t *handle, struct buffer_head *bh); struct inode *inode, struct buffer_head *bh);
#define ext4_journal_get_undo_access(handle, bh) \ #define ext4_journal_get_undo_access(handle, bh) \
__ext4_journal_get_undo_access(__func__, (handle), (bh)) __ext4_journal_get_undo_access(__func__, (handle), (bh))
...@@ -157,14 +151,57 @@ int __ext4_journal_dirty_metadata(const char *where, ...@@ -157,14 +151,57 @@ int __ext4_journal_dirty_metadata(const char *where,
__ext4_journal_revoke(__func__, (handle), (blocknr), (bh)) __ext4_journal_revoke(__func__, (handle), (blocknr), (bh))
#define ext4_journal_get_create_access(handle, bh) \ #define ext4_journal_get_create_access(handle, bh) \
__ext4_journal_get_create_access(__func__, (handle), (bh)) __ext4_journal_get_create_access(__func__, (handle), (bh))
#define ext4_journal_dirty_metadata(handle, bh) \
__ext4_journal_dirty_metadata(__func__, (handle), (bh))
#define ext4_journal_forget(handle, bh) \ #define ext4_journal_forget(handle, bh) \
__ext4_journal_forget(__func__, (handle), (bh)) __ext4_journal_forget(__func__, (handle), (bh))
#define ext4_handle_dirty_metadata(handle, inode, bh) \
__ext4_handle_dirty_metadata(__func__, (handle), (inode), (bh))
handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks); handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks);
int __ext4_journal_stop(const char *where, handle_t *handle); int __ext4_journal_stop(const char *where, handle_t *handle);
#define EXT4_NOJOURNAL_HANDLE ((handle_t *) 0x1)
static inline int ext4_handle_valid(handle_t *handle)
{
if (handle == EXT4_NOJOURNAL_HANDLE)
return 0;
return 1;
}
static inline void ext4_handle_sync(handle_t *handle)
{
if (ext4_handle_valid(handle))
handle->h_sync = 1;
}
static inline void ext4_handle_release_buffer(handle_t *handle,
struct buffer_head *bh)
{
if (ext4_handle_valid(handle))
jbd2_journal_release_buffer(handle, bh);
}
static inline int ext4_handle_is_aborted(handle_t *handle)
{
if (ext4_handle_valid(handle))
return is_handle_aborted(handle);
return 0;
}
static inline int ext4_handle_has_enough_credits(handle_t *handle, int needed)
{
if (ext4_handle_valid(handle) && handle->h_buffer_credits < needed)
return 0;
return 1;
}
static inline void ext4_journal_release_buffer(handle_t *handle,
struct buffer_head *bh)
{
if (ext4_handle_valid(handle))
jbd2_journal_release_buffer(handle, bh);
}
static inline handle_t *ext4_journal_start(struct inode *inode, int nblocks) static inline handle_t *ext4_journal_start(struct inode *inode, int nblocks)
{ {
return ext4_journal_start_sb(inode->i_sb, nblocks); return ext4_journal_start_sb(inode->i_sb, nblocks);
...@@ -180,27 +217,37 @@ static inline handle_t *ext4_journal_current_handle(void) ...@@ -180,27 +217,37 @@ static inline handle_t *ext4_journal_current_handle(void)
static inline int ext4_journal_extend(handle_t *handle, int nblocks) static inline int ext4_journal_extend(handle_t *handle, int nblocks)
{ {
return jbd2_journal_extend(handle, nblocks); if (ext4_handle_valid(handle))
return jbd2_journal_extend(handle, nblocks);
return 0;
} }
static inline int ext4_journal_restart(handle_t *handle, int nblocks) static inline int ext4_journal_restart(handle_t *handle, int nblocks)
{ {
return jbd2_journal_restart(handle, nblocks); if (ext4_handle_valid(handle))
return jbd2_journal_restart(handle, nblocks);
return 0;
} }
static inline int ext4_journal_blocks_per_page(struct inode *inode) static inline int ext4_journal_blocks_per_page(struct inode *inode)
{ {
return jbd2_journal_blocks_per_page(inode); if (EXT4_JOURNAL(inode) != NULL)
return jbd2_journal_blocks_per_page(inode);
return 0;
} }
static inline int ext4_journal_force_commit(journal_t *journal) static inline int ext4_journal_force_commit(journal_t *journal)
{ {
return jbd2_journal_force_commit(journal); if (journal)
return jbd2_journal_force_commit(journal);
return 0;
} }
static inline int ext4_jbd2_file_inode(handle_t *handle, struct inode *inode) static inline int ext4_jbd2_file_inode(handle_t *handle, struct inode *inode)
{ {
return jbd2_journal_file_inode(handle, &EXT4_I(inode)->jinode); if (ext4_handle_valid(handle))
return jbd2_journal_file_inode(handle, &EXT4_I(inode)->jinode);
return 0;
} }
/* super.c */ /* super.c */
...@@ -208,6 +255,8 @@ int ext4_force_commit(struct super_block *sb); ...@@ -208,6 +255,8 @@ int ext4_force_commit(struct super_block *sb);
static inline int ext4_should_journal_data(struct inode *inode) static inline int ext4_should_journal_data(struct inode *inode)
{ {
if (EXT4_JOURNAL(inode) == NULL)
return 0;
if (!S_ISREG(inode->i_mode)) if (!S_ISREG(inode->i_mode))
return 1; return 1;
if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
...@@ -219,6 +268,8 @@ static inline int ext4_should_journal_data(struct inode *inode) ...@@ -219,6 +268,8 @@ static inline int ext4_should_journal_data(struct inode *inode)
static inline int ext4_should_order_data(struct inode *inode) static inline int ext4_should_order_data(struct inode *inode)
{ {
if (EXT4_JOURNAL(inode) == NULL)
return 0;
if (!S_ISREG(inode->i_mode)) if (!S_ISREG(inode->i_mode))
return 0; return 0;
if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL) if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
...@@ -230,6 +281,8 @@ static inline int ext4_should_order_data(struct inode *inode) ...@@ -230,6 +281,8 @@ static inline int ext4_should_order_data(struct inode *inode)
static inline int ext4_should_writeback_data(struct inode *inode) static inline int ext4_should_writeback_data(struct inode *inode)
{ {
if (EXT4_JOURNAL(inode) == NULL)
return 0;
if (!S_ISREG(inode->i_mode)) if (!S_ISREG(inode->i_mode))
return 0; return 0;
if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL) if (EXT4_I(inode)->i_flags & EXT4_JOURNAL_DATA_FL)
......
...@@ -97,6 +97,8 @@ static int ext4_ext_journal_restart(handle_t *handle, int needed) ...@@ -97,6 +97,8 @@ static int ext4_ext_journal_restart(handle_t *handle, int needed)
{ {
int err; int err;
if (!ext4_handle_valid(handle))
return 0;
if (handle->h_buffer_credits > needed) if (handle->h_buffer_credits > needed)
return 0; return 0;
err = ext4_journal_extend(handle, needed); err = ext4_journal_extend(handle, needed);
...@@ -134,7 +136,7 @@ static int ext4_ext_dirty(handle_t *handle, struct inode *inode, ...@@ -134,7 +136,7 @@ static int ext4_ext_dirty(handle_t *handle, struct inode *inode,
int err; int err;
if (path->p_bh) { if (path->p_bh) {
/* path points to block */ /* path points to block */
err = ext4_journal_dirty_metadata(handle, path->p_bh); err = ext4_handle_dirty_metadata(handle, inode, path->p_bh);
} else { } else {
/* path points to leaf/index in inode body */ /* path points to leaf/index in inode body */
err = ext4_mark_inode_dirty(handle, inode); err = ext4_mark_inode_dirty(handle, inode);
...@@ -780,7 +782,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, ...@@ -780,7 +782,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
unlock_buffer(bh); unlock_buffer(bh);
err = ext4_journal_dirty_metadata(handle, bh); err = ext4_handle_dirty_metadata(handle, inode, bh);
if (err) if (err)
goto cleanup; goto cleanup;
brelse(bh); brelse(bh);
...@@ -859,7 +861,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, ...@@ -859,7 +861,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
unlock_buffer(bh); unlock_buffer(bh);
err = ext4_journal_dirty_metadata(handle, bh); err = ext4_handle_dirty_metadata(handle, inode, bh);
if (err) if (err)
goto cleanup; goto cleanup;
brelse(bh); brelse(bh);
...@@ -955,7 +957,7 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode, ...@@ -955,7 +957,7 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
unlock_buffer(bh); unlock_buffer(bh);
err = ext4_journal_dirty_metadata(handle, bh); err = ext4_handle_dirty_metadata(handle, inode, bh);
if (err) if (err)
goto out; goto out;
...@@ -2947,7 +2949,7 @@ void ext4_ext_truncate(struct inode *inode) ...@@ -2947,7 +2949,7 @@ void ext4_ext_truncate(struct inode *inode)
* transaction synchronous. * transaction synchronous.
*/ */
if (IS_SYNC(inode)) if (IS_SYNC(inode))
handle->h_sync = 1; ext4_handle_sync(handle);
out_stop: out_stop:
up_write(&EXT4_I(inode)->i_data_sem); up_write(&EXT4_I(inode)->i_data_sem);
......
...@@ -253,12 +253,12 @@ void ext4_free_inode(handle_t *handle, struct inode *inode) ...@@ -253,12 +253,12 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
spin_unlock(sb_bgl_lock(sbi, flex_group)); spin_unlock(sb_bgl_lock(sbi, flex_group));
} }
} }
BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata"); BUFFER_TRACE(bh2, "call ext4_handle_dirty_metadata");
err = ext4_journal_dirty_metadata(handle, bh2); err = ext4_handle_dirty_metadata(handle, NULL, bh2);
if (!fatal) fatal = err; if (!fatal) fatal = err;
} }
BUFFER_TRACE(bitmap_bh, "call ext4_journal_dirty_metadata"); BUFFER_TRACE(bitmap_bh, "call ext4_handle_dirty_metadata");
err = ext4_journal_dirty_metadata(handle, bitmap_bh); err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);
if (!fatal) if (!fatal)
fatal = err; fatal = err;
sb->s_dirt = 1; sb->s_dirt = 1;
...@@ -656,15 +656,16 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode) ...@@ -656,15 +656,16 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
ino, bitmap_bh->b_data)) { ino, bitmap_bh->b_data)) {
/* we won it */ /* we won it */
BUFFER_TRACE(bitmap_bh, BUFFER_TRACE(bitmap_bh,
"call ext4_journal_dirty_metadata"); "call ext4_handle_dirty_metadata");
err = ext4_journal_dirty_metadata(handle, err = ext4_handle_dirty_metadata(handle,
inode,
bitmap_bh); bitmap_bh);
if (err) if (err)
goto fail; goto fail;
goto got; goto got;
} }
/* we lost it */ /* we lost it */
jbd2_journal_release_buffer(handle, bitmap_bh); ext4_handle_release_buffer(handle, bitmap_bh);
if (++ino < EXT4_INODES_PER_GROUP(sb)) if (++ino < EXT4_INODES_PER_GROUP(sb))
goto repeat_in_this_group; goto repeat_in_this_group;
...@@ -726,7 +727,8 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode) ...@@ -726,7 +727,8 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
/* Don't need to dirty bitmap block if we didn't change it */ /* Don't need to dirty bitmap block if we didn't change it */
if (free) { if (free) {
BUFFER_TRACE(block_bh, "dirty block bitmap"); BUFFER_TRACE(block_bh, "dirty block bitmap");
err = ext4_journal_dirty_metadata(handle, block_bh); err = ext4_handle_dirty_metadata(handle,
NULL, block_bh);
} }
brelse(block_bh); brelse(block_bh);
...@@ -771,8 +773,8 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode) ...@@ -771,8 +773,8 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
} }
gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp); gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp);
spin_unlock(sb_bgl_lock(sbi, group)); spin_unlock(sb_bgl_lock(sbi, group));
BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata"); BUFFER_TRACE(bh2, "call ext4_handle_dirty_metadata");
err = ext4_journal_dirty_metadata(handle, bh2); err = ext4_handle_dirty_metadata(handle, NULL, bh2);
if (err) goto fail; if (err) goto fail;
percpu_counter_dec(&sbi->s_freeinodes_counter); percpu_counter_dec(&sbi->s_freeinodes_counter);
...@@ -825,7 +827,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode) ...@@ -825,7 +827,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
ext4_set_inode_flags(inode); ext4_set_inode_flags(inode);
if (IS_DIRSYNC(inode)) if (IS_DIRSYNC(inode))
handle->h_sync = 1; ext4_handle_sync(handle);
if (insert_inode_locked(inode) < 0) { if (insert_inode_locked(inode) < 0) {
err = -EINVAL; err = -EINVAL;
goto fail_drop; goto fail_drop;
...@@ -1028,4 +1030,3 @@ unsigned long ext4_count_dirs(struct super_block * sb) ...@@ -1028,4 +1030,3 @@ unsigned long ext4_count_dirs(struct super_block * sb)
} }
return count; return count;
} }
This diff is collapsed.
...@@ -99,7 +99,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -99,7 +99,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
goto flags_out; goto flags_out;
} }
if (IS_SYNC(inode)) if (IS_SYNC(inode))
handle->h_sync = 1; ext4_handle_sync(handle);
err = ext4_reserve_inode_write(handle, inode, &iloc); err = ext4_reserve_inode_write(handle, inode, &iloc);
if (err) if (err)
goto flags_err; goto flags_err;
......
...@@ -2553,7 +2553,8 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery) ...@@ -2553,7 +2553,8 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
ext4_mb_init_per_dev_proc(sb); ext4_mb_init_per_dev_proc(sb);
ext4_mb_history_init(sb); ext4_mb_history_init(sb);
sbi->s_journal->j_commit_callback = release_blocks_on_commit; if (sbi->s_journal)
sbi->s_journal->j_commit_callback = release_blocks_on_commit;
printk(KERN_INFO "EXT4-fs: mballoc enabled\n"); printk(KERN_INFO "EXT4-fs: mballoc enabled\n");
return 0; return 0;
...@@ -2854,7 +2855,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, ...@@ -2854,7 +2855,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
mb_set_bits(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group), mb_set_bits(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group),
bitmap_bh->b_data, ac->ac_b_ex.fe_start, bitmap_bh->b_data, ac->ac_b_ex.fe_start,
ac->ac_b_ex.fe_len); ac->ac_b_ex.fe_len);
err = ext4_journal_dirty_metadata(handle, bitmap_bh); err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);
if (!err) if (!err)
err = -EAGAIN; err = -EAGAIN;
goto out_err; goto out_err;
...@@ -2901,10 +2902,10 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac, ...@@ -2901,10 +2902,10 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
spin_unlock(sb_bgl_lock(sbi, flex_group)); spin_unlock(sb_bgl_lock(sbi, flex_group));
} }
err = ext4_journal_dirty_metadata(handle, bitmap_bh); err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);
if (err) if (err)
goto out_err; goto out_err;
err = ext4_journal_dirty_metadata(handle, gdp_bh); err = ext4_handle_dirty_metadata(handle, NULL, gdp_bh);
out_err: out_err:
sb->s_dirt = 1; sb->s_dirt = 1;
...@@ -4414,7 +4415,7 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b, ...@@ -4414,7 +4415,7 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b,
struct rb_node **n = &db->bb_free_root.rb_node, *node; struct rb_node **n = &db->bb_free_root.rb_node, *node;
struct rb_node *parent = NULL, *new_node; struct rb_node *parent = NULL, *new_node;
BUG_ON(!ext4_handle_valid(handle));
BUG_ON(e4b->bd_bitmap_page == NULL); BUG_ON(e4b->bd_bitmap_page == NULL);
BUG_ON(e4b->bd_buddy_page == NULL); BUG_ON(e4b->bd_buddy_page == NULL);
...@@ -4600,7 +4601,7 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode, ...@@ -4600,7 +4601,7 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode,
/* We dirtied the bitmap block */ /* We dirtied the bitmap block */
BUFFER_TRACE(bitmap_bh, "dirtied bitmap block"); BUFFER_TRACE(bitmap_bh, "dirtied bitmap block");
err = ext4_journal_dirty_metadata(handle, bitmap_bh); err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);
if (ac) { if (ac) {
ac->ac_b_ex.fe_group = block_group; ac->ac_b_ex.fe_group = block_group;
...@@ -4609,7 +4610,7 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode, ...@@ -4609,7 +4610,7 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode,
ext4_mb_store_history(ac); ext4_mb_store_history(ac);
} }
if (metadata) { if (metadata && ext4_handle_valid(handle)) {
/* blocks being freed are metadata. these blocks shouldn't /* blocks being freed are metadata. these blocks shouldn't
* be used until this transaction is committed */ * be used until this transaction is committed */
ext4_mb_free_metadata(handle, &e4b, block_group, bit, count); ext4_mb_free_metadata(handle, &e4b, block_group, bit, count);
...@@ -4639,7 +4640,7 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode, ...@@ -4639,7 +4640,7 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode,
/* And the group descriptor block */ /* And the group descriptor block */
BUFFER_TRACE(gd_bh, "dirtied group descriptor block"); BUFFER_TRACE(gd_bh, "dirtied group descriptor block");
ret = ext4_journal_dirty_metadata(handle, gd_bh); ret = ext4_handle_dirty_metadata(handle, NULL, gd_bh);
if (!err) if (!err)
err = ret; err = ret;
......
...@@ -59,7 +59,8 @@ static int finish_range(handle_t *handle, struct inode *inode, ...@@ -59,7 +59,8 @@ static int finish_range(handle_t *handle, struct inode *inode,
/* /*
* Make sure the credit we accumalated is not really high * Make sure the credit we accumalated is not really high
*/ */
if (needed && handle->h_buffer_credits >= EXT4_RESERVE_TRANS_BLOCKS) { if (needed && ext4_handle_has_enough_credits(handle,
EXT4_RESERVE_TRANS_BLOCKS)) {
retval = ext4_journal_restart(handle, needed); retval = ext4_journal_restart(handle, needed);
if (retval) if (retval)
goto err_out; goto err_out;
...@@ -229,7 +230,7 @@ static int extend_credit_for_blkdel(handle_t *handle, struct inode *inode) ...@@ -229,7 +230,7 @@ static int extend_credit_for_blkdel(handle_t *handle, struct inode *inode)
{ {
int retval = 0, needed; int retval = 0, needed;
if (handle->h_buffer_credits > EXT4_RESERVE_TRANS_BLOCKS) if (ext4_handle_has_enough_credits(handle, EXT4_RESERVE_TRANS_BLOCKS+1))
return 0; return 0;
/* /*
* We are freeing a blocks. During this we touch * We are freeing a blocks. During this we touch
......
...@@ -1233,10 +1233,10 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, ...@@ -1233,10 +1233,10 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
de = de2; de = de2;
} }
dx_insert_block(frame, hash2 + continued, newblock); dx_insert_block(frame, hash2 + continued, newblock);
err = ext4_journal_dirty_metadata(handle, bh2); err = ext4_handle_dirty_metadata(handle, dir, bh2);
if (err) if (err)
goto journal_error; goto journal_error;
err = ext4_journal_dirty_metadata(handle, frame->bh); err = ext4_handle_dirty_metadata(handle, dir, frame->bh);
if (err) if (err)
goto journal_error; goto journal_error;
brelse(bh2); brelse(bh2);
...@@ -1340,8 +1340,8 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry, ...@@ -1340,8 +1340,8 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,
ext4_update_dx_flag(dir); ext4_update_dx_flag(dir);
dir->i_version++; dir->i_version++;
ext4_mark_inode_dirty(handle, dir); ext4_mark_inode_dirty(handle, dir);
BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata"); BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata");
err = ext4_journal_dirty_metadata(handle, bh); err = ext4_handle_dirty_metadata(handle, dir, bh);
if (err) if (err)
ext4_std_error(dir->i_sb, err); ext4_std_error(dir->i_sb, err);
brelse(bh); brelse(bh);
...@@ -1581,7 +1581,7 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, ...@@ -1581,7 +1581,7 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
dxtrace(dx_show_index("node", frames[1].entries)); dxtrace(dx_show_index("node", frames[1].entries));
dxtrace(dx_show_index("node", dxtrace(dx_show_index("node",
((struct dx_node *) bh2->b_data)->entries)); ((struct dx_node *) bh2->b_data)->entries));
err = ext4_journal_dirty_metadata(handle, bh2); err = ext4_handle_dirty_metadata(handle, inode, bh2);
if (err) if (err)
goto journal_error; goto journal_error;
brelse (bh2); brelse (bh2);
...@@ -1607,7 +1607,7 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, ...@@ -1607,7 +1607,7 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
if (err) if (err)
goto journal_error; goto journal_error;
} }
ext4_journal_dirty_metadata(handle, frames[0].bh); ext4_handle_dirty_metadata(handle, inode, frames[0].bh);
} }
de = do_split(handle, dir, &bh, frame, &hinfo, &err); de = do_split(handle, dir, &bh, frame, &hinfo, &err);
if (!de) if (!de)
...@@ -1653,8 +1653,8 @@ static int ext4_delete_entry(handle_t *handle, ...@@ -1653,8 +1653,8 @@ static int ext4_delete_entry(handle_t *handle,
else else
de->inode = 0; de->inode = 0;
dir->i_version++; dir->i_version++;
BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata"); BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata");
ext4_journal_dirty_metadata(handle, bh); ext4_handle_dirty_metadata(handle, dir, bh);
return 0; return 0;
} }
i += ext4_rec_len_from_disk(de->rec_len); i += ext4_rec_len_from_disk(de->rec_len);
...@@ -1732,7 +1732,7 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, int mode, ...@@ -1732,7 +1732,7 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, int mode,
return PTR_ERR(handle); return PTR_ERR(handle);
if (IS_DIRSYNC(dir)) if (IS_DIRSYNC(dir))
handle->h_sync = 1; ext4_handle_sync(handle);
inode = ext4_new_inode (handle, dir, mode); inode = ext4_new_inode (handle, dir, mode);
err = PTR_ERR(inode); err = PTR_ERR(inode);
...@@ -1766,7 +1766,7 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry, ...@@ -1766,7 +1766,7 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry,
return PTR_ERR(handle); return PTR_ERR(handle);
if (IS_DIRSYNC(dir)) if (IS_DIRSYNC(dir))
handle->h_sync = 1; ext4_handle_sync(handle);
inode = ext4_new_inode(handle, dir, mode); inode = ext4_new_inode(handle, dir, mode);
err = PTR_ERR(inode); err = PTR_ERR(inode);
...@@ -1802,7 +1802,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -1802,7 +1802,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
return PTR_ERR(handle); return PTR_ERR(handle);
if (IS_DIRSYNC(dir)) if (IS_DIRSYNC(dir))
handle->h_sync = 1; ext4_handle_sync(handle);
inode = ext4_new_inode(handle, dir, S_IFDIR | mode); inode = ext4_new_inode(handle, dir, S_IFDIR | mode);
err = PTR_ERR(inode); err = PTR_ERR(inode);
...@@ -1831,8 +1831,8 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -1831,8 +1831,8 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
strcpy(de->name, ".."); strcpy(de->name, "..");
ext4_set_de_type(dir->i_sb, de, S_IFDIR); ext4_set_de_type(dir->i_sb, de, S_IFDIR);
inode->i_nlink = 2; inode->i_nlink = 2;
BUFFER_TRACE(dir_block, "call ext4_journal_dirty_metadata"); BUFFER_TRACE(dir_block, "call ext4_handle_dirty_metadata");
ext4_journal_dirty_metadata(handle, dir_block); ext4_handle_dirty_metadata(handle, dir, dir_block);
brelse(dir_block); brelse(dir_block);
ext4_mark_inode_dirty(handle, inode); ext4_mark_inode_dirty(handle, inode);
err = ext4_add_entry(handle, dentry, inode); err = ext4_add_entry(handle, dentry, inode);
...@@ -1944,6 +1944,9 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) ...@@ -1944,6 +1944,9 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
struct ext4_iloc iloc; struct ext4_iloc iloc;
int err = 0, rc; int err = 0, rc;
if (!ext4_handle_valid(handle))
return 0;
lock_super(sb); lock_super(sb);
if (!list_empty(&EXT4_I(inode)->i_orphan)) if (!list_empty(&EXT4_I(inode)->i_orphan))
goto out_unlock; goto out_unlock;
...@@ -1972,7 +1975,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) ...@@ -1972,7 +1975,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
/* Insert this inode at the head of the on-disk orphan list... */ /* Insert this inode at the head of the on-disk orphan list... */
NEXT_ORPHAN(inode) = le32_to_cpu(EXT4_SB(sb)->s_es->s_last_orphan); NEXT_ORPHAN(inode) = le32_to_cpu(EXT4_SB(sb)->s_es->s_last_orphan);
EXT4_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino); EXT4_SB(sb)->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
err = ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh); err = ext4_handle_dirty_metadata(handle, inode, EXT4_SB(sb)->s_sbh);
rc = ext4_mark_iloc_dirty(handle, inode, &iloc); rc = ext4_mark_iloc_dirty(handle, inode, &iloc);
if (!err) if (!err)
err = rc; err = rc;
...@@ -2010,6 +2013,9 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) ...@@ -2010,6 +2013,9 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
struct ext4_iloc iloc; struct ext4_iloc iloc;
int err = 0; int err = 0;
if (!ext4_handle_valid(handle))
return 0;
lock_super(inode->i_sb); lock_super(inode->i_sb);
if (list_empty(&ei->i_orphan)) { if (list_empty(&ei->i_orphan)) {
unlock_super(inode->i_sb); unlock_super(inode->i_sb);
...@@ -2028,7 +2034,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) ...@@ -2028,7 +2034,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
* transaction handle with which to update the orphan list on * transaction handle with which to update the orphan list on
* disk, but we still need to remove the inode from the linked * disk, but we still need to remove the inode from the linked
* list in memory. */ * list in memory. */
if (!handle) if (sbi->s_journal && !handle)
goto out; goto out;
err = ext4_reserve_inode_write(handle, inode, &iloc); err = ext4_reserve_inode_write(handle, inode, &iloc);
...@@ -2042,7 +2048,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) ...@@ -2042,7 +2048,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
if (err) if (err)
goto out_brelse; goto out_brelse;
sbi->s_es->s_last_orphan = cpu_to_le32(ino_next); sbi->s_es->s_last_orphan = cpu_to_le32(ino_next);
err = ext4_journal_dirty_metadata(handle, sbi->s_sbh); err = ext4_handle_dirty_metadata(handle, inode, sbi->s_sbh);
} else { } else {
struct ext4_iloc iloc2; struct ext4_iloc iloc2;
struct inode *i_prev = struct inode *i_prev =
...@@ -2093,7 +2099,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -2093,7 +2099,7 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
goto end_rmdir; goto end_rmdir;
if (IS_DIRSYNC(dir)) if (IS_DIRSYNC(dir))
handle->h_sync = 1; ext4_handle_sync(handle);
inode = dentry->d_inode; inode = dentry->d_inode;
...@@ -2147,7 +2153,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) ...@@ -2147,7 +2153,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
return PTR_ERR(handle); return PTR_ERR(handle);
if (IS_DIRSYNC(dir)) if (IS_DIRSYNC(dir))
handle->h_sync = 1; ext4_handle_sync(handle);
retval = -ENOENT; retval = -ENOENT;
bh = ext4_find_entry(dir, &dentry->d_name, &de); bh = ext4_find_entry(dir, &dentry->d_name, &de);
...@@ -2204,7 +2210,7 @@ static int ext4_symlink(struct inode *dir, ...@@ -2204,7 +2210,7 @@ static int ext4_symlink(struct inode *dir,
return PTR_ERR(handle); return PTR_ERR(handle);
if (IS_DIRSYNC(dir)) if (IS_DIRSYNC(dir))
handle->h_sync = 1; ext4_handle_sync(handle);
inode = ext4_new_inode(handle, dir, S_IFLNK|S_IRWXUGO); inode = ext4_new_inode(handle, dir, S_IFLNK|S_IRWXUGO);
err = PTR_ERR(inode); err = PTR_ERR(inode);
...@@ -2267,7 +2273,7 @@ static int ext4_link(struct dentry *old_dentry, ...@@ -2267,7 +2273,7 @@ static int ext4_link(struct dentry *old_dentry,
return PTR_ERR(handle); return PTR_ERR(handle);
if (IS_DIRSYNC(dir)) if (IS_DIRSYNC(dir))
handle->h_sync = 1; ext4_handle_sync(handle);
inode->i_ctime = ext4_current_time(inode); inode->i_ctime = ext4_current_time(inode);
ext4_inc_count(handle, inode); ext4_inc_count(handle, inode);
...@@ -2316,7 +2322,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2316,7 +2322,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
return PTR_ERR(handle); return PTR_ERR(handle);
if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir))
handle->h_sync = 1; ext4_handle_sync(handle);
old_bh = ext4_find_entry(old_dir, &old_dentry->d_name, &old_de); old_bh = ext4_find_entry(old_dir, &old_dentry->d_name, &old_de);
/* /*
...@@ -2370,8 +2376,8 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2370,8 +2376,8 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
new_dir->i_ctime = new_dir->i_mtime = new_dir->i_ctime = new_dir->i_mtime =
ext4_current_time(new_dir); ext4_current_time(new_dir);
ext4_mark_inode_dirty(handle, new_dir); ext4_mark_inode_dirty(handle, new_dir);
BUFFER_TRACE(new_bh, "call ext4_journal_dirty_metadata"); BUFFER_TRACE(new_bh, "call ext4_handle_dirty_metadata");
ext4_journal_dirty_metadata(handle, new_bh); ext4_handle_dirty_metadata(handle, new_dir, new_bh);
brelse(new_bh); brelse(new_bh);
new_bh = NULL; new_bh = NULL;
} }
...@@ -2421,8 +2427,8 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -2421,8 +2427,8 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
BUFFER_TRACE(dir_bh, "get_write_access"); BUFFER_TRACE(dir_bh, "get_write_access");
ext4_journal_get_write_access(handle, dir_bh); ext4_journal_get_write_access(handle, dir_bh);
PARENT_INO(dir_bh->b_data) = cpu_to_le32(new_dir->i_ino); PARENT_INO(dir_bh->b_data) = cpu_to_le32(new_dir->i_ino);
BUFFER_TRACE(dir_bh, "call ext4_journal_dirty_metadata"); BUFFER_TRACE(dir_bh, "call ext4_handle_dirty_metadata");
ext4_journal_dirty_metadata(handle, dir_bh); ext4_handle_dirty_metadata(handle, old_dir, dir_bh);
ext4_dec_count(handle, old_dir); ext4_dec_count(handle, old_dir);
if (new_inode) { if (new_inode) {
/* checked empty_dir above, can't have another parent, /* checked empty_dir above, can't have another parent,
......
...@@ -149,7 +149,7 @@ static int extend_or_restart_transaction(handle_t *handle, int thresh, ...@@ -149,7 +149,7 @@ static int extend_or_restart_transaction(handle_t *handle, int thresh,
{ {
int err; int err;
if (handle->h_buffer_credits >= thresh) if (ext4_handle_has_enough_credits(handle, thresh))
return 0; return 0;
err = ext4_journal_extend(handle, EXT4_MAX_TRANS_DATA); err = ext4_journal_extend(handle, EXT4_MAX_TRANS_DATA);
...@@ -232,7 +232,7 @@ static int setup_new_group_blocks(struct super_block *sb, ...@@ -232,7 +232,7 @@ static int setup_new_group_blocks(struct super_block *sb,
memcpy(gdb->b_data, sbi->s_group_desc[i]->b_data, gdb->b_size); memcpy(gdb->b_data, sbi->s_group_desc[i]->b_data, gdb->b_size);
set_buffer_uptodate(gdb); set_buffer_uptodate(gdb);
unlock_buffer(gdb); unlock_buffer(gdb);
ext4_journal_dirty_metadata(handle, gdb); ext4_handle_dirty_metadata(handle, NULL, gdb);
ext4_set_bit(bit, bh->b_data); ext4_set_bit(bit, bh->b_data);
brelse(gdb); brelse(gdb);
} }
...@@ -251,7 +251,7 @@ static int setup_new_group_blocks(struct super_block *sb, ...@@ -251,7 +251,7 @@ static int setup_new_group_blocks(struct super_block *sb,
err = PTR_ERR(bh); err = PTR_ERR(bh);
goto exit_bh; goto exit_bh;
} }
ext4_journal_dirty_metadata(handle, gdb); ext4_handle_dirty_metadata(handle, NULL, gdb);
ext4_set_bit(bit, bh->b_data); ext4_set_bit(bit, bh->b_data);
brelse(gdb); brelse(gdb);
} }
...@@ -276,7 +276,7 @@ static int setup_new_group_blocks(struct super_block *sb, ...@@ -276,7 +276,7 @@ static int setup_new_group_blocks(struct super_block *sb,
err = PTR_ERR(it); err = PTR_ERR(it);
goto exit_bh; goto exit_bh;
} }
ext4_journal_dirty_metadata(handle, it); ext4_handle_dirty_metadata(handle, NULL, it);
brelse(it); brelse(it);
ext4_set_bit(bit, bh->b_data); ext4_set_bit(bit, bh->b_data);
} }
...@@ -286,7 +286,7 @@ static int setup_new_group_blocks(struct super_block *sb, ...@@ -286,7 +286,7 @@ static int setup_new_group_blocks(struct super_block *sb,
mark_bitmap_end(input->blocks_count, EXT4_BLOCKS_PER_GROUP(sb), mark_bitmap_end(input->blocks_count, EXT4_BLOCKS_PER_GROUP(sb),
bh->b_data); bh->b_data);
ext4_journal_dirty_metadata(handle, bh); ext4_handle_dirty_metadata(handle, NULL, bh);
brelse(bh); brelse(bh);
/* Mark unused entries in inode bitmap used */ /* Mark unused entries in inode bitmap used */
...@@ -299,7 +299,7 @@ static int setup_new_group_blocks(struct super_block *sb, ...@@ -299,7 +299,7 @@ static int setup_new_group_blocks(struct super_block *sb,
mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), EXT4_BLOCKS_PER_GROUP(sb), mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), EXT4_BLOCKS_PER_GROUP(sb),
bh->b_data); bh->b_data);
ext4_journal_dirty_metadata(handle, bh); ext4_handle_dirty_metadata(handle, NULL, bh);
exit_bh: exit_bh:
brelse(bh); brelse(bh);
...@@ -486,12 +486,12 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, ...@@ -486,12 +486,12 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
* reserved inode, and will become GDT blocks (primary and backup). * reserved inode, and will become GDT blocks (primary and backup).
*/ */
data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)] = 0; data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)] = 0;
ext4_journal_dirty_metadata(handle, dind); ext4_handle_dirty_metadata(handle, NULL, dind);
brelse(dind); brelse(dind);
inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9; inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9;
ext4_mark_iloc_dirty(handle, inode, &iloc); ext4_mark_iloc_dirty(handle, inode, &iloc);
memset((*primary)->b_data, 0, sb->s_blocksize); memset((*primary)->b_data, 0, sb->s_blocksize);
ext4_journal_dirty_metadata(handle, *primary); ext4_handle_dirty_metadata(handle, NULL, *primary);
o_group_desc = EXT4_SB(sb)->s_group_desc; o_group_desc = EXT4_SB(sb)->s_group_desc;
memcpy(n_group_desc, o_group_desc, memcpy(n_group_desc, o_group_desc,
...@@ -502,7 +502,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, ...@@ -502,7 +502,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
kfree(o_group_desc); kfree(o_group_desc);
le16_add_cpu(&es->s_reserved_gdt_blocks, -1); le16_add_cpu(&es->s_reserved_gdt_blocks, -1);
ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh); ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
return 0; return 0;
...@@ -618,7 +618,7 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode, ...@@ -618,7 +618,7 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
primary[i]->b_blocknr, gdbackups, primary[i]->b_blocknr, gdbackups,
blk + primary[i]->b_blocknr); */ blk + primary[i]->b_blocknr); */
data[gdbackups] = cpu_to_le32(blk + primary[i]->b_blocknr); data[gdbackups] = cpu_to_le32(blk + primary[i]->b_blocknr);
err2 = ext4_journal_dirty_metadata(handle, primary[i]); err2 = ext4_handle_dirty_metadata(handle, NULL, primary[i]);
if (!err) if (!err)
err = err2; err = err2;
} }
...@@ -676,7 +676,8 @@ static void update_backups(struct super_block *sb, ...@@ -676,7 +676,8 @@ static void update_backups(struct super_block *sb,
struct buffer_head *bh; struct buffer_head *bh;
/* Out of journal space, and can't get more - abort - so sad */ /* Out of journal space, and can't get more - abort - so sad */
if (handle->h_buffer_credits == 0 && if (ext4_handle_valid(handle) &&
handle->h_buffer_credits == 0 &&
ext4_journal_extend(handle, EXT4_MAX_TRANS_DATA) && ext4_journal_extend(handle, EXT4_MAX_TRANS_DATA) &&
(err = ext4_journal_restart(handle, EXT4_MAX_TRANS_DATA))) (err = ext4_journal_restart(handle, EXT4_MAX_TRANS_DATA)))
break; break;
...@@ -696,7 +697,7 @@ static void update_backups(struct super_block *sb, ...@@ -696,7 +697,7 @@ static void update_backups(struct super_block *sb,
memset(bh->b_data + size, 0, rest); memset(bh->b_data + size, 0, rest);
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
unlock_buffer(bh); unlock_buffer(bh);
ext4_journal_dirty_metadata(handle, bh); ext4_handle_dirty_metadata(handle, NULL, bh);
brelse(bh); brelse(bh);
} }
if ((err2 = ext4_journal_stop(handle)) && !err) if ((err2 = ext4_journal_stop(handle)) && !err)
...@@ -916,7 +917,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) ...@@ -916,7 +917,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
/* Update the global fs size fields */ /* Update the global fs size fields */
sbi->s_groups_count++; sbi->s_groups_count++;
ext4_journal_dirty_metadata(handle, primary); ext4_handle_dirty_metadata(handle, NULL, primary);
/* Update the reserved block counts only once the new group is /* Update the reserved block counts only once the new group is
* active. */ * active. */
...@@ -938,7 +939,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input) ...@@ -938,7 +939,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
EXT4_INODES_PER_GROUP(sb); EXT4_INODES_PER_GROUP(sb);
} }
ext4_journal_dirty_metadata(handle, sbi->s_sbh); ext4_handle_dirty_metadata(handle, NULL, sbi->s_sbh);
sb->s_dirt = 1; sb->s_dirt = 1;
exit_journal: exit_journal:
...@@ -1072,7 +1073,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es, ...@@ -1072,7 +1073,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
goto exit_put; goto exit_put;
} }
ext4_blocks_count_set(es, o_blocks_count + add); ext4_blocks_count_set(es, o_blocks_count + add);
ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh); ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
sb->s_dirt = 1; sb->s_dirt = 1;
unlock_super(sb); unlock_super(sb);
ext4_debug("freeing blocks %llu through %llu\n", o_blocks_count, ext4_debug("freeing blocks %llu through %llu\n", o_blocks_count,
......
This diff is collapsed.
...@@ -457,7 +457,7 @@ static void ext4_xattr_update_super_block(handle_t *handle, ...@@ -457,7 +457,7 @@ static void ext4_xattr_update_super_block(handle_t *handle,
if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) { if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR); EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR);
sb->s_dirt = 1; sb->s_dirt = 1;
ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh); ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
} }
} }
...@@ -487,9 +487,9 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode, ...@@ -487,9 +487,9 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
ext4_forget(handle, 1, inode, bh, bh->b_blocknr); ext4_forget(handle, 1, inode, bh, bh->b_blocknr);
} else { } else {
le32_add_cpu(&BHDR(bh)->h_refcount, -1); le32_add_cpu(&BHDR(bh)->h_refcount, -1);
error = ext4_journal_dirty_metadata(handle, bh); error = ext4_handle_dirty_metadata(handle, inode, bh);
if (IS_SYNC(inode)) if (IS_SYNC(inode))
handle->h_sync = 1; ext4_handle_sync(handle);
DQUOT_FREE_BLOCK(inode, 1); DQUOT_FREE_BLOCK(inode, 1);
ea_bdebug(bh, "refcount now=%d; releasing", ea_bdebug(bh, "refcount now=%d; releasing",
le32_to_cpu(BHDR(bh)->h_refcount)); le32_to_cpu(BHDR(bh)->h_refcount));
...@@ -724,8 +724,9 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -724,8 +724,9 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
if (error == -EIO) if (error == -EIO)
goto bad_block; goto bad_block;
if (!error) if (!error)
error = ext4_journal_dirty_metadata(handle, error = ext4_handle_dirty_metadata(handle,
bs->bh); inode,
bs->bh);
if (error) if (error)
goto cleanup; goto cleanup;
goto inserted; goto inserted;
...@@ -794,8 +795,9 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -794,8 +795,9 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
ea_bdebug(new_bh, "reusing; refcount now=%d", ea_bdebug(new_bh, "reusing; refcount now=%d",
le32_to_cpu(BHDR(new_bh)->h_refcount)); le32_to_cpu(BHDR(new_bh)->h_refcount));
unlock_buffer(new_bh); unlock_buffer(new_bh);
error = ext4_journal_dirty_metadata(handle, error = ext4_handle_dirty_metadata(handle,
new_bh); inode,
new_bh);
if (error) if (error)
goto cleanup_dquot; goto cleanup_dquot;
} }
...@@ -833,7 +835,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -833,7 +835,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
set_buffer_uptodate(new_bh); set_buffer_uptodate(new_bh);
unlock_buffer(new_bh); unlock_buffer(new_bh);
ext4_xattr_cache_insert(new_bh); ext4_xattr_cache_insert(new_bh);
error = ext4_journal_dirty_metadata(handle, new_bh); error = ext4_handle_dirty_metadata(handle,
inode, new_bh);
if (error) if (error)
goto cleanup; goto cleanup;
} }
...@@ -1040,7 +1043,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, ...@@ -1040,7 +1043,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
*/ */
is.iloc.bh = NULL; is.iloc.bh = NULL;
if (IS_SYNC(inode)) if (IS_SYNC(inode))
handle->h_sync = 1; ext4_handle_sync(handle);
} }
cleanup: cleanup:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment