Ext4 patches planned for submission upstream
Theodore Ts'o
maintainerRFC PATCH 1/1 Ext4 patches planned for submission upstream
The following ext4 patches are planned for submission to Linus once the merge window for 2.6.24-rc1 is opened.
- Ted
Theodore Ts'o
maintainerPATCH 1/1 jbd/jbd2: JBD memory allocation cleanups
From: Mingming Cao <[email protected]>
JBD: Replace slab allocations with page cache allocations
JBD allocate memory for committed_data and frozen_data from slab. However
JBD should not pass slab pages down to the block layer. Use page allocator pages instead. This will also prepare JBD for the large blocksize patchset.
Also this patch cleans up jbd_kmalloc and replace it with kmalloc directly
--- fs/jbd/commit.c | 6 +- fs/jbd/journal.c | 99 ++---------------------------------------------- fs/jbd/transaction.c | 12 +++--- fs/jbd2/commit.c | 6 +- fs/jbd2/journal.c | 99 ++---------------------------------------------- fs/jbd2/transaction.c | 18 ++++---- include/linux/jbd.h | 18 +++++---- include/linux/jbd2.h | 19 +++++---- 8 files changed, 51 insertions(+), 226 deletions(-)
fs/jbd/commit.c +3 -3
@@ -375,7 +375,7 @@ void journal_commit_transaction(journal_t *journal)struct buffer_head *bh =jh2bh (jh);jbd_lock_bh_state (bh); -jbd_slab_free (jh->b_committed_data, bh->b_size); +jbd_free (jh->b_committed_data, bh->b_size); jh->b_committed_data =NULL ;jbd_unlock_bh_state (bh); }
@@ -792,14 +792,14 @@ restart_loop:* Otherwise, we can just throw away the frozen data now. */ if (jh->b_committed_data) { -jbd_slab_free (jh->b_committed_data, bh->b_size); +jbd_free (jh->b_committed_data, bh->b_size); jh->b_committed_data =NULL ;if (jh->b_frozen_data) { jh->b_committed_data = jh->b_frozen_data; jh->b_frozen_data =NULL ; } }else if (jh->b_frozen_data) { -jbd_slab_free (jh->b_frozen_data, bh->b_size); +jbd_free (jh->b_frozen_data, bh->b_size); jh->b_frozen_data =NULL ; }
fs/jbd/journal.c +5 -94
148 lines not on this page · raw message
fs/jbd/transaction.c +6 -6
@@ -96,8 +96,8 @@ static int start_this_handle(journal_t *journal, handle_t *handle) alloc_transaction:if (!journal->j_running_transaction) { - new_transaction =jbd_kmalloc (sizeof (*new_transaction), -GFP_NOFS ); + new_transaction =kmalloc (sizeof (*new_transaction), +GFP_NOFS |__GFP_NOFAIL);if (!new_transaction) { ret = -ENOMEM ; goto out;
@@ -668,7 +668,7 @@ repeat:JBUFFER_TRACE (jh,"allocate memory for buffer" );jbd_unlock_bh_state (bh); frozen_buffer = -jbd_slab_alloc (jh2bh (jh)->b_size, +jbd_alloc (jh2bh (jh)->b_size,GFP_NOFS );if (!frozen_buffer) { printk(KERN_EMERG
@@ -728,7 +728,7 @@ done: out:if (unlikely (frozen_buffer))/* It's usually NULL */ -jbd_slab_free (frozen_buffer, bh->b_size); +jbd_free (frozen_buffer, bh->b_size);JBUFFER_TRACE (jh,"exit" );return error;
@@ -881,7 +881,7 @@ int journal_get_undo_access(handle_t *handle, struct buffer_head *bh) repeat:if (!jh->b_committed_data) { - committed_data =jbd_slab_alloc (jh2bh (jh)->b_size,GFP_NOFS ); + committed_data =jbd_alloc (jh2bh (jh)->b_size,GFP_NOFS );if (!committed_data) {printk (KERN_EMERG "%s: No memory for committed data\n" , __FUNCTION__);
@@ -908,7 +908,7 @@ repeat: out:journal_put_journal_head (jh);if (unlikely (committed_data)) -jbd_slab_free (committed_data, bh->b_size); +jbd_free (committed_data, bh->b_size);return err; }
fs/jbd2/commit.c +3 -3
@@ -384,7 +384,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)struct buffer_head *bh =jh2bh (jh);jbd_lock_bh_state (bh); -jbd2_slab_free (jh->b_committed_data, bh->b_size); +jbd2_free (jh->b_committed_data, bh->b_size); jh->b_committed_data =NULL ;jbd_unlock_bh_state (bh); }
@@ -801,14 +801,14 @@ restart_loop:* Otherwise, we can just throw away the frozen data now. */ if (jh->b_committed_data) { -jbd2_slab_free (jh->b_committed_data, bh->b_size); +jbd2_free (jh->b_committed_data, bh->b_size); jh->b_committed_data =NULL ;if (jh->b_frozen_data) { jh->b_committed_data = jh->b_frozen_data; jh->b_frozen_data =NULL ; } }else if (jh->b_frozen_data) { -jbd2_slab_free (jh->b_frozen_data, bh->b_size); +jbd2_free (jh->b_frozen_data, bh->b_size); jh->b_frozen_data =NULL ; }
fs/jbd2/journal.c +5 -94
148 lines not on this page · raw message
fs/jbd2/transaction.c +9 -9
@@ -96,8 +96,8 @@ static int start_this_handle(journal_t *journal, handle_t *handle) alloc_transaction:if (!journal->j_running_transaction) { - new_transaction =jbd_kmalloc (sizeof (*new_transaction), -GFP_NOFS ); + new_transaction =kmalloc (sizeof (*new_transaction), +GFP_NOFS |__GFP_NOFAIL);if (!new_transaction) { ret = -ENOMEM ; goto out;
@@ -236,7 +236,7 @@ out:/* Allocate a new handle. This should probably be in a slab... */ static handle_t *new_handle (int nblocks) { -handle_t *handle =jbd_alloc_handle (GFP_NOFS ); +handle_t *handle =jbd2_alloc_handle (GFP_NOFS );if (!handle)return NULL ;memset (handle,0 ,sizeof (*handle));
@@ -282,7 +282,7 @@ handle_t *jbd2_journal_start(journal_t *journal, int nblocks) err =start_this_handle (journal, handle);if (err <0 ) { -jbd_free_handle (handle); +jbd2_free_handle (handle); current->journal_info =NULL ; handle =ERR_PTR (err); }
@@ -668,7 +668,7 @@ repeat:JBUFFER_TRACE (jh,"allocate memory for buffer" );jbd_unlock_bh_state (bh); frozen_buffer = -jbd2_slab_alloc (jh2bh (jh)->b_size, +jbd2_alloc (jh2bh (jh)->b_size,GFP_NOFS );if (!frozen_buffer) { printk(KERN_EMERG
@@ -728,7 +728,7 @@ done: out:if (unlikely (frozen_buffer))/* It's usually NULL */ -jbd2_slab_free (frozen_buffer, bh->b_size); +jbd2_free (frozen_buffer, bh->b_size);JBUFFER_TRACE (jh,"exit" );return error;
@@ -881,7 +881,7 @@ int jbd2_journal_get_undo_access(handle_t *handle, struct buffer_head *bh) repeat:if (!jh->b_committed_data) { - committed_data =jbd2_slab_alloc (jh2bh (jh)->b_size,GFP_NOFS ); + committed_data =jbd2_alloc (jh2bh (jh)->b_size,GFP_NOFS );if (!committed_data) {printk (KERN_EMERG "%s: No memory for committed data\n" , __FUNCTION__);
@@ -908,7 +908,7 @@ repeat: out:jbd2_journal_put_journal_head (jh);if (unlikely (committed_data)) -jbd2_slab_free (committed_data, bh->b_size); +jbd2_free (committed_data, bh->b_size);return err; }
@@ -1411,7 +1411,7 @@ int jbd2_journal_stop(handle_t *handle)spin_unlock (&journal->j_state_lock); } -jbd_free_handle (handle); +jbd2_free_handle (handle);return err; }
include/linux/jbd.h +10 -8
@@ -71,14 +71,16 @@ extern int journal_enable_debug; #define jbd_debug(f, a...) /**/#endif -extern void *__jbd_kmalloc (const char *where,size_t size,gfp_t flags,int retry); -extern void *jbd_slab_alloc (size_t size,gfp_t flags); -extern void jbd_slab_free (void *ptr,size_t size); - -#define jbd_kmalloc (size, flags) \ - __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry) -#define jbd_rep_kmalloc (size, flags) \ - __jbd_kmalloc(__FUNCTION__, (size), (flags), 1) + +static inline void *jbd_alloc (size_t size,gfp_t flags) +{ +return (void *)__get_free_pages (flags,get_order (size)); +} + +static inline void jbd_free (void *ptr,size_t size) +{ +free_pages ((unsigned long )ptr,get_order (size)); +};#define JFS_MIN_JOURNAL_BLOCKS 1024
include/linux/jbd2.h +10 -9
@@ -71,14 +71,15 @@ extern u8 jbd2_journal_enable_debug; #define jbd_debug(f, a...) /**/#endif -extern void *__jbd2_kmalloc (const char *where,size_t size,gfp_t flags,int retry); -extern void *jbd2_slab_alloc (size_t size,gfp_t flags); -extern void jbd2_slab_free (void *ptr,size_t size); +static inline void *jbd2_alloc (size_t size,gfp_t flags) +{ +return (void *)__get_free_pages (flags,get_order (size)); +} -#define jbd_kmalloc (size, flags) \ - __jbd2_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry) -#define jbd_rep_kmalloc (size, flags) \ - __jbd2_kmalloc(__FUNCTION__, (size), (flags), 1) +static inline void jbd2_free (void *ptr,size_t size) +{ +free_pages ((unsigned long )ptr,get_order (size)); +};#define JBD2_MIN_JOURNAL_BLOCKS 1024
@@ -959,12 +960,12 @@ void jbd2_journal_put_journal_head(struct journal_head *jh);*/ extern struct kmem_cache *jbd2_handle_cache; -static inline handle_t *jbd_alloc_handle (gfp_t gfp_flags) +static inline handle_t *jbd2_alloc_handle (gfp_t gfp_flags) {return kmem_cache_alloc (jbd2_handle_cache, gfp_flags); } -static inline void jbd_free_handle (handle_t *handle) +static inline void jbd2_free_handle (handle_t *handle) {kmem_cache_free (jbd2_handle_cache, handle); }
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 jbd/jbd2: Journal initialization doesn't need __GFP_NOFAIL
From: Aneesh Kumar K.V <[email protected]>
--- fs/jbd/journal.c | 2 +- fs/jbd2/journal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/jbd/journal.c +1 -1
@@ -653,7 +653,7 @@ static journal_t * journal_init_common (void)journal_t *journal;int err; - journal =kmalloc (sizeof (*journal),GFP_KERNEL |__GFP_NOFAIL); + journal =kmalloc (sizeof (*journal),GFP_KERNEL );if (!journal) goto fail;memset (journal,0 ,sizeof (*journal));
fs/jbd2/journal.c +1 -1
@@ -654,7 +654,7 @@ static journal_t * journal_init_common (void)journal_t *journal;int err; - journal =kmalloc (sizeof (*journal),GFP_KERNEL |__GFP_NOFAIL); + journal =kmalloc (sizeof (*journal),GFP_KERNEL );if (!journal) goto fail;memset (journal,0 ,sizeof (*journal));
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 JBD2/Ext4: Convert kmalloc to kzalloc in jbd2/ext4
From: Mingming Cao <[email protected]>
Convert kmalloc to kzalloc() and get rid of the memset().
--- fs/ext4/xattr.c | 3 +-- fs/jbd2/journal.c | 3 +-- fs/jbd2/transaction.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-)
fs/ext4/xattr.c +1 -2
@@ -750,12 +750,11 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, } }else {/* Allocate a buffer where we construct the new block. */ - s->base =kmalloc (sb->s_blocksize,GFP_KERNEL ); + s->base =kzalloc (sb->s_blocksize,GFP_KERNEL );/* assert(header == s->base) */ error = -ENOMEM ;if (s->base ==NULL ) goto cleanup; -memset (s->base,0 , sb->s_blocksize);header (s->base)->h_magic =cpu_to_le32 (EXT4_XATTR_MAGIC );header (s->base)->h_blocks =cpu_to_le32 (1 );header (s->base)->h_refcount =cpu_to_le32 (1 );
fs/jbd2/journal.c +1 -2
@@ -654,10 +654,9 @@ static journal_t * journal_init_common (void)journal_t *journal;int err; - journal =kmalloc (sizeof (*journal),GFP_KERNEL ); + journal =kzalloc (sizeof (*journal),GFP_KERNEL |__GFP_NOFAIL);if (!journal) goto fail; -memset (journal,0 ,sizeof (*journal));init_waitqueue_head (&journal->j_wait_transaction_locked);init_waitqueue_head (&journal->j_wait_logspace);
fs/jbd2/transaction.c +1 -2
@@ -96,13 +96,12 @@ static int start_this_handle(journal_t *journal, handle_t *handle) alloc_transaction:if (!journal->j_running_transaction) { - new_transaction =kmalloc (sizeof (*new_transaction), + new_transaction =kzalloc (sizeof (*new_transaction),GFP_NOFS |__GFP_NOFAIL);if (!new_transaction) { ret = -ENOMEM ; goto out; } -memset (new_transaction,0 ,sizeof (*new_transaction)); }jbd_debug (3 ,"New handle %p going live.\n" , handle);
Signature · 1 line
1.5.3.2.81.g17ed
A message that is not in the archive (sent off-list or not yet received): [email protected]
Theodore Ts'o
maintainerPATCH 1/1 jbd2: fix commit code to properly abort journal
From: Jan Kara <[email protected]>
We should really call journal_abort() and not __journal_abort_hard() in case of errors. The latter call does not record the error in the journal superblock and thus filesystem won't be marked as with errors later (and user could happily mount it without any warning).
--- fs/jbd2/commit.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
fs/jbd2/commit.c +4 -4
@@ -475,7 +475,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)spin_unlock (&journal->j_list_lock);if (err) -__jbd2_journal_abort_hard (journal); +jbd2_journal_abort (journal, err);jbd2_journal_write_revoke_records (journal, commit_transaction);
@@ -533,7 +533,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) descriptor =jbd2_journal_get_descriptor_buffer (journal);if (!descriptor) { -__jbd2_journal_abort_hard (journal); +jbd2_journal_abort (journal, -EIO );continue ; }
@@ -566,7 +566,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)and repeat this loop: we'll fall into the refile-on-abort condition above. */ if (err) { -__jbd2_journal_abort_hard (journal); +jbd2_journal_abort (journal, err);continue ; }
@@ -757,7 +757,7 @@ wait_for_iobuf: err = -EIO ;if (err) -__jbd2_journal_abort_hard (journal); +jbd2_journal_abort (journal, err);/* End of a transaction! Finally, we can do checkpoint processing: any buffers committed as a result of this
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 JBD2: debug code cleanup.
From: Jose R. Santos <[email protected]>
Mostly stolen from akpm's JBD cleanup patch.
- use #ifdef foo' instead of #if defined(foo)'
- Make journal_enable_debug __read_mostly just for the heck of it
- Make jbd_debugfs_dir and jbd_debug static
- debugfs_remove(NULL) is legal: remove unneeded tests
- remove unnecessary empty loops
--- fs/jbd2/journal.c | 20 ++++++-------------- 1 files changed, 6 insertions(+), 14 deletions(-)
fs/jbd2/journal.c +6 -14
@@ -1864,16 +1864,14 @@ void jbd2_journal_put_journal_head(struct journal_head *jh)/* * debugfs tunables */ -#if defined(CONFIG_JBD2_DEBUG ) -u8 jbd2_journal_enable_debug; +#ifdef CONFIG_JBD2_DEBUG +u8 jbd2_journal_enable_debug__read_mostly ;EXPORT_SYMBOL (jbd2_journal_enable_debug); -#endif - -#if defined(CONFIG_JBD2_DEBUG ) && defined(CONFIG_DEBUG_FS )#define JBD2_DEBUG_NAME "jbd2-debug" -struct dentry *jbd2_debugfs_dir, *jbd2_debug; +static struct dentry *jbd2_debugfs_dir; +static struct dentry *jbd2_debug;static void __init jbd2_create_debugfs_entry (void ) {
@@ -1886,24 +1884,18 @@ static void __init jbd2_create_debugfs_entry(void) static void __exit jbd2_remove_debugfs_entry(void) { -if (jbd2_debug) -debugfs_remove (jbd2_debug); -if (jbd2_debugfs_dir) -debugfs_remove (jbd2_debugfs_dir); +debugfs_remove (jbd2_debug); +debugfs_remove (jbd2_debugfs_dir); }#else static void __init jbd2_create_debugfs_entry (void ) { -do { - }while (0 ); } static void __exit jbd2_remove_debugfs_entry(void) { -do { - }while (0 ); }#endif
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 Once ext4 will not implement fragment, it is believed it will never be
From: Coly Li <[email protected]>
implement in future. Therefore fragment related source code in ext4 should be obsoleted -- no one will use it.
This patch obsolete fragment from ext4. Another patch posted on linux-ext4 removing fragment supporting from e2fsprogs.
--- fs/ext4/ialloc.c | 5 ----- fs/ext4/inode.c | 10 ---------- fs/ext4/super.c | 15 --------------- include/linux/ext4_fs.h | 35 ++++++----------------------------- include/linux/ext4_fs_i.h | 5 ----- include/linux/ext4_fs_sb.h | 3 --- 6 files changed, 6 insertions(+), 67 deletions(-)
fs/ext4/ialloc.c +0 -5
@@ -576,11 +576,6 @@ got:/* dirsync only applies to directories */ if (!S_ISDIR (mode)) ei->i_flags &= ~EXT4_DIRSYNC_FL ; -#ifdef EXT4_FRAGMENTS - ei->i_faddr =0 ; - ei->i_frag_no =0 ; - ei->i_frag_size =0 ; -#endif ei->i_file_acl =0 ; ei->i_dir_acl =0 ; ei->i_dtime =0 ;
fs/ext4/inode.c +0 -10
@@ -2645,11 +2645,6 @@ void ext4_read_inode(struct inode * inode) } inode->i_blocks =le32_to_cpu (raw_inode->i_blocks); ei->i_flags =le32_to_cpu (raw_inode->i_flags); -#ifdef EXT4_FRAGMENTS - ei->i_faddr =le32_to_cpu (raw_inode->i_faddr); - ei->i_frag_no = raw_inode->i_frag; - ei->i_frag_size = raw_inode->i_fsize; -#endif ei->i_file_acl =le32_to_cpu (raw_inode->i_file_acl);if (EXT4_SB (inode->i_sb)->s_es->s_creator_os !=cpu_to_le32 (EXT4_OS_HURD ))
@@ -2794,11 +2789,6 @@ static int ext4_do_update_inode(handle_t *handle, raw_inode->i_blocks =cpu_to_le32 (inode->i_blocks); raw_inode->i_dtime =cpu_to_le32 (ei->i_dtime); raw_inode->i_flags =cpu_to_le32 (ei->i_flags); -#ifdef EXT4_FRAGMENTS - raw_inode->i_faddr =cpu_to_le32 (ei->i_faddr); - raw_inode->i_frag = ei->i_frag_no; - raw_inode->i_fsize = ei->i_frag_size; -#endif if (EXT4_SB (inode->i_sb)->s_es->s_creator_os !=cpu_to_le32 (EXT4_OS_HURD )) raw_inode->i_file_acl_high =
fs/ext4/super.c +0 -15
@@ -1655,14 +1655,6 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)if (sbi->s_inode_size >EXT4_GOOD_OLD_INODE_SIZE ) sb->s_time_gran =1 << (EXT4_EPOCH_BITS -2 ); } - sbi->s_frag_size =EXT4_MIN_FRAG_SIZE << -le32_to_cpu (es->s_log_frag_size); -if (blocksize != sbi->s_frag_size) { -printk (KERN_ERR -"EXT4-fs: fragsize %lu != blocksize %u (unsupported)\n" , - sbi->s_frag_size, blocksize); - goto failed_mount; - } sbi->s_desc_size =le16_to_cpu (es->s_desc_size);if (EXT4_HAS_INCOMPAT_FEATURE (sb,EXT4_FEATURE_INCOMPAT_64BIT )) { if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT ||
@@ -1676,7 +1668,6 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) }else sbi->s_desc_size =EXT4_MIN_DESC_SIZE ; sbi->s_blocks_per_group =le32_to_cpu (es->s_blocks_per_group); - sbi->s_frags_per_group =le32_to_cpu (es->s_frags_per_group); sbi->s_inodes_per_group =le32_to_cpu (es->s_inodes_per_group);if (EXT4_INODE_SIZE (sb) ==0 ) goto cantfind_ext4;
@@ -1700,12 +1691,6 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) sbi->s_blocks_per_group); goto failed_mount; } -if (sbi->s_frags_per_group > blocksize *8 ) { -printk (KERN_ERR -"EXT4-fs: #fragments per group too big: %lu\n" , - sbi->s_frags_per_group); - goto failed_mount; - }if (sbi->s_inodes_per_group > blocksize *8 ) { printk (KERN_ERR "EXT4-fs: #inodes per group too big: %lu\n",
include/linux/ext4_fs.h +6 -29
@@ -105,20 +105,6 @@#define EXT4_BLOCK_ALIGN (size, blkbits) ALIGN((size), (1 << (blkbits)))/* -* Macro-instructions used to manage fragments -*/ -#define EXT4_MIN_FRAG_SIZE 1024 -#define EXT4_MAX_FRAG_SIZE 4096 -#define EXT4_MIN_FRAG_LOG_SIZE 10 -#ifdef __KERNEL__ -# define EXT4_FRAG_SIZE (s) (EXT4_SB(s)->s_frag_size) -# define EXT4_FRAGS_PER_BLOCK (s) (EXT4_SB(s)->s_frags_per_block) -#else -# define EXT4_FRAG_SIZE (s) (EXT4_MIN_FRAG_SIZE << (s)->s_log_frag_size) -# define EXT4_FRAGS_PER_BLOCK (s) (EXT4_BLOCK_SIZE(s) / EXT4_FRAG_SIZE(s)) -#endif - -/* * Structure of a blocks group descriptor */ struct ext4_group_desc
@@ -311,27 +297,24 @@ struct ext4_inode {__le32 i_generation;/* File version (for NFS) */ __le32 i_file_acl;/* File ACL */ __le32 i_dir_acl;/* Directory ACL */ -__le32 i_faddr;/* Fragment address */ +__le32 i_obso_faddr;/* Obsoleted fragment address */ union {struct { -__u8 l_i_frag;/* Fragment number */ -__u8 l_i_fsize;/* Fragment size */ +__le16 l_i_reserved1;/* Obsoleted fragment number/size which are removed in ext4 */ __le16 l_i_file_acl_high;__le16 l_i_uid_high;/* these 2 fields */ __le16 l_i_gid_high;/* were reserved2[0] */ __u32 l_i_reserved2; } linux2;struct { -__u8 h_i_frag;/* Fragment number */ -__u8 h_i_fsize;/* Fragment size */ +__le16 h_i_reserved1;/* Obsoleted fragment number/size which are removed in ext4 */ __u16 h_i_mode_high;__u16 h_i_uid_high;__u16 h_i_gid_high;__u32 h_i_author; } hurd2;struct { -__u8 m_i_frag;/* Fragment number */ -__u8 m_i_fsize;/* Fragment size */ +__le16 h_i_reserved1;/* Obsoleted fragment number/size which are removed in ext4 */ __le16 m_i_file_acl_high;__u32 m_i_reserved2[2 ]; } masix2;
@@ -419,8 +402,6 @@ do { \#if defined(__KERNEL__) || defined(__linux__)#define i_reserved1 osd1.linux1.l_i_reserved1 -#define i_frag osd2.linux2.l_i_frag -#define i_fsize osd2.linux2.l_i_fsize#define i_file_acl_high osd2.linux2.l_i_file_acl_high#define i_uid_low i_uid#define i_gid_low i_gid
@@ -431,8 +412,6 @@ do { \#elif defined(__GNU__)#define i_translator osd1.hurd1.h_i_translator -#define i_frag osd2.hurd2.h_i_frag; -#define i_fsize osd2.hurd2.h_i_fsize;#define i_uid_high osd2.hurd2.h_i_uid_high#define i_gid_high osd2.hurd2.h_i_gid_high#define i_author osd2.hurd2.h_i_author
@@ -440,8 +419,6 @@ do { \#elif defined(__masix__)#define i_reserved1 osd1.masix1.m_i_reserved1 -#define i_frag osd2.masix2.m_i_frag -#define i_fsize osd2.masix2.m_i_fsize#define i_file_acl_high osd2.masix2.m_i_file_acl_high#define i_reserved2 osd2.masix2.m_i_reserved2
@@ -528,9 +505,9 @@ struct ext4_super_block {/*10*/ __le32 s_free_inodes_count;/* Free inodes count */ __le32 s_first_data_block;/* First Data Block */ __le32 s_log_block_size;/* Block size */ -__le32 s_log_frag_size;/* Fragment size */ +__le32 s_obso_log_frag_size;/* Obsoleted fragment size */ /*20*/ __le32 s_blocks_per_group;/* # Blocks per group */ -__le32 s_frags_per_group;/* # Fragments per group */ +__le32 s_obso_frags_per_group;/* Obsoleted fragments per group */ __le32 s_inodes_per_group;/* # Inodes per group */ __le32 s_mtime;/* Mount time */ /*30*/ __le32 s_wtime;/* Write time */
include/linux/ext4_fs_i.h +0 -5
@@ -78,11 +78,6 @@ struct ext4_ext_cache {struct ext4_inode_info {__le32 i_data[15 ];/* unconverted */ __u32 i_flags; -#ifdef EXT4_FRAGMENTS -__u32 i_faddr; -__u8 i_frag_no; -__u8 i_frag_size; -#endif ext4_fsblk_t i_file_acl;__u32 i_dir_acl;__u32 i_dtime;
include/linux/ext4_fs_sb.h +0 -3
@@ -28,11 +28,8 @@* third extended-fs super-block data in memory */ struct ext4_sb_info { -unsigned long s_frag_size;/* Size of a fragment in bytes */ unsigned long s_desc_size;/* Size of a group descriptor in bytes */ -unsigned long s_frags_per_block;/* Number of fragments per block */ unsigned long s_inodes_per_block;/* Number of inodes per block */ -unsigned long s_frags_per_group;/* Number of fragments in a group */ unsigned long s_blocks_per_group;/* Number of blocks in a group */ unsigned long s_inodes_per_group;/* Number of inodes in a group */ unsigned long s_itb_per_group;/* Number of inode table blocks per group */
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext4: remove #ifdef CONFIG_EXT4_INDEX
From: Eric Sandeen <[email protected]>
CONFIG_EXT4_INDEX is not an exposed config option in the kernel, and it is unconditionally defined in ext4_fs.h. tune2fs is already able to turn off dir indexing, so at this point it's just cluttering up the code. Remove it.
--- fs/ext4/dir.c | 7 ------- fs/ext4/namei.c | 20 -------------------- include/linux/ext4_fs.h | 14 ++------------ 3 files changed, 2 insertions(+), 39 deletions(-)
fs/ext4/dir.c +0 -7
@@ -47,9 +47,7 @@ const struct file_operations ext4_dir_operations = { .compat_ioctl = ext4_compat_ioctl, #endif .fsync = ext4_sync_file, /* BKL held */ -#ifdef CONFIG_EXT4_INDEX .release = ext4_release_dir, -#endif };
@@ -107,7 +105,6 @@ static int ext4_readdir(struct file * filp, sb = inode->i_sb; -#ifdef CONFIG_EXT4_INDEX if (EXT4_HAS_COMPAT_FEATURE(inode->i_sb, EXT4_FEATURE_COMPAT_DIR_INDEX) && ((EXT4_I(inode)->i_flags & EXT4_INDEX_FL) ||
@@ -123,7 +120,6 @@ static int ext4_readdir(struct file * filp,*/ EXT4_I (filp->f_path.dentry->d_inode)->i_flags &= ~EXT4_INDEX_FL ; } -#endif stored =0 ; offset = filp->f_pos & (sb->s_blocksize -1 );
@@ -232,7 +228,6 @@ out:return ret; } -#ifdef CONFIG_EXT4_INDEX /* * These functions convert from the major/minor hash to an f_pos * value.
@@ -518,5 +513,3 @@ static int ext4_release_dir (struct inode * inode, struct file * filp)return 0 ; } - -#endif
fs/ext4/namei.c +0 -20
@@ -144,7 +144,6 @@ struct dx_map_entryu16 size; }; -#ifdef CONFIG_EXT4_INDEX static inline unsigned dx_get_block (struct dx_entry *entry);static void dx_set_block (struct dx_entry *entry,unsigned value);static inline unsigned dx_get_hash (struct dx_entry *entry);
@@ -766,8 +765,6 @@ static void dx_insert_block(struct dx_frame *frame, u32 hash, u32 block)dx_set_block (new, block);dx_set_count (entries, count +1 ); } -#endif -static void ext4_update_dx_flag (struct inode *inode) {
@@ -869,7 +866,6 @@ static struct buffer_head * ext4_find_entry (struct dentry *dentry, name = dentry->d_name.name;if (namelen >EXT4_NAME_LEN )return NULL ; -#ifdef CONFIG_EXT4_INDEX if (is_dx (dir)) { bh =ext4_dx_find_entry (dentry, res_dir, &err);/*
@@ -881,7 +877,6 @@ static struct buffer_head * ext4_find_entry (struct dentry *dentry,return bh;dxtrace (printk ("ext4_find_entry: dx failed, falling back\n" )); } -#endif nblocks = dir->i_size >>EXT4_BLOCK_SIZE_BITS (sb); start =EXT4_I (dir)->i_dir_start_lookup;if (start >= nblocks)
@@ -957,7 +952,6 @@ cleanup_and_exit:return ret; } -#ifdef CONFIG_EXT4_INDEX static struct buffer_head *ext4_dx_find_entry (struct dentry *dentry,struct ext4_dir_entry_2 **res_dir,int *err) {
@@ -1025,7 +1019,6 @@ errout:dx_release (frames);return NULL ; } -#endif static struct dentry *ext4_lookup (struct inode * dir,struct dentry *dentry,struct nameidata *nd) {
@@ -1121,7 +1114,6 @@ static inline void ext4_set_de_type(struct super_block *sb, de->file_type = ext4_type_by_mode[(mode &S_IFMT )>>S_SHIFT ]; } -#ifdef CONFIG_EXT4_INDEX /* * Move count entries from end of map between two memory locations. * Returns pointer to last entry moved.
@@ -1266,8 +1258,6 @@ errout: *error = err;return NULL ; } -#endif -/* * Add a new entry into a directory (leaf) block. If de is non-NULL,
@@ -1364,7 +1354,6 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,return 0 ; } -#ifdef CONFIG_EXT4_INDEX /* * This converts a one block unindexed directory to a 3 block indexed * directory, and adds the dentry to the indexed directory.
@@ -1443,7 +1432,6 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,return add_dirent_to_buf (handle, dentry, inode, de, bh); } -#endif /* * ext4_add_entry()
@@ -1464,9 +1452,7 @@ static int ext4_add_entry (handle_t *handle, struct dentry *dentry,struct ext4_dir_entry_2 *de;struct super_block * sb;int retval; -#ifdef CONFIG_EXT4_INDEX int dx_fallback=0 ; -#endif unsigned blocksize;u32 block, blocks;
@@ -1474,7 +1460,6 @@ static int ext4_add_entry (handle_t *handle, struct dentry *dentry, blocksize = sb->s_blocksize;if (!dentry->d_name.len)return -EINVAL ; -#ifdef CONFIG_EXT4_INDEX if (is_dx (dir)) { retval =ext4_dx_add_entry (handle, dentry, inode);if (!retval || (retval !=ERR_BAD_DX_DIR ))
@@ -1483,7 +1468,6 @@ static int ext4_add_entry (handle_t *handle, struct dentry *dentry, dx_fallback++;ext4_mark_inode_dirty (handle, dir); } -#endif blocks = dir->i_size >> sb->s_blocksize_bits;for (block =0 , offset =0 ; block < blocks; block++) { bh =ext4_bread (handle, dir, block,0 , &retval);
@@ -1493,11 +1477,9 @@ static int ext4_add_entry (handle_t *handle, struct dentry *dentry,if (retval != -ENOSPC )return retval; -#ifdef CONFIG_EXT4_INDEX if (blocks ==1 && !dx_fallback &&EXT4_HAS_COMPAT_FEATURE (sb,EXT4_FEATURE_COMPAT_DIR_INDEX ))return make_indexed_dir (handle, dentry, inode, bh); -#endif brelse (bh); } bh =ext4_append (handle, dir, &block, &retval);
@@ -1509,7 +1491,6 @@ static int ext4_add_entry (handle_t *handle, struct dentry *dentry,return add_dirent_to_buf (handle, dentry, inode, de, bh); } -#ifdef CONFIG_EXT4_INDEX /* * Returns 0 for success, or a negative error value */
@@ -1644,7 +1625,6 @@ cleanup:dx_release (frames);return err; } -#endif /* * ext4_delete_entry deletes a directory entry by merging it with the
include/linux/ext4_fs.h +2 -12
@@ -36,10 +36,6 @@/*max window size: 1024(direct blocks) + 3([t,d]indirect blocks) */ #define EXT4_MAX_RESERVE_BLOCKS 1027#define EXT4_RESERVE_WINDOW_NOT_ALLOCATED 0 -/* -* Always enable hashed directories -*/ -#define CONFIG_EXT4_INDEX /* * Debug code
@@ -766,17 +762,11 @@ struct ext4_dir_entry_2 {* (c) Daniel Phillips, 2001 */ -#ifdef CONFIG_EXT4_INDEX -#define is_dx (dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \ - EXT4_FEATURE_COMPAT_DIR_INDEX) && \ +#define is_dx (dir) (EXT4_HAS_COMPAT_FEATURE(dir->i_sb, \ + EXT4_FEATURE_COMPAT_DIR_INDEX) && \ (EXT4_I(dir)->i_flags & EXT4_INDEX_FL))#define EXT4_DIR_LINK_MAX (dir) (!is_dx(dir) && (dir)->i_nlink >= EXT4_LINK_MAX)#define EXT4_DIR_LINK_EMPTY (dir) ((dir)->i_nlink == 2 || (dir)->i_nlink == 1) -#else -#define is_dx (dir) 0 -#define EXT4_DIR_LINK_MAX (dir) ((dir)->i_nlink >= EXT4_LINK_MAX) -#define EXT4_DIR_LINK_EMPTY (dir) ((dir)->i_nlink == 2) -#endif /* Legal values for the dx_root hash_version field: */
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 Ext4: Uninitialized Block Groups
From: Andreas Dilger <[email protected]>
In pass1 of e2fsck, every inode table in the fileystem is scanned and checked, regardless of whether it is in use. This is this the most time consuming part of the filesystem check. The unintialized block group feature can greatly reduce e2fsck time by eliminating checking of uninitialized inodes.
With this feature, there is a a high water mark of used inodes for each block group. Block and inode bitmaps can be uninitialized on disk via a flag in the group descriptor to avoid reading or scanning them at e2fsck time. A checksum of each group descriptor is used to ensure that corruption in the group descriptor's bit flags does not cause incorrect operation.
The feature is enabled through a mkfs option
mke2fs /dev/ -O uninit_groups
A patch adding support for uninitialized block groups to e2fsprogs tools has been posted to the linux-ext4 mailing list.
The patches have been stress tested with fsstress and fsx. In performance tests testing e2fsck time, we have seen that e2fsck time on ext3 grows linearly with the total number of inodes in the filesytem. In ext4 with the uninitialized block groups feature, the e2fsck time is constant, based solely on the number of used inodes rather than the total inode count. Since typical ext4 filesystems only use 1-10% of their inodes, this feature can greatly reduce e2fsck time for users. With performance improvement of 2-20 times, depending on how full the filesystem is.
The attached graph shows the major improvements in e2fsck times in filesystems with a large total inode count, but few inodes in use.
In each group descriptor if we have
EXT4_BG_INODE_UNINIT set in bg_flags:
Inode table is not initialized/used in this group. So we can skip the consistency check during fsck.EXT4_BG_BLOCK_UNINIT set in bg_flags:
No block in the group is used. So we can skip the block bitmap verification for this group.
We also add two new fields to group descriptor as a part of uninitialized group patch.
__le16 bg_itable_unused; /* Unused inodes count */
__le16 bg_checksum; /* crc16(sb_uuid+group+desc) */bg_itable_unused:
If we have EXT4_BG_INODE_UNINIT not set in bg_flags then bg_itable_unused will give the offset within the inode table till the inodes are used. This can be used by fsck to skip list of inodes that are marked unused.
bg_checksum:
Now that we depend on bg_flags and bg_itable_unused to determine the block and inode usage, we need to make sure group descriptor is not corrupt. We add checksum to group descriptor to detect corruption. If the descriptor is found to be corrupt, we mark all the blocks and inodes in the group used.
--- fs/Kconfig | 1 + fs/ext4/balloc.c | 92 ++++++++++++++++++++++++++++- fs/ext4/group.h | 29 +++++++++ fs/ext4/ialloc.c | 146 ++++++++++++++++++++++++++++++++++++++++++++--- fs/ext4/resize.c | 2 + fs/ext4/super.c | 47 +++++++++++++++ include/linux/ext4_fs.h | 16 ++++- 7 files changed, 317 insertions(+), 16 deletions(-) create mode 100644 fs/ext4/group.h
fs/Kconfig +1 -0
@@ -140,6 +140,7 @@ config EXT4DEV_FS tristate "Ext4dev/ext4 extended fs support development (EXPERIMENTAL)" depends on EXPERIMENTAL select JBD2 + select CRC16 help Ext4dev is a predecessor filesystem of the next generation extended fs ext4, based on ext3 filesystem code. It will be
fs/ext4/balloc.c +89 -3
131 lines not on this page · raw message
fs/ext4/group.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* linux/fs/ext4/group.h +* +* Copyright (C) 2007 Cluster File Systems, Inc +* +* Author: Andreas Dilger <[email protected]> +*/ + +#ifndef _LINUX_EXT4_GROUP_H +#define _LINUX_EXT4_GROUP_H +#if defined(CONFIG_CRC16 ) +#include <linux/crc16.h> +#endif + +extern __le16 ext4_group_desc_csum (struct ext4_sb_info *sbi,__u32 group, +struct ext4_group_desc *gdp); +extern int ext4_group_desc_csum_verify (struct ext4_sb_info *sbi,__u32 group, +struct ext4_group_desc *gdp); +struct buffer_head *read_block_bitmap (struct super_block *sb, +unsigned int block_group); +extern unsigned ext4_init_block_bitmap (struct super_block *sb, +struct buffer_head *bh,int group, +struct ext4_group_desc *desc); +#define ext4_free_blocks_after_init (sb, group, desc) \ + ext4_init_block_bitmap(sb, NULL, group, desc) +extern unsigned ext4_init_inode_bitmap (struct super_block *sb, +struct buffer_head *bh,int group, +struct ext4_group_desc *desc); +#endif /* _LINUX_EXT4_GROUP_H */
fs/ext4/ialloc.c +137 -9
201 lines not on this page · raw message
fs/ext4/resize.c +2 -0
@@ -16,6 +16,7 @@#include <linux/errno.h> #include <linux/slab.h> +#include "group.h" #define outside (b, first, last) ((b) < (first) || (b) >= (last))#define inside (b, first, last) ((b) >= (first) && (b) < (last))
@@ -842,6 +843,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)ext4_inode_table_set (sb, gdp, input->inode_table);/* LV FIXME */ gdp->bg_free_blocks_count =cpu_to_le16 (input->free_blocks_count); gdp->bg_free_inodes_count =cpu_to_le16 (EXT4_INODES_PER_GROUP (sb)); + gdp->bg_checksum =ext4_group_desc_csum (sbi, input->group, gdp);/* * Make the new blocks and inodes valid next. We do this before
fs/ext4/super.c +47 -0
71 lines not on this page · raw message
include/linux/ext4_fs.h +12 -4
@@ -105,19 +105,25 @@*/ struct ext4_group_desc { -__le32 bg_block_bitmap;/* Blocks bitmap block */ -__le32 bg_inode_bitmap;/* Inodes bitmap block */ +__le32 bg_block_bitmap;/* Blocks bitmap block */ +__le32 bg_inode_bitmap;/* Inodes bitmap block */ __le32 bg_inode_table;/* Inodes table block */ __le16 bg_free_blocks_count;/* Free blocks count */ __le16 bg_free_inodes_count;/* Free inodes count */ __le16 bg_used_dirs_count;/* Directories count */ -__u16 bg_flags; -__u32 bg_reserved[3 ]; +__le16 bg_flags;/* EXT4_BG_flags (INODE_UNINIT, etc) */ +__u32 bg_reserved[2 ];/* Likely block/inode bitmap checksum */ +__le16 bg_itable_unused;/* Unused inodes count */ +__le16 bg_checksum;/* crc16(sb_uuid+group+desc) */ __le32 bg_block_bitmap_hi;/* Blocks bitmap block MSB */ __le32 bg_inode_bitmap_hi;/* Inodes bitmap block MSB */ __le32 bg_inode_table_hi;/* Inodes table block MSB */ }; +#define EXT4_BG_INODE_UNINIT 0x0001/* Inode table/bitmap not in use */ +#define EXT4_BG_BLOCK_UNINIT 0x0002/* Block bitmap not in use */ +#define EXT4_BG_INODE_ZEROED 0x0004/* On-disk itable initialized to zero */ +#ifdef __KERNEL__#include <linux/ext4_fs_i.h> #include <linux/ext4_fs_sb.h>
@@ -665,6 +671,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 +#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
@@ -684,6 +691,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino) EXT4_FEATURE_INCOMPAT_64BIT)#define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ + EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \ EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \ EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \ EXT4_FEATURE_RO_COMPAT_BTREE_DIR)
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext4: Fix sparse warnings
From: Aneesh Kumar K.V <[email protected]>
--- fs/ext4/inode.c | 6 ++++-- include/linux/ext4_fs.h | 14 +++++++------- 2 files changed, 11 insertions(+), 9 deletions(-)
fs/ext4/inode.c +4 -2
@@ -3167,12 +3167,14 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode) iloc, handle);if (ret) {EXT4_I (inode)->i_state |=EXT4_STATE_NO_EXPAND ; -if (mnt_count != sbi->s_es->s_mnt_count) { +if (mnt_count != +le16_to_cpu (sbi->s_es->s_mnt_count)) {ext4_warning (inode->i_sb, __FUNCTION__,"Unable to expand inode %lu. Delete" " some EAs or run e2fsck." , inode->i_ino); - mnt_count = sbi->s_es->s_mnt_count; + mnt_count = +le16_to_cpu (sbi->s_es->s_mnt_count); } } }
include/linux/ext4_fs.h +7 -7
@@ -574,13 +574,13 @@ struct ext4_super_block {/*150*/ __le32 s_blocks_count_hi;/* Blocks count */ __le32 s_r_blocks_count_hi;/* Reserved blocks count */ __le32 s_free_blocks_count_hi;/* Free blocks count */ -__u16 s_min_extra_isize;/* All inodes have at least # bytes */ -__u16 s_want_extra_isize;/* New inodes should reserve # bytes */ -__u32 s_flags;/* Miscellaneous flags */ -__u16 s_raid_stride;/* RAID stride */ -__u16 s_mmp_interval;/* # seconds to wait in MMP checking */ -__u64 s_mmp_block;/* Block for multi-mount protection */ -__u32 s_raid_stripe_width;/* blocks on all data disks (N*stride)*/ +__le16 s_min_extra_isize;/* All inodes have at least # bytes */ +__le16 s_want_extra_isize;/* New inodes should reserve # bytes */ +__le32 s_flags;/* Miscellaneous flags */ +__le16 s_raid_stride;/* RAID stride */ +__le16 s_mmp_interval;/* # seconds to wait in MMP checking */ +__le64 s_mmp_block;/* Block for multi-mount protection */ +__le32 s_raid_stripe_width;/* blocks on all data disks (N*stride)*/ __u32 s_reserved[163 ];/* Padding to the end of the block */ };
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 This feature relaxes check restrictions on where each block groups meta
From: Jose R. Santos <[email protected]>
data is located within the storage media. This allows for the allocation of bitmaps or inode tables outside the block group boundaries in cases where bad blocks forces us to look for new blocks which the owning block group can not satisfy. This will also allow for new meta-data allocation schemes to improve performance and scalability.
--- fs/ext4/super.c | 9 +++++++-- include/linux/ext4_fs.h | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-)
fs/ext4/super.c +7 -2
@@ -1287,13 +1287,17 @@ static int ext4_check_descriptors (struct super_block * sb)ext4_fsblk_t inode_table;struct ext4_group_desc * gdp =NULL ;int desc_block =0 ; +int flexbg_flag =0 ;int i; +if (EXT4_HAS_INCOMPAT_FEATURE (sb,EXT4_FEATURE_INCOMPAT_FLEX_BG )) + flexbg_flag =1 ; +ext4_debug ("Checking group descriptors" );for (i =0 ; i < sbi->s_groups_count; i++) { -if (i == sbi->s_groups_count -1 ) +if (i == sbi->s_groups_count -1 || flexbg_flag) last_block =ext4_blocks_count (sbi->s_es) -1 ;else last_block = first_block +
@@ -1338,7 +1342,8 @@ static int ext4_check_descriptors (struct super_block * sb) le16_to_cpu(gdp->bg_checksum));return 0 ; } - first_block +=EXT4_BLOCKS_PER_GROUP (sb); +if (!flexbg_flag) + first_block +=EXT4_BLOCKS_PER_GROUP (sb); gdp = (struct ext4_group_desc *) ((__u8 *)gdp +EXT4_DESC_SIZE (sb)); }
include/linux/ext4_fs.h +3 -1
@@ -682,13 +682,15 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)#define EXT4_FEATURE_INCOMPAT_META_BG 0x0010#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040/* extents support */ #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 +#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200#define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR#define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \ EXT4_FEATURE_INCOMPAT_RECOVER| \ EXT4_FEATURE_INCOMPAT_META_BG| \ EXT4_FEATURE_INCOMPAT_EXTENTS| \ - EXT4_FEATURE_INCOMPAT_64BIT) + EXT4_FEATURE_INCOMPAT_64BIT| \ + EXT4_FEATURE_INCOMPAT_FLEX_BG)#define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 Support large blocksize up to PAGESIZE (max 64KB) for ext4
From: Takashi Sato <[email protected]>
This patch set supports large block size(>4k, <=64k) in ext4, just enlarging the block size limit. But it is NOT possible to have 64kB blocksize on ext4 without some changes to the directory handling code. The reason is that an empty 64kB directory block would have a rec_len == (__u16)2^16 == 0, and this would cause an error to be hit in the filesystem. The proposed solution is treat 64k rec_len with a an impossible value like rec_len = 0xffff to handle this.
The Patch-set consists of the following 2 patches.
[1/2] ext4: enlarge blocksize
- Allow blocksize up to pagesize
[2/2] ext4: fix rec_len overflow
- prevent rec_len from overflow with 64KB blocksize
Now on 64k page ppc64 box runs with this patch set we could create a 64k block size ext4dev, and able to handle empty directory block.
--- fs/ext4/super.c | 5 +++++ include/linux/ext4_fs.h | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-)
fs/ext4/super.c +5 -0
@@ -1548,6 +1548,11 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) goto out_fail; } +if (!sb_set_blocksize (sb, blocksize)) { +printk (KERN_ERR "EXT4-fs: bad blocksize %d.\n" , blocksize); + goto out_fail; + } +/* * The ext4 superblock will not be buffer aligned for other than 1kB * block sizes. We need to calculate the offset from buffer start.
include/linux/ext4_fs.h +2 -2
@@ -73,8 +73,8 @@* Macro-instructions used to manage several block sizes */ #define EXT4_MIN_BLOCK_SIZE 1024 -#define EXT4_MAX_BLOCK_SIZE 4096 -#define EXT4_MIN_BLOCK_LOG_SIZE 10 +#define EXT4_MAX_BLOCK_SIZE 65536 +#define EXT4_MIN_BLOCK_LOG_SIZE 10#ifdef __KERNEL__# define EXT4_BLOCK_SIZE (s) ((s)->s_blocksize)#else
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext4: Avoid rec_len overflow with 64KB block size
From: Jan Kara <[email protected]>
With 64KB blocksize, a directory entry can have size 64KB which does not fit into 16 bits we have for entry lenght. So we store 0xffff instead and convert value when read from / written to disk. The patch also converts some places to use ext4_next_entry() when we are changing them anyway.
--- fs/ext4/dir.c | 12 ++++---- fs/ext4/namei.c | 76 ++++++++++++++++++++++------------------------ include/linux/ext4_fs.h | 20 ++++++++++++ 3 files changed, 62 insertions(+), 46 deletions(-)
fs/ext4/dir.c +6 -6
@@ -67,7 +67,7 @@ int ext4_check_dir_entry (const char * function, struct inode * dir, unsigned long offset) {const char * error_msg =NULL ; -const int rlen =le16_to_cpu (de->rec_len); +const int rlen =ext4_rec_len_from_disk (de->rec_len);if (rlen <EXT4_DIR_REC_LEN (1 )) error_msg ="rec_len is smaller than minimal" ;
@@ -172,10 +172,10 @@ revalidate:* least that it is non-zero. A * failure will be detected in the * dirent test below. */ -if (le16_to_cpu (de->rec_len) < -EXT4_DIR_REC_LEN (1 )) +if (ext4_rec_len_from_disk (de->rec_len) + <EXT4_DIR_REC_LEN (1 ))break ; - i +=le16_to_cpu (de->rec_len); + i +=ext4_rec_len_from_disk (de->rec_len); } offset = i; filp->f_pos = (filp->f_pos & ~(sb->s_blocksize -1 ))
@@ -197,7 +197,7 @@ revalidate: ret = stored; goto out; } - offset +=le16_to_cpu (de->rec_len); + offset +=ext4_rec_len_from_disk (de->rec_len);if (le32_to_cpu (de->inode)) {/* We might block in the next section * if the data destination is
@@ -219,7 +219,7 @@ revalidate: goto revalidate; stored ++; } - filp->f_pos +=le16_to_cpu (de->rec_len); + filp->f_pos +=ext4_rec_len_from_disk (de->rec_len); } offset =0 ;brelse (bh);
fs/ext4/namei.c +36 -40
207 lines not on this page · raw message
include/linux/ext4_fs.h +20 -0
@@ -767,6 +767,26 @@ struct ext4_dir_entry_2 {#define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)#define EXT4_DIR_REC_LEN (name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \ ~EXT4_DIR_ROUND) +#define EXT4_MAX_REC_LEN ((1<<16)-1) + +static inline unsigned ext4_rec_len_from_disk (__le16 dlen) +{ +unsigned len =le16_to_cpu (dlen); + +if (len ==EXT4_MAX_REC_LEN ) +return 1 <<16 ; +return len; +} + +static inline __le16 ext4_rec_len_to_disk (unsigned len) +{ +if (len == (1 <<16 )) +return cpu_to_le16 (EXT4_MAX_REC_LEN ); +else if (len > (1 <<16 )) +BUG (); +return cpu_to_le16 (len); +} +/* * Hash Tree Directory indexing * (c) Daniel Phillips, 2001
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 Support large blocksize up to PAGESIZE (max 64KB) for ext2
From: Takashi Sato <[email protected]>
This patch set supports large block size(>4k, <=64k) in ext2, just enlarging the block size limit. But it is NOT possible to have 64kB blocksize on ext2 without some changes to the directory handling code. The reason is that an empty 64kB directory block would have a rec_len == (__u16)2^16 == 0, and this would cause an error to be hit in the filesystem. The proposed solution is treat 64k rec_len with a an impossible value like rec_len = 0xffff to handle this.
The Patch-set consists of the following 2 patches.
[1/2] ext2: enlarge blocksize
- Allow blocksize up to pagesize
[2/2] ext2: fix rec_len overflow
- prevent rec_len from overflow with 64KB blocksize
Now on 64k page ppc64 box runs with this patch set we could create a 64k block size ext2, and able to handle empty directory block.
--- fs/ext2/super.c | 3 ++- include/linux/ext2_fs.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
fs/ext2/super.c +2 -1
@@ -775,7 +775,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)brelse (bh);if (!sb_set_blocksize (sb, blocksize)) { -printk (KERN_ERR "EXT2-fs: blocksize too small for device.\n" ); +printk (KERN_ERR "EXT2-fs: bad blocksize %d.\n" , + blocksize); goto failed_sbi; }
include/linux/ext2_fs.h +2 -2
@@ -86,8 +86,8 @@ static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb)* Macro-instructions used to manage several block sizes */ #define EXT2_MIN_BLOCK_SIZE 1024 -#define EXT2_MAX_BLOCK_SIZE 4096 -#define EXT2_MIN_BLOCK_LOG_SIZE 10 +#define EXT2_MAX_BLOCK_SIZE 65536 +#define EXT2_MIN_BLOCK_LOG_SIZE 10#ifdef __KERNEL__# define EXT2_BLOCK_SIZE (s) ((s)->s_blocksize)#else
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 Support large blocksize up to PAGESIZE (max 64KB) for ext3
From: Takashi Sato <[email protected]>
This patch set supports large block size(>4k, <=64k) in ext3 just enlarging the block size limit. But it is NOT possible to have 64kB blocksize on ext3 without some changes to the directory handling code. The reason is that an empty 64kB directory block would have a rec_len == (__u16)2^16 == 0, and this would cause an error to be hit in the filesystem. The proposed solution is treat 64k rec_len with a an impossible value like rec_len = 0xffff to handle this.
The Patch-set consists of the following 2 patches.
[1/2] ext3: enlarge blocksize
- Allow blocksize up to pagesize
[2/2] ext3: fix rec_len overflow
- prevent rec_len from overflow with 64KB blocksize
Now on 64k page ppc64 box runs with this patch set we could create a 64k block size ext3, and able to handle empty directory block.
--- fs/ext3/super.c | 6 +++++- include/linux/ext3_fs.h | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-)
fs/ext3/super.c +5 -1
@@ -1549,7 +1549,11 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) }brelse (bh); -sb_set_blocksize (sb, blocksize); +if (!sb_set_blocksize (sb, blocksize)) { +printk (KERN_ERR "EXT3-fs: bad blocksize %d.\n" , + blocksize); + goto out_fail; + } logic_sb_block = (sb_block *EXT3_MIN_BLOCK_SIZE ) / blocksize; offset = (sb_block *EXT3_MIN_BLOCK_SIZE ) % blocksize; bh =sb_bread (sb, logic_sb_block);
include/linux/ext3_fs.h +2 -2
@@ -76,8 +76,8 @@* Macro-instructions used to manage several block sizes */ #define EXT3_MIN_BLOCK_SIZE 1024 -#define EXT3_MAX_BLOCK_SIZE 4096 -#define EXT3_MIN_BLOCK_LOG_SIZE 10 +#define EXT3_MAX_BLOCK_SIZE 65536 +#define EXT3_MIN_BLOCK_LOG_SIZE 10#ifdef __KERNEL__# define EXT3_BLOCK_SIZE (s) ((s)->s_blocksize)#else
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext2: Avoid rec_len overflow with 64KB block size
From: Jan Kara <[email protected]>
With 64KB blocksize, a directory entry can have size 64KB which does not fit into 16 bits we have for entry lenght. So we store 0xffff instead and convert value when read from / written to disk.
--- fs/ext2/dir.c | 43 +++++++++++++++++++++++++++++++------------ include/linux/ext2_fs.h | 1 + 2 files changed, 32 insertions(+), 12 deletions(-)
fs/ext2/dir.c +31 -12
@@ -26,6 +26,24 @@typedef struct ext2_dir_entry_2 ext2_dirent ; +static inline unsigned ext2_rec_len_from_disk (__le16 dlen) +{ +unsigned len =le16_to_cpu (dlen); + +if (len ==EXT2_MAX_REC_LEN ) +return 1 <<16 ; +return len; +} + +static inline __le16 ext2_rec_len_to_disk (unsigned len) +{ +if (len == (1 <<16 )) +return cpu_to_le16 (EXT2_MAX_REC_LEN ); +else if (len > (1 <<16 )) +BUG (); +return cpu_to_le16 (len); +} +/* * ext2 uses block-sized chunks. Arguably, sector-sized ones would be * more robust, but we have what we have
@@ -95,7 +113,7 @@ static void ext2_check_page(struct page *page) }for (offs =0 ; offs <= limit -EXT2_DIR_REC_LEN (1 ); offs += rec_len) { p = (ext2_dirent *)(kaddr + offs); - rec_len =le16_to_cpu (p->rec_len); + rec_len =ext2_rec_len_from_disk (p->rec_len);if (rec_len <EXT2_DIR_REC_LEN (1 )) goto Eshort;
@@ -193,7 +211,8 @@ static inline int ext2_match (int len, const char * const name,*/ static inline ext2_dirent *ext2_next_entry (ext2_dirent *p) { -return (ext2_dirent *)((char *)p +le16_to_cpu (p->rec_len)); +return (ext2_dirent *)((char *)p + +ext2_rec_len_from_disk (p->rec_len)); } static inline unsigned
@@ -305,7 +324,7 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir)return 0 ; } } - filp->f_pos +=le16_to_cpu (de->rec_len); + filp->f_pos +=ext2_rec_len_from_disk (de->rec_len); }ext2_put_page (page); }
@@ -413,7 +432,7 @@ void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de, struct page *page, struct inode *inode) { unsigned from = (char *) de - (char *) page_address(page); -unsigned to = from +le16_to_cpu (de->rec_len); +unsigned to = from +ext2_rec_len_from_disk (de->rec_len);int err;lock_page (page);
@@ -469,7 +488,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)/* We hit i_size */ name_len =0 ; rec_len = chunk_size; - de->rec_len =cpu_to_le16 (chunk_size); + de->rec_len =ext2_rec_len_to_disk (chunk_size); de->inode =0 ; goto got_it; }
@@ -483,7 +502,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)if (ext2_match (namelen, name, de)) goto out_unlock; name_len =EXT2_DIR_REC_LEN (de->name_len); - rec_len =le16_to_cpu (de->rec_len); + rec_len =ext2_rec_len_from_disk (de->rec_len);if (!de->inode && rec_len >= reclen) goto got_it;if (rec_len >= name_len + reclen)
@@ -504,8 +523,8 @@ got_it: goto out_unlock;if (de->inode) {ext2_dirent *de1 = (ext2_dirent *) ((char *) de + name_len); - de1->rec_len =cpu_to_le16 (rec_len - name_len); - de->rec_len =cpu_to_le16 (name_len); + de1->rec_len =ext2_rec_len_to_disk (rec_len - name_len); + de->rec_len =ext2_rec_len_to_disk (name_len); de = de1; } de->name_len = namelen;
@@ -536,7 +555,7 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page )struct inode *inode = mapping->host;char *kaddr =page_address (page);unsigned from = ((char *)dir - kaddr) & ~(ext2_chunk_size (inode)-1 ); -unsigned to = ((char *)dir - kaddr) +le16_to_cpu (dir->rec_len); +unsigned to = ((char *)dir - kaddr) +ext2_rec_len_from_disk (dir->rec_len);ext2_dirent * pde =NULL ;ext2_dirent * de = (ext2_dirent *) (kaddr + from);int err;
@@ -557,7 +576,7 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ) err = mapping->a_ops->prepare_write (NULL , page, from, to);BUG_ON (err);if (pde) - pde->rec_len =cpu_to_le16 (to-from); + pde->rec_len =ext2_rec_len_to_disk (to-from); dir->inode =0 ; err =ext2_commit_chunk (page, from, to); inode->i_ctime = inode->i_mtime =CURRENT_TIME_SEC ;
@@ -591,14 +610,14 @@ int ext2_make_empty(struct inode *inode, struct inode *parent)memset (kaddr,0 , chunk_size); de = (struct ext2_dir_entry_2 *)kaddr; de->name_len =1 ; - de->rec_len =cpu_to_le16 (EXT2_DIR_REC_LEN (1 )); + de->rec_len =ext2_rec_len_to_disk (EXT2_DIR_REC_LEN (1 ));memcpy (de->name,".\0\0" ,4 ); de->inode =cpu_to_le32 (inode->i_ino);ext2_set_de_type (de, inode); de = (struct ext2_dir_entry_2 *)(kaddr +EXT2_DIR_REC_LEN (1 )); de->name_len =2 ; - de->rec_len =cpu_to_le16 (chunk_size -EXT2_DIR_REC_LEN (1 )); + de->rec_len =ext2_rec_len_to_disk (chunk_size -EXT2_DIR_REC_LEN (1 )); de->inode =cpu_to_le32 (parent->i_ino);memcpy (de->name,"..\0" ,4 );ext2_set_de_type (de, inode);
include/linux/ext2_fs.h +1 -0
@@ -557,5 +557,6 @@ enum {#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)#define EXT2_DIR_REC_LEN (name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \ ~EXT2_DIR_ROUND) +#define EXT2_MAX_REC_LEN ((1<<16)-1)#endif /* _LINUX_EXT2_FS_H */
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext3: Avoid rec_len overflow with 64KB block size
From: Jan Kara <[email protected]>
With 64KB blocksize, a directory entry can have size 64KB which does not fit into 16 bits we have for entry lenght. So we store 0xffff instead and convert value when read from / written to disk. The patch also converts some places to use ext3_next_entry() when we are changing them anyway.
--- fs/ext3/dir.c | 10 +++--- fs/ext3/namei.c | 90 ++++++++++++++++++++++------------------------ include/linux/ext3_fs.h | 20 ++++++++++ 3 files changed, 68 insertions(+), 52 deletions(-)
fs/ext3/dir.c +5 -5
@@ -69,7 +69,7 @@ int ext3_check_dir_entry (const char * function, struct inode * dir, unsigned long offset) {const char * error_msg =NULL ; -const int rlen =le16_to_cpu (de->rec_len); +const int rlen =ext3_rec_len_from_disk (de->rec_len);if (rlen <EXT3_DIR_REC_LEN (1 )) error_msg ="rec_len is smaller than minimal" ;
@@ -177,10 +177,10 @@ revalidate:* least that it is non-zero. A * failure will be detected in the * dirent test below. */ -if (le16_to_cpu (de->rec_len) < +if (ext3_rec_len_from_disk (de->rec_len) <EXT3_DIR_REC_LEN (1 ))break ; - i +=le16_to_cpu (de->rec_len); + i +=ext3_rec_len_from_disk (de->rec_len); } offset = i; filp->f_pos = (filp->f_pos & ~(sb->s_blocksize -1 ))
@@ -201,7 +201,7 @@ revalidate: ret = stored; goto out; } - offset +=le16_to_cpu (de->rec_len); + offset +=ext3_rec_len_from_disk (de->rec_len);if (le32_to_cpu (de->inode)) {/* We might block in the next section * if the data destination is
@@ -223,7 +223,7 @@ revalidate: goto revalidate; stored ++; } - filp->f_pos +=le16_to_cpu (de->rec_len); + filp->f_pos +=ext3_rec_len_from_disk (de->rec_len); } offset =0 ;brelse (bh);
fs/ext3/namei.c +43 -47
227 lines not on this page · raw message
include/linux/ext3_fs.h +20 -0
@@ -660,6 +660,26 @@ struct ext3_dir_entry_2 {#define EXT3_DIR_ROUND (EXT3_DIR_PAD - 1)#define EXT3_DIR_REC_LEN (name_len) (((name_len) + 8 + EXT3_DIR_ROUND) & \ ~EXT3_DIR_ROUND) +#define EXT3_MAX_REC_LEN ((1<<16)-1) + +static inline unsigned ext3_rec_len_from_disk (__le16 dlen) +{ +unsigned len =le16_to_cpu (dlen); + +if (len ==EXT3_MAX_REC_LEN ) +return 1 <<16 ; +return len; +} + +static inline __le16 ext3_rec_len_to_disk (unsigned len) +{ +if (len == (1 <<16 )) +return cpu_to_le16 (EXT3_MAX_REC_LEN ); +else if (len > (1 <<16 )) +BUG (); +return cpu_to_le16 (len); +} +/* * Hash Tree Directory indexing * (c) Daniel Phillips, 2001
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext4: Convert bg_block_bitmap to bg_block_bitmap_lo
From: Aneesh Kumar K.V <[email protected]>
Convert bg_block_bitmap to bg_block_bitmap_lo
This helps in catching some BUGS due to direct
partial access of these split fields.
--- fs/ext4/super.c | 6 +++--- include/linux/ext4_fs.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
fs/ext4/super.c +3 -3
@@ -70,9 +70,9 @@ static void ext4_write_super_lockfs(struct super_block *sb);ext4_fsblk_t ext4_block_bitmap (struct super_block *sb,struct ext4_group_desc *bg) { -return le32_to_cpu (bg->bg_block_bitmap) | +return le32_to_cpu (bg->bg_block_bitmap_lo) | (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ? - (ext4_fsblk_t )le32_to_cpu (bg->bg_block_bitmap_hi) <<32 :0 ); + (ext4_fsblk_t )le32_to_cpu (bg->bg_block_bitmap_hi) <<32 :0 ); } ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
@@ -94,7 +94,7 @@ ext4_fsblk_t ext4_inode_table(struct super_block *sb,void ext4_block_bitmap_set (struct super_block *sb,struct ext4_group_desc *bg,ext4_fsblk_t blk) { - bg->bg_block_bitmap =cpu_to_le32 ((u32 )blk); + bg->bg_block_bitmap_lo =cpu_to_le32 ((u32 )blk);if (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ) bg->bg_block_bitmap_hi =cpu_to_le32 (blk >>32 ); }
include/linux/ext4_fs.h +1 -1
@@ -105,7 +105,7 @@*/ struct ext4_group_desc { -__le32 bg_block_bitmap;/* Blocks bitmap block */ +__le32 bg_block_bitmap_lo;/* Blocks bitmap block */ __le32 bg_inode_bitmap;/* Inodes bitmap block */ __le32 bg_inode_table;/* Inodes table block */ __le16 bg_free_blocks_count;/* Free blocks count */
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext4: Convert bg_inode_bitmap and bg_inode_table
From: Aneesh Kumar K.V <[email protected]>
Convert bg_inode_bitmap and bg_inode_table to bg_inode_bitmap_lo and bg_inode_table_lo. This helps in finding BUGs due to direct partial access of these split 64 bit values
Also fix one direct partial access
--- fs/ext4/balloc.c | 2 +- fs/ext4/super.c | 12 ++++++------ include/linux/ext4_fs.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
fs/ext4/balloc.c +1 -1
@@ -103,7 +103,7 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,/* Set bits for block and inode bitmaps, and inode table */ ext4_set_bit (ext4_block_bitmap (sb, gdp) - start, bh->b_data);ext4_set_bit (ext4_inode_bitmap (sb, gdp) - start, bh->b_data); -for (bit =le32_to_cpu (gdp->bg_inode_table) - start, +for (bit = (ext4_inode_table (sb, gdp) - start), bit_max = bit + sbi->s_itb_per_group; bit < bit_max; bit++)ext4_set_bit (bit, bh->b_data); }
fs/ext4/super.c +6 -6
@@ -78,17 +78,17 @@ ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,ext4_fsblk_t ext4_inode_bitmap (struct super_block *sb,struct ext4_group_desc *bg) { -return le32_to_cpu (bg->bg_inode_bitmap) | +return le32_to_cpu (bg->bg_inode_bitmap_lo) | (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ? - (ext4_fsblk_t )le32_to_cpu (bg->bg_inode_bitmap_hi) <<32 :0 ); + (ext4_fsblk_t )le32_to_cpu (bg->bg_inode_bitmap_hi) <<32 :0 ); }ext4_fsblk_t ext4_inode_table (struct super_block *sb,struct ext4_group_desc *bg) { -return le32_to_cpu (bg->bg_inode_table) | +return le32_to_cpu (bg->bg_inode_table_lo) | (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ? - (ext4_fsblk_t )le32_to_cpu (bg->bg_inode_table_hi) <<32 :0 ); + (ext4_fsblk_t )le32_to_cpu (bg->bg_inode_table_hi) <<32 :0 ); } void ext4_block_bitmap_set(struct super_block *sb,
@@ -102,7 +102,7 @@ void ext4_block_bitmap_set(struct super_block *sb,void ext4_inode_bitmap_set (struct super_block *sb,struct ext4_group_desc *bg,ext4_fsblk_t blk) { - bg->bg_inode_bitmap =cpu_to_le32 ((u32 )blk); + bg->bg_inode_bitmap_lo =cpu_to_le32 ((u32 )blk);if (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ) bg->bg_inode_bitmap_hi =cpu_to_le32 (blk >>32 ); }
@@ -110,7 +110,7 @@ void ext4_inode_bitmap_set(struct super_block *sb,void ext4_inode_table_set (struct super_block *sb,struct ext4_group_desc *bg,ext4_fsblk_t blk) { - bg->bg_inode_table =cpu_to_le32 ((u32 )blk); + bg->bg_inode_table_lo =cpu_to_le32 ((u32 )blk);if (EXT4_DESC_SIZE (sb) >=EXT4_MIN_DESC_SIZE_64BIT ) bg->bg_inode_table_hi =cpu_to_le32 (blk >>32 ); }
include/linux/ext4_fs.h +2 -2
@@ -106,8 +106,8 @@struct ext4_group_desc {__le32 bg_block_bitmap_lo;/* Blocks bitmap block */ -__le32 bg_inode_bitmap;/* Inodes bitmap block */ -__le32 bg_inode_table;/* Inodes table block */ +__le32 bg_inode_bitmap_lo;/* Inodes bitmap block */ +__le32 bg_inode_table_lo;/* Inodes table block */ __le16 bg_free_blocks_count;/* Free blocks count */ __le16 bg_free_inodes_count;/* Free inodes count */ __le16 bg_used_dirs_count;/* Directories count */
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext4: Convert s_blocks_count to s_blocks_count_lo
From: Aneesh Kumar K.V <[email protected]>
Convert s_blocks_count to s_blocks_count_lo
This helps in finding BUGs due to direct partial access of these split 64 bit values
Also fix direct partial access in ext4 code
--- fs/ext4/super.c | 4 ++-- include/linux/ext4_fs.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
fs/ext4/super.c +2 -2
@@ -2593,7 +2593,7 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)if (test_opt (sb,MINIX_DF )) { sbi->s_overhead_last =0 ; - }else if (sbi->s_blocks_last !=le32_to_cpu (es->s_blocks_count)) { + }else if (sbi->s_blocks_last !=ext4_blocks_count (es)) {unsigned long ngroups = sbi->s_groups_count, i;ext4_fsblk_t overhead =0 ;smp_rmb ();
@@ -2628,7 +2628,7 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf) overhead += ngroups * (2 + sbi->s_itb_per_group); sbi->s_overhead_last = overhead;smp_wmb (); - sbi->s_blocks_last =le32_to_cpu (es->s_blocks_count); + sbi->s_blocks_last =ext4_blocks_count (es); } buf->f_type =EXT4_SUPER_MAGIC ;
include/linux/ext4_fs.h +3 -3
@@ -501,7 +501,7 @@ do { \*/ struct ext4_super_block {/*00*/ __le32 s_inodes_count;/* Inodes count */ -__le32 s_blocks_count;/* Blocks count */ +__le32 s_blocks_count_lo;/* Blocks count */ __le32 s_r_blocks_count;/* Reserved blocks count */ __le32 s_free_blocks_count;/* Free blocks count */ /*10*/ __le32 s_free_inodes_count;/* Free inodes count */
@@ -1001,7 +1001,7 @@ extern void ext4_inode_table_set(struct super_block *sb,static inline ext4_fsblk_t ext4_blocks_count (struct ext4_super_block *es) {return ((ext4_fsblk_t )le32_to_cpu (es->s_blocks_count_hi) <<32 ) | -le32_to_cpu (es->s_blocks_count); +le32_to_cpu (es->s_blocks_count_lo); }static inline ext4_fsblk_t ext4_r_blocks_count (struct ext4_super_block *es)
@@ -1019,7 +1019,7 @@ static inline ext4_fsblk_t ext4_free_blocks_count(struct ext4_super_block *es)static inline void ext4_blocks_count_set (struct ext4_super_block *es,ext4_fsblk_t blk) { - es->s_blocks_count =cpu_to_le32 ((u32 )blk); + es->s_blocks_count_lo =cpu_to_le32 ((u32 )blk); es->s_blocks_count_hi =cpu_to_le32 (blk >>32 ); }
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext4: Convert s_r_blocks_count and s_free_blocks_count
From: Aneesh Kumar K.V <[email protected]>
Convert s_r_blocks_count and s_free_blocks_count to s_r_blocks_count_lo and s_free_blocks_count_lo
This helps in finding BUGs due to direct partial access of these split 64 bit values
Also fix direct partial access in ext4 code
--- fs/ext4/super.c | 2 +- include/linux/ext4_fs.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
fs/ext4/super.c +1 -1
@@ -2635,7 +2635,7 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf) buf->f_bsize = sb->s_blocksize; buf->f_blocks =ext4_blocks_count (es) - sbi->s_overhead_last; buf->f_bfree =percpu_counter_sum (&sbi->s_freeblocks_counter); - es->s_free_blocks_count =cpu_to_le32 (buf->f_bfree); +ext4_free_blocks_count_set (es, buf->f_bfree); buf->f_bavail = buf->f_bfree -ext4_r_blocks_count (es);if (buf->f_bfree <ext4_r_blocks_count (es)) buf->f_bavail =0 ;
include/linux/ext4_fs.h +6 -6
@@ -502,8 +502,8 @@ do { \struct ext4_super_block {/*00*/ __le32 s_inodes_count;/* Inodes count */ __le32 s_blocks_count_lo;/* Blocks count */ -__le32 s_r_blocks_count;/* Reserved blocks count */ -__le32 s_free_blocks_count;/* Free blocks count */ +__le32 s_r_blocks_count_lo;/* Reserved blocks count */ +__le32 s_free_blocks_count_lo;/* Free blocks count */ /*10*/ __le32 s_free_inodes_count;/* Free inodes count */ __le32 s_first_data_block;/* First Data Block */ __le32 s_log_block_size;/* Block size */
@@ -1007,13 +1007,13 @@ static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es)static inline ext4_fsblk_t ext4_r_blocks_count (struct ext4_super_block *es) {return ((ext4_fsblk_t )le32_to_cpu (es->s_r_blocks_count_hi) <<32 ) | -le32_to_cpu (es->s_r_blocks_count); +le32_to_cpu (es->s_r_blocks_count_lo); }static inline ext4_fsblk_t ext4_free_blocks_count (struct ext4_super_block *es) {return ((ext4_fsblk_t )le32_to_cpu (es->s_free_blocks_count_hi) <<32 ) | -le32_to_cpu (es->s_free_blocks_count); +le32_to_cpu (es->s_free_blocks_count_lo); } static inline void ext4_blocks_count_set(struct ext4_super_block *es,
@@ -1026,14 +1026,14 @@ static inline void ext4_blocks_count_set(struct ext4_super_block *es,static inline void ext4_free_blocks_count_set (struct ext4_super_block *es,ext4_fsblk_t blk) { - es->s_free_blocks_count =cpu_to_le32 ((u32 )blk); + es->s_free_blocks_count_lo =cpu_to_le32 ((u32 )blk); es->s_free_blocks_count_hi =cpu_to_le32 (blk >>32 ); }static inline void ext4_r_blocks_count_set (struct ext4_super_block *es,ext4_fsblk_t blk) { - es->s_r_blocks_count =cpu_to_le32 ((u32 )blk); + es->s_r_blocks_count_lo =cpu_to_le32 ((u32 )blk); es->s_r_blocks_count_hi =cpu_to_le32 (blk >>32 ); }
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext4: Convert ext4_extent.ee_start to ext4_extent.ee_start_lo
From: Aneesh Kumar K.V <[email protected]>
Convert ext4_extent.ee_start to ext4_extent.ee_start_lo This helps in finding BUGs due to direct partial access of these split 48 bit values
Also fix direct partial access in ext4 code
--- fs/ext4/extents.c | 8 +++----- include/linux/ext4_fs_extents.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-)
fs/ext4/extents.c +3 -5
@@ -52,7 +52,7 @@ static ext4_fsblk_t ext_pblock(struct ext4_extent *ex) {ext4_fsblk_t block; - block =le32_to_cpu (ex->ee_start); + block =le32_to_cpu (ex->ee_start_lo); block |= ((ext4_fsblk_t )le16_to_cpu (ex->ee_start_hi) <<31 ) <<1 ;return block; }
@@ -77,7 +77,7 @@ static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)*/ static void ext4_ext_store_pblock (struct ext4_extent *ex,ext4_fsblk_t pb) { - ex->ee_start =cpu_to_le32 ((unsigned long ) (pb &0xffffffff )); + ex->ee_start_lo =cpu_to_le32 ((unsigned long ) (pb &0xffffffff )); ex->ee_start_hi =cpu_to_le16 ((unsigned long ) ((pb >>31 ) >>1 ) &0xffff ); }
@@ -1409,8 +1409,7 @@ has_space: eh->eh_entries =cpu_to_le16 (le16_to_cpu (eh->eh_entries)+1 ); nearex = path[depth].p_ext; nearex->ee_block = newext->ee_block; - nearex->ee_start = newext->ee_start; - nearex->ee_start_hi = newext->ee_start_hi; +ext4_ext_store_pblock (nearex,ext_pblock (newext)); nearex->ee_len = newext->ee_len; merge:
@@ -2177,7 +2176,6 @@ int ext4_ext_convert_to_initialized(handle_t *handle, struct inode *inode, }/* ex2: iblock to iblock + maxblocks-1 : initialised */ ex2->ee_block =cpu_to_le32 (iblock); - ex2->ee_start =cpu_to_le32 (newblock);ext4_ext_store_pblock (ex2, newblock); ex2->ee_len =cpu_to_le16 (allocated);if (ex2 != ex)
include/linux/ext4_fs_extents.h +1 -1
@@ -74,7 +74,7 @@ struct ext4_extent {__le32 ee_block;/* first logical block extent covers */ __le16 ee_len;/* number of blocks covered by extent */ __le16 ee_start_hi;/* high 16 bits of physical block */ -__le32 ee_start;/* low 32 bits of physical block */ +__le32 ee_start_lo;/* low 32 bits of physical block */ };/*
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext4: Convert ext4_extent_idx.ei_leaf to ext4_extent_idx.ei_leaf_lo
From: Aneesh Kumar K.V <[email protected]>
Convert ext4_extent_idx.ei_leaf ext4_extent_idx.ei_leaf_lo This helps in finding BUGs due to direct partial access of these split 48 bit values.
--- fs/ext4/extents.c | 4 ++-- include/linux/ext4_fs_extents.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
fs/ext4/extents.c +2 -2
@@ -65,7 +65,7 @@ static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix) {ext4_fsblk_t block; - block =le32_to_cpu (ix->ei_leaf); + block =le32_to_cpu (ix->ei_leaf_lo); block |= ((ext4_fsblk_t )le16_to_cpu (ix->ei_leaf_hi) <<31 ) <<1 ;return block; }
@@ -88,7 +88,7 @@ static void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)*/ static void ext4_idx_store_pblock (struct ext4_extent_idx *ix,ext4_fsblk_t pb) { - ix->ei_leaf =cpu_to_le32 ((unsigned long ) (pb &0xffffffff )); + ix->ei_leaf_lo =cpu_to_le32 ((unsigned long ) (pb &0xffffffff )); ix->ei_leaf_hi =cpu_to_le16 ((unsigned long ) ((pb >>31 ) >>1 ) &0xffff ); }
include/linux/ext4_fs_extents.h +1 -1
@@ -83,7 +83,7 @@ struct ext4_extent {*/ struct ext4_extent_idx {__le32 ei_block;/* index covers logical blocks from 'block' */ -__le32 ei_leaf;/* pointer to the physical block of the next * +__le32 ei_leaf_lo;/* pointer to the physical block of the next * * level. leaf or next index could be there */ __le16 ei_leaf_hi;/* high 16 bits of physical block */ __u16 ei_unused;
Signature · 1 line
1.5.3.2.81.g17ed
Theodore Ts'o
maintainerPATCH 1/1 ext4: sparse fixes
From: Aneesh Kumar K.V <[email protected]>
--- fs/ext4/fsync.c | 2 +- fs/ext4/inode.c | 2 +- fs/ext4/xattr.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/ext4/fsync.c +1 -1
@@ -47,7 +47,7 @@ int ext4_sync_file(struct file * file, struct dentry *dentry, int datasync)struct inode *inode = dentry->d_inode;int ret =0 ; -J_ASSERT (ext4_journal_current_handle () ==0 ); +J_ASSERT (ext4_journal_current_handle () ==NULL );/* * data=writeback:
fs/ext4/inode.c +1 -1
@@ -1027,7 +1027,7 @@ struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode, }if (buffer_new (&dummy)) {J_ASSERT (create !=0 ); -J_ASSERT (handle !=0 ); +J_ASSERT (handle !=NULL );/* * Now that we do not always journal data, we should
fs/ext4/xattr.c +2 -2
@@ -1120,7 +1120,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,int total_ino, total_blk;void *base, *start, *end;int extra_isize =0 , error =0 , tried_min_extra_isize =0 ; -int s_min_extra_isize =EXT4_SB (inode->i_sb)->s_es->s_min_extra_isize; +int s_min_extra_isize =le16_to_cpu (EXT4_SB (inode->i_sb)->s_es->s_min_extra_isize);down_write (&EXT4_I (inode)->xattr_sem); retry:
@@ -1292,7 +1292,7 @@ retry: i.name = b_entry_name; i.value = buffer; - i.value_len =cpu_to_le32 (size); + i.value_len = size; error =ext4_xattr_block_find (inode, &i, bs);if (error) goto cleanup;
Signature · 1 line
1.5.3.2.81.g17ed
Re: [PATCH] jbd/jbd2: JBD memory allocation cleanups
In reply to Theodore Ts'oQuoted 3 lines · Theodore Ts'o
From: Mingming Cao <[email protected]>
JBD: Replace slab allocations with page cache allocations
It's page allocations, not page cache allocations.
Quoted 1 line
Also this patch cleans up
jbd_kmallocand replace it with kmalloc directly
That sounds like it should be a different patch..
Re: [PATCH] jbd/jbd2: JBD memory allocation cleanups
Quoted 10 lines · Christoph Hellwig
Quoted 3 lines · Theodore Ts'o
From: Mingming Cao <[email protected]>
JBD: Replace slab allocations with page cache allocations
It's page allocations, not page cache allocations.
Quoted 1 line
Also this patch cleans up
jbd_kmallocand replace it with kmalloc directlyThat sounds like it should be a different patch..
Okay. Will sent the patches, that also separate JBD2 changes to a different patch.
PATCH 1/1 jbd: JBD slab allocation cleanups
In reply to Christoph HellwigJBD: JBD slab allocation cleanups
From: Mingming Cao <[email protected]>
JBD: Replace slab allocations with page allocations
JBD allocate memory for committed_data and frozen_data from slab. However
JBD should not pass slab pages down to the block layer. Use page allocator pages instead. This will also prepare JBD for the large blocksize patchset.
---
fs/jbd/commit.c | 6 +-- fs/jbd/journal.c | 88 ++------------------------------------------------- fs/jbd/transaction.c | 8 ++-- include/linux/jbd.h | 13 +++++-- 4 files changed, 21 insertions(+), 94 deletions(-)
fs/jbd/commit.c +3 -3
@@ -375,7 +375,7 @@ void journal_commit_transaction(journal_struct buffer_head *bh =jh2bh (jh);jbd_lock_bh_state (bh); -jbd_slab_free (jh->b_committed_data, bh->b_size); +jbd_free (jh->b_committed_data, bh->b_size); jh->b_committed_data =NULL ;jbd_unlock_bh_state (bh); }
@@ -792,14 +792,14 @@ restart_loop:* Otherwise, we can just throw away the frozen data now. */ if (jh->b_committed_data) { -jbd_slab_free (jh->b_committed_data, bh->b_size); +jbd_free (jh->b_committed_data, bh->b_size); jh->b_committed_data =NULL ;if (jh->b_frozen_data) { jh->b_committed_data = jh->b_frozen_data; jh->b_frozen_data =NULL ; } }else if (jh->b_frozen_data) { -jbd_slab_free (jh->b_frozen_data, bh->b_size); +jbd_free (jh->b_frozen_data, bh->b_size); jh->b_frozen_data =NULL ; }
fs/jbd/journal.c +4 -84
131 lines not on this page · raw message
fs/jbd/transaction.c +4 -4
@@ -668,7 +668,7 @@ repeat:JBUFFER_TRACE (jh,"allocate memory for buffer" );jbd_unlock_bh_state (bh); frozen_buffer = -jbd_slab_alloc (jh2bh (jh)->b_size, +jbd_alloc (jh2bh (jh)->b_size,GFP_NOFS );if (!frozen_buffer) { printk(KERN_EMERG
@@ -728,7 +728,7 @@ done: out:if (unlikely (frozen_buffer))/* It's usually NULL */ -jbd_slab_free (frozen_buffer, bh->b_size); +jbd_free (frozen_buffer, bh->b_size);JBUFFER_TRACE (jh,"exit" );return error;
@@ -881,7 +881,7 @@ int journal_get_undo_access(handle_t *ha repeat:if (!jh->b_committed_data) { - committed_data =jbd_slab_alloc (jh2bh (jh)->b_size,GFP_NOFS ); + committed_data =jbd_alloc (jh2bh (jh)->b_size,GFP_NOFS );if (!committed_data) {printk (KERN_EMERG "%s: No memory for committed data\n" , __FUNCTION__);
@@ -908,7 +908,7 @@ repeat: out:journal_put_journal_head (jh);if (unlikely (committed_data)) -jbd_slab_free (committed_data, bh->b_size); +jbd_free (committed_data, bh->b_size);return err; }
include/linux/jbd.h +10 -3
@@ -72,14 +72,21 @@ extern int journal_enable_debug;#endif extern void *__jbd_kmalloc (const char *where,size_t size,gfp_t flags,int retry); -extern void *jbd_slab_alloc (size_t size,gfp_t flags); -extern void jbd_slab_free (void *ptr,size_t size); -#define jbd_kmalloc (size, flags) \ __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)#define jbd_rep_kmalloc (size, flags) \ __jbd_kmalloc(__FUNCTION__, (size), (flags), 1) +static inline void *jbd_alloc (size_t size,gfp_t flags) +{ +return (void *)__get_free_pages (flags,get_order (size)); +} + +static inline void jbd_free (void *ptr,size_t size) +{ +free_pages ((unsigned long )ptr,get_order (size)); +}; +#define JFS_MIN_JOURNAL_BLOCKS 1024#ifdef __KERNEL__
PATCH 1/1 jbd2: JBD2 slab allocation cleanups
In reply to Christoph HellwigJBD2: jbd2 slab allocation cleanups
From: Mingming Cao <[email protected]>
JBD2: Replace slab allocations with page allocations
JBD2 allocate memory for committed_data and frozen_data from slab. However JBD2 should not pass slab pages down to the block layer. Use page allocator pages instead. This will also prepare JBD for the large blocksize patchset.
---
fs/jbd2/commit.c | 6 +-- fs/jbd2/journal.c | 88 ++------------------------------------------------ fs/jbd2/transaction.c | 14 +++---- include/linux/jbd2.h | 18 +++++++--- 4 files changed, 27 insertions(+), 99 deletions(-)
fs/jbd2/commit.c +3 -3
@@ -384,7 +384,7 @@ void jbd2_journal_commit_transaction(joustruct buffer_head *bh =jh2bh (jh);jbd_lock_bh_state (bh); -jbd2_slab_free (jh->b_committed_data, bh->b_size); +jbd2_free (jh->b_committed_data, bh->b_size); jh->b_committed_data =NULL ;jbd_unlock_bh_state (bh); }
@@ -801,14 +801,14 @@ restart_loop:* Otherwise, we can just throw away the frozen data now. */ if (jh->b_committed_data) { -jbd2_slab_free (jh->b_committed_data, bh->b_size); +jbd2_free (jh->b_committed_data, bh->b_size); jh->b_committed_data =NULL ;if (jh->b_frozen_data) { jh->b_committed_data = jh->b_frozen_data; jh->b_frozen_data =NULL ; } }else if (jh->b_frozen_data) { -jbd2_slab_free (jh->b_frozen_data, bh->b_size); +jbd2_free (jh->b_frozen_data, bh->b_size); jh->b_frozen_data =NULL ; }
fs/jbd2/journal.c +4 -84
131 lines not on this page · raw message
fs/jbd2/transaction.c +7 -7
@@ -236,7 +236,7 @@ out:/* Allocate a new handle. This should probably be in a slab... */ static handle_t *new_handle (int nblocks) { -handle_t *handle =jbd_alloc_handle (GFP_NOFS ); +handle_t *handle =jbd2_alloc_handle (GFP_NOFS );if (!handle)return NULL ;memset (handle,0 ,sizeof (*handle));
@@ -282,7 +282,7 @@ handle_t *jbd2_journal_start(journal_t * err =start_this_handle (journal, handle);if (err <0 ) { -jbd_free_handle (handle); +jbd2_free_handle (handle); current->journal_info =NULL ; handle =ERR_PTR (err); }
@@ -668,7 +668,7 @@ repeat:JBUFFER_TRACE (jh,"allocate memory for buffer" );jbd_unlock_bh_state (bh); frozen_buffer = -jbd2_slab_alloc (jh2bh (jh)->b_size, +jbd2_alloc (jh2bh (jh)->b_size,GFP_NOFS );if (!frozen_buffer) { printk(KERN_EMERG
@@ -728,7 +728,7 @@ done: out:if (unlikely (frozen_buffer))/* It's usually NULL */ -jbd2_slab_free (frozen_buffer, bh->b_size); +jbd2_free (frozen_buffer, bh->b_size);JBUFFER_TRACE (jh,"exit" );return error;
@@ -881,7 +881,7 @@ int jbd2_journal_get_undo_access(handle_ repeat:if (!jh->b_committed_data) { - committed_data =jbd2_slab_alloc (jh2bh (jh)->b_size,GFP_NOFS ); + committed_data =jbd2_alloc (jh2bh (jh)->b_size,GFP_NOFS );if (!committed_data) {printk (KERN_EMERG "%s: No memory for committed data\n" , __FUNCTION__);
@@ -908,7 +908,7 @@ repeat: out:jbd2_journal_put_journal_head (jh);if (unlikely (committed_data)) -jbd2_slab_free (committed_data, bh->b_size); +jbd2_free (committed_data, bh->b_size);return err; }
@@ -1411,7 +1411,7 @@ int jbd2_journal_stop(handle_t *handle)spin_unlock (&journal->j_state_lock); } -jbd_free_handle (handle); +jbd2_free_handle (handle);return err; }
include/linux/jbd2.h +13 -5
@@ -72,14 +72,22 @@ extern u8 jbd2_journal_enable_debug;#endif extern void *__jbd2_kmalloc (const char *where,size_t size,gfp_t flags,int retry); -extern void *jbd2_slab_alloc (size_t size,gfp_t flags); -extern void jbd2_slab_free (void *ptr,size_t size); -#define jbd_kmalloc (size, flags) \ __jbd2_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)#define jbd_rep_kmalloc (size, flags) \ __jbd2_kmalloc(__FUNCTION__, (size), (flags), 1) + +static inline void *jbd2_alloc (size_t size,gfp_t flags) +{ +return (void *)__get_free_pages (flags,get_order (size)); +} + +static inline void jbd2_free (void *ptr,size_t size) +{ +free_pages ((unsigned long )ptr,get_order (size)); +}; +#define JBD2_MIN_JOURNAL_BLOCKS 1024#ifdef __KERNEL__
@@ -959,12 +967,12 @@ void jbd2_journal_put_journal_head(struc*/ extern struct kmem_cache *jbd2_handle_cache; -static inline handle_t *jbd_alloc_handle (gfp_t gfp_flags) +static inline handle_t *jbd2_alloc_handle (gfp_t gfp_flags) {return kmem_cache_alloc (jbd2_handle_cache, gfp_flags); } -static inline void jbd_free_handle (handle_t *handle) +static inline void jbd2_free_handle (handle_t *handle) {kmem_cache_free (jbd2_handle_cache, handle); }
PATCH 1/1 jbd: JBD replace jbd_kmalloc with kmalloc
In reply to Christoph HellwigJBD: JBD replace jbd_kmalloc with kmalloc
From: Mingming Cao <[email protected]>
This patch cleans up jbd_kmalloc and replace it with kmalloc directly
---
fs/jbd/journal.c | 11 +---------- fs/jbd/transaction.c | 4 ++-- include/linux/jbd.h | 6 ------ 3 files changed, 3 insertions(+), 18 deletions(-)
fs/jbd/journal.c +1 -10
@@ -653,7 +653,7 @@ static journal_t * journal_init_common (journal_t *journal;int err; - journal =jbd_kmalloc (sizeof (*journal),GFP_KERNEL ); + journal =kmalloc (sizeof (*journal),GFP_KERNEL );if (!journal) goto fail;memset (journal,0 ,sizeof (*journal));
@@ -1607,15 +1607,6 @@ int journal_blocks_per_page(struct inode }/* -* Simple support for retrying memory allocations. Introduced to help to -* debug different VM deadlock avoidance strategies. -*/ -void *__jbd_kmalloc (const char *where,size_t size,gfp_t flags,int retry) -{ -return kmalloc (size, flags | (retry ? __GFP_NOFAIL :0 )); -} - -/* * Journal_head storage management */ static struct kmem_cache *journal_head_cache;
fs/jbd/transaction.c +2 -2
@@ -96,8 +96,8 @@ static int start_this_handle(journal_t * alloc_transaction:if (!journal->j_running_transaction) { - new_transaction =jbd_kmalloc (sizeof (*new_transaction), -GFP_NOFS ); + new_transaction =kmalloc (sizeof (*new_transaction), +GFP_NOFS |__GFP_NOFAIL);if (!new_transaction) { ret = -ENOMEM ; goto out;
include/linux/jbd.h +0 -6
@@ -71,12 +71,6 @@ extern int journal_enable_debug; #define jbd_debug(f, a...) /**/#endif -extern void *__jbd_kmalloc (const char *where,size_t size,gfp_t flags,int retry); -#define jbd_kmalloc (size, flags) \ - __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry) -#define jbd_rep_kmalloc (size, flags) \ - __jbd_kmalloc(__FUNCTION__, (size), (flags), 1) -static inline void *jbd_alloc (size_t size,gfp_t flags) {return (void *)__get_free_pages (flags,get_order (size));
Re: [PATCH] jbd: JBD replace jbd_kmalloc with kmalloc
fs/jbd/transaction.c static int start_this_handle(journal_t * · line 100
Quoted 12 lines · Mingming Cao
Index:
linux-2.6.23-rc9/fs/jbd/transaction.c
===================================================================fs/jbd/transaction.c +2
-2@@ -96,8 +96,8 @@ static int start_this_handle(journal_t * alloc_transaction:if (!journal->j_running_transaction) { - new_transaction =jbd_kmalloc (sizeof (*new_transaction), -GFP_NOFS ); + new_transaction =kmalloc (sizeof (*new_transaction), +GFP_NOFS |__GFP_NOFAIL);
Why was a __GFP_NOFAIL added here? I do not see a use of jbd_rep_kmalloc?
fs/jbd/transaction.c static int start_this_handle(journal_t * · line 102
Quoted 2 lines
fs/jbd/transaction.c +0
-2-#define jbd_kmalloc (size, flags) \ - __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
journal_oom_retry is no longer used?
Re: [PATCH] jbd: JBD replace jbd_kmalloc with kmalloc
Quoted 18 lines · Christoph Lameter
fs/jbd/transaction.c static int start_this_handle(journal_t * · line 100
Quoted 12 lines · Mingming Cao
Index:
linux-2.6.23-rc9/fs/jbd/transaction.c
===================================================================fs/jbd/transaction.c +2
-2@@ -96,8 +96,8 @@ static int start_this_handle(journal_t * alloc_transaction:if (!journal->j_running_transaction) { - new_transaction =jbd_kmalloc (sizeof (*new_transaction), -GFP_NOFS ); + new_transaction =kmalloc (sizeof (*new_transaction), +GFP_NOFS |__GFP_NOFAIL);Why was a
__GFP_NOFAILadded here? I do not see a use ofjbd_rep_kmalloc?
Quoted 5 lines
fs/jbd/transaction.c static int start_this_handle(journal_t * · line 102
Quoted 2 lines
fs/jbd/transaction.c +0
-2-#define jbd_kmalloc (size, flags) \ - __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
journal_oom_retryis no longer used?
-
journal_oom_retry (which is defined as 1 currently) is still being used in revoke.c, the cleanup patch doesn't remove the define of journal_oom_retry.
Since journal_oom_retry is always 1 to __jbd_kmalloc,
void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
{
return kmalloc(size, flags | (retry ? __GFP_NOFAIL : 0));
}So we replace jbd_kmalloc() to kmalloc() with __GFP_NOFAIL flag on in start_this_handle(). Other two places replacing to kmalloc() is part of the init process, so no need for __GFP_NOFAIL flag there.
Mingming
Quoted 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Christoph Lameter
Acked-byRe: [PATCH] jbd: JBD replace jbd_kmalloc with kmalloc
Quoted 3 lines · Mingming Cao
So we replace
jbd_kmalloc()tokmalloc()with__GFP_NOFAILflag on instart_this_handle(). Other two places replacing tokmalloc()is part of the init process, so no need for__GFP_NOFAILflag there.
PATCH 1/1 jbd2: JBD replace jbd2_kmalloc with kmalloc
In reply to Christoph HellwigJBD2: JBD2 replace jbd2_kmalloc with kmalloc
From: Mingming Cao <[email protected]>
This patch cleans up jbd_kmalloc and replace it with kmalloc directly
---
fs/jbd2/journal.c | 11 +---------- fs/jbd2/transaction.c | 4 ++-- include/linux/jbd2.h | 7 ------- 3 files changed, 3 insertions(+), 19 deletions(-)
fs/jbd2/journal.c +1 -10
@@ -654,7 +654,7 @@ static journal_t * journal_init_common (journal_t *journal;int err; - journal =jbd_kmalloc (sizeof (*journal),GFP_KERNEL ); + journal =kmalloc (sizeof (*journal),GFP_KERNEL );if (!journal) goto fail;memset (journal,0 ,sizeof (*journal));
@@ -1619,15 +1619,6 @@ size_t journal_tag_bytes(journal_t *jour }/* -* Simple support for retrying memory allocations. Introduced to help to -* debug different VM deadlock avoidance strategies. -*/ -void *__jbd2_kmalloc (const char *where,size_t size,gfp_t flags,int retry) -{ -return kmalloc (size, flags | (retry ? __GFP_NOFAIL :0 )); -} - -/* * Journal_head storage management */ static struct kmem_cache *jbd2_journal_head_cache;
fs/jbd2/transaction.c +2 -2
@@ -96,8 +96,8 @@ static int start_this_handle(journal_t * alloc_transaction:if (!journal->j_running_transaction) { - new_transaction =jbd_kmalloc (sizeof (*new_transaction), -GFP_NOFS ); + new_transaction =kmalloc (sizeof (*new_transaction), +GFP_NOFS |__GFP_NOFAIL);if (!new_transaction) { ret = -ENOMEM ; goto out;
include/linux/jbd2.h +0 -7
@@ -71,13 +71,6 @@ extern u8 jbd2_journal_enable_debug; #define jbd_debug(f, a...) /**/#endif -extern void *__jbd2_kmalloc (const char *where,size_t size,gfp_t flags,int retry); -#define jbd_kmalloc (size, flags) \ - __jbd2_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry) -#define jbd_rep_kmalloc (size, flags) \ - __jbd2_kmalloc(__FUNCTION__, (size), (flags), 1) - -static inline void *jbd2_alloc (size_t size,gfp_t flags) {return (void *)__get_free_pages (flags,get_order (size));
Re: [PATCH] jbd2: JBD replace jbd2_kmalloc with kmalloc