Skip to content

Commit

Permalink
[PATCH] jbd2: enable building of jbd2 and have ext4 use it rather tha…
Browse files Browse the repository at this point in the history
…n jbd

Reworked from a patch by Mingming Cao and Randy Dunlap

Signed-off-By: Randy Dunlap <[email protected]>
Signed-off-by: Mingming Cao <[email protected]>
Signed-off-by: Dave Kleikamp <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Mingming Cao authored and Linus Torvalds committed Oct 11, 2006
1 parent a920e94 commit dab291a
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 108 deletions.
48 changes: 40 additions & 8 deletions fs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,24 @@ config EXT3_FS_SECURITY
config EXT4DEV_FS
tristate "Ext4dev/ext4 extended fs support development (EXPERIMENTAL)"
depends on EXPERIMENTAL
select JBD
help
select JBD2
help
Ext4dev is a predecessor filesystem of the next generation
extended fs ext4, based on ext3 filesystem code. It will be
renamed ext4 fs later, once ext4dev is mature and stabilized.

Unlike the change from ext2 filesystem to ext3 filesystem,
the on-disk format of ext4dev is not the same as ext3 any more:
Unlike the change from ext2 filesystem to ext3 filesystem,
the on-disk format of ext4dev is not the same as ext3 any more:
it is based on extent maps and it supports 48-bit physical block
numbers. These combined on-disk format changes will allow
numbers. These combined on-disk format changes will allow
ext4dev/ext4 to handle more than 16 TB filesystem volumes --
a hard limit that ext3 cannot overcome without changing the
on-disk format.
on-disk format.

Other than extent maps and 48-bit block numbers, ext4dev also is
likely to have other new features such as persistent preallocation,
likely to have other new features such as persistent preallocation,
high resolution time stamps, and larger file support etc. These
features will be added to ext4dev gradually.
features will be added to ext4dev gradually.

To compile this file system support as a module, choose M here. The
module will be called ext4dev. Be aware, however, that the filesystem
Expand Down Expand Up @@ -239,6 +239,38 @@ config JBD_DEBUG
generated. To turn debugging off again, do
"echo 0 > /proc/sys/fs/jbd-debug".

config JBD2
tristate
help
This is a generic journaling layer for block devices that support
both 32-bit and 64-bit block numbers. It is currently used by
the ext4dev/ext4 filesystem, but it could also be used to add
journal support to other file systems or block devices such
as RAID or LVM.

If you are using ext4dev/ext4, you need to say Y here. If you are not
using ext4dev/ext4 then you will probably want to say N.

To compile this device as a module, choose M here. The module will be
called jbd2. If you are compiling ext4dev/ext4 into the kernel,
you cannot compile this code as a module.

config JBD2_DEBUG
bool "JBD2 (ext4dev/ext4) debugging support"
depends on JBD2
help
If you are using the ext4dev/ext4 journaled file system (or
potentially any other filesystem/device using JBD2), this option
allows you to enable debugging output while the system is running,
in order to help track down any problems you are having.
By default, the debugging output will be turned off.

If you select Y here, then you will be able to turn on debugging
with "echo N > /proc/sys/fs/jbd2-debug", where N is a number between
1 and 5. The higher the number, the more debugging output is
generated. To turn debugging off again, do
"echo 0 > /proc/sys/fs/jbd2-debug".

config FS_MBCACHE
# Meta block cache for Extended Attributes (ext2/ext3/ext4)
tristate
Expand Down
1 change: 1 addition & 0 deletions fs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ obj-$(CONFIG_REISERFS_FS) += reiserfs/
obj-$(CONFIG_EXT3_FS) += ext3/ # Before ext2 so root fs can be ext3
obj-$(CONFIG_EXT4DEV_FS) += ext4/ # Before ext2 so root fs can be ext4dev
obj-$(CONFIG_JBD) += jbd/
obj-$(CONFIG_JBD2) += jbd2/
obj-$(CONFIG_EXT2_FS) += ext2/
obj-$(CONFIG_CRAMFS) += cramfs/
obj-$(CONFIG_RAMFS) += ramfs/
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <linux/slab.h>
#include <linux/capability.h>
#include <linux/fs.h>
#include <linux/ext4_jbd.h>
#include <linux/ext4_jbd2.h>
#include <linux/ext4_fs.h>
#include "xattr.h"
#include "acl.h"
Expand Down
10 changes: 5 additions & 5 deletions fs/ext4/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#include <linux/time.h>
#include <linux/capability.h>
#include <linux/fs.h>
#include <linux/jbd.h>
#include <linux/jbd2.h>
#include <linux/ext4_fs.h>
#include <linux/ext4_jbd.h>
#include <linux/ext4_jbd2.h>
#include <linux/quotaops.h>
#include <linux/buffer_head.h>

Expand Down Expand Up @@ -526,12 +526,12 @@ void ext4_free_blocks_sb(handle_t *handle, struct super_block *sb,
* transaction.
*
* Ideally we would want to allow that to happen, but to
* do so requires making journal_forget() capable of
* do so requires making jbd2_journal_forget() capable of
* revoking the queued write of a data block, which
* implies blocking on the journal lock. *forget()
* cannot block due to truncate races.
*
* Eventually we can fix this by making journal_forget()
* Eventually we can fix this by making jbd2_journal_forget()
* return a status indicating whether or not it was able
* to revoke the buffer. On successful revoke, it is
* safe not to set the allocation bit in the committed
Expand Down Expand Up @@ -1382,7 +1382,7 @@ int ext4_should_retry_alloc(struct super_block *sb, int *retries)

jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);

return journal_force_commit_nested(EXT4_SB(sb)->s_journal);
return jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

#include <linux/buffer_head.h>
#include <linux/jbd.h>
#include <linux/jbd2.h>
#include <linux/ext4_fs.h>

#ifdef EXT4FS_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

#include <linux/fs.h>
#include <linux/jbd.h>
#include <linux/jbd2.h>
#include <linux/ext4_fs.h>
#include <linux/buffer_head.h>
#include <linux/smp_lock.h>
Expand Down
4 changes: 2 additions & 2 deletions fs/ext4/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

#include <linux/time.h>
#include <linux/fs.h>
#include <linux/jbd.h>
#include <linux/jbd2.h>
#include <linux/ext4_fs.h>
#include <linux/ext4_jbd.h>
#include <linux/ext4_jbd2.h>
#include "xattr.h"
#include "acl.h"

Expand Down
4 changes: 2 additions & 2 deletions fs/ext4/fsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/writeback.h>
#include <linux/jbd.h>
#include <linux/jbd2.h>
#include <linux/ext4_fs.h>
#include <linux/ext4_jbd.h>
#include <linux/ext4_jbd2.h>

/*
* akpm: A new design for ext4_sync_file().
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

#include <linux/fs.h>
#include <linux/jbd.h>
#include <linux/jbd2.h>
#include <linux/sched.h>
#include <linux/ext4_fs.h>
#include <linux/cryptohash.h>
Expand Down
6 changes: 3 additions & 3 deletions fs/ext4/ialloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#include <linux/time.h>
#include <linux/fs.h>
#include <linux/jbd.h>
#include <linux/jbd2.h>
#include <linux/ext4_fs.h>
#include <linux/ext4_jbd.h>
#include <linux/ext4_jbd2.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/quotaops.h>
Expand Down Expand Up @@ -497,7 +497,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode * dir, int mode)
goto got;
}
/* we lost it */
journal_release_buffer(handle, bitmap_bh);
jbd2_journal_release_buffer(handle, bitmap_bh);

if (++ino < EXT4_INODES_PER_GROUP(sb))
goto repeat_in_this_group;
Expand Down
52 changes: 26 additions & 26 deletions fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/time.h>
#include <linux/ext4_jbd.h>
#include <linux/jbd.h>
#include <linux/ext4_jbd2.h>
#include <linux/jbd2.h>
#include <linux/smp_lock.h>
#include <linux/highuid.h>
#include <linux/pagemap.h>
Expand Down Expand Up @@ -84,7 +84,7 @@ int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
(!is_metadata && !ext4_should_journal_data(inode))) {
if (bh) {
BUFFER_TRACE(bh, "call journal_forget");
BUFFER_TRACE(bh, "call jbd2_journal_forget");
return ext4_journal_forget(handle, bh);
}
return 0;
Expand Down Expand Up @@ -657,7 +657,7 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode,
failed:
/* Allocation failed, free what we already allocated */
for (i = 1; i <= n ; i++) {
BUFFER_TRACE(branch[i].bh, "call journal_forget");
BUFFER_TRACE(branch[i].bh, "call jbd2_journal_forget");
ext4_journal_forget(handle, branch[i].bh);
}
for (i = 0; i <indirect_blks; i++)
Expand Down Expand Up @@ -758,7 +758,7 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode,

err_out:
for (i = 1; i <= num; i++) {
BUFFER_TRACE(where[i].bh, "call journal_forget");
BUFFER_TRACE(where[i].bh, "call jbd2_journal_forget");
ext4_journal_forget(handle, where[i].bh);
ext4_free_blocks(handle,inode,le32_to_cpu(where[i-1].key),1);
}
Expand Down Expand Up @@ -1119,7 +1119,7 @@ static int walk_page_buffers( handle_t *handle,
* To preserve ordering, it is essential that the hole instantiation and
* the data write be encapsulated in a single transaction. We cannot
* close off a transaction and start a new one between the ext4_get_block()
* and the commit_write(). So doing the journal_start at the start of
* and the commit_write(). So doing the jbd2_journal_start at the start of
* prepare_write() is the right place.
*
* Also, this function can nest inside ext4_writepage() ->
Expand All @@ -1135,7 +1135,7 @@ static int walk_page_buffers( handle_t *handle,
* transaction open and was blocking on the quota lock - a ranking
* violation.
*
* So what we do is to rely on the fact that journal_stop/journal_start
* So what we do is to rely on the fact that jbd2_journal_stop/journal_start
* will _not_ run commit under these circumstances because handle->h_ref
* is elevated. We'll still have enough credits for the tiny quotafile
* write.
Expand Down Expand Up @@ -1184,7 +1184,7 @@ static int ext4_prepare_write(struct file *file, struct page *page,

int ext4_journal_dirty_data(handle_t *handle, struct buffer_head *bh)
{
int err = journal_dirty_data(handle, bh);
int err = jbd2_journal_dirty_data(handle, bh);
if (err)
ext4_journal_abort_handle(__FUNCTION__, __FUNCTION__,
bh, handle,err);
Expand Down Expand Up @@ -1333,9 +1333,9 @@ static sector_t ext4_bmap(struct address_space *mapping, sector_t block)

EXT4_I(inode)->i_state &= ~EXT4_STATE_JDATA;
journal = EXT4_JOURNAL(inode);
journal_lock_updates(journal);
err = journal_flush(journal);
journal_unlock_updates(journal);
jbd2_journal_lock_updates(journal);
err = jbd2_journal_flush(journal);
jbd2_journal_unlock_updates(journal);

if (err)
return 0;
Expand All @@ -1356,7 +1356,7 @@ static int bput_one(handle_t *handle, struct buffer_head *bh)
return 0;
}

static int journal_dirty_data_fn(handle_t *handle, struct buffer_head *bh)
static int jbd2_journal_dirty_data_fn(handle_t *handle, struct buffer_head *bh)
{
if (buffer_mapped(bh))
return ext4_journal_dirty_data(handle, bh);
Expand Down Expand Up @@ -1464,7 +1464,7 @@ static int ext4_ordered_writepage(struct page *page,
*/
if (ret == 0) {
err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE,
NULL, journal_dirty_data_fn);
NULL, jbd2_journal_dirty_data_fn);
if (!ret)
ret = err;
}
Expand Down Expand Up @@ -1595,7 +1595,7 @@ static void ext4_invalidatepage(struct page *page, unsigned long offset)
if (offset == 0)
ClearPageChecked(page);

journal_invalidatepage(journal, page, offset);
jbd2_journal_invalidatepage(journal, page, offset);
}

static int ext4_releasepage(struct page *page, gfp_t wait)
Expand All @@ -1605,7 +1605,7 @@ static int ext4_releasepage(struct page *page, gfp_t wait)
WARN_ON(PageChecked(page));
if (!page_has_buffers(page))
return 0;
return journal_try_to_free_buffers(journal, page, wait);
return jbd2_journal_try_to_free_buffers(journal, page, wait);
}

/*
Expand Down Expand Up @@ -1982,11 +1982,11 @@ static void ext4_clear_blocks(handle_t *handle, struct inode *inode,

/*
* Any buffers which are on the journal will be in memory. We find
* them on the hash table so journal_revoke() will run journal_forget()
* them on the hash table so jbd2_journal_revoke() will run jbd2_journal_forget()
* on them. We've already detached each block from the file, so
* bforget() in journal_forget() should be safe.
* bforget() in jbd2_journal_forget() should be safe.
*
* AKPM: turn on bforget in journal_forget()!!!
* AKPM: turn on bforget in jbd2_journal_forget()!!!
*/
for (p = first; p < last; p++) {
u32 nr = le32_to_cpu(*p);
Expand Down Expand Up @@ -2132,11 +2132,11 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
* We've probably journalled the indirect block several
* times during the truncate. But it's no longer
* needed and we now drop it from the transaction via
* journal_revoke().
* jbd2_journal_revoke().
*
* That's easy if it's exclusively part of this
* transaction. But if it's part of the committing
* transaction then journal_forget() will simply
* transaction then jbd2_journal_forget() will simply
* brelse() it. That means that if the underlying
* block is reallocated in ext4_get_block(),
* unmap_underlying_metadata() will find this block
Expand Down Expand Up @@ -2251,7 +2251,7 @@ void ext4_truncate(struct inode *inode)

/*
* We have to lock the EOF page here, because lock_page() nests
* outside journal_start().
* outside jbd2_journal_start().
*/
if ((inode->i_size & (blocksize - 1)) == 0) {
/* Block boundary? Nothing to do */
Expand Down Expand Up @@ -3035,7 +3035,7 @@ int ext4_mark_iloc_dirty(handle_t *handle,
/* the do_update_inode consumes one bh->b_count */
get_bh(iloc->bh);

/* ext4_do_update_inode() does journal_dirty_metadata */
/* ext4_do_update_inode() does jbd2_journal_dirty_metadata */
err = ext4_do_update_inode(handle, inode, iloc);
put_bh(iloc->bh);
return err;
Expand Down Expand Up @@ -3153,7 +3153,7 @@ static int ext4_pin_inode(handle_t *handle, struct inode *inode)
err = ext4_get_inode_loc(inode, &iloc);
if (!err) {
BUFFER_TRACE(iloc.bh, "get_write_access");
err = journal_get_write_access(handle, iloc.bh);
err = jbd2_journal_get_write_access(handle, iloc.bh);
if (!err)
err = ext4_journal_dirty_metadata(handle,
iloc.bh);
Expand Down Expand Up @@ -3185,8 +3185,8 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
if (is_journal_aborted(journal) || IS_RDONLY(inode))
return -EROFS;

journal_lock_updates(journal);
journal_flush(journal);
jbd2_journal_lock_updates(journal);
jbd2_journal_flush(journal);

/*
* OK, there are no updates running now, and all cached data is
Expand All @@ -3202,7 +3202,7 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
EXT4_I(inode)->i_flags &= ~EXT4_JOURNAL_DATA_FL;
ext4_set_aops(inode);

journal_unlock_updates(journal);
jbd2_journal_unlock_updates(journal);

/* Finally we can mark the inode as dirty. */

Expand Down
Loading

0 comments on commit dab291a

Please sign in to comment.