From: Greg Kroah-Hartman Date: Fri, 19 Jul 2013 00:04:27 +0000 (-0700) Subject: 3.10-stable patches X-Git-Tag: v3.9.11~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba3c3daf500d975179c784731efc10abeff93f5d;p=thirdparty%2Fkernel%2Fstable-queue.git 3.10-stable patches added patches: ext4-don-t-allow-ext4_free_blocks-to-fail-due-to-enomem.patch ext4-don-t-show-usrquota-grpquota-twice-in-proc-mounts.patch ext4-fix-data-offset-overflow-in-ext4_xattr_fiemap-on-32-bit-archs.patch ext4-fix-data-offset-overflow-on-32-bit-archs-in-ext4_inline_data_fiemap.patch ext4-fix-ext4_get_group_number.patch ext4-fix-overflows-in-seek_hole-seek_data-implementations.patch ext4-fix-overflow-when-counting-used-blocks-on-32-bit-architectures.patch --- diff --git a/queue-3.10/ext4-don-t-allow-ext4_free_blocks-to-fail-due-to-enomem.patch b/queue-3.10/ext4-don-t-allow-ext4_free_blocks-to-fail-due-to-enomem.patch new file mode 100644 index 00000000000..75ee386bca7 --- /dev/null +++ b/queue-3.10/ext4-don-t-allow-ext4_free_blocks-to-fail-due-to-enomem.patch @@ -0,0 +1,45 @@ +From e7676a704ee0a1ef71a6b23760b5a8f6896cb1a1 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Sat, 13 Jul 2013 00:40:35 -0400 +Subject: ext4: don't allow ext4_free_blocks() to fail due to ENOMEM + +From: Theodore Ts'o + +commit e7676a704ee0a1ef71a6b23760b5a8f6896cb1a1 upstream. + +The filesystem should not be marked inconsistent if ext4_free_blocks() +is not able to allocate memory. Unfortunately some callers (most +notably ext4_truncate) don't have a way to reflect an error back up to +the VFS. And even if we did, most userspace applications won't deal +with most system calls returning ENOMEM anyway. + +Reported-by: Nagachandra P +Signed-off-by: "Theodore Ts'o" +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ext4/mballoc.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +--- a/fs/ext4/mballoc.c ++++ b/fs/ext4/mballoc.c +@@ -4735,11 +4735,16 @@ do_more: + * blocks being freed are metadata. these blocks shouldn't + * be used until this transaction is committed + */ ++ retry: + new_entry = kmem_cache_alloc(ext4_free_data_cachep, GFP_NOFS); + if (!new_entry) { +- ext4_mb_unload_buddy(&e4b); +- err = -ENOMEM; +- goto error_return; ++ /* ++ * We use a retry loop because ++ * ext4_free_blocks() is not allowed to fail. ++ */ ++ cond_resched(); ++ congestion_wait(BLK_RW_ASYNC, HZ/50); ++ goto retry; + } + new_entry->efd_start_cluster = bit; + new_entry->efd_group = block_group; diff --git a/queue-3.10/ext4-don-t-show-usrquota-grpquota-twice-in-proc-mounts.patch b/queue-3.10/ext4-don-t-show-usrquota-grpquota-twice-in-proc-mounts.patch new file mode 100644 index 00000000000..9a50d4af76f --- /dev/null +++ b/queue-3.10/ext4-don-t-show-usrquota-grpquota-twice-in-proc-mounts.patch @@ -0,0 +1,40 @@ +From ad065dd01662ae22138899e6b1c8eeb3a529964f Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Thu, 11 Jul 2013 18:54:37 -0400 +Subject: ext4: don't show usrquota/grpquota twice in /proc/mounts + +From: Theodore Ts'o + +commit ad065dd01662ae22138899e6b1c8eeb3a529964f upstream. + +We now print mount options in a generic fashion in +ext4_show_options(), so we shouldn't be explicitly printing the +{usr,grp}quota options in ext4_show_quota_options(). + +Without this patch, /proc/mounts can look like this: + + /dev/vdb /vdb ext4 rw,relatime,quota,usrquota,data=ordered,usrquota 0 0 + ^^^^^^^^ ^^^^^^^^ + +Signed-off-by: "Theodore Ts'o" +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ext4/super.c | 6 ------ + 1 file changed, 6 deletions(-) + +--- a/fs/ext4/super.c ++++ b/fs/ext4/super.c +@@ -1684,12 +1684,6 @@ static inline void ext4_show_quota_optio + + if (sbi->s_qf_names[GRPQUOTA]) + seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); +- +- if (test_opt(sb, USRQUOTA)) +- seq_puts(seq, ",usrquota"); +- +- if (test_opt(sb, GRPQUOTA)) +- seq_puts(seq, ",grpquota"); + #endif + } + diff --git a/queue-3.10/ext4-fix-data-offset-overflow-in-ext4_xattr_fiemap-on-32-bit-archs.patch b/queue-3.10/ext4-fix-data-offset-overflow-in-ext4_xattr_fiemap-on-32-bit-archs.patch new file mode 100644 index 00000000000..4409a42f082 --- /dev/null +++ b/queue-3.10/ext4-fix-data-offset-overflow-in-ext4_xattr_fiemap-on-32-bit-archs.patch @@ -0,0 +1,42 @@ +From a60697f411eb365fb09e639e6f183fe33d1eb796 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Fri, 31 May 2013 19:38:56 -0400 +Subject: ext4: fix data offset overflow in ext4_xattr_fiemap() on 32-bit archs + +From: Jan Kara + +commit a60697f411eb365fb09e639e6f183fe33d1eb796 upstream. + +On 32-bit architectures with 32-bit sector_t computation of data offset +in ext4_xattr_fiemap() can overflow resulting in reporting bogus data +location. Fix the problem by typing block number to proper type before +shifting. + +Signed-off-by: Jan Kara +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ext4/extents.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/fs/ext4/extents.c ++++ b/fs/ext4/extents.c +@@ -4659,7 +4659,7 @@ static int ext4_xattr_fiemap(struct inod + error = ext4_get_inode_loc(inode, &iloc); + if (error) + return error; +- physical = iloc.bh->b_blocknr << blockbits; ++ physical = (__u64)iloc.bh->b_blocknr << blockbits; + offset = EXT4_GOOD_OLD_INODE_SIZE + + EXT4_I(inode)->i_extra_isize; + physical += offset; +@@ -4667,7 +4667,7 @@ static int ext4_xattr_fiemap(struct inod + flags |= FIEMAP_EXTENT_DATA_INLINE; + brelse(iloc.bh); + } else { /* external block */ +- physical = EXT4_I(inode)->i_file_acl << blockbits; ++ physical = (__u64)EXT4_I(inode)->i_file_acl << blockbits; + length = inode->i_sb->s_blocksize; + } + diff --git a/queue-3.10/ext4-fix-data-offset-overflow-on-32-bit-archs-in-ext4_inline_data_fiemap.patch b/queue-3.10/ext4-fix-data-offset-overflow-on-32-bit-archs-in-ext4_inline_data_fiemap.patch new file mode 100644 index 00000000000..ee09cb1c58e --- /dev/null +++ b/queue-3.10/ext4-fix-data-offset-overflow-on-32-bit-archs-in-ext4_inline_data_fiemap.patch @@ -0,0 +1,32 @@ +From eaf3793728d07d995f1e74250b2d0005f7ae98b5 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Fri, 31 May 2013 19:33:42 -0400 +Subject: ext4: fix data offset overflow on 32-bit archs in ext4_inline_data_fiemap() + +From: Jan Kara + +commit eaf3793728d07d995f1e74250b2d0005f7ae98b5 upstream. + +On 32-bit archs when sector_t is defined as 32-bit the logic computing +data offset in ext4_inline_data_fiemap(). Fix that by properly typing +the shifted value. + +Signed-off-by: Jan Kara +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ext4/inline.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/fs/ext4/inline.c ++++ b/fs/ext4/inline.c +@@ -1842,7 +1842,7 @@ int ext4_inline_data_fiemap(struct inode + if (error) + goto out; + +- physical = iloc.bh->b_blocknr << inode->i_sb->s_blocksize_bits; ++ physical = (__u64)iloc.bh->b_blocknr << inode->i_sb->s_blocksize_bits; + physical += (char *)ext4_raw_inode(&iloc) - iloc.bh->b_data; + physical += offsetof(struct ext4_inode, i_block); + length = i_size_read(inode); diff --git a/queue-3.10/ext4-fix-ext4_get_group_number.patch b/queue-3.10/ext4-fix-ext4_get_group_number.patch new file mode 100644 index 00000000000..02a737412da --- /dev/null +++ b/queue-3.10/ext4-fix-ext4_get_group_number.patch @@ -0,0 +1,110 @@ +From 960fd856fdc3b08b3638f3f9b6b4bfceb77660c7 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Fri, 5 Jul 2013 23:11:16 -0400 +Subject: ext4: fix ext4_get_group_number() + +From: Theodore Ts'o + +commit 960fd856fdc3b08b3638f3f9b6b4bfceb77660c7 upstream. + +The function ext4_get_group_number() was introduced as an optimization +in commit bd86298e60b8. Unfortunately, this commit incorrectly +calculate the group number for file systems with a 1k block size (when +s_first_data_block is 1 instead of zero). This could cause the +following kernel BUG: + +[ 568.877799] ------------[ cut here ]------------ +[ 568.877833] kernel BUG at fs/ext4/mballoc.c:3728! +[ 568.877840] Oops: Exception in kernel mode, sig: 5 [#1] +[ 568.877845] SMP NR_CPUS=32 NUMA pSeries +[ 568.877852] Modules linked in: binfmt_misc +[ 568.877861] CPU: 1 PID: 3516 Comm: fs_mark Not tainted 3.10.0-03216-g7c6809f-dirty #1 +[ 568.877867] task: c0000001fb0b8000 ti: c0000001fa954000 task.ti: c0000001fa954000 +[ 568.877873] NIP: c0000000002f42a4 LR: c0000000002f4274 CTR: c000000000317ef8 +[ 568.877879] REGS: c0000001fa956ed0 TRAP: 0700 Not tainted (3.10.0-03216-g7c6809f-dirty) +[ 568.877884] MSR: 8000000000029032 CR: 24000428 XER: 00000000 +[ 568.877902] SOFTE: 1 +[ 568.877905] CFAR: c0000000002b5464 +[ 568.877908] +GPR00: 0000000000000001 c0000001fa957150 c000000000c6a408 c0000001fb588000 +GPR04: 0000000000003fff c0000001fa9571c0 c0000001fa9571c4 000138098c50625f +GPR08: 1301200000000000 0000000000000002 0000000000000001 0000000000000000 +GPR12: 0000000024000422 c00000000f33a300 0000000000008000 c0000001fa9577f0 +GPR16: c0000001fb7d0100 c000000000c29190 c0000000007f46e8 c000000000a14672 +GPR20: 0000000000000001 0000000000000008 ffffffffffffffff 0000000000000000 +GPR24: 0000000000000100 c0000001fa957278 c0000001fdb2bc78 c0000001fa957288 +GPR28: 0000000000100100 c0000001fa957288 c0000001fb588000 c0000001fdb2bd10 +[ 568.877993] NIP [c0000000002f42a4] .ext4_mb_release_group_pa+0xec/0x1c0 +[ 568.877999] LR [c0000000002f4274] .ext4_mb_release_group_pa+0xbc/0x1c0 +[ 568.878004] Call Trace: +[ 568.878008] [c0000001fa957150] [c0000000002f4274] .ext4_mb_release_group_pa+0xbc/0x1c0 (unreliable) +[ 568.878017] [c0000001fa957200] [c0000000002fb070] .ext4_mb_discard_lg_preallocations+0x394/0x444 +[ 568.878025] [c0000001fa957340] [c0000000002fb45c] .ext4_mb_release_context+0x33c/0x734 +[ 568.878032] [c0000001fa957440] [c0000000002fbcf8] .ext4_mb_new_blocks+0x4a4/0x5f4 +[ 568.878039] [c0000001fa957510] [c0000000002ef56c] .ext4_ext_map_blocks+0xc28/0x1178 +[ 568.878047] [c0000001fa957640] [c0000000002c1a94] .ext4_map_blocks+0x2c8/0x490 +[ 568.878054] [c0000001fa957730] [c0000000002c536c] .ext4_writepages+0x738/0xc60 +[ 568.878062] [c0000001fa957950] [c000000000168a78] .do_writepages+0x5c/0x80 +[ 568.878069] [c0000001fa9579d0] [c00000000015d1c4] .__filemap_fdatawrite_range+0x88/0xb0 +[ 568.878078] [c0000001fa957aa0] [c00000000015d23c] .filemap_write_and_wait_range+0x50/0xfc +[ 568.878085] [c0000001fa957b30] [c0000000002b8edc] .ext4_sync_file+0x220/0x3c4 +[ 568.878092] [c0000001fa957be0] [c0000000001f849c] .vfs_fsync_range+0x64/0x80 +[ 568.878098] [c0000001fa957c70] [c0000000001f84f0] .vfs_fsync+0x38/0x4c +[ 568.878105] [c0000001fa957d00] [c0000000001f87f4] .do_fsync+0x54/0x90 +[ 568.878111] [c0000001fa957db0] [c0000000001f8894] .SyS_fsync+0x28/0x3c +[ 568.878120] [c0000001fa957e30] [c000000000009c88] syscall_exit+0x0/0x7c +[ 568.878125] Instruction dump: +[ 568.878130] 60000000 813d0034 81610070 38000000 7f8b4800 419e001c 813f007c 7d2bfe70 +[ 568.878144] 7d604a78 7c005850 54000ffe 7c0007b4 <0b000000> e8a10076 e87f0090 7fa4eb78 +[ 568.878160] ---[ end trace 594d911d9654770b ]--- + +In addition fix the STD_GROUP optimization so that it works for +bigalloc file systems as well. + +Signed-off-by: "Theodore Ts'o" +Reported-by: Li Zhong +Reviewed-by: Lukas Czerner +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ext4/balloc.c | 4 ++-- + fs/ext4/super.c | 8 ++++---- + 2 files changed, 6 insertions(+), 6 deletions(-) + +--- a/fs/ext4/balloc.c ++++ b/fs/ext4/balloc.c +@@ -38,8 +38,8 @@ ext4_group_t ext4_get_group_number(struc + ext4_group_t group; + + if (test_opt2(sb, STD_GROUP_SIZE)) +- group = (le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) + +- block) >> ++ group = (block - ++ le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) >> + (EXT4_BLOCK_SIZE_BITS(sb) + EXT4_CLUSTER_BITS(sb) + 3); + else + ext4_get_group_no_and_offset(sb, block, &group, NULL); +--- a/fs/ext4/super.c ++++ b/fs/ext4/super.c +@@ -3586,10 +3586,6 @@ static int ext4_fill_super(struct super_ + sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); + sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); + +- /* Do we have standard group size of blocksize * 8 blocks ? */ +- if (sbi->s_blocks_per_group == blocksize << 3) +- set_opt2(sb, STD_GROUP_SIZE); +- + for (i = 0; i < 4; i++) + sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); + sbi->s_def_hash_version = es->s_def_hash_version; +@@ -3659,6 +3655,10 @@ static int ext4_fill_super(struct super_ + goto failed_mount; + } + ++ /* Do we have standard group size of clustersize * 8 blocks ? */ ++ if (sbi->s_blocks_per_group == clustersize << 3) ++ set_opt2(sb, STD_GROUP_SIZE); ++ + /* + * Test whether we have more sectors than will fit in sector_t, + * and whether the max offset is addressable by the page cache. diff --git a/queue-3.10/ext4-fix-overflow-when-counting-used-blocks-on-32-bit-architectures.patch b/queue-3.10/ext4-fix-overflow-when-counting-used-blocks-on-32-bit-architectures.patch new file mode 100644 index 00000000000..937ad8f3fc2 --- /dev/null +++ b/queue-3.10/ext4-fix-overflow-when-counting-used-blocks-on-32-bit-architectures.patch @@ -0,0 +1,43 @@ +From 8af8eecc1331dbf5e8c662022272cf667e213da5 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Fri, 31 May 2013 19:39:56 -0400 +Subject: ext4: fix overflow when counting used blocks on 32-bit architectures + +From: Jan Kara + +commit 8af8eecc1331dbf5e8c662022272cf667e213da5 upstream. + +The arithmetics adding delalloc blocks to the number of used blocks in +ext4_getattr() can easily overflow on 32-bit archs as we first multiply +number of blocks by blocksize and then divide back by 512. Make the +arithmetics more clever and also use proper type (unsigned long long +instead of unsigned long). + +Signed-off-by: Jan Kara +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ext4/inode.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/fs/ext4/inode.c ++++ b/fs/ext4/inode.c +@@ -4808,7 +4808,7 @@ int ext4_getattr(struct vfsmount *mnt, s + struct kstat *stat) + { + struct inode *inode; +- unsigned long delalloc_blocks; ++ unsigned long long delalloc_blocks; + + inode = dentry->d_inode; + generic_fillattr(inode, stat); +@@ -4826,7 +4826,7 @@ int ext4_getattr(struct vfsmount *mnt, s + delalloc_blocks = EXT4_C2B(EXT4_SB(inode->i_sb), + EXT4_I(inode)->i_reserved_data_blocks); + +- stat->blocks += (delalloc_blocks << inode->i_sb->s_blocksize_bits)>>9; ++ stat->blocks += delalloc_blocks << (inode->i_sb->s_blocksize_bits-9); + return 0; + } + diff --git a/queue-3.10/ext4-fix-overflows-in-seek_hole-seek_data-implementations.patch b/queue-3.10/ext4-fix-overflows-in-seek_hole-seek_data-implementations.patch new file mode 100644 index 00000000000..6a1fb4584ad --- /dev/null +++ b/queue-3.10/ext4-fix-overflows-in-seek_hole-seek_data-implementations.patch @@ -0,0 +1,87 @@ +From e7293fd146846e2a44d29e0477e0860c60fb856b Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Fri, 31 May 2013 19:37:56 -0400 +Subject: ext4: fix overflows in SEEK_HOLE, SEEK_DATA implementations + +From: Jan Kara + +commit e7293fd146846e2a44d29e0477e0860c60fb856b upstream. + +ext4_lblk_t is just u32 so multiplying it by blocksize can easily +overflow for files larger than 4 GB. Fix that by properly typing the +block offsets before shifting. + +Signed-off-by: Jan Kara +Signed-off-by: Theodore Ts'o +Reviewed-by: Zheng Liu +Signed-off-by: Greg Kroah-Hartman + +--- + fs/ext4/file.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +--- a/fs/ext4/file.c ++++ b/fs/ext4/file.c +@@ -312,7 +312,7 @@ static int ext4_find_unwritten_pgoff(str + blkbits = inode->i_sb->s_blocksize_bits; + startoff = *offset; + lastoff = startoff; +- endoff = (map->m_lblk + map->m_len) << blkbits; ++ endoff = (loff_t)(map->m_lblk + map->m_len) << blkbits; + + index = startoff >> PAGE_CACHE_SHIFT; + end = endoff >> PAGE_CACHE_SHIFT; +@@ -457,7 +457,7 @@ static loff_t ext4_seek_data(struct file + ret = ext4_map_blocks(NULL, inode, &map, 0); + if (ret > 0 && !(map.m_flags & EXT4_MAP_UNWRITTEN)) { + if (last != start) +- dataoff = last << blkbits; ++ dataoff = (loff_t)last << blkbits; + break; + } + +@@ -468,7 +468,7 @@ static loff_t ext4_seek_data(struct file + ext4_es_find_delayed_extent_range(inode, last, last, &es); + if (es.es_len != 0 && in_range(last, es.es_lblk, es.es_len)) { + if (last != start) +- dataoff = last << blkbits; ++ dataoff = (loff_t)last << blkbits; + break; + } + +@@ -486,7 +486,7 @@ static loff_t ext4_seek_data(struct file + } + + last++; +- dataoff = last << blkbits; ++ dataoff = (loff_t)last << blkbits; + } while (last <= end); + + mutex_unlock(&inode->i_mutex); +@@ -540,7 +540,7 @@ static loff_t ext4_seek_hole(struct file + ret = ext4_map_blocks(NULL, inode, &map, 0); + if (ret > 0 && !(map.m_flags & EXT4_MAP_UNWRITTEN)) { + last += ret; +- holeoff = last << blkbits; ++ holeoff = (loff_t)last << blkbits; + continue; + } + +@@ -551,7 +551,7 @@ static loff_t ext4_seek_hole(struct file + ext4_es_find_delayed_extent_range(inode, last, last, &es); + if (es.es_len != 0 && in_range(last, es.es_lblk, es.es_len)) { + last = es.es_lblk + es.es_len; +- holeoff = last << blkbits; ++ holeoff = (loff_t)last << blkbits; + continue; + } + +@@ -566,7 +566,7 @@ static loff_t ext4_seek_hole(struct file + &map, &holeoff); + if (!unwritten) { + last += ret; +- holeoff = last << blkbits; ++ holeoff = (loff_t)last << blkbits; + continue; + } + } diff --git a/queue-3.10/series b/queue-3.10/series index 965fe7e15a5..22a1563ba94 100644 --- a/queue-3.10/series +++ b/queue-3.10/series @@ -49,3 +49,10 @@ timer-fix-jiffies-wrap-behavior-of-round_jiffies_common.patch btrfs-fix-estale-with-btrfs-send.patch btrfs-hold-the-tree-mod-lock-in-__tree_mod_log_rewind.patch btrfs-only-do-the-tree_mod_log_free_eb-if-this-is-our-last.patch +ext4-fix-data-offset-overflow-on-32-bit-archs-in-ext4_inline_data_fiemap.patch +ext4-fix-overflows-in-seek_hole-seek_data-implementations.patch +ext4-fix-data-offset-overflow-in-ext4_xattr_fiemap-on-32-bit-archs.patch +ext4-fix-overflow-when-counting-used-blocks-on-32-bit-architectures.patch +ext4-fix-ext4_get_group_number.patch +ext4-don-t-show-usrquota-grpquota-twice-in-proc-mounts.patch +ext4-don-t-allow-ext4_free_blocks-to-fail-due-to-enomem.patch