Skip to content

Commit

Permalink
ocfs2: Switch over to JBD2.
Browse files Browse the repository at this point in the history
ocfs2 wants JBD2 for many reasons, not the least of which is that JBD is
limiting our maximum filesystem size.

It's a pretty trivial change.  Most functions are just renamed.  The
only functional change is moving to Jan's inode-based ordered data mode.
It's better, too.

Because JBD2 reads and writes JBD journals, this is compatible with any
existing filesystem.  It can even interact with JBD-based ocfs2 as long
as the journal is formated for JBD.

We provide a compatibility option so that paranoid people can still use
JBD for the time being.  This will go away shortly.

[ Moved call of ocfs2_begin_ordered_truncate() from ocfs2_delete_inode() to
  ocfs2_truncate_for_delete(). --Mark ]

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
  • Loading branch information
Joel Becker authored and Mark Fasheh committed Oct 14, 2008
1 parent 12462f1 commit 2b4e30f
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 81 deletions.
34 changes: 22 additions & 12 deletions fs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,16 @@ config JBD
tristate
help
This is a generic journalling layer for block devices. It is
currently used by the ext3 and OCFS2 file systems, but it could
also be used to add journal support to other file systems or block
currently used by the ext3 file system, 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 the ext3 or OCFS2 file systems, you need to
say Y here. If you are not using ext3 OCFS2 then you will probably
want to say N.
If you are using the ext3 file system, you need to say Y here.
If you are not using ext3 then you will probably want to say N.

To compile this device as a module, choose M here: the module will be
called jbd. If you are compiling ext3 or OCFS2 into the kernel,
you cannot compile this code as a module.
called jbd. If you are compiling ext3 into the kernel, you
cannot compile this code as a module.

config JBD_DEBUG
bool "JBD (ext3) debugging support"
Expand All @@ -254,15 +253,16 @@ config JBD2
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 ext4 filesystem, but it could also be used to add
the ext4 and OCFS2 filesystems, 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 ext4, you need to say Y here. If you are not
using ext4 then you will probably want to say N.
If you are using ext4 or OCFS2, you need to say Y here.
If you are not using ext4 or OCFS2 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 ext4 into the kernel,
called jbd2. If you are compiling ext4 or OCFS2 into the kernel,
you cannot compile this code as a module.

config JBD2_DEBUG
Expand Down Expand Up @@ -440,7 +440,7 @@ config OCFS2_FS
tristate "OCFS2 file system support"
depends on NET && SYSFS
select CONFIGFS_FS
select JBD
select JBD2
select CRC32
help
OCFS2 is a general purpose extent based shared disk cluster file
Expand Down Expand Up @@ -511,6 +511,16 @@ config OCFS2_DEBUG_FS
this option for debugging only as it is likely to decrease
performance of the filesystem.

config OCFS2_COMPAT_JBD
bool "Use JBD for compatibility"
depends on OCFS2_FS
default n
select JBD
help
The ocfs2 filesystem now uses JBD2 for its journalling. JBD2
is backwards compatible with JBD. It is safe to say N here.
However, if you really want to use the original JBD, say Y here.

endif # BLOCK

config DNOTIFY
Expand Down
28 changes: 11 additions & 17 deletions fs/ocfs2/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6421,20 +6421,13 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
return status;
}

static int ocfs2_writeback_zero_func(handle_t *handle, struct buffer_head *bh)
static int ocfs2_zero_func(handle_t *handle, struct buffer_head *bh)
{
set_buffer_uptodate(bh);
mark_buffer_dirty(bh);
return 0;
}

static int ocfs2_ordered_zero_func(handle_t *handle, struct buffer_head *bh)
{
set_buffer_uptodate(bh);
mark_buffer_dirty(bh);
return ocfs2_journal_dirty_data(handle, bh);
}

static void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle,
unsigned int from, unsigned int to,
struct page *page, int zero, u64 *phys)
Expand All @@ -6453,17 +6446,18 @@ static void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle,
* here if they aren't - ocfs2_map_page_blocks()
* might've skipped some
*/
if (ocfs2_should_order_data(inode)) {
ret = walk_page_buffers(handle,
page_buffers(page),
from, to, &partial,
ocfs2_ordered_zero_func);
if (ret < 0)
mlog_errno(ret);
} else {
ret = walk_page_buffers(handle, page_buffers(page),
from, to, &partial,
ocfs2_zero_func);
if (ret < 0)
mlog_errno(ret);
else if (ocfs2_should_order_data(inode)) {
ret = ocfs2_jbd2_file_inode(handle, inode);
#ifdef CONFIG_OCFS2_COMPAT_JBD
ret = walk_page_buffers(handle, page_buffers(page),
from, to, &partial,
ocfs2_writeback_zero_func);
ocfs2_journal_dirty_data);
#endif
if (ret < 0)
mlog_errno(ret);
}
Expand Down
21 changes: 16 additions & 5 deletions fs/ocfs2/aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,14 @@ handle_t *ocfs2_start_walk_page_trans(struct inode *inode,
}

if (ocfs2_should_order_data(inode)) {
ret = ocfs2_jbd2_file_inode(handle, inode);
#ifdef CONFIG_OCFS2_COMPAT_JBD
ret = walk_page_buffers(handle,
page_buffers(page),
from, to, NULL,
ocfs2_journal_dirty_data);
if (ret < 0)
#endif
if (ret < 0)
mlog_errno(ret);
}
out:
Expand Down Expand Up @@ -669,7 +672,7 @@ static void ocfs2_invalidatepage(struct page *page, unsigned long offset)
{
journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal;

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

static int ocfs2_releasepage(struct page *page, gfp_t wait)
Expand All @@ -678,7 +681,7 @@ static int ocfs2_releasepage(struct page *page, gfp_t wait)

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);
}

static ssize_t ocfs2_direct_IO(int rw,
Expand Down Expand Up @@ -1074,11 +1077,15 @@ static void ocfs2_write_failure(struct inode *inode,
tmppage = wc->w_pages[i];

if (page_has_buffers(tmppage)) {
if (ocfs2_should_order_data(inode))
if (ocfs2_should_order_data(inode)) {
ocfs2_jbd2_file_inode(wc->w_handle, inode);
#ifdef CONFIG_OCFS2_COMPAT_JBD
walk_page_buffers(wc->w_handle,
page_buffers(tmppage),
from, to, NULL,
ocfs2_journal_dirty_data);
#endif
}

block_commit_write(tmppage, from, to);
}
Expand Down Expand Up @@ -1917,11 +1924,15 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
}

if (page_has_buffers(tmppage)) {
if (ocfs2_should_order_data(inode))
if (ocfs2_should_order_data(inode)) {
ocfs2_jbd2_file_inode(wc->w_handle, inode);
#ifdef CONFIG_OCFS2_COMPAT_JBD
walk_page_buffers(wc->w_handle,
page_buffers(tmppage),
from, to, NULL,
ocfs2_journal_dirty_data);
#endif
}
block_commit_write(tmppage, from, to);
}
}
Expand Down
14 changes: 10 additions & 4 deletions fs/ocfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static int ocfs2_sync_file(struct file *file,
goto bail;

journal = osb->journal->j_journal;
err = journal_force_commit(journal);
err = jbd2_journal_force_commit(journal);

bail:
mlog_exit(err);
Expand Down Expand Up @@ -941,9 +941,15 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
goto bail_unlock;
}

if (i_size_read(inode) > attr->ia_size)
if (i_size_read(inode) > attr->ia_size) {
if (ocfs2_should_order_data(inode)) {
status = ocfs2_begin_ordered_truncate(inode,
attr->ia_size);
if (status)
goto bail_unlock;
}
status = ocfs2_truncate_file(inode, bh, attr->ia_size);
else
} else
status = ocfs2_extend_file(inode, bh, attr->ia_size);
if (status < 0) {
if (status != -ENOSPC)
Expand Down Expand Up @@ -1888,7 +1894,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
*/
if (old_size != i_size_read(inode) ||
old_clusters != OCFS2_I(inode)->ip_clusters) {
ret = journal_force_commit(osb->journal->j_journal);
ret = jbd2_journal_force_commit(osb->journal->j_journal);
if (ret < 0)
written = ret;
}
Expand Down
5 changes: 5 additions & 0 deletions fs/ocfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
* data and fast symlinks.
*/
if (fe->i_clusters) {
if (ocfs2_should_order_data(inode))
ocfs2_begin_ordered_truncate(inode, 0);

handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
if (IS_ERR(handle)) {
status = PTR_ERR(handle);
Expand Down Expand Up @@ -1100,6 +1103,8 @@ void ocfs2_clear_inode(struct inode *inode)
oi->ip_last_trans = 0;
oi->ip_dir_start_lookup = 0;
oi->ip_blkno = 0ULL;
jbd2_journal_release_jbd_inode(OCFS2_SB(inode->i_sb)->journal->j_journal,
&oi->ip_jinode);

bail:
mlog_exit_void();
Expand Down
1 change: 1 addition & 0 deletions fs/ocfs2/inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct ocfs2_inode_info
struct ocfs2_extent_map ip_extent_map;

struct inode vfs_inode;
struct jbd2_inode ip_jinode;
};

/*
Expand Down
Loading

0 comments on commit 2b4e30f

Please sign in to comment.