public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, "Theodore Tso" <tytso@mit.edu>,
	Li Zhong <lizhongfs@gmail.com>,
	Lukas Czerner <lczerner@redhat.com>
Subject: [ 56/72] ext4: fix ext4_get_group_number()
Date: Thu, 18 Jul 2013 22:26:13 -0700	[thread overview]
Message-ID: <20130719052603.685456377@linuxfoundation.org> (raw)
In-Reply-To: <20130719052559.852627424@linuxfoundation.org>

3.10-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Theodore Ts'o <tytso@mit.edu>

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 <SF,EE,ME,IR,DR,RI>  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" <tytso@mit.edu>
Reported-by: Li Zhong <lizhongfs@gmail.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 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.



  parent reply	other threads:[~2013-07-19  5:31 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-19  5:25 [ 00/72] 3.10.2-stable review Greg Kroah-Hartman
2013-07-19  5:25 ` [ 01/72] CIFS use sensible file nlink values if unprovided Greg Kroah-Hartman
2013-07-19  5:25 ` [ 02/72] CIFS: Fix a deadlock when a file is reopened Greg Kroah-Hartman
2013-07-19  5:25 ` [ 03/72] rtlwifi: rtl8192cu: Add new USB ID for TP-Link TL-WN8200ND Greg Kroah-Hartman
2013-07-19  5:25 ` [ 04/72] rtlwifi: rtl8723ae: Fix typo in firmware names Greg Kroah-Hartman
2013-07-19  5:25 ` [ 05/72] rtlwifi: rtl8192cu: Fix duplicate if test Greg Kroah-Hartman
2013-07-19  5:25 ` [ 06/72] jbd2: move superblock checksum calculation to jbd2_write_superblock() Greg Kroah-Hartman
2013-07-19  5:25 ` [ 07/72] jbd2: fix theoretical race in jbd2__journal_restart Greg Kroah-Hartman
2013-07-19  5:25 ` [ 08/72] ext4: fix corruption when online resizing a fs with 1K block size Greg Kroah-Hartman
2013-07-19  5:25 ` [ 09/72] ext3,ext4: dont mess with dir_file->f_pos in htree_dirblock_to_tree() Greg Kroah-Hartman
2013-07-19  5:25 ` [ 10/72] ext4: check error return from ext4_write_inline_data_end() Greg Kroah-Hartman
2013-07-19  5:25 ` [ 11/72] pch_uart: Add uart_clk selection for the MinnowBoard Greg Kroah-Hartman
2013-07-19  5:25 ` [ 12/72] USB: option,qcserial: move Novatel Gobi1K IDs to qcserial Greg Kroah-Hartman
2013-07-19  5:25 ` [ 13/72] usb: gadget: f_mass_storage: add missing memory barrier for thread_wakeup_needed Greg Kroah-Hartman
2013-07-19  5:25 ` [ 14/72] USB: ehci-omap: Tweak PHY initialization sequence Greg Kroah-Hartman
2013-07-19  5:25 ` [ 15/72] xhci: check for failed dma pool allocation Greg Kroah-Hartman
2013-07-19  5:25 ` [ 16/72] usb: host: xhci-plat: release mem region while removing module Greg Kroah-Hartman
2013-07-19  5:25 ` [ 17/72] drivers: hv: switch to use mb() instead of smp_mb() Greg Kroah-Hartman
2013-07-19  5:25 ` [ 18/72] pcmcia: at91_cf: fix gpio_get_value in at91_cf_get_status Greg Kroah-Hartman
2013-07-19  5:25 ` [ 19/72] cgroup: fix umount vs cgroup_event_remove() race Greg Kroah-Hartman
2013-07-19  5:25 ` [ 20/72] cgroup: fix RCU accesses to task->cgroups Greg Kroah-Hartman
2013-07-19  5:25 ` [ 21/72] parisc: document the shadow registers Greg Kroah-Hartman
2013-07-19  5:25 ` [ 22/72] parisc: Fix gcc miscompilation in pa_memcpy() Greg Kroah-Hartman
2013-07-19  5:25 ` [ 23/72] slab: fix init_lock_keys Greg Kroah-Hartman
2013-07-19  5:25 ` [ 24/72] parisc: Ensure volatile space register %sr1 is not clobbered Greg Kroah-Hartman
2013-07-19  5:25 ` [ 25/72] parisc: fix LMMIO mismatch between PAT length and MASK register Greg Kroah-Hartman
2013-07-19  5:25 ` [ 26/72] parisc: optimize mtsp(0,sr) inline assembly Greg Kroah-Hartman
2013-07-19  5:25 ` [ 27/72] x86, efi: retry ExitBootServices() on failure Greg Kroah-Hartman
2013-07-19  5:25 ` [ 28/72] xen/time: remove blocked time accounting from xen "clockchip" Greg Kroah-Hartman
2013-07-19  5:25 ` [ 29/72] xen/pcifront: Deal with toolstack missing XenbusStateClosing state Greg Kroah-Hartman
2013-07-19  5:25 ` [ 30/72] genirq: Fix can_request_irq() for IRQs without an action Greg Kroah-Hartman
2013-07-19  5:25 ` [ 31/72] drivers/rtc/rtc-rv3029c2.c: fix disabling AIE irq Greg Kroah-Hartman
2013-07-19  5:25 ` [ 32/72] ACPI: Add CMOS RTC Operation Region handler support Greg Kroah-Hartman
2013-07-19  5:25 ` [ 33/72] ACPI / EC: Add HP Folio 13 to ec_dmi_table in order to skip DSDT scan Greg Kroah-Hartman
2013-07-19  5:25 ` [ 34/72] ACPICA: Do not use extended sleep registers unless HW-reduced bit is set Greg Kroah-Hartman
2013-07-19  5:25 ` [ 35/72] ACPI / PM: Fix corner case in acpi_bus_update_power() Greg Kroah-Hartman
2013-07-19  5:25 ` [ 36/72] HID: apple: Add support for the 2013 Macbook Air Greg Kroah-Hartman
2013-07-19  5:25 ` [ 37/72] Input: bcm5974 - add support for the 2013 MacBook Air Greg Kroah-Hartman
2013-07-19  5:40   ` Dmitry Torokhov
2013-07-19  5:44     ` Greg Kroah-Hartman
2013-07-22  1:42       ` Greg Kroah-Hartman
2013-07-22  2:21         ` Dmitry Torokhov
2013-07-22 10:07           ` rydberg
2013-07-19  5:25 ` [ 38/72] arch: c6x: mm: include "asm/uaccess.h" to pass compiling Greg Kroah-Hartman
2013-07-19  5:25 ` [ 39/72] ocfs2: xattr: fix inlined xattr reflink Greg Kroah-Hartman
2013-07-19  5:25 ` [ 40/72] nbd: correct disconnect behavior Greg Kroah-Hartman
2013-07-19  5:25 ` [ 41/72] PCI: Finish SR-IOV VF setup before adding the device Greg Kroah-Hartman
2013-07-19  5:25 ` [ 42/72] PCI: Fix refcount issue in pci_create_root_bus() error recovery path Greg Kroah-Hartman
2013-07-19  5:26 ` [ 43/72] iwlwifi: pcie: fix race in queue unmapping Greg Kroah-Hartman
2013-07-19  5:26 ` [ 44/72] iwlwifi: pcie: wake the queue if stopped when being unmapped Greg Kroah-Hartman
2013-07-19  5:26 ` [ 45/72] ahci: Add AMD CZ SATA device ID Greg Kroah-Hartman
2013-07-19  5:26 ` [ 46/72] ahci: AHCI-mode SATA patch for Intel Coleto Creek DeviceIDs Greg Kroah-Hartman
2013-07-19  5:26 ` [ 47/72] ahci: remove pmp link online check in FBS EH Greg Kroah-Hartman
2013-07-19  5:26 ` [ 48/72] timer: Fix jiffies wrap behavior of round_jiffies_common() Greg Kroah-Hartman
2013-07-19  5:26 ` [ 49/72] Btrfs: fix estale with btrfs send Greg Kroah-Hartman
2013-07-19  5:26 ` [ 50/72] Btrfs: hold the tree mod lock in __tree_mod_log_rewind Greg Kroah-Hartman
2013-07-19  5:26 ` [ 51/72] Btrfs: only do the tree_mod_log_free_eb if this is our last ref Greg Kroah-Hartman
2013-07-19  5:26 ` [ 52/72] ext4: fix data offset overflow on 32-bit archs in ext4_inline_data_fiemap() Greg Kroah-Hartman
2013-07-19  5:26 ` [ 53/72] ext4: fix overflows in SEEK_HOLE, SEEK_DATA implementations Greg Kroah-Hartman
2013-07-19  5:26 ` [ 54/72] ext4: fix data offset overflow in ext4_xattr_fiemap() on 32-bit archs Greg Kroah-Hartman
2013-07-19  5:26 ` [ 55/72] ext4: fix overflow when counting used blocks on 32-bit architectures Greg Kroah-Hartman
2013-07-19  5:26 ` Greg Kroah-Hartman [this message]
2013-07-19  5:26 ` [ 57/72] ext4: dont show usrquota/grpquota twice in /proc/mounts Greg Kroah-Hartman
2013-07-19  5:26 ` [ 58/72] ext4: dont allow ext4_free_blocks() to fail due to ENOMEM Greg Kroah-Hartman
2013-07-19  5:26 ` [ 59/72] ARM: 7765/1: perf: Record the user-mode PC in the call chain Greg Kroah-Hartman
2013-07-19  5:26 ` [ 60/72] ARM: 7767/1: let the ASID allocator handle suspended animation Greg Kroah-Hartman
2013-07-19  5:26 ` [ 61/72] ARM: 7768/1: prevent risks of out-of-bound access in ASID allocator Greg Kroah-Hartman
2013-07-19  5:26 ` [ 62/72] ARM: 7769/1: Cortex-A15: fix erratum 798181 implementation Greg Kroah-Hartman
2013-07-19  5:26 ` [ 63/72] ARM: 7778/1: smp_twd: twd_update_frequency need be run on all online CPUs Greg Kroah-Hartman
2013-07-19  5:26 ` [ 64/72] ARM: dts: imx: cpus/cpu nodes dts updates Greg Kroah-Hartman
2013-07-19  5:26 ` [ 65/72] ARM: shmobile: r8a73a4: Fix resources for SCIFB0 Greg Kroah-Hartman
2013-07-19  5:26 ` [ 66/72] ARM: shmobile: emev2 GIO3 resource fix Greg Kroah-Hartman
2013-07-19  5:26 ` [ 67/72] ARM: mm: fix boot on SA1110 Assabet Greg Kroah-Hartman
2013-07-19  5:26 ` [ 68/72] drivers/dma/pl330.c: fix locking in pl330_free_chan_resources() Greg Kroah-Hartman
2013-07-19  5:26 ` [ 69/72] memcg, kmem: fix reference count handling on the error path Greg Kroah-Hartman
2013-07-19  5:26 ` [ 70/72] mm/memory-hotplug: fix lowmem count overflow when offline pages Greg Kroah-Hartman
2013-07-19  5:26 ` [ 71/72] Handle big endianness in NTLM (ntlmv2) authentication Greg Kroah-Hartman
2013-07-19  5:26 ` [ 72/72] UBIFS: correct mount message Greg Kroah-Hartman
2013-07-19  7:27 ` [ 00/72] 3.10.2-stable review Sven Joachim
2013-07-19 15:40   ` Greg Kroah-Hartman
2013-07-21  2:23     ` Satoru Takeuchi
2013-07-19 23:16 ` Shuah Khan
2013-07-19 23:44   ` Greg Kroah-Hartman
2013-07-20  0:17 ` Stefan Lippers-Hollmann
2013-07-20  0:25   ` [please disregard] " Stefan Lippers-Hollmann
2013-07-21  7:56 ` Willy Tarreau
2013-07-21 15:50   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130719052603.685456377@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=lczerner@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhongfs@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox