Commit 2b4e30fb authored by Joel Becker's avatar Joel Becker Committed by Mark Fasheh
Browse files

ocfs2: Switch over to JBD2.



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: default avatarJoel Becker <joel.becker@oracle.com>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent 12462f1d
Loading
Loading
Loading
Loading
+22 −12
Original line number Diff line number Diff line
@@ -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"
@@ -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
@@ -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
@@ -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
+11 −17
Original line number Diff line number Diff line
@@ -6421,20 +6421,13 @@ bail:
	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)
@@ -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),
	ret = walk_page_buffers(handle, page_buffers(page),
				from, to, &partial,
					ocfs2_ordered_zero_func);
				ocfs2_zero_func);
	if (ret < 0)
		mlog_errno(ret);
	} else {
	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);
	}
+16 −5
Original line number Diff line number Diff line
@@ -485,10 +485,13 @@ 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);
#endif
		if (ret < 0)
			mlog_errno(ret);
	}
@@ -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)
@@ -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,
@@ -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);
		}
@@ -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);
		}
	}
+10 −4
Original line number Diff line number Diff line
@@ -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);
@@ -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)
@@ -1888,7 +1894,7 @@ out_dio:
		 */
		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;
		}
+5 −0
Original line number Diff line number Diff line
@@ -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);
@@ -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();
Loading