Skip to contentSkip to conversation

Allow ext4 to run without a journal.

RFC PATCH In review Frank Mayhar 4 participants 14 messages Oct 30, 2008 – Dec 1, 2008 ext4 file system

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Allow ext4 to run without a journal.

We have a need to run ext4 on existing ext2 file systems. To get there we need to be able to run ext4 without a journal. I've managed to come up with an early patch that gets us at least partway there.

This patch just allows ext4 to mount and run with an ext2 root; I haven't tried it with anything else yet. It also scribbles in the superblock, so it takes an fsck to get it back to ext2 compatibility. I'm posting it to get you guys involved and to hear any comments you guys have about how I did it.

I say that I did it, but actually it was a sequential collaboration between Peter Kukul <[email protected]> and I. He did the first pass and I went behind him, changed things around a bit and made it actually sort of work.

This only modifies ext4 itself, it touches nothing else. I'm not including a signed-off-by since I don't intend this as an official submission. There is more work to do. I just want to get it out and let you guys take a look and beat on it if you care to.

---
 acl.c       |    4 
 balloc.c    |   12 +-
 ext4_jbd2.c |   60 +++++++++----
 extents.c   |   34 +++----
 fsync.c     |    2 
 ialloc.c    |   29 +++---
 inode.c     |  258 +++++++++++++++++++++++++++++++++---------------------------
 ioctl.c     |   10 +-
 mballoc.c   |   20 ++--
 migrate.c   |   13 +--
 namei.c     |   83 +++++++++----------
 resize.c    |   50 +++++------
 super.c     |  247 +++++++++++++++++++++++++++++++++++++++------------------
 xattr.c     |   23 +++--
 14 files changed, 501 insertions(+), 344 deletions(-)
fs/ext4/acl.c +2 -2
diff -up -r linux-2.6.26.y/fs/ext4/acl.c foo/fs/ext4/acl.c
@@ -396,7 +396,7 @@ ext4_acl_chmod(struct inode *inode)
 	retry:
 		handle = ext4_journal_start(inode,
 				EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
-		if (IS_ERR(handle)) {
+		if (handle && IS_ERR(handle)) {
 			error = PTR_ERR(handle);
 			ext4_std_error(inode->i_sb, error);
 			goto out;
@@ -506,7 +506,7 @@ ext4_xattr_set_acl(struct inode *inode, 
 
 retry:
 	handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
-	if (IS_ERR(handle))
+	if (handle && IS_ERR(handle))
 		return PTR_ERR(handle);
 	error = ext4_set_acl(handle, inode, type, acl);
 	ext4_journal_stop(handle);
fs/ext4/balloc.c +6 -6
diff -up -r linux-2.6.26.y/fs/ext4/balloc.c foo/fs/ext4/balloc.c
@@ -816,11 +816,11 @@ do_more:
 
 	/* We dirtied the 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 */
 	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;
 	*pdquot_freed_blocks += group_freed;
 
@@ -1585,9 +1585,9 @@ ext4_try_to_allocate_with_rsv(struct sup
 	}
 out:
 	if (ret >= 0) {
-		BUFFER_TRACE(bitmap_bh, "journal_dirty_metadata for "
+		BUFFER_TRACE(bitmap_bh, "handle_dirty_metadata for "
 					"bitmap block");
-		fatal = ext4_journal_dirty_metadata(handle, bitmap_bh);
+		fatal = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);
 		if (fatal) {
 			*errp = fatal;
 			return -1;
@@ -1920,8 +1920,8 @@ allocated:
 		spin_unlock(sb_bgl_lock(sbi, flex_group));
 	}
 
-	BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor");
-	err = ext4_journal_dirty_metadata(handle, gdp_bh);
+	BUFFER_TRACE(gdp_bh, "handle_dirty_metadata for group descriptor");
+	err = ext4_handle_dirty_metadata(handle, NULL, gdp_bh);
 	if (!fatal)
 		fatal = err;
 
fs/ext4/ext4_jbd2.c +42 -18

95 lines not on this page · raw message

fs/ext4/extents.c +17 -17
diff -up -r linux-2.6.26.y/fs/ext4/extents.c foo/fs/ext4/extents.c
@@ -96,7 +96,7 @@ static int ext4_ext_journal_restart(hand
 {
 	int err;
 
-	if (handle->h_buffer_credits > needed)
+	if (handle && handle->h_buffer_credits > needed)
 		return 0;
 	err = ext4_journal_extend(handle, needed);
 	if (err <= 0)
@@ -133,7 +133,7 @@ static int ext4_ext_dirty(handle_t *hand
 	int err;
 	if (path->p_bh) {
 		/* path points to block */
-		err = ext4_journal_dirty_metadata(handle, path->p_bh);
+		err = ext4_handle_dirty_metadata(handle, inode, path->p_bh);
 	} else {
 		/* path points to leaf/index in inode body */
 		err = ext4_mark_inode_dirty(handle, inode);
@@ -778,7 +778,7 @@ static int ext4_ext_split(handle_t *hand
 	set_buffer_uptodate(bh);
 	unlock_buffer(bh);
 
-	err = ext4_journal_dirty_metadata(handle, bh);
+	err = ext4_handle_dirty_metadata(handle, inode, bh);
 	if (err)
 		goto cleanup;
 	brelse(bh);
@@ -857,7 +857,7 @@ static int ext4_ext_split(handle_t *hand
 		set_buffer_uptodate(bh);
 		unlock_buffer(bh);
 
-		err = ext4_journal_dirty_metadata(handle, bh);
+		err = ext4_handle_dirty_metadata(handle, inode, bh);
 		if (err)
 			goto cleanup;
 		brelse(bh);
@@ -953,7 +953,7 @@ static int ext4_ext_grow_indepth(handle_
 	set_buffer_uptodate(bh);
 	unlock_buffer(bh);
 
-	err = ext4_journal_dirty_metadata(handle, bh);
+	err = ext4_handle_dirty_metadata(handle, inode, bh);
 	if (err)
 		goto out;
 
@@ -1885,7 +1885,7 @@ ext4_ext_rm_leaf(handle_t *handle, struc
 
 	while (ex >= EXT_FIRST_EXTENT(eh) &&
 			ex_ee_block + ex_ee_len > start) {
-		ext_debug("remove ext %lu:%u\n", ex_ee_block, ex_ee_len);
+		ext_debug("remove ext %lu:%u\n", (unsigned long)ex_ee_block, ex_ee_len);
 		path[depth].p_ext = ex;
 
 		a = ex_ee_block > start ? ex_ee_block : start;
@@ -2012,7 +2012,7 @@ static int ext4_ext_remove_space(struct 
 
 	/* probably first extent we're gonna free will be last in block */
 	handle = ext4_journal_start(inode, depth + 1);
-	if (IS_ERR(handle))
+	if (handle && IS_ERR(handle))
 		return PTR_ERR(handle);
 
 	ext4_ext_invalidate_cache(inode);
@@ -2023,7 +2023,7 @@ static int ext4_ext_remove_space(struct 
 	 */
 	path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_NOFS);
 	if (path == NULL) {
-		ext4_journal_stop(handle);
+		ext4_journal_stop(sb, handle);
 		return -ENOMEM;
 	}
 	path[0].p_hdr = ext_inode_hdr(inode);
@@ -2126,7 +2126,7 @@ out:
 	ext4_ext_tree_changed(inode);
 	ext4_ext_drop_refs(path);
 	kfree(path);
-	ext4_journal_stop(handle);
+	ext4_journal_stop(sb, handle);
 
 	return err;
 }
@@ -2582,7 +2582,7 @@ int ext4_ext_get_blocks(handle_t *handle
 
 	__clear_bit(BH_New, &bh_result->b_state);
 	ext_debug("blocks %u/%lu requested for inode %u\n",
-			iblock, max_blocks, inode->i_ino);
+			iblock, max_blocks, (unsigned)inode->i_ino);
 
 	/* check in cache */
 	goal = ext4_ext_in_cache(inode, iblock, &newex);
@@ -2645,7 +2645,7 @@ int ext4_ext_get_blocks(handle_t *handle
 			/* number of remaining blocks in the extent */
 			allocated = ee_len - (iblock - ee_block);
 			ext_debug("%u fit into %lu:%d -> %llu\n", iblock,
-					ee_block, ee_len, newblock);
+					(unsigned long)ee_block, ee_len, newblock);
 
 			/* Do not put uninitialized extent in the cache */
 			if (!ext4_ext_is_uninitialized(ex)) {
@@ -2811,7 +2811,7 @@ void ext4_ext_truncate(struct inode *ino
 	 */
 	handle = ext4_journal_start(inode,
 				    ext4_writepages_trans_blocks(inode, 1) + 3);
-	if (IS_ERR(handle))
+	if (handle && IS_ERR(handle))
 		return;
 
 	if (inode->i_size & (sb->s_blocksize - 1))
@@ -2842,7 +2842,7 @@ void ext4_ext_truncate(struct inode *ino
 	/* In a multi-transaction truncate, we only make the final
 	 * transaction synchronous.
 	 */
-	if (IS_SYNC(inode))
+	if (handle && IS_SYNC(inode))
 		handle->h_sync = 1;
 
 out_stop:
@@ -2859,7 +2859,7 @@ out_stop:
 
 	inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
 	ext4_mark_inode_dirty(handle, inode);
-	ext4_journal_stop(handle);
+	ext4_journal_stop(sb, handle);
 }
 
 /*
@@ -2962,7 +2962,7 @@ retry:
 		block = block + ret;
 		max_blocks = max_blocks - ret;
 		handle = ext4_journal_start(inode, credits);
-		if (IS_ERR(handle)) {
+		if (handle && IS_ERR(handle)) {
 			ret = PTR_ERR(handle);
 			break;
 		}
@@ -2978,7 +2978,7 @@ retry:
 				    inode->i_ino, block, max_blocks);
 #endif
 			ext4_mark_inode_dirty(handle, inode);
-			ret2 = ext4_journal_stop(handle);
+			ret2 = ext4_journal_stop(inode->i_sb, handle);
 			break;
 		}
 		if ((block + ret) >= (EXT4_BLOCK_ALIGN(offset + len,
@@ -2990,7 +2990,7 @@ retry:
 		ext4_falloc_update_inode(inode, mode, new_size,
 						buffer_new(&map_bh));
 		ext4_mark_inode_dirty(handle, inode);
-		ret2 = ext4_journal_stop(handle);
+		ret2 = ext4_journal_stop(inode->i_sb, handle);
 		if (ret2)
 			break;
 	}
fs/ext4/fsync.c +1 -1
diff -up -r linux-2.6.26.y/fs/ext4/fsync.c foo/fs/ext4/fsync.c
@@ -49,7 +49,7 @@ int ext4_sync_file(struct file * file, s
 	journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
 	int ret = 0;
 
-	J_ASSERT(ext4_journal_current_handle() == NULL);
+	J_ASSERT(ext4_journal_current_handle(inode->i_sb) == NULL);
 
 	/*
 	 * data=writeback:
fs/ext4/ialloc.c +16 -13
diff -up -r linux-2.6.26.y/fs/ext4/ialloc.c foo/fs/ext4/ialloc.c
@@ -250,12 +250,12 @@ void ext4_free_inode (handle_t *handle, 
 				spin_unlock(sb_bgl_lock(sbi, flex_group));
 			}
 		}
-		BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
-		err = ext4_journal_dirty_metadata(handle, bh2);
+		BUFFER_TRACE(bh2, "call ext4_handle_dirty_metadata");
+		err = ext4_handle_dirty_metadata(handle, NULL, bh2);
 		if (!fatal) fatal = err;
 	}
-	BUFFER_TRACE(bitmap_bh, "call ext4_journal_dirty_metadata");
-	err = ext4_journal_dirty_metadata(handle, bitmap_bh);
+	BUFFER_TRACE(bitmap_bh, "call ext4_handle_dirty_metadata");
+	err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);
 	if (!fatal)
 		fatal = err;
 	sb->s_dirt = 1;
@@ -645,7 +645,8 @@ repeat_in_this_group:
 		if (ino < EXT4_INODES_PER_GROUP(sb)) {
 
 			BUFFER_TRACE(bitmap_bh, "get_write_access");
-			err = ext4_journal_get_write_access(handle, bitmap_bh);
+			err = ext4_journal_get_write_access(handle,
+								    bitmap_bh);
 			if (err)
 				goto fail;
 
@@ -653,15 +654,17 @@ repeat_in_this_group:
 						ino, bitmap_bh->b_data)) {
 				/* we won it */
 				BUFFER_TRACE(bitmap_bh,
-					"call ext4_journal_dirty_metadata");
-				err = ext4_journal_dirty_metadata(handle,
+					    "call ext4_handle_dirty_metadata");
+				err = ext4_handle_dirty_metadata(handle,
+								inode,
 								bitmap_bh);
 				if (err)
 					goto fail;
 				goto got;
 			}
 			/* we lost it */
-			jbd2_journal_release_buffer(handle, bitmap_bh);
+			if (handle)
+				jbd2_journal_release_buffer(handle, bitmap_bh);
 
 			if (++ino < EXT4_INODES_PER_GROUP(sb))
 				goto repeat_in_this_group;
@@ -721,7 +724,8 @@ got:
 		/* Don't need to dirty bitmap block if we didn't change it */
 		if (free) {
 			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);
@@ -766,8 +770,8 @@ got:
 	}
 	gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp);
 	spin_unlock(sb_bgl_lock(sbi, group));
-	BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
-	err = ext4_journal_dirty_metadata(handle, bh2);
+	BUFFER_TRACE(bh2, "call ext4_handle_dirty_metadata");
+	err = ext4_handle_dirty_metadata(handle, NULL, bh2);
 	if (err) goto fail;
 
 	percpu_counter_dec(&sbi->s_freeinodes_counter);
@@ -820,7 +824,7 @@ got:
 	ei->i_block_group = group;
 
 	ext4_set_inode_flags(inode);
-	if (IS_DIRSYNC(inode))
+	if (handle && IS_DIRSYNC(inode))
 		handle->h_sync = 1;
 	insert_inode_hash(inode);
 	spin_lock(&sbi->s_next_gen_lock);
@@ -1019,4 +1023,3 @@ unsigned long ext4_count_dirs (struct su
 	}
 	return count;
 }
-
fs/ext4/inode.c +145 -113

650 lines not on this page · raw message

fs/ext4/ioctl.c +5 -5
diff -up -r linux-2.6.26.y/fs/ext4/ioctl.c foo/fs/ext4/ioctl.c
@@ -84,11 +84,11 @@ long ext4_ioctl(struct file *filp, unsig
 		}
 
 		handle = ext4_journal_start(inode, 1);
-		if (IS_ERR(handle)) {
+		if (handle && IS_ERR(handle)) {
 			err = PTR_ERR(handle);
 			goto flags_out;
 		}
-		if (IS_SYNC(inode))
+		if (handle && IS_SYNC(inode))
 			handle->h_sync = 1;
 		err = ext4_reserve_inode_write(handle, inode, &iloc);
 		if (err)
@@ -103,7 +103,7 @@ long ext4_ioctl(struct file *filp, unsig
 
 		err = ext4_mark_iloc_dirty(handle, inode, &iloc);
 flags_err:
-		ext4_journal_stop(handle);
+		ext4_journal_stop(inode->i_sb, handle);
 		if (err)
 			goto flags_out;
 
@@ -136,7 +136,7 @@ flags_out:
 		}
 
 		handle = ext4_journal_start(inode, 1);
-		if (IS_ERR(handle)) {
+		if (handle && IS_ERR(handle)) {
 			err = PTR_ERR(handle);
 			goto setversion_out;
 		}
@@ -146,7 +146,7 @@ flags_out:
 			inode->i_generation = generation;
 			err = ext4_mark_iloc_dirty(handle, inode, &iloc);
 		}
-		ext4_journal_stop(handle);
+		ext4_journal_stop(inode->i_sb, handle);
 setversion_out:
 		mnt_drop_write(filp->f_path.mnt);
 		return err;
fs/ext4/mballoc.c +12 -8
diff -up -r linux-2.6.26.y/fs/ext4/mballoc.c foo/fs/ext4/mballoc.c
@@ -2940,7 +2940,7 @@ ext4_mb_mark_diskspace_used(struct ext4_
 		mb_set_bits(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group),
 				bitmap_bh->b_data, ac->ac_b_ex.fe_start,
 				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)
 			err = -EAGAIN;
 		goto out_err;
@@ -2986,10 +2986,10 @@ ext4_mb_mark_diskspace_used(struct ext4_
 		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)
 		goto out_err;
-	err = ext4_journal_dirty_metadata(handle, gdp_bh);
+	err = ext4_handle_dirty_metadata(handle, NULL, gdp_bh);
 
 out_err:
 	sb->s_dirt = 1;
@@ -4442,6 +4442,8 @@ static void ext4_mb_poll_new_transaction
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 
+	if (!handle)
+		return;
 	if (sbi->s_last_transaction == handle->h_transaction->t_tid)
 		return;
 
@@ -4478,13 +4480,15 @@ ext4_mb_free_metadata(handle_t *handle, 
 	struct ext4_free_metadata *md;
 	int i;
 
+	BUG_ON(!handle);
 	BUG_ON(e4b->bd_bitmap_page == NULL);
 	BUG_ON(e4b->bd_buddy_page == NULL);
 
 	ext4_lock_group(sb, group);
 	for (i = 0; i < count; i++) {
+		int htid = handle->h_transaction->t_tid;
 		md = db->bb_md_cur;
-		if (md && db->bb_tid != handle->h_transaction->t_tid) {
+		if (md && db->bb_tid != htid) {
 			db->bb_md_cur = NULL;
 			md = NULL;
 		}
@@ -4509,7 +4513,7 @@ ext4_mb_free_metadata(handle_t *handle, 
 				page_cache_get(e4b->bd_buddy_page);
 				page_cache_get(e4b->bd_bitmap_page);
 				db->bb_md_cur = md;
-				db->bb_tid = handle->h_transaction->t_tid;
+				db->bb_tid = htid;
 				mb_debug("new md 0x%p for group %lu\n",
 						md, md->group);
 			} else {
@@ -4643,7 +4647,7 @@ do_more:
 
 	/* We dirtied the 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) {
 		ac->ac_b_ex.fe_group = block_group;
@@ -4652,7 +4656,7 @@ do_more:
 		ext4_mb_store_history(ac);
 	}
 
-	if (metadata) {
+	if (handle && metadata) {
 		/* blocks being freed are metadata. these blocks shouldn't
 		 * be used until this transaction is committed */
 		ext4_mb_free_metadata(handle, &e4b, block_group, bit, count);
@@ -4682,7 +4686,7 @@ do_more:
 
 	/* And the 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;
 
fs/ext4/migrate.c +7 -6
diff -up -r linux-2.6.26.y/fs/ext4/migrate.c foo/fs/ext4/migrate.c
@@ -60,7 +60,8 @@ static int finish_range(handle_t *handle
 	/*
 	 * Make sure the credit we accumalated is not really high
 	 */
-	if (needed && handle->h_buffer_credits >= EXT4_RESERVE_TRANS_BLOCKS) {
+	if (needed && handle &&
+	    handle->h_buffer_credits >= EXT4_RESERVE_TRANS_BLOCKS) {
 		retval = ext4_journal_restart(handle, needed);
 		if (retval)
 			goto err_out;
@@ -230,7 +231,7 @@ static int extend_credit_for_blkdel(hand
 {
 	int retval = 0, needed;
 
-	if (handle->h_buffer_credits > EXT4_RESERVE_TRANS_BLOCKS)
+	if (handle && handle->h_buffer_credits > EXT4_RESERVE_TRANS_BLOCKS)
 		return 0;
 	/*
 	 * We are freeing a blocks. During this we touch
@@ -480,7 +481,7 @@ int ext4_ext_migrate(struct inode *inode
 					EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
 					2 * EXT4_QUOTA_INIT_BLOCKS(inode->i_sb)
 					+ 1);
-	if (IS_ERR(handle)) {
+	if (handle && IS_ERR(handle)) {
 		retval = PTR_ERR(handle);
 		goto err_out;
 	}
@@ -489,7 +490,7 @@ int ext4_ext_migrate(struct inode *inode
 				S_IFREG);
 	if (IS_ERR(tmp_inode)) {
 		retval = -ENOMEM;
-		ext4_journal_stop(handle);
+		ext4_journal_stop(inode->i_sb, handle);
 		tmp_inode = NULL;
 		goto err_out;
 	}
@@ -506,7 +507,7 @@ int ext4_ext_migrate(struct inode *inode
 
 	ext4_ext_tree_init(handle, tmp_inode);
 	ext4_orphan_add(handle, tmp_inode);
-	ext4_journal_stop(handle);
+	ext4_journal_stop(inode->i_sb, handle);
 
 	/*
 	 * start with one credit accounted for
@@ -623,7 +624,7 @@ err_out:
 	 */
 	tmp_inode->i_nlink = 0;
 
-	ext4_journal_stop(handle);
+	ext4_journal_stop(inode->i_sb, handle);
 	mutex_unlock(&(inode->i_mutex));
 
 	if (tmp_inode)
fs/ext4/namei.c +42 -41

267 lines not on this page · raw message

fs/ext4/resize.c +25 -25

188 lines not on this page · raw message

fs/ext4/super.c +168 -79

548 lines not on this page · raw message

fs/ext4/xattr.c +13 -10
diff -up -r linux-2.6.26.y/fs/ext4/xattr.c foo/fs/ext4/xattr.c
@@ -457,7 +457,7 @@ static void ext4_xattr_update_super_bloc
 	if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
 		EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR);
 		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,8 +487,8 @@ ext4_xattr_release_block(handle_t *handl
 		ext4_forget(handle, 1, inode, bh, bh->b_blocknr);
 	} else {
 		le32_add_cpu(&BHDR(bh)->h_refcount, -1);
-		error = ext4_journal_dirty_metadata(handle, bh);
-		if (IS_SYNC(inode))
+		error = ext4_handle_dirty_metadata(handle, inode, bh);
+		if (handle && IS_SYNC(inode))
 			handle->h_sync = 1;
 		DQUOT_FREE_BLOCK(inode, 1);
 		ea_bdebug(bh, "refcount now=%d; releasing",
@@ -724,8 +724,9 @@ ext4_xattr_block_set(handle_t *handle, s
 			if (error == -EIO)
 				goto bad_block;
 			if (!error)
-				error = ext4_journal_dirty_metadata(handle,
-								    bs->bh);
+				error = ext4_handle_dirty_metadata(handle,
+								   inode,
+								   bs->bh);
 			if (error)
 				goto cleanup;
 			goto inserted;
@@ -794,8 +795,9 @@ inserted:
 				ea_bdebug(new_bh, "reusing; refcount now=%d",
 					le32_to_cpu(BHDR(new_bh)->h_refcount));
 				unlock_buffer(new_bh);
-				error = ext4_journal_dirty_metadata(handle,
-								    new_bh);
+				error = ext4_handle_dirty_metadata(handle,
+								   inode,
+								   new_bh);
 				if (error)
 					goto cleanup_dquot;
 			}
@@ -833,7 +835,8 @@ getblk_failed:
 			set_buffer_uptodate(new_bh);
 			unlock_buffer(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)
 				goto cleanup;
 		}
@@ -1035,7 +1038,7 @@ ext4_xattr_set_handle(handle_t *handle, 
 		 * error != 0.
 		 */
 		is.iloc.bh = NULL;
-		if (IS_SYNC(inode))
+		if (handle && IS_SYNC(inode))
 			handle->h_sync = 1;
 	}
 
@@ -1063,7 +1066,7 @@ ext4_xattr_set(struct inode *inode, int 
 
 retry:
 	handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
-	if (IS_ERR(handle)) {
+	if (handle && IS_ERR(handle)) {
 		error = PTR_ERR(handle);
 	} else {
 		int error2;
Signature · 2 lines
Frank Mayhar <[email protected]>
Google, Inc.
#1 lore raw

Firstly,
thanks for working on this. It is a huge patch, and my suggested changes are some effort to reduce the size of the patch and keep this functionality more maintainable.

I'd be terribly interested in ext2 vs. ext4 with/without journal performance numbers, if you have any.

Quoted 7 lines · Frank Mayhar

We have a need to run ext4 on existing ext2 file systems. To get there we need to be able to run ext4 without a journal. I've managed to come up with an early patch that gets us at least partway there.

This patch just allows ext4 to mount and run with an ext2 root; I haven't tried it with anything else yet. It also scribbles in the superblock, so it takes an fsck to get it back to ext2 compatibility.

What is the reason for this? In the final form all that should happen is the normal ext2 "mark filesystem dirty" operation.

Review ext4_acl_chmod(struct inode *inode) · line 396

Quoted 3 lines
(quoted diff) +1 -1
@@ -396,7 +396,7 @@ ext4_acl_chmod(struct inode *inode)
-		if (IS_ERR(handle)) {
+		if (handle && IS_ERR(handle)) {

Actually, if handle is NULL then "IS_ERR(handle)" is false from my reading:

	unlikely(0UL >= -4095UL)

No need to change all of this code.

fs/ext4/extents.c static int ext4_ext_journal_restart(hand · line 98

Quoted 5 lines
fs/ext4/extents.c +1 -1
@@ -96,7 +96,7 @@ static int ext4_ext_journal_restart(hand
 {
-	if (handle->h_buffer_credits > needed)
+	if (handle && handle->h_buffer_credits > needed)
 		return 0;

This should just be "if (!handle) return 0;" as the first condition.

fs/ext4/extents.c ext4_ext_rm_leaf(handle_t *handle, struc · line 1888

Quoted 6 lines
fs/ext4/extents.c +1 -1
@@ -1885,7 +1885,7 @@ ext4_ext_rm_leaf(handle_t *handle, struc
 
 	while (ex >= EXT_FIRST_EXTENT(eh) &&
 			ex_ee_block + ex_ee_len > start) {
-		ext_debug("remove ext %lu:%u\n", ex_ee_block, ex_ee_len);
+		ext_debug("remove ext %lu:%u\n", (unsigned long)ex_ee_block, ex_ee_len);

This is the wrong fix. Instead it should just be using "%u" to print the block number, since it is limited to 32 bits right now. Same is true of all similar fixes.

fs/ext4/extents.c int ext4_ext_get_blocks(handle_t *handle · line 2583

Quoted 4 lines
fs/ext4/extents.c +1 -1
@@ -2582,7 +2582,7 @@ int ext4_ext_get_blocks(handle_t *handle
 	ext_debug("blocks %u/%lu requested for inode %u\n",
-			iblock, max_blocks, inode->i_ino);
+			iblock, max_blocks, (unsigned)inode->i_ino);

Similarly, the right format for ino_t is %lu instead of casting the value.

fs/ext4/extents.c void ext4_ext_truncate(struct inode *ino · line 2843

Quoted 4 lines
fs/ext4/extents.c +1 -1
@@ -2842,7 +2842,7 @@ void ext4_ext_truncate(struct inode *ino
-	if (IS_SYNC(inode))
+	if (handle && IS_SYNC(inode))
 		handle->h_sync = 1;

It would be nice to have a helper function that does this transparently:

static inline void ext4_handle_sync(handle)

{
	if (handle)
		handle->h_sync = 1;
}

This could be submitted before the rest of the patch without "if (handle)" and then you only need to change the code in one place.

fs/ext4/ialloc.c void ext4_free_inode (handle_t *handle, · line 254

Quoted 4 lines
fs/ext4/ialloc.c +2 -2
-		BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
-		err = ext4_journal_dirty_metadata(handle, bh2);
+		BUFFER_TRACE(bh2, "call ext4_handle_dirty_metadata");
+		err = ext4_handle_dirty_metadata(handle, NULL, bh2);

With this change are you removing the older ext4_journal_*() functions completely (ensuring that all callers have to be fixed to use ext4_handle*() instead), or are they still available? Unfortunately, this part of the patch is missing.

If the ext4_journal_*() functions are still available this exposes us to endless bugs from code that doesn't get fixed to work in unjournalled mode, but 99% of users won't notice it.

fs/ext4/ialloc.c repeat_in_this_group: · line 646

Quoted 4 lines
fs/ext4/ialloc.c +2 -1
@@ -645,7 +645,8 @@ repeat_in_this_group:
-			err = ext4_journal_get_write_access(handle, bitmap_bh);
+			err = ext4_journal_get_write_access(handle,
+								    bitmap_bh);

I'm not sure why that was changed.

fs/ext4/ialloc.c repeat_in_this_group: · line 656

Quoted 5 lines
fs/ext4/ialloc.c +2 -1
@@ -653,15 +654,17 @@ repeat_in_this_group:
 			/* we lost it */
-			jbd2_journal_release_buffer(handle, bitmap_bh);
+			if (handle)
+				jbd2_journal_release_buffer(handle, bitmap_bh);

This should probably also be wrapped in ext4_handle_release_buffer() so we don't need to expose all of the callsites to this check.

fs/ext4/ialloc.c got: · line 825

Quoted 4 lines
fs/ext4/ialloc.c +1 -1
@@ -820,7 +824,7 @@ got:
-	if (IS_DIRSYNC(inode))
+	if (handle && IS_DIRSYNC(inode))
 		handle->h_sync = 1;

Use ext4_handle_sync(handle) helper as suggested above.

fs/ext4/inode.c void ext4_delete_inode (struct inode * i · line 239

Quoted 2 lines
fs/ext4/inode.c +1 -0
@@ -232,7 +239,7 @@ void ext4_delete_inode (struct inode * i
+	if (handle && handle->h_buffer_credits < 3) {

A new helper ext4_handle_has_enough_credits(handle, needed) would be useful in a few places, and can always return 1 if handle is NULL.

fs/ext4/inode.c int ext4_get_blocks_handle(handle_t *han · line 889

Quoted 4 lines
fs/ext4/inode.c +1 -1
@@ -881,7 +888,8 @@ int ext4_get_blocks_handle(handle_t *han
 	J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL));
-	J_ASSERT(handle != NULL || create == 0);
+	/*J_ASSERT(handle != NULL || create == 0);*/

I would predicate this assertion on sbi->s_journal instead of just removing it:

	J_ASSERT(create == 0 ||
		 (handle != NULL) == (EXT4_SB(inode->i_sb)->s_journal != NULL));

fs/ext4/inode.c struct buffer_head *ext4_getblk(handle_t · line 1226

Quoted 9 lines
fs/ext4/inode.c +0 -2
@@ -1198,8 +1206,6 @@ struct buffer_head *ext4_getblk(handle_t
 	struct buffer_head dummy;
 	int fatal = 0, err;
 
-	J_ASSERT(handle != NULL || create == 0);
@@ -1224,7 +1230,6 @@ struct buffer_head *ext4_getblk(handle_t
 		if (buffer_new(&dummy)) {
 			J_ASSERT(create != 0);
-			J_ASSERT(handle != NULL);

Please keep the assertion in place, as above.

fs/ext4/inode.c restart_loop: · line 2265

Quoted 4 lines
fs/ext4/inode.c +2 -0
@@ -2265,33 +2263,37 @@ restart_loop:
 		/* start a new transaction*/
+		if (EXT4_HAS_COMPAT_FEATURE(inode->i_sb,
+					    EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {

Instead of making all of the internal checks dependent upon the on-disk HAS_JOURNAL flag, it should instead check sbi->s_journal == NULL. Not only is that faster (one less pointer deref each time, and no swabbing) but it would also allow e.g. to mount the filesystem with a "journal=none" option and check this only in ext4_fill_super(). It also avoids the extra complication that COMPAT_HAS_JOURNAL can be set on a mounted filesystem by tune2fs in order to enable journaling on the next reboot (needed to upgrade ext2->ext3/4 on the root filesystem.

The rest of the ext4 code should never check whether COMPAT_HAS_JOURNAL is set or not.

Review restart_loop: · line 2266

Quoted 2 lines
(quoted diff) +1 -1
-		err = ext4_journal_stop(handle);
+		err = ext4_journal_stop(inode->i_sb, handle);

For journal functions it is traditional to put the "handle" argument first (should we actually need to do this).

fs/ext4/inode.c static void ext4_free_branches(handle_t · line 3315

Quoted 3 lines
fs/ext4/inode.c +1 -1
@@ -3311,7 +3315,7 @@ static void ext4_free_branches(handle_t 
-	if (is_handle_aborted(handle))
+	if (handle && is_handle_aborted(handle))

This should be wrapped in ext4_handle_is_aborted(handle) that returns 0 if handle == NULL.

fs/ext4/inode.c static void ext4_free_branches(handle_t · line 3394

Quoted 11 lines
fs/ext4/inode.c +7 -0
@@ -3381,11 +3385,13 @@ static void ext4_free_branches(handle_t 
 			 * will merely complain about releasing a free block,
 			 * rather than leaking blocks.
 			 */
+			if (handle) {
+				if (is_handle_aborted(handle))
+					return;
+				if (try_to_extend_transaction(handle, inode)) {
+					ext4_mark_inode_dirty(handle, inode);
+					ext4_journal_test_restart(handle, inode);
+				}

Instead, please put a check into try_to_extend_transaction() that returns 0 if handle == NULL. Calling it ext4_try_to_extend_transaction() wouldn't hurt.

fs/ext4/inode.c int ext4_write_inode(struct inode *inode · line 4212

Quoted 10 lines
fs/ext4/inode.c +9 -0
@@ -4196,6 +4204,23 @@ int ext4_write_inode(struct inode *inode
+int __ext4_write_dirty_metadata(struct inode *inode, struct buffer_head *bh)
+{
+	mark_buffer_dirty(bh);
+	if (inode && inode_needs_sync(inode)) {
+		sync_dirty_buffer(bh);
+		if (buffer_req(bh) && !buffer_uptodate(bh)) {
+			printk ("IO error syncing ext4 inode [%s:%08lx]\n",
+				inode->i_sb->s_id,
+				(unsigned long) inode->i_ino);

This should be an ext4_error(). Any error that involves filesystem metadata needs to use ext4_error(), though not file data errors.

fs/ext4/inode.c int ext4_setattr(struct dentry *dentry, · line 4309

Quoted 3 lines
fs/ext4/inode.c +2 -0
@@ -4283,9 +4308,10 @@ int ext4_setattr(struct dentry *dentry, 
+		if (EXT4_HAS_COMPAT_FEATURE(inode->i_sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL) &&
+		    ext4_should_order_data(inode)) {

The ext4_should_order_data() code can just return 0 if EXT4_SB(inode->i_sb)->sb_journal == NULL.

fs/ext4/inode.c int ext4_mark_inode_dirty(handle_t *hand

Quoted 5 lines
fs/ext4/inode.c +3 -0
 void ext4_dirty_inode(struct inode *inode)
 {
+	handle_t *current_handle = ext4_journal_current_handle(inode->i_sb);
+	if (!current_handle) {
+	handle_t *current_handle = ext4_journal_current_handle(inode->i_sb);

Wouldn't ext4_journal_current_handle() just return NULL always for an unjournalled ext4 filesystem? Unfortunately, I can't see what "sb" is used for because your patch doesn't include the ext4_journal_current_handle() code.

One option is to start with a wrapper like "ext4_handle_valid(handle)" instead of checking "handle == NULL" everywhere. Then, we could put a magic value into "handle" and current->journal_info (maybe the the ext3_sb_info pointer). Put a magic value at the start of ext4_sb_info that can be validated as never belonging to a journal handle, and then you don't need to pass "sb" everywhere. It also allows you to distinguish between the "no handle was ever started" case and "running unjournalled".

In any case, I'm not sure if this code is completely correct, since the previous code allowed calling ext4_dirty_inode() without first starting a journal handle, and now it would just silently do nothing and cause filesystem corruption for the journalled case.

fs/ext4/inode.c int ext4_change_inode_journal_flag(struc · line 4707

Quoted 4 lines
fs/ext4/inode.c +0 -0
@@ -4673,7 +4705,7 @@ int ext4_change_inode_journal_flag(struc
 
 	err = ext4_mark_inode_dirty(handle, inode);
 	handle->h_sync = 1;

Isn't this missing a handle != NULL check? This is called from ext4_ioctl() with EXT4_IOC_SETFLAGS, and it should still be possible to set the "+j" inode flag even if the filesystem is unjournaled.

Quoted 7 lines
fs/ext4/mballoc.c +1 -0
@@ -4478,13 +4480,15 @@ ext4_mb_free_metadata(handle_t *handle, 
 	struct ext4_free_metadata *md;
 	int i;
 
+	BUG_ON(!handle);
 	BUG_ON(e4b->bd_bitmap_page == NULL);
 	BUG_ON(e4b->bd_buddy_page == NULL);

fs/ext4/mballoc.c ext4_mb_free_metadata(handle_t *handle, · line 4494

Quoted 10 lines
fs/ext4/mballoc.c +2 -1
 
 	ext4_lock_group(sb, group);
 	for (i = 0; i < count; i++) {
+		int htid = handle->h_transaction->t_tid;
 		md = db->bb_md_cur;
-		if (md && db->bb_tid != handle->h_transaction->t_tid) {
+		if (md && db->bb_tid != htid) {
 			db->bb_md_cur = NULL;
 			md = NULL;
 		}

I think Ted just re-wrote this code.

fs/ext4/migrate.c static int finish_range(handle_t *handle · line 64

Quoted 7 lines
fs/ext4/migrate.c +2 -1
@@ -60,7 +60,8 @@ static int finish_range(handle_t *handle
 	/*
 	 * Make sure the credit we accumalated is not really high
 	 */
-	if (needed && handle->h_buffer_credits >= EXT4_RESERVE_TRANS_BLOCKS) {
+	if (needed && handle &&
+	    handle->h_buffer_credits >= EXT4_RESERVE_TRANS_BLOCKS) {

All of the functions here should use ext4_handle_has_enough_credits().

fs/ext4/super.c handle_t *ext4_journal_start_sb(struct s · line 163

Quoted 7 lines
fs/ext4/super.c +6 -0
+int __ext4_journal_stop(const char *where, struct super_block *sb, handle_t *handle)
 {
+	if (!handle ||
+	    !(EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)))
+		return 0;
+
+	BUG_ON(sb != handle->h_transaction->t_journal->j_private);

Couldn't this just check for handle == NULL and return, instead of changing all of the callsites?

fs/ext4/super.c static void ext4_handle_error(struct sup · line 225

Quoted 4 lines
fs/ext4/super.c +2 -1
@@ -214,8 +224,10 @@ static void ext4_handle_error(struct sup
-		if (journal)
+		if (journal) {
+			BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL));

You can't BUG_ON() data that is stored on disk. This should be only checking the in-memory sbi->s_journal data, as previously discussed.

fs/ext4/super.c static void ext4_put_super(struct super_ · line 525

Quoted 8 lines
fs/ext4/super.c +7 -0
@@ -503,8 +519,13 @@ static void ext4_put_super(struct super_
+	if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
+		BUG_ON(sbi->s_journal == NULL);
+		jbd2_journal_destroy(sbi->s_journal);
+		sbi->s_journal = NULL;
+	} else {
+		BUG_ON(sbi->s_journal != NULL);
+	}

Should only check sbi->s_journal != NULL.

fs/ext4/super.c static int ext4_setup_super(struct super · line 1505

Quoted 10 lines
fs/ext4/super.c +8 -0
@@ -1473,13 +1497,15 @@ static int ext4_setup_super(struct super
+	if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
+		if (EXT4_SB(sb)->s_journal->j_inode == NULL) {
+			char b[BDEVNAME_SIZE];
 
+			printk("external journal on %s\n",
+				bdevname(EXT4_SB(sb)->s_journal->j_dev, b));
+		} else {
+			printk("internal journal\n");
+		}

I'd prefer this message be kept, and just print "no journal" in this case.

fs/ext4/super.c static int ext4_fill_super(struct super_ · line 2076

Quoted 8 lines
fs/ext4/super.c +6 -0
@@ -2044,9 +2070,12 @@ static int ext4_fill_super(struct super_
 	if (!(le32_to_cpu(es->s_flags) & EXT2_FLAGS_TEST_FILESYS)) {
+		/* As a temp hack, don't give up when there is no journal */
+		if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
+			printk(KERN_WARNING "EXT4-fs: %s: not marked "
+			       "OK to use with test code.\n", sb->s_id);
+			goto failed_mount;
+		}

I don't understand this - it means "if filesystem is not a test filesystem, but the journal exists fail the mount"? It should rather be the reverse:

	if (!(le32_to_cpu(es->s_flags) & EXT2_FLAGS_TEST_FILESYS)) {
		/* Unjournalled usage is only allowed for test filesystems */
		if (!EXT4_HAS_COMPAT_FEATURE(sb,
					     EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
			printk(KERN_WARNING "EXT4-fs: %s: not marked "
			       "OK to use with test code.\n", sb->s_id);
			goto failed_mount;
		}

fs/ext4/super.c static int ext4_fill_super(struct super_ · line 2364

Quoted 4 lines
fs/ext4/super.c +3 -0
@@ -2333,7 +2362,12 @@ static int ext4_fill_super(struct super_
+		// ISSUE: do we need to do anything else here?
+		clear_opt(sbi->s_mount_opt, DATA_FLAGS);
+		  set_opt(sbi->s_mount_opt, WRITEBACK_DATA);

(style) please fix indenting.

This should probably clear the s_mount_state VALID_FS flag in the superblock, like ext2 does in ext2_setup_super->ext2_write_super()

fs/ext4/super.c static int ext4_fill_super(struct super_ · line 2509

Quoted 4 lines
fs/ext4/super.c +2 -1
@@ -2470,7 +2508,8 @@ static int ext4_fill_super(struct super_
-	ext4_mb_init(sb, needs_recovery);
+	if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL))
+		ext4_mb_init(sb, needs_recovery);

mballoc has nothing to do with journaling, I'm not sure why this is here. The "needs_recovery" parameter is likely a hold-over from when mballoc stored state on disk instead of recomputing the buddy bitmaps each mount.

fs/ext4/super.c cantfind_ext4: · line 2526

Quoted 7 lines
fs/ext4/super.c +6 -0
@@ -2482,8 +2521,12 @@ cantfind_ext4:
+	if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
+		jbd2_journal_destroy(sbi->s_journal);
+		sbi->s_journal = NULL;
+	} else {
+		BUG_ON(sbi->s_journal != NULL);
+	}

I'd personally just prefer this to be simpler, since it is concievable that e.g. some kind of superblock corruption during journal recovery results in the COMPAT_HAS_JOURNAL flag being cleared. Instead a more foolproof code:

	if (sbi->s_journal != NULL) {
		jbd2_journal_destroy(sbi->s_journal);
		sbi->s_journal = NULL;
	}

fs/ext4/super.c static journal_t *ext4_get_journal(struc · line 2583

Quoted 5 lines
fs/ext4/super.c +1 -0
@@ -2535,6 +2580,8 @@ static journal_t *ext4_get_journal(struc
 	struct inode *journal_inode;
 	journal_t *journal;
 
+	BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL));

This would break ext4_create_journal() because the COMPAT_HAS_JOURNAL flag is only set afterward.

Review static int ext4_create_journal(struct su · line 2808

Quoted 3 lines
(quoted diff) +1 -0
@@ -2756,6 +2807,8 @@ static int ext4_create_journal(struct su
 
+	BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL));

This is also broken, because the whole point of ext4_create_journal() is to create a new journal file on an existing ext2 filesystem, and the COMPAT_HAS_JOURNAL flag is not set until this happens successfully.

To be honest, we could just get rid of ext4_create_journal(). This was a very old way of upgrading an ext2 filesystem to ext4 before tune2fs could do this. That this code sets COMPAT flags from within the ext4 code is frowned upon these days also (this should be done by the admin with tune2fs).

fs/ext4/super.c int ext4_force_commit(struct super_block · line 2965

Quoted 3 lines
fs/ext4/super.c +1 -0
 static void ext4_write_super(struct super_block *sb)
 {
+	if(EXT4_SB(sb)->s_journal) {

(style) Please put space between "if" and "(".

fs/ext4/super.c int ext4_force_commit(struct super_block · line 2971

Quoted 3 lines
fs/ext4/super.c +3 -0
+	}
+	else
+		ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);

(style) Should be:

	} else {
		ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);
	}

fs/ext4/super.c static void ext4_write_super_lockfs(stru · line 2999

Quoted 3 lines
fs/ext4/super.c +2 -0
@@ -2925,9 +2998,13 @@ static void ext4_write_super_lockfs(stru
+		} else {
+			BUG_ON(EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL));

Please wrap all code at 80 columns.

fs/ext4/super.c static ssize_t ext4_quota_write(struct s · line 3518

Quoted 3 lines
fs/ext4/super.c +0 -0
@@ -3429,7 +3517,8 @@ static ssize_t ext4_quota_write(struct s
 	struct buffer_head *bh;
 	handle_t *handle = journal_current_handle();

This is a defect - it should call ext4_journal_current_handle() I think.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#2 lore raw
Quoted 2 lines · Andreas Dilger

I'd be terribly interested in ext2 vs. ext4 with/without journal performance numbers, if you have any.

We plan to send out performance numbers to this list. Apologies since it might take more time than we would like as we are still setting up our changes to autotest.

Figuring out ext2 vs ext4 vs ext4-without-journaling is important to us.

mrubin

Quoted 418 lines · Frank Mayhar
Quoted 7 lines

We have a need to run ext4 on existing ext2 file systems. To get there we need to be able to run ext4 without a journal. I've managed to come up with an early patch that gets us at least partway there.

This patch just allows ext4 to mount and run with an ext2 root; I haven't tried it with anything else yet. It also scribbles in the superblock, so it takes an fsck to get it back to ext2 compatibility.

What is the reason for this? In the final form all that should happen is the normal ext2 "mark filesystem dirty" operation.

Review ext4_acl_chmod(struct inode *inode) · line 396

Quoted 3 lines
(quoted diff) +1 -1
@@ -396,7 +396,7 @@ ext4_acl_chmod(struct inode *inode)
-             if (IS_ERR(handle)) {
+             if (handle && IS_ERR(handle)) {

Actually, if handle is NULL then "IS_ERR(handle)" is false from my reading:

       unlikely(0UL >= -4095UL)

No need to change all of this code.

fs/ext4/extents.c static int ext4_ext_journal_restart(hand · line 98

Quoted 5 lines
fs/ext4/extents.c +1 -1
@@ -96,7 +96,7 @@ static int ext4_ext_journal_restart(hand
 {
-     if (handle->h_buffer_credits > needed)
+     if (handle && handle->h_buffer_credits > needed)
              return 0;

This should just be "if (!handle) return 0;" as the first condition.

fs/ext4/extents.c ext4_ext_rm_leaf(handle_t *handle, struc · line 1888

Quoted 6 lines
fs/ext4/extents.c +1 -1
@@ -1885,7 +1885,7 @@ ext4_ext_rm_leaf(handle_t *handle, struc
 
      while (ex >= EXT_FIRST_EXTENT(eh) &&
                      ex_ee_block + ex_ee_len > start) {
-             ext_debug("remove ext %lu:%u\n", ex_ee_block, ex_ee_len);
+             ext_debug("remove ext %lu:%u\n", (unsigned long)ex_ee_block, ex_ee_len);

This is the wrong fix. Instead it should just be using "%u" to print the block number, since it is limited to 32 bits right now. Same is true of all similar fixes.

fs/ext4/extents.c int ext4_ext_get_blocks(handle_t *handle · line 2583

Quoted 4 lines
fs/ext4/extents.c +1 -1
@@ -2582,7 +2582,7 @@ int ext4_ext_get_blocks(handle_t *handle
      ext_debug("blocks %u/%lu requested for inode %u\n",
-                     iblock, max_blocks, inode->i_ino);
+                     iblock, max_blocks, (unsigned)inode->i_ino);

Similarly, the right format for ino_t is %lu instead of casting the value.

fs/ext4/extents.c void ext4_ext_truncate(struct inode *ino · line 2843

Quoted 4 lines
fs/ext4/extents.c +1 -1
@@ -2842,7 +2842,7 @@ void ext4_ext_truncate(struct inode *ino
-     if (IS_SYNC(inode))
+     if (handle && IS_SYNC(inode))
              handle->h_sync = 1;

It would be nice to have a helper function that does this transparently:

static inline void ext4_handle_sync(handle)

{
       if (handle)
               handle->h_sync = 1;
}

This could be submitted before the rest of the patch without "if (handle)" and then you only need to change the code in one place.

fs/ext4/ialloc.c void ext4_free_inode (handle_t *handle, · line 254

Quoted 4 lines
fs/ext4/ialloc.c +2 -2
-             BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
-             err = ext4_journal_dirty_metadata(handle, bh2);
+             BUFFER_TRACE(bh2, "call ext4_handle_dirty_metadata");
+             err = ext4_handle_dirty_metadata(handle, NULL, bh2);

With this change are you removing the older ext4_journal_*() functions completely (ensuring that all callers have to be fixed to use ext4_handle*() instead), or are they still available? Unfortunately, this part of the patch is missing.

If the ext4_journal_*() functions are still available this exposes us to endless bugs from code that doesn't get fixed to work in unjournalled mode, but 99% of users won't notice it.

fs/ext4/ialloc.c repeat_in_this_group: · line 646

Quoted 4 lines
fs/ext4/ialloc.c +2 -1
@@ -645,7 +645,8 @@ repeat_in_this_group:
-                     err = ext4_journal_get_write_access(handle, bitmap_bh);
+                     err = ext4_journal_get_write_access(handle,
+                                                                 bitmap_bh);

I'm not sure why that was changed.

fs/ext4/ialloc.c repeat_in_this_group: · line 656

Quoted 5 lines
fs/ext4/ialloc.c +2 -1
@@ -653,15 +654,17 @@ repeat_in_this_group:
                      /* we lost it */
-                     jbd2_journal_release_buffer(handle, bitmap_bh);
+                     if (handle)
+                             jbd2_journal_release_buffer(handle, bitmap_bh);

This should probably also be wrapped in ext4_handle_release_buffer() so we don't need to expose all of the callsites to this check.

fs/ext4/ialloc.c got: · line 825

Quoted 4 lines
fs/ext4/ialloc.c +1 -1
@@ -820,7 +824,7 @@ got:
-     if (IS_DIRSYNC(inode))
+     if (handle && IS_DIRSYNC(inode))
              handle->h_sync = 1;

Use ext4_handle_sync(handle) helper as suggested above.

fs/ext4/inode.c void ext4_delete_inode (struct inode * i · line 239

Quoted 2 lines
fs/ext4/inode.c +1 -0
@@ -232,7 +239,7 @@ void ext4_delete_inode (struct inode * i
+     if (handle && handle->h_buffer_credits < 3) {

A new helper ext4_handle_has_enough_credits(handle, needed) would be useful in a few places, and can always return 1 if handle is NULL.

fs/ext4/inode.c int ext4_get_blocks_handle(handle_t *han · line 889

Quoted 4 lines
fs/ext4/inode.c +1 -1
@@ -881,7 +888,8 @@ int ext4_get_blocks_handle(handle_t *han
      J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL));
-     J_ASSERT(handle != NULL || create == 0);
+     /*J_ASSERT(handle != NULL || create == 0);*/

I would predicate this assertion on sbi->s_journal instead of just removing it:

       J_ASSERT(create == 0 ||
                (handle != NULL) == (EXT4_SB(inode->i_sb)->s_journal != NULL));

fs/ext4/inode.c struct buffer_head *ext4_getblk(handle_t · line 1226

Quoted 9 lines
fs/ext4/inode.c +0 -2
@@ -1198,8 +1206,6 @@ struct buffer_head *ext4_getblk(handle_t
      struct buffer_head dummy;
      int fatal = 0, err;
 
-     J_ASSERT(handle != NULL || create == 0);
@@ -1224,7 +1230,6 @@ struct buffer_head *ext4_getblk(handle_t
              if (buffer_new(&dummy)) {
                      J_ASSERT(create != 0);
-                     J_ASSERT(handle != NULL);

Please keep the assertion in place, as above.

fs/ext4/inode.c restart_loop: · line 2265

Quoted 4 lines
fs/ext4/inode.c +2 -0
@@ -2265,33 +2263,37 @@ restart_loop:
              /* start a new transaction*/
+             if (EXT4_HAS_COMPAT_FEATURE(inode->i_sb,
+                                         EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {

Instead of making all of the internal checks dependent upon the on-disk HAS_JOURNAL flag, it should instead check sbi->s_journal == NULL. Not only is that faster (one less pointer deref each time, and no swabbing) but it would also allow e.g. to mount the filesystem with a "journal=none" option and check this only in ext4_fill_super(). It also avoids the extra complication that COMPAT_HAS_JOURNAL can be set on a mounted filesystem by tune2fs in order to enable journaling on the next reboot (needed to upgrade ext2->ext3/4 on the root filesystem.

The rest of the ext4 code should never check whether COMPAT_HAS_JOURNAL is set or not.

Review restart_loop: · line 2266

Quoted 2 lines
(quoted diff) +1 -1
-             err = ext4_journal_stop(handle);
+             err = ext4_journal_stop(inode->i_sb, handle);

For journal functions it is traditional to put the "handle" argument first (should we actually need to do this).

fs/ext4/inode.c static void ext4_free_branches(handle_t · line 3315

Quoted 3 lines
fs/ext4/inode.c +1 -1
@@ -3311,7 +3315,7 @@ static void ext4_free_branches(handle_t
-     if (is_handle_aborted(handle))
+     if (handle && is_handle_aborted(handle))

This should be wrapped in ext4_handle_is_aborted(handle) that returns 0 if handle == NULL.

fs/ext4/inode.c static void ext4_free_branches(handle_t · line 3394

Quoted 11 lines
fs/ext4/inode.c +7 -0
@@ -3381,11 +3385,13 @@ static void ext4_free_branches(handle_t
                       * will merely complain about releasing a free block,
                       * rather than leaking blocks.
                       */
+                     if (handle) {
+                             if (is_handle_aborted(handle))
+                                     return;
+                             if (try_to_extend_transaction(handle, inode)) {
+                                     ext4_mark_inode_dirty(handle, inode);
+                                     ext4_journal_test_restart(handle, inode);
+                             }

Instead, please put a check into try_to_extend_transaction() that returns 0 if handle == NULL. Calling it ext4_try_to_extend_transaction() wouldn't hurt.

fs/ext4/inode.c int ext4_write_inode(struct inode *inode · line 4212

Quoted 10 lines
fs/ext4/inode.c +9 -0
@@ -4196,6 +4204,23 @@ int ext4_write_inode(struct inode *inode
+int __ext4_write_dirty_metadata(struct inode *inode, struct buffer_head *bh)
+{
+     mark_buffer_dirty(bh);
+     if (inode && inode_needs_sync(inode)) {
+             sync_dirty_buffer(bh);
+             if (buffer_req(bh) && !buffer_uptodate(bh)) {
+                     printk ("IO error syncing ext4 inode [%s:%08lx]\n",
+                             inode->i_sb->s_id,
+                             (unsigned long) inode->i_ino);

This should be an ext4_error(). Any error that involves filesystem metadata needs to use ext4_error(), though not file data errors.

fs/ext4/inode.c int ext4_setattr(struct dentry *dentry, · line 4309

Quoted 3 lines
fs/ext4/inode.c +2 -0
@@ -4283,9 +4308,10 @@ int ext4_setattr(struct dentry *dentry,
+             if (EXT4_HAS_COMPAT_FEATURE(inode->i_sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL) &&
+                 ext4_should_order_data(inode)) {

The ext4_should_order_data() code can just return 0 if EXT4_SB(inode->i_sb)->sb_journal == NULL.

fs/ext4/inode.c int ext4_mark_inode_dirty(handle_t *hand

Quoted 5 lines
fs/ext4/inode.c +3 -0
 void ext4_dirty_inode(struct inode *inode)
 {
+     handle_t *current_handle = ext4_journal_current_handle(inode->i_sb);
+     if (!current_handle) {
+     handle_t *current_handle = ext4_journal_current_handle(inode->i_sb);

Wouldn't ext4_journal_current_handle() just return NULL always for an unjournalled ext4 filesystem? Unfortunately, I can't see what "sb" is used for because your patch doesn't include the ext4_journal_current_handle() code.

One option is to start with a wrapper like "ext4_handle_valid(handle)" instead of checking "handle == NULL" everywhere. Then, we could put a magic value into "handle" and current->journal_info (maybe the the ext3_sb_info pointer). Put a magic value at the start of ext4_sb_info that can be validated as never belonging to a journal handle, and then you don't need to pass "sb" everywhere. It also allows you to distinguish between the "no handle was ever started" case and "running unjournalled".

In any case, I'm not sure if this code is completely correct, since the previous code allowed calling ext4_dirty_inode() without first starting a journal handle, and now it would just silently do nothing and cause filesystem corruption for the journalled case.

fs/ext4/inode.c int ext4_change_inode_journal_flag(struc · line 4707

Quoted 4 lines
fs/ext4/inode.c +0 -0
@@ -4673,7 +4705,7 @@ int ext4_change_inode_journal_flag(struc
 
      err = ext4_mark_inode_dirty(handle, inode);
      handle->h_sync = 1;

Isn't this missing a handle != NULL check? This is called from ext4_ioctl() with EXT4_IOC_SETFLAGS, and it should still be possible to set the "+j" inode flag even if the filesystem is unjournaled.

Quoted 7 lines
fs/ext4/mballoc.c +1 -0
@@ -4478,13 +4480,15 @@ ext4_mb_free_metadata(handle_t *handle,
      struct ext4_free_metadata *md;
      int i;
 
+     BUG_ON(!handle);
      BUG_ON(e4b->bd_bitmap_page == NULL);
      BUG_ON(e4b->bd_buddy_page == NULL);

fs/ext4/mballoc.c ext4_mb_free_metadata(handle_t *handle, · line 4494

Quoted 10 lines
fs/ext4/mballoc.c +2 -1
 
      ext4_lock_group(sb, group);
      for (i = 0; i < count; i++) {
+             int htid = handle->h_transaction->t_tid;
              md = db->bb_md_cur;
-             if (md && db->bb_tid != handle->h_transaction->t_tid) {
+             if (md && db->bb_tid != htid) {
                      db->bb_md_cur = NULL;
                      md = NULL;
              }

I think Ted just re-wrote this code.

fs/ext4/migrate.c static int finish_range(handle_t *handle · line 64

Quoted 7 lines
fs/ext4/migrate.c +2 -1
@@ -60,7 +60,8 @@ static int finish_range(handle_t *handle
      /*
       * Make sure the credit we accumalated is not really high
       */
-     if (needed && handle->h_buffer_credits >= EXT4_RESERVE_TRANS_BLOCKS) {
+     if (needed && handle &&
+         handle->h_buffer_credits >= EXT4_RESERVE_TRANS_BLOCKS) {

All of the functions here should use ext4_handle_has_enough_credits().

fs/ext4/super.c handle_t *ext4_journal_start_sb(struct s · line 163

Quoted 7 lines
fs/ext4/super.c +6 -0
+int __ext4_journal_stop(const char *where, struct super_block *sb, handle_t *handle)
 {
+     if (!handle ||
+         !(EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)))
+             return 0;
+
+     BUG_ON(sb != handle->h_transaction->t_journal->j_private);

Couldn't this just check for handle == NULL and return, instead of changing all of the callsites?

fs/ext4/super.c static void ext4_handle_error(struct sup · line 225

Quoted 4 lines
fs/ext4/super.c +2 -1
@@ -214,8 +224,10 @@ static void ext4_handle_error(struct sup
-             if (journal)
+             if (journal) {
+                     BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL));

You can't BUG_ON() data that is stored on disk. This should be only checking the in-memory sbi->s_journal data, as previously discussed.

fs/ext4/super.c static void ext4_put_super(struct super_ · line 525

Quoted 8 lines
fs/ext4/super.c +7 -0
@@ -503,8 +519,13 @@ static void ext4_put_super(struct super_
+     if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
+             BUG_ON(sbi->s_journal == NULL);
+             jbd2_journal_destroy(sbi->s_journal);
+             sbi->s_journal = NULL;
+     } else {
+             BUG_ON(sbi->s_journal != NULL);
+     }

Should only check sbi->s_journal != NULL.

fs/ext4/super.c static int ext4_setup_super(struct super · line 1505

Quoted 10 lines
fs/ext4/super.c +8 -0
@@ -1473,13 +1497,15 @@ static int ext4_setup_super(struct super
+     if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
+             if (EXT4_SB(sb)->s_journal->j_inode == NULL) {
+                     char b[BDEVNAME_SIZE];
 
+                     printk("external journal on %s\n",
+                             bdevname(EXT4_SB(sb)->s_journal->j_dev, b));
+             } else {
+                     printk("internal journal\n");
+             }

I'd prefer this message be kept, and just print "no journal" in this case.

fs/ext4/super.c static int ext4_fill_super(struct super_ · line 2076

Quoted 8 lines
fs/ext4/super.c +6 -0
@@ -2044,9 +2070,12 @@ static int ext4_fill_super(struct super_
      if (!(le32_to_cpu(es->s_flags) & EXT2_FLAGS_TEST_FILESYS)) {
+             /* As a temp hack, don't give up when there is no journal */
+             if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
+                     printk(KERN_WARNING "EXT4-fs: %s: not marked "
+                            "OK to use with test code.\n", sb->s_id);
+                     goto failed_mount;
+             }

I don't understand this - it means "if filesystem is not a test filesystem, but the journal exists fail the mount"? It should rather be the reverse:

       if (!(le32_to_cpu(es->s_flags) & EXT2_FLAGS_TEST_FILESYS)) {
               /* Unjournalled usage is only allowed for test filesystems */
               if (!EXT4_HAS_COMPAT_FEATURE(sb,
                                            EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
                       printk(KERN_WARNING "EXT4-fs: %s: not marked "
                              "OK to use with test code.\n", sb->s_id);
                       goto failed_mount;
               }

fs/ext4/super.c static int ext4_fill_super(struct super_ · line 2364

Quoted 4 lines
fs/ext4/super.c +3 -0
@@ -2333,7 +2362,12 @@ static int ext4_fill_super(struct super_
+             // ISSUE: do we need to do anything else here?
+             clear_opt(sbi->s_mount_opt, DATA_FLAGS);
+               set_opt(sbi->s_mount_opt, WRITEBACK_DATA);

(style) please fix indenting.

This should probably clear the s_mount_state VALID_FS flag in the superblock, like ext2 does in ext2_setup_super->ext2_write_super()

fs/ext4/super.c static int ext4_fill_super(struct super_ · line 2509

Quoted 4 lines
fs/ext4/super.c +2 -1
@@ -2470,7 +2508,8 @@ static int ext4_fill_super(struct super_
-     ext4_mb_init(sb, needs_recovery);
+     if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL))
+             ext4_mb_init(sb, needs_recovery);

mballoc has nothing to do with journaling, I'm not sure why this is here. The "needs_recovery" parameter is likely a hold-over from when mballoc stored state on disk instead of recomputing the buddy bitmaps each mount.

fs/ext4/super.c cantfind_ext4: · line 2526

Quoted 7 lines
fs/ext4/super.c +6 -0
@@ -2482,8 +2521,12 @@ cantfind_ext4:
+     if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
+             jbd2_journal_destroy(sbi->s_journal);
+             sbi->s_journal = NULL;
+     } else {
+             BUG_ON(sbi->s_journal != NULL);
+     }

I'd personally just prefer this to be simpler, since it is concievable that e.g. some kind of superblock corruption during journal recovery results in the COMPAT_HAS_JOURNAL flag being cleared. Instead a more foolproof code:

       if (sbi->s_journal != NULL) {
               jbd2_journal_destroy(sbi->s_journal);
               sbi->s_journal = NULL;
       }

fs/ext4/super.c static journal_t *ext4_get_journal(struc · line 2583

Quoted 5 lines
fs/ext4/super.c +1 -0
@@ -2535,6 +2580,8 @@ static journal_t *ext4_get_journal(struc
      struct inode *journal_inode;
      journal_t *journal;
 
+     BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL));

This would break ext4_create_journal() because the COMPAT_HAS_JOURNAL flag is only set afterward.

Review static int ext4_create_journal(struct su · line 2808

Quoted 3 lines
(quoted diff) +1 -0
@@ -2756,6 +2807,8 @@ static int ext4_create_journal(struct su
 
+     BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL));

This is also broken, because the whole point of ext4_create_journal() is to create a new journal file on an existing ext2 filesystem, and the COMPAT_HAS_JOURNAL flag is not set until this happens successfully.

To be honest, we could just get rid of ext4_create_journal(). This was a very old way of upgrading an ext2 filesystem to ext4 before tune2fs could do this. That this code sets COMPAT flags from within the ext4 code is frowned upon these days also (this should be done by the admin with tune2fs).

fs/ext4/super.c int ext4_force_commit(struct super_block · line 2965

Quoted 3 lines
fs/ext4/super.c +1 -0
 static void ext4_write_super(struct super_block *sb)
 {
+     if(EXT4_SB(sb)->s_journal) {

(style) Please put space between "if" and "(".

fs/ext4/super.c int ext4_force_commit(struct super_block · line 2971

Quoted 3 lines
fs/ext4/super.c +3 -0
+     }
+     else
+             ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);

(style) Should be:

       } else {
               ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);
       }

fs/ext4/super.c static void ext4_write_super_lockfs(stru · line 2999

Quoted 3 lines
fs/ext4/super.c +2 -0
@@ -2925,9 +2998,13 @@ static void ext4_write_super_lockfs(stru
+             } else {
+                     BUG_ON(EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL));

Please wrap all code at 80 columns.

fs/ext4/super.c static ssize_t ext4_quota_write(struct s · line 3518

Quoted 3 lines
fs/ext4/super.c +0 -0
@@ -3429,7 +3517,8 @@ static ssize_t ext4_quota_write(struct s
      struct buffer_head *bh;
      handle_t *handle = journal_current_handle();

This is a defect - it should call ext4_journal_current_handle() I think.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#3 lore raw
In reply to Andreas Dilger
Quoted 4 lines · Andreas Dilger

Firstly,
thanks for working on this. It is a huge patch, and my suggested changes are some effort to reduce the size of the patch and keep this functionality more maintainable.

Andreas, thanks very much for your comments. They all seem to make sense; I'll go through them in detail over the next couple of days and generate a new patch.

Signature · 2 lines
Frank Mayhar <[email protected]>
Google, Inc.
#4 lore raw
In reply to Andreas Dilger
Quoted 11 lines · Andreas Dilger
Quoted 7 lines · Frank Mayhar

We have a need to run ext4 on existing ext2 file systems. To get there we need to be able to run ext4 without a journal. I've managed to come up with an early patch that gets us at least partway there.

This patch just allows ext4 to mount and run with an ext2 root; I haven't tried it with anything else yet. It also scribbles in the superblock, so it takes an fsck to get it back to ext2 compatibility.

What is the reason for this? In the final form all that should happen is the normal ext2 "mark filesystem dirty" operation.

I haven't yet had a chance to track this down, but it's setting the ext3 "needs_recovery" flag. Almost certainly an oversight somewhere.

Quoted 7 lines

fs/ext4/extents.c void ext4_ext_truncate(struct inode *ino · line 2843

Quoted 4 lines
fs/ext4/extents.c +1 -1
@@ -2842,7 +2842,7 @@ void ext4_ext_truncate(struct inode *ino
-	if (IS_SYNC(inode))
+	if (handle && IS_SYNC(inode))
 		handle->h_sync = 1;

It would be nice to have a helper function that does this transparently:

Quoted 8 lines

static inline void ext4_handle_sync(handle)

{
	if (handle)
		handle->h_sync = 1;
}

This could be submitted before the rest of the patch without "if (handle)" and then you only need to change the code in one place.

Okay, I'll submit that bit separately. I'll try to send it out today.

Quoted 10 lines

fs/ext4/ialloc.c void ext4_free_inode (handle_t *handle, · line 254

Quoted 4 lines
fs/ext4/ialloc.c +2 -2
-		BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
-		err = ext4_journal_dirty_metadata(handle, bh2);
+		BUFFER_TRACE(bh2, "call ext4_handle_dirty_metadata");
+		err = ext4_handle_dirty_metadata(handle, NULL, bh2);

With this change are you removing the older ext4_journal_*() functions completely (ensuring that all callers have to be fixed to use ext4_handle*() instead), or are they still available? Unfortunately, this part of the patch is missing.

Quoted 3 lines

If the ext4_journal_*() functions are still available this exposes us to endless bugs from code that doesn't get fixed to work in unjournalled mode, but 99% of users won't notice it.

Not sure how this bit of the patch got dropped, but in any event, the ext4_journal_dirty_metadata() function is now gone, replaced by ext4_handle_dirty_metadata(). The underlying function __ext4_journal_dirty_metadata() still exists, however. The rest of the ext4_journal_xxx() functions still exist but have been modified to check their 'handle' parameter (or, in a few cases, the superblock COMPAT_HAS_JOURNAL flag).

Quoted 6 lines

fs/ext4/ialloc.c repeat_in_this_group: · line 646

Quoted 4 lines
fs/ext4/ialloc.c +2 -1
@@ -645,7 +645,8 @@ repeat_in_this_group:
-			err = ext4_journal_get_write_access(handle, bitmap_bh);
+			err = ext4_journal_get_write_access(handle,
+								    bitmap_bh);

I'm not sure why that was changed.

This has gone through a couple of iterations, this may be an artifact of that. I'll clean it up.

Quoted 8 lines

fs/ext4/ialloc.c repeat_in_this_group: · line 656

Quoted 5 lines
fs/ext4/ialloc.c +2 -1
@@ -653,15 +654,17 @@ repeat_in_this_group:
 			/* we lost it */
-			jbd2_journal_release_buffer(handle, bitmap_bh);
+			if (handle)
+				jbd2_journal_release_buffer(handle, bitmap_bh);

This should probably also be wrapped in ext4_handle_release_buffer() so we don't need to expose all of the callsites to this check.

Good point.

Quoted 10 lines

fs/ext4/inode.c int ext4_get_blocks_handle(handle_t *han · line 889

Quoted 4 lines
fs/ext4/inode.c +1 -1
@@ -881,7 +888,8 @@ int ext4_get_blocks_handle(handle_t *han
 	J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL));
-	J_ASSERT(handle != NULL || create == 0);
+	/*J_ASSERT(handle != NULL || create == 0);*/

I would predicate this assertion on sbi->s_journal instead of just removing it:

	J_ASSERT(create == 0 ||
		 (handle != NULL) == (EXT4_SB(inode->i_sb)->s_journal != NULL));

Thanks. I had intended to come back to that anyway.

Quoted 4 lines

In any case, I'm not sure if this code is completely correct, since the previous code allowed calling ext4_dirty_inode() without first starting a journal handle, and now it would just silently do nothing and cause filesystem corruption for the journalled case.

I was hoping to avoid in-band magic numbers (as well as any change that would touch jbd2). I'll see if I can continue that; regardless it sounds like the null-handle thing is the wrong way to go, at least in a few cases.

Quoted 8 lines

fs/ext4/inode.c int ext4_change_inode_journal_flag(struc · line 4707

Quoted 4 lines
fs/ext4/inode.c +0 -0
@@ -4673,7 +4705,7 @@ int ext4_change_inode_journal_flag(struc
 
 	err = ext4_mark_inode_dirty(handle, inode);
 	handle->h_sync = 1;

Isn't this missing a handle != NULL check? This is called from ext4_ioctl() with EXT4_IOC_SETFLAGS, and it should still be possible to set the "+j" inode flag even if the filesystem is unjournaled.

Yeah, I missed that one. Thanks.

Quoted 7 lines

Review static int ext4_create_journal(struct su · line 2808

Quoted 3 lines
(quoted diff) +1 -0
@@ -2756,6 +2807,8 @@ static int ext4_create_journal(struct su
 
+	BUG_ON(!EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL));

This is also broken, because the whole point of ext4_create_journal() is to create a new journal file on an existing ext2 filesystem, and the COMPAT_HAS_JOURNAL flag is not set until this happens successfully.

Ah. Thanks for this explanation.

Quoted 5 lines

To be honest, we could just get rid of ext4_create_journal(). This was a very old way of upgrading an ext2 filesystem to ext4 before tune2fs could do this. That this code sets COMPAT flags from within the ext4 code is frowned upon these days also (this should be done by the admin with tune2fs).

I'll look into this.

Again, thanks for your review, this helps a lot.

Signature · 2 lines
Frank Mayhar <[email protected]>
Google, Inc.
#5 lore raw
In reply to Andreas Dilger
Quoted 10 lines · Andreas Dilger

fs/ext4/inode.c int ext4_mark_inode_dirty(handle_t *hand

Quoted 5 lines

void ext4_dirty_inode(struct inode *inode)
{

fs/ext4/inode.c +3 -0
+	handle_t *current_handle = ext4_journal_current_handle(inode->i_sb);
+	if (!current_handle) {
+	handle_t *current_handle = ext4_journal_current_handle(inode->i_sb);

Wouldn't ext4_journal_current_handle() just return NULL always for an unjournalled ext4 filesystem? Unfortunately, I can't see what "sb" is used for because your patch doesn't include the ext4_journal_current_handle() code.

Sorry about that, I'm doing the work in a p4 repository and somehow that file didn't get p4 opened so it didn't generate the diff. The short version is that it was checking the COMPAT_HAS_JOURNAL flag.

Quoted 7 lines

One option is to start with a wrapper like "ext4_handle_valid(handle)" instead of checking "handle == NULL" everywhere. Then, we could put a magic value into "handle" and current->journal_info (maybe the the ext3_sb_info pointer). Put a magic value at the start of ext4_sb_info that can be validated as never belonging to a journal handle, and then you don't need to pass "sb" everywhere. It also allows you to distinguish between the "no handle was ever started" case and "running unjournalled".

Okay, yeah, this sounds like the way to go. I had seen the previous handle==NULL case but had put it aside to get a proof-of-concept implementation going as quickly as possible. Your explanation here clears things up.

My suggestion is, for the non-journalling flag, set the first field (which in the handle is a pointer to the transaction) to NULL to distinguish it from a real handle. As far as I can tell from browsing the code the h_transaction pointer in a real handle should never be NULL. Please let me know if this is not the case. And maybe offer another suggestion...?

(As an aside, this particular situation is one of the reasons a friend of mine, Tom Van Vleck, strongly insists on putting magic numbers and versions into structures. I'm not as insistent about it as he is but it certainly would have helped here.)

Quoted 4 lines

In any case, I'm not sure if this code is completely correct, since the previous code allowed calling ext4_dirty_inode() without first starting a journal handle, and now it would just silently do nothing and cause filesystem corruption for the journalled case.

So now handle==NULL will only refer to this case, correct? And I infer from your comment that handle != NULL refers to a started handle, that is, a handle that has a non-NULL h_transaction pointer (for my purposes).

Signature · 2 lines
Frank Mayhar <[email protected]>
Google, Inc.
#6 lore raw
Quoted 9 lines · Frank Mayhar
Quoted 7 lines · Andreas Dilger

One option is to start with a wrapper like "ext4_handle_valid(handle)" instead of checking "handle == NULL" everywhere. Then, we could put a magic value into "handle" and current->journal_info (maybe the the ext3_sb_info pointer). Put a magic value at the start of ext4_sb_info that can be validated as never belonging to a journal handle, and then you don't need to pass "sb" everywhere. It also allows you to distinguish between the "no handle was ever started" case and "running unjournalled".

Quoted 4 lines

Okay, yeah, this sounds like the way to go. I had seen the previous handle==NULL case but had put it aside to get a proof-of-concept implementation going as quickly as possible. Your explanation here clears things up.

True - my inspection was from the "what is needed to make this acceptable for inclusion". The code definitely looks reasonable for performance testing under different loads.

Quoted 6 lines

My suggestion is, for the non-journalling flag, set the first field (which in the handle is a pointer to the transaction) to NULL to distinguish it from a real handle. As far as I can tell from browsing the code the h_transaction pointer in a real handle should never be NULL. Please let me know if this is not the case. And maybe offer another suggestion...?

I'm not dead set on a "magic number" solution either, just something I thought of while looking through the patch. It would definitely help find places where the code is not doing matching start/stop of the handle. That isn't important if you are doing a lot of testing with journals enabled, but it

Quoted 10 lines

(As an aside, this particular situation is one of the reasons a friend of mine, Tom Van Vleck, strongly insists on putting magic numbers and versions into structures. I'm not as insistent about it as he is but it certainly would have helped here.)

Quoted 4 lines

In any case, I'm not sure if this code is completely correct, since the previous code allowed calling ext4_dirty_inode() without first starting a journal handle, and now it would just silently do nothing and cause filesystem corruption for the journalled case.

Quoted 4 lines

So now handle==NULL will only refer to this case, correct? And I infer from your comment that handle != NULL refers to a started handle, that is, a handle that has a non-NULL h_transaction pointer (for my purposes).

Right. It might even be worthwhile to add in some debugging to see if ext4_dirty_inode() is EVER called with handle != NULL, or if this conditional behaviour is just a residual from days of yore. It seems the only callsite is from the VFS and there may never be a transaction started at that point, I'm not sure.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#7 lore raw

RFC PATCH 1/1 Allow ext4 to run without a journal, take 2.

In reply to Frank Mayhar

At the end of October I posted the first patch that was intended to allow ext4 to run on existing ext2 file systems. It certainly had its flaws and I got some great feedback from Andreas. I've integrated his suggestions, fixed a few bugs and have generated a new patch for your review and enjoyment.

With this patch I've managed to mount an ext2 root with a 2.6.26 kernel (with ext4 patches to almost 2.6.28), muck about with it, then reboot to a 2.6.18 kernel without ext4 and have it Just Work.

As before, this only modifies ext4 itself, it touches nothing else. I'm not including a signed-off-by since I don't intend this as an official submission; there is almost certainly more work to do. I just want to get it out and let you guys take a look and beat on it if you care to.

I'm particularly interested in hearing what you think of the approach, how well you think it will work and if I have overlooked anything.

Thanks!

 balloc.c    |    4 -
 defrag.c    |    2 
 ext4_jbd2.c |   60 +++++++++++++++-------
 ext4_jbd2.h |  105 ++++++++++++++++++++++++++++++++++-----
 ext4_sb.h   |    1 
 extents.c   |   12 ++--
 ialloc.c    |   25 ++++-----
 inode.c     |  131 +++++++++++++++++++++++++++++++------------------
 ioctl.c     |    2 
 mballoc.c   |   16 +++---
 migrate.c   |    5 +
 namei.c     |   50 +++++++++---------
 resize.c    |   31 ++++++-----
 super.c     |  159 ++++++++++++++++++++++++++++++++++++++++++------------------
 xattr.c     |   21 ++++---
 15 files changed, 419 insertions(+), 205 deletions(-)
ext4/balloc.c renamed from ext4/balloc.c#3 +2 -2
@@ -531,11 +531,11 @@
 
 	/* We dirtied the 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 */
 	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;
 	*pdquot_freed_blocks += group_freed;
 
ext4/defrag.c renamed from ext4/defrag.c#1 +1 -1
@@ -409,7 +409,7 @@
 	}
 
 	if (depth) {
-		ret = ext4_journal_dirty_metadata(handle, org_path->p_bh);
+		ret = ext4_handle_dirty_metadata(handle, org_inode, org_path->p_bh);
 		if (ret)
 			return ret;
 	} else {
ext4/ext4_jbd2.c renamed from ext4/ext4_jbd2.c#1 +42 -18

95 lines not on this page · raw message

ext4/ext4_jbd2.h renamed from ext4/ext4_jbd2.h#3 +91 -14

173 lines not on this page · raw message

ext4/ext4_sb.h renamed from ext4/ext4_sb.h#3 +1 -0
@@ -28,6 +28,7 @@
  * fourth extended-fs super-block data in memory
  */
 struct ext4_sb_info {
+	int *s_nojournal_flag;		/* Null to indicate "not a handle" */
 	unsigned long s_desc_size;	/* Size of a group descriptor in bytes */
 	unsigned long s_inodes_per_block;/* Number of inodes per block */
 	unsigned long s_blocks_per_group;/* Number of blocks in a group */
ext4/extents.c renamed from ext4/extents.c#3 +7 -5
@@ -97,6 +97,8 @@
 {
 	int err;
 
+	if (!ext4_handle_valid(handle))
+		return 0;
 	if (handle->h_buffer_credits > needed)
 		return 0;
 	err = ext4_journal_extend(handle, needed);
@@ -134,7 +136,7 @@
 	int err;
 	if (path->p_bh) {
 		/* path points to block */
-		err = ext4_journal_dirty_metadata(handle, path->p_bh);
+		err = ext4_handle_dirty_metadata(handle, inode, path->p_bh);
 	} else {
 		/* path points to leaf/index in inode body */
 		err = ext4_mark_inode_dirty(handle, inode);
@@ -780,7 +782,7 @@
 	set_buffer_uptodate(bh);
 	unlock_buffer(bh);
 
-	err = ext4_journal_dirty_metadata(handle, bh);
+	err = ext4_handle_dirty_metadata(handle, inode, bh);
 	if (err)
 		goto cleanup;
 	brelse(bh);
@@ -859,7 +861,7 @@
 		set_buffer_uptodate(bh);
 		unlock_buffer(bh);
 
-		err = ext4_journal_dirty_metadata(handle, bh);
+		err = ext4_handle_dirty_metadata(handle, inode, bh);
 		if (err)
 			goto cleanup;
 		brelse(bh);
@@ -955,7 +957,7 @@
 	set_buffer_uptodate(bh);
 	unlock_buffer(bh);
 
-	err = ext4_journal_dirty_metadata(handle, bh);
+	err = ext4_handle_dirty_metadata(handle, inode, bh);
 	if (err)
 		goto out;
 
@@ -2950,7 +2952,7 @@
 	 * transaction synchronous.
 	 */
 	if (IS_SYNC(inode))
-		handle->h_sync = 1;
+		ext4_handle_sync(handle);
 
 out_stop:
 	up_write(&EXT4_I(inode)->i_data_sem);
ext4/ialloc.c renamed from ext4/ialloc.c#3 +13 -12
@@ -253,12 +253,12 @@
 				spin_unlock(sb_bgl_lock(sbi, flex_group));
 			}
 		}
-		BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
-		err = ext4_journal_dirty_metadata(handle, bh2);
+		BUFFER_TRACE(bh2, "call ext4_handle_dirty_metadata");
+		err = ext4_handle_dirty_metadata(handle, NULL, bh2);
 		if (!fatal) fatal = err;
 	}
-	BUFFER_TRACE(bitmap_bh, "call ext4_journal_dirty_metadata");
-	err = ext4_journal_dirty_metadata(handle, bitmap_bh);
+	BUFFER_TRACE(bitmap_bh, "call ext4_handle_dirty_metadata");
+	err = ext4_handle_dirty_metadata(handle, NULL, bitmap_bh);
 	if (!fatal)
 		fatal = err;
 	sb->s_dirt = 1;
@@ -656,15 +656,16 @@
 						ino, bitmap_bh->b_data)) {
 				/* we won it */
 				BUFFER_TRACE(bitmap_bh,
-					"call ext4_journal_dirty_metadata");
-				err = ext4_journal_dirty_metadata(handle,
+					"call ext4_handle_dirty_metadata");
+				err = ext4_handle_dirty_metadata(handle,
+								inode,
 								bitmap_bh);
 				if (err)
 					goto fail;
 				goto got;
 			}
 			/* we lost it */
-			jbd2_journal_release_buffer(handle, bitmap_bh);
+			ext4_handle_release_buffer(handle, bitmap_bh);
 
 			if (++ino < EXT4_INODES_PER_GROUP(sb))
 				goto repeat_in_this_group;
@@ -724,7 +725,8 @@
 		/* Don't need to dirty bitmap block if we didn't change it */
 		if (free) {
 			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);
@@ -769,8 +771,8 @@
 	}
 	gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp);
 	spin_unlock(sb_bgl_lock(sbi, group));
-	BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
-	err = ext4_journal_dirty_metadata(handle, bh2);
+	BUFFER_TRACE(bh2, "call ext4_handle_dirty_metadata");
+	err = ext4_handle_dirty_metadata(handle, NULL, bh2);
 	if (err) goto fail;
 
 	percpu_counter_dec(&sbi->s_freeinodes_counter);
@@ -823,7 +825,7 @@
 
 	ext4_set_inode_flags(inode);
 	if (IS_DIRSYNC(inode))
-		handle->h_sync = 1;
+		ext4_handle_sync(handle);
 	insert_inode_hash(inode);
 	spin_lock(&sbi->s_next_gen_lock);
 	inode->i_generation = sbi->s_next_generation++;
@@ -1022,4 +1024,3 @@
 	}
 	return count;
 }
-
ext4/inode.c renamed from ext4/inode.c#3 +84 -47

320 lines not on this page · raw message

ext4/ioctl.c renamed from ext4/ioctl.c#2 +1 -1
@@ -99,7 +99,7 @@
 			goto flags_out;
 		}
 		if (IS_SYNC(inode))
-			handle->h_sync = 1;
+			ext4_handle_sync(handle);
 		err = ext4_reserve_inode_write(handle, inode, &iloc);
 		if (err)
 			goto flags_err;
ext4/mballoc.c renamed from ext4/mballoc.c#3 +9 -7
@@ -2876,7 +2876,7 @@
 		mb_set_bits(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group),
 				bitmap_bh->b_data, ac->ac_b_ex.fe_start,
 				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)
 			err = -EAGAIN;
 		goto out_err;
@@ -2923,10 +2923,10 @@
 		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)
 		goto out_err;
-	err = ext4_journal_dirty_metadata(handle, gdp_bh);
+	err = ext4_handle_dirty_metadata(handle, NULL, gdp_bh);
 
 out_err:
 	sb->s_dirt = 1;
@@ -4416,6 +4416,8 @@
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 
+	if (!ext4_handle_valid(handle))
+		return;
 	if (sbi->s_last_transaction == handle->h_transaction->t_tid)
 		return;
 
@@ -4468,7 +4470,7 @@
 	struct rb_node **n = &db->bb_free_root.rb_node, *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_buddy_page == NULL);
 
@@ -4648,7 +4650,7 @@
 
 	/* We dirtied the 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) {
 		ac->ac_b_ex.fe_group = block_group;
@@ -4657,7 +4659,7 @@
 		ext4_mb_store_history(ac);
 	}
 
-	if (metadata) {
+	if (ext4_handle_valid(handle) && metadata) {
 		/* blocks being freed are metadata. these blocks shouldn't
 		 * be used until this transaction is committed */
 		ext4_mb_free_metadata(handle, &e4b, block_group, bit, count);
@@ -4687,7 +4689,7 @@
 
 	/* And the 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;
 
ext4/migrate.c renamed from ext4/migrate.c#3 +3 -2
@@ -59,7 +59,8 @@
 	/*
 	 * 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);
 		if (retval)
 			goto err_out;
@@ -229,7 +230,7 @@
 {
 	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;
 	/*
 	 * We are freeing a blocks. During this we touch
ext4/namei.c renamed from ext4/namei.c#3 +25 -25

166 lines not on this page · raw message

ext4/resize.c renamed from ext4/resize.c#3 +16 -15
@@ -149,7 +149,7 @@
 {
 	int err;
 
-	if (handle->h_buffer_credits >= thresh)
+	if (ext4_handle_has_enough_credits(handle, thresh))
 		return 0;
 
 	err = ext4_journal_extend(handle, EXT4_MAX_TRANS_DATA);
@@ -232,7 +232,7 @@
 		memcpy(gdb->b_data, sbi->s_group_desc[i]->b_data, gdb->b_size);
 		set_buffer_uptodate(gdb);
 		unlock_buffer(gdb);
-		ext4_journal_dirty_metadata(handle, gdb);
+		ext4_handle_dirty_metadata(handle, NULL, gdb);
 		ext4_set_bit(bit, bh->b_data);
 		brelse(gdb);
 	}
@@ -251,7 +251,7 @@
 			err = PTR_ERR(bh);
 			goto exit_bh;
 		}
-		ext4_journal_dirty_metadata(handle, gdb);
+		ext4_handle_dirty_metadata(handle, NULL, gdb);
 		ext4_set_bit(bit, bh->b_data);
 		brelse(gdb);
 	}
@@ -276,7 +276,7 @@
 			err = PTR_ERR(it);
 			goto exit_bh;
 		}
-		ext4_journal_dirty_metadata(handle, it);
+		ext4_handle_dirty_metadata(handle, NULL, it);
 		brelse(it);
 		ext4_set_bit(bit, bh->b_data);
 	}
@@ -286,7 +286,7 @@
 
 	mark_bitmap_end(input->blocks_count, EXT4_BLOCKS_PER_GROUP(sb),
 			bh->b_data);
-	ext4_journal_dirty_metadata(handle, bh);
+	ext4_handle_dirty_metadata(handle, NULL, bh);
 	brelse(bh);
 
 	/* Mark unused entries in inode bitmap used */
@@ -299,7 +299,7 @@
 
 	mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), EXT4_BLOCKS_PER_GROUP(sb),
 			bh->b_data);
-	ext4_journal_dirty_metadata(handle, bh);
+	ext4_handle_dirty_metadata(handle, NULL, bh);
 exit_bh:
 	brelse(bh);
 
@@ -486,12 +486,12 @@
 	 * reserved inode, and will become GDT blocks (primary and backup).
 	 */
 	data[gdb_num % EXT4_ADDR_PER_BLOCK(sb)] = 0;
-	ext4_journal_dirty_metadata(handle, dind);
+	ext4_handle_dirty_metadata(handle, NULL, dind);
 	brelse(dind);
 	inode->i_blocks -= (gdbackups + 1) * sb->s_blocksize >> 9;
 	ext4_mark_iloc_dirty(handle, inode, &iloc);
 	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;
 	memcpy(n_group_desc, o_group_desc,
@@ -502,7 +502,7 @@
 	kfree(o_group_desc);
 
 	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;
 
@@ -618,7 +618,7 @@
 		       primary[i]->b_blocknr, gdbackups,
 		       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)
 			err = err2;
 	}
@@ -676,7 +676,8 @@
 		struct buffer_head *bh;
 
 		/* 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) &&
 		    (err = ext4_journal_restart(handle, EXT4_MAX_TRANS_DATA)))
 			break;
@@ -696,7 +697,7 @@
 			memset(bh->b_data + size, 0, rest);
 		set_buffer_uptodate(bh);
 		unlock_buffer(bh);
-		ext4_journal_dirty_metadata(handle, bh);
+		ext4_handle_dirty_metadata(handle, NULL, bh);
 		brelse(bh);
 	}
 	if ((err2 = ext4_journal_stop(handle)) && !err)
@@ -915,7 +916,7 @@
 	/* Update the global fs size fields */
 	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
 	 * active. */
@@ -937,7 +938,7 @@
 			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;
 
 exit_journal:
@@ -1071,7 +1072,7 @@
 		goto exit_put;
 	}
 	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;
 	unlock_super(sb);
 	ext4_debug("freeing blocks %llu through %llu\n", o_blocks_count,
ext4/super.c renamed from ext4/super.c#5 +112 -47

354 lines not on this page · raw message

ext4/xattr.c renamed from ext4/xattr.c#3 +12 -9
@@ -457,7 +457,7 @@
 	if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
 		EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR);
 		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_forget(handle, 1, inode, bh, bh->b_blocknr);
 	} else {
 		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))
-			handle->h_sync = 1;
+			ext4_handle_sync(handle);
 		DQUOT_FREE_BLOCK(inode, 1);
 		ea_bdebug(bh, "refcount now=%d; releasing",
 			  le32_to_cpu(BHDR(bh)->h_refcount));
@@ -724,8 +724,9 @@
 			if (error == -EIO)
 				goto bad_block;
 			if (!error)
-				error = ext4_journal_dirty_metadata(handle,
-								    bs->bh);
+				error = ext4_handle_dirty_metadata(handle,
+								   inode,
+								   bs->bh);
 			if (error)
 				goto cleanup;
 			goto inserted;
@@ -794,8 +795,9 @@
 				ea_bdebug(new_bh, "reusing; refcount now=%d",
 					le32_to_cpu(BHDR(new_bh)->h_refcount));
 				unlock_buffer(new_bh);
-				error = ext4_journal_dirty_metadata(handle,
-								    new_bh);
+				error = ext4_handle_dirty_metadata(handle,
+								   inode,
+								   new_bh);
 				if (error)
 					goto cleanup_dquot;
 			}
@@ -833,7 +835,8 @@
 			set_buffer_uptodate(new_bh);
 			unlock_buffer(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)
 				goto cleanup;
 		}
@@ -1040,7 +1043,7 @@
 		 */
 		is.iloc.bh = NULL;
 		if (IS_SYNC(inode))
-			handle->h_sync = 1;
+			ext4_handle_sync(handle);
 	}
 
 cleanup:
Signature · 2 lines
Frank Mayhar <[email protected]>
Google, Inc.
#8 lore raw

Re: [RFC PATCH 1/1] Allow ext4 to run without a journal, take 2.

ext4/ext4_jbd2.h line 165

Quoted 4 lines · Frank Mayhar
ext4/ext4_jbd2.h renamed from ext4/ext4_jbd2.h#3 +4 -0
+static inline int ext4_handle_valid(handle_t *handle)
+{
+	if (!handle)
+		return 0;

My preference is to use "if (handle == NULL)", because handle is not a boolean.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (handle->h_transaction == NULL)
+		return 0;

Does this ever happen? Ah, is this the case where the handle is pointing to the ext4_sb_info()? I think I'd prefer to have a magic value here, so that it isn't possible to accidentally dereference a pointer that happens to have NULL data in it.

ext4/ext4_jbd2.h line 180

Quoted 10 lines
ext4/ext4_jbd2.h renamed from ext4/ext4_jbd2.h#3 +10 -0
+static inline int ext4_handle_dirty_metadata(handle_t *handle,
+				struct inode *inode, struct buffer_head *bh)
+{
+	int err = 0;
+
+	if (ext4_handle_valid(handle)) {
+		err = __ext4_journal_dirty_metadata(__func__, handle, bh);
+	} else {
+		err = __ext4_write_dirty_metadata(inode, bh);
+	}

You don't need to initialize "err = 0" here.

ext4/ext4_sb.h line 31

Quoted 2 lines

struct ext4_sb_info {

ext4/ext4_sb.h renamed from ext4/ext4_sb.h#3 +1 -0
+	int *s_nojournal_flag;		/* Null to indicate "not a handle" */

I don't really see where and how this is used.

Review line 97

Quoted 2 lines
(quoted diff) +0 -0
@@ -97,6 +97,8 @@
 {

Please, in the future use "diff -up" so that it includes the function names in the patch context. Without the function names it is difficult to know what is being changed by the patch.

ext4/mballoc.c line 4659

Quoted 3 lines
ext4/mballoc.c renamed from ext4/mballoc.c#3 +1 -1
@@ -4657,7 +4659,7 @@
-	if (metadata) {
+	if (ext4_handle_valid(handle) && metadata) {

It is probably a tiny bit more efficient to check "metadata" first.

ext4/super.c line 145

Quoted 11 lines
ext4/super.c renamed from ext4/super.c#5 +9 -0
@@ -136,13 +136,16 @@
+	if (journal) {
+		if (is_journal_aborted(journal)) {
+			ext4_abort(sb, __func__,
+				   "Detected aborted journal");
+			return ERR_PTR(-EROFS);
+		}
+		return jbd2_journal_start(journal, nblocks);
 	}
+	current->journal_info = (handle_t *)EXT4_SB(sb);
+	return current->journal_info;

So, this appears to be the place where ext4_sb_info->s_nojournal_flag is actually used. To make this more clear, it would be better to do actually reference this variable here so that it is easier for the reader to follow.

	current->journal_info = &EXT4_SB(sb)->s_nojournal_flag;

ext4/super.c line 602

Quoted 5 lines
ext4/super.c renamed from ext4/super.c#5 +1 -0
@@ -588,7 +599,8 @@
 	}
 #endif
 	ext4_discard_preallocations(inode);
+	if (EXT4_SB(inode->i_sb)->s_journal)

I think this is the same thing as EXT4_JOURNAL(inode)?

ext4/super.c line 2962

Quoted 9 lines
ext4/super.c renamed from ext4/super.c#5 +7 -0
 static void ext4_write_super(struct super_block *sb)
 {
+	if (EXT4_SB(sb)->s_journal) {
+		if (mutex_trylock(&sb->s_lock) != 0)
+			BUG();
+		sb->s_dirt = 0;
+	}
+	else
+		ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);

This should be "} else { ... }"

ext4/super.c line 3002

Quoted 6 lines
ext4/super.c renamed from ext4/super.c#5 +6 -0
+			/*
+			 * We don't want to clear needs_recovery flag when we failed
+			 * to flush the journal.
+			 */
+			if (jbd2_journal_flush(journal) < 0)
+				return;

This comment needs to be wrapped at 80 columns.

I like this patch a lot better than the previous one. It remains very readable, and isn't too intrusive to the code.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#9 lore raw

Re: [RFC PATCH 1/1] Allow ext4 to run without a journal, take 2.

I'll address the comments in code in a bit but wanted to reply now.

Quoted 7 lines · Andreas Dilger

ext4/ext4_jbd2.h line 165

Quoted 4 lines · Frank Mayhar
ext4/ext4_jbd2.h renamed from ext4/ext4_jbd2.h#3 +4 -0
+static inline int ext4_handle_valid(handle_t *handle)
+{
+	if (!handle)
+		return 0;

My preference is to use "if (handle == NULL)", because handle is not a boolean.

That's actually my preference as well, but I was trying to match other parts of the code. I'll change it.

Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (handle->h_transaction == NULL)
+		return 0;

Does this ever happen? Ah, is this the case where the handle is pointing to the ext4_sb_info()? I think I'd prefer to have a magic value here, so that it isn't possible to accidentally dereference a pointer that happens to have NULL data in it.

So some magic value that gets stuffed into the pointer? Or just a magic pointer value that gets stuffed into 'handle'?

Quoted 4 lines
Quoted 4 lines
ext4/ext4_jbd2.h renamed from ext4/ext4_jbd2.h#3 +4 -0
+static inline int ext4_handle_dirty_metadata(handle_t *handle,
+				struct inode *inode, struct buffer_head *bh)
+{
+	int err = 0;
Quoted 8 lines

ext4/ext4_jbd2.h line 180

Quoted 6 lines
ext4/ext4_jbd2.h renamed from ext4/ext4_jbd2.h#3 +6 -0
+
+	if (ext4_handle_valid(handle)) {
+		err = __ext4_journal_dirty_metadata(__func__, handle, bh);
+	} else {
+		err = __ext4_write_dirty_metadata(inode, bh);
+	}

You don't need to initialize "err = 0" here.

Good point.

Quoted 4 lines

ext4/ext4_sb.h line 31

Quoted 2 lines

struct ext4_sb_info {

ext4/ext4_sb.h renamed from ext4/ext4_sb.h#3 +1 -0
+	int *s_nojournal_flag;		/* Null to indicate "not a handle" */

I don't really see where and how this is used.

Yeah, this is pretty opaque, I'm getting similar comments from the internal reviewer. This is how I was distinguishing the "pointer to a real handle" from the "pointer to ext4_sb_info".

Quoted 6 lines

Review line 97

Quoted 2 lines
(quoted diff) +0 -0
@@ -97,6 +97,8 @@
 {

Please, in the future use "diff -up" so that it includes the function names in the patch context. Without the function names it is difficult to know what is being changed by the patch.

Sorry, I usually do that but forgot in this case.

Quoted 5 lines

ext4/mballoc.c line 4659

Quoted 3 lines
ext4/mballoc.c renamed from ext4/mballoc.c#3 +1 -1
@@ -4657,7 +4659,7 @@
-	if (metadata) {
+	if (ext4_handle_valid(handle) && metadata) {

It is probably a tiny bit more efficient to check "metadata" first.

OK.

Quoted 16 lines

ext4/super.c line 145

Quoted 11 lines
ext4/super.c renamed from ext4/super.c#5 +9 -0
@@ -136,13 +136,16 @@
+	if (journal) {
+		if (is_journal_aborted(journal)) {
+			ext4_abort(sb, __func__,
+				   "Detected aborted journal");
+			return ERR_PTR(-EROFS);
+		}
+		return jbd2_journal_start(journal, nblocks);
 	}
+	current->journal_info = (handle_t *)EXT4_SB(sb);
+	return current->journal_info;

So, this appears to be the place where ext4_sb_info->s_nojournal_flag is actually used. To make this more clear, it would be better to do actually reference this variable here so that it is easier for the reader to follow.

Quoted 1 line
	current->journal_info = &EXT4_SB(sb)->s_nojournal_flag;

Hmm. Okay, I'll have to think about this a bit; I haven't had my coffee yet.

Quoted 7 lines

ext4/super.c line 602

Quoted 5 lines
ext4/super.c renamed from ext4/super.c#5 +1 -0
@@ -588,7 +599,8 @@
 	}
 #endif
 	ext4_discard_preallocations(inode);
+	if (EXT4_SB(inode->i_sb)->s_journal)

I think this is the same thing as EXT4_JOURNAL(inode)?

Yeah, I noticed this after the patch went out.

Quoted 22 lines

ext4/super.c line 2962

Quoted 9 lines
ext4/super.c renamed from ext4/super.c#5 +7 -0
 static void ext4_write_super(struct super_block *sb)
 {
+	if (EXT4_SB(sb)->s_journal) {
+		if (mutex_trylock(&sb->s_lock) != 0)
+			BUG();
+		sb->s_dirt = 0;
+	}
+	else
+		ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);

This should be "} else { ... }"

ext4/super.c line 3002

Quoted 6 lines
ext4/super.c renamed from ext4/super.c#5 +6 -0
+			/*
+			 * We don't want to clear needs_recovery flag when we failed
+			 * to flush the journal.
+			 */
+			if (jbd2_journal_flush(journal) < 0)
+				return;

This comment needs to be wrapped at 80 columns.

Quoted 2 lines

I like this patch a lot better than the previous one. It remains very readable, and isn't too intrusive to the code.

Okay, thanks, and thanks for the comments. I'll make the indicated changes and roll another patch today.

Signature · 2 lines
Frank Mayhar <[email protected]>
Google, Inc.
#10 lore raw

Re: [RFC PATCH 1/1] Allow ext4 to run without a journal, take 2.

Quoted 10 lines · Frank Mayhar
Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (handle->h_transaction == NULL)
+		return 0;

Does this ever happen? Ah, is this the case where the handle is pointing to the ext4_sb_info()? I think I'd prefer to have a magic value here, so that it isn't possible to accidentally dereference a pointer that happens to have NULL data in it.

So some magic value that gets stuffed into the pointer? Or just a magic pointer value that gets stuffed into 'handle'?

I mean a magic value that is stuffed into the s_nojournal_flag pointer instead of just using NULL (which is a very common value of pointers to random memory). Ideally this value will be chosen in a way that it is unlikely to be a valid pointer (e.g. 0x01234567 for 32-bit machines, 0x0123456789abcdef for 64-bit machines).

Quoted 8 lines
Quoted 5 lines

So, this appears to be the place where ext4_sb_info->s_nojournal_flag is actually used. To make this more clear, it would be better to do actually reference this variable here so that it is easier for the reader to follow.

	current->journal_info = &EXT4_SB(sb)->s_nojournal_flag;

Hmm. Okay, I'll have to think about this a bit; I haven't had my coffee yet.

This is functionally equivalent to the method you are using (i.e. it stores the pointer to the start of the struct), except that it allows the reader to find where this field is used.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#11 lore raw

Re: [RFC PATCH 1/1] Allow ext4 to run without a journal, take 2.

Quoted 9 lines · Andreas Dilger
Quoted 8 lines · Frank Mayhar
Quoted 7 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	if (handle->h_transaction == NULL)
+		return 0;

Does this ever happen? Ah, is this the case where the handle is pointing to the ext4_sb_info()? I think I'd prefer to have a magic value here, so that it isn't possible to accidentally dereference a pointer that happens to have NULL data in it.

Quoted 8 lines
Quoted 2 lines

So some magic value that gets stuffed into the pointer? Or just a magic pointer value that gets stuffed into 'handle'?

I mean a magic value that is stuffed into the s_nojournal_flag pointer instead of just using NULL (which is a very common value of pointers to random memory). Ideally this value will be chosen in a way that it is unlikely to be a valid pointer (e.g. 0x01234567 for 32-bit machines, 0x0123456789abcdef for 64-bit machines).

Okay, makes sense, will do.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

So, this appears to be the place where ext4_sb_info->s_nojournal_flag is actually used. To make this more clear, it would be better to do actually reference this variable here so that it is easier for the reader to follow.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line
	current->journal_info = &EXT4_SB(sb)->s_nojournal_flag;

Hmm. Okay, I'll have to think about this a bit; I haven't had my coffee yet.

This is functionally equivalent to the method you are using (i.e. it stores the pointer to the start of the struct), except that it allows the reader to find where this field is used.

Yeah, that's what I thought, but like I said, I hadn't had my coffee yet. :-)

Signature · 2 lines
Frank Mayhar <[email protected]>
Google, Inc.
#12 lore raw

Re: [RFC PATCH 1/1] Allow ext4 to run without a journal, take 2.

In reply to Frank Mayhar

Hi, Frank

I somehow managed to apply your patch against v2.6.28-rc3 kernel. With some small modifications, it worked just as supposed.

now, I have tested the modified patch in three ways, so far so good:
1. mount an ext2 fs image as ext4 and muck about with it. Then mount it as ext2
2. unmark an ext4 image's has_journal flag and mount it as ext4, and compile a kernel and delete all files on it.
3. mount a normal ext4 image, and compile a kernel and delete all files on it.

ext4/ext4_jbd2.h line 317

Quoted 12 lines · Frank Mayhar
ext4/ext4_jbd2.h renamed from ext4/ext4_jbd2.h#3 +11 -0
+static inline int ext4_journal_max_transaction_buffers(struct inode *inode)
+{
+	/*
+	 * max transaction buffers
+	 * calculation based on
+	 * journal->j_max_transaction_buffers = journal->j_maxlen / 4;
+	 */
+	if (EXT4_JOURNAL(inode) != NULL)
+		return (EXT4_JOURNAL(inode))->j_maxlen / 4;
+	return 0;
+}

I didn't see where/how this is used. So I dropped it.

ext4/inode.c line 206

Quoted 6 lines
ext4/inode.c renamed from ext4/inode.c#3 +1 -1
@@ -195,7 +203,8 @@
 	handle_t *handle;
 	int err;
 
-	if (ext4_should_order_data(inode))
+	if (EXT4_JOURNAL(inode) != NULL &&

this is already checked in ext4_should_order_data(inode). So no need to test it twice.

ext4/inode.c line 3509

Quoted 9 lines
ext4/inode.c renamed from ext4/inode.c#3 +1 -1
@@ -3493,7 +3503,7 @@
 		 * the block was cleared. Check for this instead of OOPSing.
 		 */
 		if (bh2jh(this_bh))
-			ext4_journal_dirty_metadata(handle, this_bh);
+			ext4_handle_dirty_metadata(handle, inode, this_bh);
 		else
 			ext4_error(inode->i_sb, __func__,
 				   "circular indirect block detected, "

--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
one more check is needed here so that ext4_free_data doesn't print false error messages in no-journal mode.
@@ -3515,7 +3515,7 @@ static void ext4_free_data(handle_t *handle, struct inode *inode,
* block pointed to itself, it would have been detached when
* the block was cleared. Check for this instead of OOPSing. */
- if (bh2jh(this_bh))
+ if (!ext4_handle_valid(handle) || bh2jh(this_bh))

                        ext4_handle_dirty_metadata(handle, inode, this_bh);
                else
                        ext4_error(inode->i_sb, __func__,

ext4/mballoc.c

Quoted 2 lines
ext4/mballoc.c renamed from ext4/mballoc.c#3 +0 -0

I noticed that one more change is needed here also.
@@ -2551,7 +2551,8 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
ext4_mb_init_per_dev_proc(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"); return 0;

ext4/mballoc.c line 2516

Quoted 5 lines
ext4/mballoc.c renamed from ext4/mballoc.c#3 +1 -0
@@ -2484,6 +2513,8 @@
 {
       struct ext4_sb_info *sbi = EXT4_SB(sb);
 
+       BUG_ON(sbi->s_journal == NULL);

This will always trigger because at mount time sbi->s_journal is set *after* ext4_get_journal when mounting ext4 image with journal.

Quoted 4 lines
ext4/mballoc.c renamed from ext4/mballoc.c#3 +1 -0
+
      if (sbi->s_commit_interval)
               journal->j_commit_interval = sbi->s_commit_interval;
       /* We could also set up an ext4-specific default for the commit
Signature · 5 lines
Cheers,

Bergwolf

Here lieth one whose name was writ on water.
#13 lore raw

Re: [RFC PATCH 1/1] Allow ext4 to run without a journal, take 2.

Quoted 5 lines · Peng Tao

Hi, Frank

I somehow managed to apply your patch against v2.6.28-rc3 kernel. With some small modifications, it worked just as supposed.

Quoted 7 lines

now, I have tested the modified patch in three ways, so far so good:
1. mount an ext2 fs image as ext4 and muck about with it. Then mount it as ext2
2. unmark an ext4 image's has_journal flag and mount it as ext4, and compile a kernel and delete all files on it.
3. mount a normal ext4 image, and compile a kernel and delete all files on it.

I have a new version of the patch that has several problems corrected and one or two bugs fixed. One of us ran into a memory leak on Wednesday (after I had already left for the long weekend), though, so I'll resubmit the patch after we get that fixed. (The memory leak is only when using ext4 without a journal, with a journal it works fine. Looks like the no-journal case is missing a code path with a free somewhere but I haven't had a chance to look at it yet.)

Signature · 2 lines
Frank Mayhar <[email protected]>
Google, Inc.