ocfs2: Switch over to JBD2.
cover ocfs2: Switch over to JBD2.
ocfs2 currently uses the Journaled Block Device (JBD) for its journaling. This is a very stable and tested codebase. However, JBD is limited by architecture to 32bit block numbers. This means an ocfs2 filesystem is limited to 2^32 blocks. With a 4K blocksize, that's 16TB. People want larger volumes.
Fortunately, there is now JBD2. JBD2 adds 64bit block number support and some other features. JBD2 is backwards compatible, so it can be used with existing filesystems. The new features won't be accessed until the ocfs2-tools turn them on.
Before we support JBD2, however, we need to ensure that inode blocks are allocated below that 32bit boundary. stat(2) cannot handle larger inode numbers on 32bit machines. With that limit in place, we can fully support JBD2 in the kernel filesystem. Like XFS, we provide the 'inode64' option to remove that limit.
A config option is provided (OCFS2_COMPAT_JBD) to force ocfs2 to use the old JBD. This is for the paranoid while we test JBD2.
The kernel code is available on the 'jbd2' branch of my git repository.
View:
http://oss.oracle.com/git/?p=jlbec/linux-2.6.git;a=shortlog;h=jbd2
Pull:
git pull git://oss.oracle.com/git/jlbec/linux-2.6.git jbd2
PATCH 1/3 ocfs2: Limit inode allocation to 32bits.
ocfs2 inode numbers are block numbers. For any filesystem with less than 2^32 blocks, this is not a problem. However, when ocfs2 starts using JDB2, it will be able to support filesystems with more than 2^32 blocks. This would result in inode numbers higher than 2^32.
The problem is that stat(2) can't handle those numbers on 32bit machines. The simple solution is to have ocfs2 allocate all inodes below that boundary.
The suballoc code is changed to honor an optional block limit. Only the inode suballocator sets that limit - all other allocations stay unlimited.
The biggest trick is to grow the inode suballocator beneath that limit. There's no point in allocating block groups that are above the limit, then rejecting their elements later on. We want to prevent the inode allocator from ever having block groups above the limit. This involves a little gyration with the local alloc code. If the local alloc window is above the limit, it signals the caller to try the global bitmap but does not disable the local alloc file (which can be used for other allocations).
--- fs/ocfs2/localalloc.c | 55 +++++++++++++++++++++++++++++++ fs/ocfs2/suballoc.c | 86 +++++++++++++++++++++++++++++++++++++++--------- fs/ocfs2/suballoc.h | 11 ++++-- 3 files changed, 132 insertions(+), 20 deletions(-)
fs/ocfs2/localalloc.c +55 -0
@@ -453,6 +453,46 @@ out:return status; } +/* Check to see if the local alloc window is within ac->ac_max_block */ +static int ocfs2_local_alloc_in_range (struct inode *inode, +struct ocfs2_alloc_context *ac, +u32 bits_wanted) +{ +struct ocfs2_super *osb =OCFS2_SB (inode->i_sb); +struct ocfs2_dinode *alloc; +struct ocfs2_local_alloc *la; +int start; +u64 block_off; + +if (!ac->ac_max_block) +return 1 ; + + alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; + la =OCFS2_LOCAL_ALLOC (alloc); + + start =ocfs2_local_alloc_find_clear_bits (osb, alloc, bits_wanted); +if (start ==-1 ) { +mlog_errno (-ENOSPC ); +return 0 ; + } + +/* +* Converting (bm_off + start + bits_wanted) to blocks gives us +* the blkno just past our actual allocation. This is perfect +* to compare with ac_max_block. +*/ + block_off =ocfs2_clusters_to_blocks (inode->i_sb, +le32_to_cpu (la->la_bm_off) + + start + bits_wanted); +mlog (0 ,"Checking %llu against %llu\n" , + (unsigned long long )block_off, + (unsigned long long )ac->ac_max_block); +if (block_off > ac->ac_max_block) +return 0 ; + +return 1 ; +} +/* * make sure we've got at least bitswanted contiguous bits in the * local alloc. You lose them when you drop i_mutex.
@@ -524,6 +564,21 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, } } +if (ac->ac_max_block) +mlog (0 ,"Calling in_range for max block %llu\n" , + (unsigned long long )ac->ac_max_block); + +if (!ocfs2_local_alloc_in_range (local_alloc_inode, ac, + bits_wanted)) { +/* +* The window is outside ac->ac_max_block. +* This errno tells the caller to keep localalloc enabled +* but to get the allocation from the main bitmap. +*/ + status = -EFBIG ; + goto bail; + } + ac->ac_inode = local_alloc_inode;/* We should never use localalloc from another slot */ ac->ac_alloc_slot = osb->slot_num;
fs/ocfs2/suballoc.c +70 -16
206 lines not on this page · raw message
fs/ocfs2/suballoc.h +7 -4
@@ -28,10 +28,11 @@typedef int (group_search_t )(struct inode *,struct buffer_head *, -u32 , -u32 , -u16 *, -u16 *); +u32 ,/* bits_wanted */ +u32 ,/* min_bits */ +u64 ,/* max_block */ +u16 *,/* *bit_off */ +u16 *);/* *bits_found */ struct ocfs2_alloc_context {struct inode *ac_inode;/* which bitmap are we allocating from? */
@@ -51,6 +52,8 @@ struct ocfs2_alloc_context {group_search_t *ac_group_search;u64 ac_last_group; +u64 ac_max_block;/* Highest block number to allocate. 0 is +is the same as ~0 - unlimited */ };void ocfs2_free_alloc_context (struct ocfs2_alloc_context *ac);
Signature · 1 line
1.5.6.3
PATCH 1/3 ocfs2: Limit inode allocation to 32bits.
Quoted 8 lines · Joel Becker
ocfs2 inode numbers are block numbers. For any filesystem with less than 2^32 blocks, this is not a problem. However, when ocfs2 starts using JDB2, it will be able to support filesystems with more than 2^32 blocks. This would result in inode numbers higher than 2^32.
The problem is that stat(2) can't handle those numbers on 32bit machines. The simple solution is to have ocfs2 allocate all inodes below that boundary.
Actually stat64 which most apps should use handles it just fine, but there are various programs still around not using it.
But limiting your inodes to this lower part of the disk really, really sucks. XFS has the same problem because it also has a direct corelation of inode numbers and disk addresses. It's so bad for some workloads that there have been repeated talks about adding a virtual to physical inode number remapping btree.
At least make this limitation a mount option, similar to inode64 in XFS.
PATCH 1/3 ocfs2: Limit inode allocation to 32bits.
Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · Joel Becker
ocfs2 inode numbers are block numbers. For any filesystem with less than 2^32 blocks, this is not a problem. However, when ocfs2 starts using JDB2, it will be able to support filesystems with more than 2^32 blocks. This would result in inode numbers higher than 2^32.
Quoted 6 lines
Quoted 3 lines
The problem is that stat(2) can't handle those numbers on 32bit machines. The simple solution is to have ocfs2 allocate all inodes below that boundary.
Actually stat64 which most apps should use handles it just fine, but there are various programs still around not using it.
Somehow I got the impression that some systems couldn't handle
inode64 at all. If it's just some userspace, that gives us more flexibility.
Joel
Signature · 9 lines
Life's Little Instruction Book #3 "Watch a sunrise at least once a year." Joel Becker Principal Software Developer Oracle E-mail: joel.becker at oracle.com Phone: (650) 506-8127
PATCH 2/3 ocfs2: Add the 'inode64' mount option.
In reply to Joel BeckerNow that ocfs2 limits inode numbers to 32bits, add a mount option to disable the limit. This parallels XFS. 64bit systems can handle the larger inode numbers.
--- fs/ocfs2/ocfs2.h | 1 + fs/ocfs2/suballoc.c | 5 +++-- fs/ocfs2/super.c | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-)
fs/ocfs2/ocfs2.h +1 -0
@@ -184,6 +184,7 @@ enum ocfs2_mount_optionsOCFS2_MOUNT_ERRORS_PANIC =1 <<3 ,/* Panic on errors */ OCFS2_MOUNT_DATA_WRITEBACK =1 <<4 ,/* No data ordering */ OCFS2_MOUNT_LOCALFLOCKS =1 <<5 ,/* No cluster aware user file locks */ + OCFS2_MOUNT_INODE64 = 1 << 6, /* Allow inode numbers > 2^32 */ };#define OCFS2_OSB_SOFT_RO 0x0001
fs/ocfs2/suballoc.c +3 -2
@@ -592,9 +592,10 @@ int ocfs2_reserve_new_inode(struct ocfs2_super *osb,/* * stat(2) can't handle i_ino > 32bits, so we tell the * lower levels not to allocate us a block group past that -* limit. +* limit. The 'inode64' mount option avoids this behavior. */ - (*ac)->ac_max_block = (u32 )~0U ; +if (!(osb->s_mount_opt &OCFS2_MOUNT_INODE64 )) + (*ac)->ac_max_block = (u32 )~0U ;/* * slot is set when we successfully steal inode from other nodes.
fs/ocfs2/super.c +17 -0
@@ -154,6 +154,7 @@ enum { Opt_localalloc, Opt_localflocks, Opt_stack, + Opt_inode64, Opt_err, };
@@ -173,6 +174,7 @@ static match_table_t tokens = { {Opt_localalloc, "localalloc=%d"}, {Opt_localflocks, "localflocks"}, {Opt_stack, "cluster_stack=%s"}, + {Opt_inode64, "inode64"}, {Opt_err, NULL} };
@@ -406,6 +408,15 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data) goto out; } +/* Probably don't want this on remount; it might +* mess with other nodes */ +if (!(osb->s_mount_opt &OCFS2_MOUNT_INODE64 ) && + (parsed_options.mount_opt &OCFS2_MOUNT_INODE64 )) { + ret = -EINVAL ; +mlog (ML_ERROR ,"Cannot enable inode64 on remount\n" ); + goto out; + } +/* We're going to/from readonly mode. */ if ((*flags &MS_RDONLY ) != (sb->s_flags &MS_RDONLY )) {/* Lock here so the check of HARD_RO and the potential
@@ -918,6 +929,9 @@ static int ocfs2_parse_options(struct super_block *sb, OCFS2_STACK_LABEL_LEN); mopt->cluster_stack[OCFS2_STACK_LABEL_LEN ] ='\0' ;break ; +case Opt_inode64: + mopt->mount_opt |=OCFS2_MOUNT_INODE64 ; +break ;default :mlog (ML_ERROR , "Unrecognized mount option \"%s\" "
@@ -980,6 +994,9 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt)seq_printf (s,",cluster_stack=%.*s" ,OCFS2_STACK_LABEL_LEN , osb->osb_cluster_stack); +if (opts &OCFS2_MOUNT_INODE64 ) +seq_printf (s,",inode64" ); +return 0 ; }
Signature · 1 line
1.5.6.3
PATCH 2/3 ocfs2: Add the 'inode64' mount option.
Quoted 3 lines · Joel Becker
Now that ocfs2 limits inode numbers to 32bits, add a mount option to disable the limit. This parallels XFS. 64bit systems can handle the larger inode numbers.
sorry, should have read all patches in the thread :)
PATCH 3/3 ocfs2: Switch over to JBD2.
In reply to Joel Beckerocfs2 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.
--- fs/Kconfig | 40 +++++++++++++-------- fs/ocfs2/alloc.c | 28 ++++++--------- fs/ocfs2/aops.c | 21 ++++++++--- fs/ocfs2/file.c | 14 +++++-- fs/ocfs2/inode.c | 5 +++ fs/ocfs2/inode.h | 1 + fs/ocfs2/journal.c | 72 ++++++++++++++++++++------------------ fs/ocfs2/journal.h | 25 +++++++++++-- fs/ocfs2/ocfs2.h | 7 +++- fs/ocfs2/ocfs2_jbd_compat.h | 82 +++++++++++++++++++++++++++++++++++++++++++ fs/ocfs2/super.c | 10 +++-- fs/ocfs2/uptodate.c | 6 +++- 12 files changed, 227 insertions(+), 84 deletions(-) create mode 100644 fs/ocfs2/ocfs2_jbd_compat.h
fs/Kconfig +25 -15
@@ -206,17 +206,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"
@@ -240,16 +239,17 @@ 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 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. + the ext4dev/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 ext4dev/ext4, you need to say Y here. If you are not - using ext4dev/ext4 then you will probably want to say N. + If you are using ext4dev/ext4 or OCFS2, you need to say Y here. + If you are not using ext4dev/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 ext4dev/ext4 into the kernel, - you cannot compile this code as a module. + called jbd2. If you are compiling ext4dev/ext4 or OCFS2 into the + kernel, you cannot compile this code as a module. config JBD2_DEBUG bool "JBD2 (ext4dev/ext4) debugging support"
@@ -426,7 +426,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
@@ -497,6 +497,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
fs/ocfs2/alloc.c +11 -17
@@ -6008,20 +6008,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)
@@ -6040,17 +6033,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); }
fs/ocfs2/aops.c +16 -5
@@ -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:
@@ -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); }
@@ -1905,11 +1912,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); } }
fs/ocfs2/file.c +10 -4
@@ -184,7 +184,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);
@@ -1096,9 +1096,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 )
@@ -2040,7 +2046,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; }
fs/ocfs2/inode.c +5 -0
@@ -909,6 +909,9 @@ void ocfs2_delete_inode(struct inode *inode) goto bail; } +if (ocfs2_should_order_data (inode)) +ocfs2_begin_ordered_truncate (inode,0 ); +if (!ocfs2_inode_is_valid_to_delete (inode)) {/* It's probably not necessary to truncate_inode_pages * here but we do it for safety anyway (it will most
@@ -1081,6 +1084,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 ();
fs/ocfs2/inode.h +1 -0
@@ -68,6 +68,7 @@ struct ocfs2_inode_infostruct ocfs2_extent_map ip_extent_map;struct inode vfs_inode; +struct jbd2_inode ip_jinode; };/*
fs/ocfs2/journal.c +38 -34
225 lines not on this page · raw message
fs/ocfs2/journal.h +22 -3
@@ -27,7 +27,12 @@#define OCFS2_JOURNAL_H #include <linux/fs.h> -#include <linux/jbd.h> +#ifndef CONFIG_OCFS2_COMPAT_JBD +# include <linux/jbd2.h> +#else +# include <linux/jbd.h> +# include "ocfs2_jbd_compat.h" +#endif enum ocfs2_journal_state {OCFS2_JOURNAL_FREE =0 ,
@@ -215,8 +220,8 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode)* buffer. Will have to call ocfs2_journal_dirty once * we've actually dirtied it. Type is one of . or . * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. -* ocfs2_journal_dirty_data - Indicate that a data buffer should go out before -* the current handle commits. +* ocfs2_jbd2_file_inode - Mark an inode so that its data goes out before +* the current handle commits. */ /* You must always start_trans with a number of buffs > 0, but it's
@@ -268,8 +273,10 @@ int ocfs2_journal_access(handle_t *handle,*/ int ocfs2_journal_dirty (handle_t *handle,struct buffer_head *bh); +#ifdef CONFIG_OCFS2_COMPAT_JBD int ocfs2_journal_dirty_data (handle_t *handle,struct buffer_head *bh); +#endif /* * Credit Macros:
@@ -415,4 +422,16 @@ static inline int ocfs2_calc_tree_trunc_credits(struct super_block *sb, return credits; } +static inline int ocfs2_jbd2_file_inode (handle_t *handle,struct inode *inode) +{ +return jbd2_journal_file_inode (handle, &OCFS2_I (inode)->ip_jinode); +} + +static inline int ocfs2_begin_ordered_truncate (struct inode *inode, +loff_t new_size) +{ +return jbd2_journal_begin_ordered_truncate (&OCFS2_I (inode)->ip_jinode, + new_size); +} +#endif /* OCFS2_JOURNAL_H */
fs/ocfs2/ocfs2.h +6 -1
@@ -34,7 +34,12 @@#include <linux/workqueue.h> #include <linux/kref.h> #include <linux/mutex.h> -#include <linux/jbd.h> +#ifndef CONFIG_OCFS2_COMPAT_JBD +# include <linux/jbd2.h> +#else +# include <linux/jbd.h> +# include "ocfs2_jbd_compat.h" +#endif /* For union ocfs2_dlm_lksb */ #include "stackglue.h"
fs/ocfs2/ocfs2_jbd_compat.h new file +82 -0
82 lines not on this page · raw message
fs/ocfs2/super.c +6 -4
@@ -207,10 +207,11 @@ static int ocfs2_sync_fs(struct super_block *sb, int wait)ocfs2_schedule_truncate_log_flush (osb,0 ); } -if (journal_start_commit (OCFS2_SB (sb)->journal->j_journal, &target)) { +if (jbd2_journal_start_commit (OCFS2_SB (sb)->journal->j_journal, + &target)) {if (wait) -log_wait_commit (OCFS2_SB (sb)->journal->j_journal, - target); +jbd2_log_wait_commit (OCFS2_SB (sb)->journal->j_journal, + target); }return 0 ; }
@@ -327,6 +328,7 @@ static struct inode *ocfs2_alloc_inode(struct super_block *sb)if (!oi)return NULL ; +jbd2_journal_init_jbd_inode (&oi->ip_jinode, &oi->vfs_inode);return &oi->vfs_inode; }
@@ -884,7 +886,7 @@ static int ocfs2_parse_options(struct super_block *sb,if (option <0 )return 0 ;if (option ==0 ) - option =JBD_DEFAULT_MAX_COMMIT_AGE ; + option =JBD2_DEFAULT_MAX_COMMIT_AGE ; mopt->commit_interval =HZ * option;break ;case Opt_localalloc:
fs/ocfs2/uptodate.c +5 -1
@@ -53,7 +53,11 @@#include <linux/highmem.h> #include <linux/buffer_head.h> #include <linux/rbtree.h> -#include <linux/jbd.h> +#ifndef CONFIG_OCFS2_COMPAT_JBD +# include <linux/jbd2.h> +#else +# include <linux/jbd.h> +#endif #define MLOG_MASK_PREFIX ML_UPTODATE
Signature · 1 line
1.5.6.3
PATCH 3/3 ocfs2: Switch over to JBD2.
Quoted 7 lines · Joel Becker
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.
Quoted 6 lines
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.
Having to parallel codepathes switched by a little option is a really bad idea. Those paranoid people (if they exist at all) should just stick to an old kernel.
PATCH 3/3 ocfs2: Switch over to JBD2.
Quoted 12 lines · Christoph Hellwig
Quoted 11 lines · Joel Becker
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.
Quoted 6 lines
Quoted 2 lines
We provide a compatibility option so that paranoid people can still use JBD for the time being. This will go away shortly.
Having to parallel codepathes switched by a little option is a really bad idea. Those paranoid people (if they exist at all) should just stick to an old kernel.
This will live exactly as long as it takes us to stress test
JBD2. Something like .28 will have this option and .29 will drop it.
Joel
Signature · 11 lines
"There is no more evil thing on earth than race prejudice, none at
all. I write deliberately -- it is the worst single thing in life
now. It justifies and holds together more baseness, cruelty and
abomination than any other sort of error in the world."
- H. G. Wells
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127PATCH 3/3 ocfs2: Switch over to JBD2.
In reply to Joel Beckerocfs2 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.
--- fs/Kconfig | 40 +++++++++++++-------- fs/ocfs2/alloc.c | 28 ++++++--------- fs/ocfs2/aops.c | 21 ++++++++--- fs/ocfs2/file.c | 14 +++++-- fs/ocfs2/inode.c | 5 +++ fs/ocfs2/inode.h | 1 + fs/ocfs2/journal.c | 72 ++++++++++++++++++++------------------ fs/ocfs2/journal.h | 25 +++++++++++-- fs/ocfs2/ocfs2.h | 7 +++- fs/ocfs2/ocfs2_jbd_compat.h | 82 +++++++++++++++++++++++++++++++++++++++++++ fs/ocfs2/super.c | 10 +++-- fs/ocfs2/uptodate.c | 6 +++- 12 files changed, 227 insertions(+), 84 deletions(-) create mode 100644 fs/ocfs2/ocfs2_jbd_compat.h
fs/Kconfig +25 -15
@@ -206,17 +206,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"
@@ -240,16 +239,17 @@ 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 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. + the ext4dev/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 ext4dev/ext4, you need to say Y here. If you are not - using ext4dev/ext4 then you will probably want to say N. + If you are using ext4dev/ext4 or OCFS2, you need to say Y here. + If you are not using ext4dev/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 ext4dev/ext4 into the kernel, - you cannot compile this code as a module. + called jbd2. If you are compiling ext4dev/ext4 or OCFS2 into the + kernel, you cannot compile this code as a module. config JBD2_DEBUG bool "JBD2 (ext4dev/ext4) debugging support"
@@ -426,7 +426,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
@@ -497,6 +497,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
fs/ocfs2/alloc.c +11 -17
@@ -6008,20 +6008,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)
@@ -6040,17 +6033,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); }
fs/ocfs2/aops.c +16 -5
@@ -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:
@@ -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); }
@@ -1905,11 +1912,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); } }
fs/ocfs2/file.c +10 -4
@@ -184,7 +184,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);
@@ -1096,9 +1096,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 )
@@ -2040,7 +2046,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; }
fs/ocfs2/inode.c +5 -0
@@ -909,6 +909,9 @@ void ocfs2_delete_inode(struct inode *inode) goto bail; } +if (ocfs2_should_order_data (inode)) +ocfs2_begin_ordered_truncate (inode,0 ); +if (!ocfs2_inode_is_valid_to_delete (inode)) {/* It's probably not necessary to truncate_inode_pages * here but we do it for safety anyway (it will most
@@ -1081,6 +1084,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 ();
fs/ocfs2/inode.h +1 -0
@@ -68,6 +68,7 @@ struct ocfs2_inode_infostruct ocfs2_extent_map ip_extent_map;struct inode vfs_inode; +struct jbd2_inode ip_jinode; };/*
fs/ocfs2/journal.c +38 -34
225 lines not on this page · raw message
fs/ocfs2/journal.h +22 -3
@@ -27,7 +27,12 @@#define OCFS2_JOURNAL_H #include <linux/fs.h> -#include <linux/jbd.h> +#ifndef CONFIG_OCFS2_COMPAT_JBD +# include <linux/jbd2.h> +#else +# include <linux/jbd.h> +# include "ocfs2_jbd_compat.h" +#endif enum ocfs2_journal_state {OCFS2_JOURNAL_FREE =0 ,
@@ -215,8 +220,8 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode)* buffer. Will have to call ocfs2_journal_dirty once * we've actually dirtied it. Type is one of . or . * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. -* ocfs2_journal_dirty_data - Indicate that a data buffer should go out before -* the current handle commits. +* ocfs2_jbd2_file_inode - Mark an inode so that its data goes out before +* the current handle commits. */ /* You must always start_trans with a number of buffs > 0, but it's
@@ -268,8 +273,10 @@ int ocfs2_journal_access(handle_t *handle,*/ int ocfs2_journal_dirty (handle_t *handle,struct buffer_head *bh); +#ifdef CONFIG_OCFS2_COMPAT_JBD int ocfs2_journal_dirty_data (handle_t *handle,struct buffer_head *bh); +#endif /* * Credit Macros:
@@ -415,4 +422,16 @@ static inline int ocfs2_calc_tree_trunc_credits(struct super_block *sb, return credits; } +static inline int ocfs2_jbd2_file_inode (handle_t *handle,struct inode *inode) +{ +return jbd2_journal_file_inode (handle, &OCFS2_I (inode)->ip_jinode); +} + +static inline int ocfs2_begin_ordered_truncate (struct inode *inode, +loff_t new_size) +{ +return jbd2_journal_begin_ordered_truncate (&OCFS2_I (inode)->ip_jinode, + new_size); +} +#endif /* OCFS2_JOURNAL_H */
fs/ocfs2/ocfs2.h +6 -1
@@ -34,7 +34,12 @@#include <linux/workqueue.h> #include <linux/kref.h> #include <linux/mutex.h> -#include <linux/jbd.h> +#ifndef CONFIG_OCFS2_COMPAT_JBD +# include <linux/jbd2.h> +#else +# include <linux/jbd.h> +# include "ocfs2_jbd_compat.h" +#endif /* For union ocfs2_dlm_lksb */ #include "stackglue.h"
fs/ocfs2/ocfs2_jbd_compat.h new file +82 -0
82 lines not on this page · raw message
fs/ocfs2/super.c +6 -4
@@ -207,10 +207,11 @@ static int ocfs2_sync_fs(struct super_block *sb, int wait)ocfs2_schedule_truncate_log_flush (osb,0 ); } -if (journal_start_commit (OCFS2_SB (sb)->journal->j_journal, &target)) { +if (jbd2_journal_start_commit (OCFS2_SB (sb)->journal->j_journal, + &target)) {if (wait) -log_wait_commit (OCFS2_SB (sb)->journal->j_journal, - target); +jbd2_log_wait_commit (OCFS2_SB (sb)->journal->j_journal, + target); }return 0 ; }
@@ -327,6 +328,7 @@ static struct inode *ocfs2_alloc_inode(struct super_block *sb)if (!oi)return NULL ; +jbd2_journal_init_jbd_inode (&oi->ip_jinode, &oi->vfs_inode);return &oi->vfs_inode; }
@@ -884,7 +886,7 @@ static int ocfs2_parse_options(struct super_block *sb,if (option <0 )return 0 ;if (option ==0 ) - option =JBD_DEFAULT_MAX_COMMIT_AGE ; + option =JBD2_DEFAULT_MAX_COMMIT_AGE ; mopt->commit_interval =HZ * option;break ;case Opt_localalloc:
fs/ocfs2/uptodate.c +5 -1
@@ -53,7 +53,11 @@#include <linux/highmem.h> #include <linux/buffer_head.h> #include <linux/rbtree.h> -#include <linux/jbd.h> +#ifndef CONFIG_OCFS2_COMPAT_JBD +# include <linux/jbd2.h> +#else +# include <linux/jbd.h> +#endif #define MLOG_MASK_PREFIX ML_UPTODATE
Signature · 1 line
1.5.6.3
cover ocfs2: Switch over to JBD2.
In reply to Joel BeckerQuoted 20 lines · Joel Becker
ocfs2 currently uses the Journaled Block Device (JBD) for its journaling. This is a very stable and tested codebase. However, JBD is limited by architecture to 32bit block numbers. This means an ocfs2 filesystem is limited to 2^32 blocks. With a 4K blocksize, that's 16TB. People want larger volumes.
Fortunately, there is now JBD2. JBD2 adds 64bit block number support and some other features. JBD2 is backwards compatible, so it can be used with existing filesystems. The new features won't be accessed until the ocfs2-tools turn them on.
Before we support JBD2, however, we need to ensure that inode blocks are allocated below that 32bit boundary. stat(2) cannot handle larger inode numbers on 32bit machines. With that limit in place, we can fully support JBD2 in the kernel filesystem. Like XFS, we provide the 'inode64' option to remove that limit.
A config option is provided (
OCFS2_COMPAT_JBD) to force ocfs2 to use the old JBD. This is for the paranoid while we test JBD2.
Quoted 6 lines
The kernel code is available on the 'jbd2' branch of my git repository.
View:
http://oss.oracle.com/git/?p=jlbec/linux-2.6.git;a=shortlog;h=jbd2
Pull:
git pullgit://oss.oracle.com/git/jlbec/linux-2.6.gitjbd2
Ok, these look great. A couple of notes:
- I removed an ML_NOTICE in the 1st patch
- I added information to Documentation/filesystems/ocfs2.txt in the 2nd patch
- Unsurprisingly, the last patch conflicted with lots of things:
CONFLICT (content): Merge conflict in fs/ocfs2/ocfs2.h CONFLICT (content): Merge conflict in fs/ocfs2/suballoc.c CONFLICT (content): Merge conflict in fs/ocfs2/super.c
They were fairly easy to fix - please double check my work. I created a branch 'feature_merge' in which I pulled in xattrs, dyn_la, and then jbd2 (purposfully keeping it on top). I'll just pull that into linux-next for now, since linux-next is throwaway and I don't want to have to re-merge every time I create it.
--Mark
--
Mark Fasheh