linux/fs/ext4
Dmitry Monakhov 5d3ee20855 ext4: fix journal callback list traversal
It is incorrect to use list_for_each_entry_safe() for journal callback
traversial because ->next may be removed by other task:
->ext4_mb_free_metadata()
  ->ext4_mb_free_metadata()
    ->ext4_journal_callback_del()

This results in the following issue:

WARNING: at lib/list_debug.c:62 __list_del_entry+0x1c0/0x250()
Hardware name:
list_del corruption. prev->next should be ffff88019a4ec198, but was 6b6b6b6b6b6b6b6b
Modules linked in: cpufreq_ondemand acpi_cpufreq freq_table mperf coretemp kvm_intel kvm crc32c_intel ghash_clmulni_intel microcode sg xhci_hcd button sd_mod crc_t10dif aesni_intel ablk_helper cryptd lrw aes_x86_64 xts gf128mul ahci libahci pata_acpi ata_generic dm_mirror dm_region_hash dm_log dm_mod
Pid: 16400, comm: jbd2/dm-1-8 Tainted: G        W    3.8.0-rc3+ #107
Call Trace:
 [<ffffffff8106fb0d>] warn_slowpath_common+0xad/0xf0
 [<ffffffff8106fc06>] warn_slowpath_fmt+0x46/0x50
 [<ffffffff813637e9>] ? ext4_journal_commit_callback+0x99/0xc0
 [<ffffffff8148cae0>] __list_del_entry+0x1c0/0x250
 [<ffffffff813637bf>] ext4_journal_commit_callback+0x6f/0xc0
 [<ffffffff813ca336>] jbd2_journal_commit_transaction+0x23a6/0x2570
 [<ffffffff8108aa42>] ? try_to_del_timer_sync+0x82/0xa0
 [<ffffffff8108b491>] ? del_timer_sync+0x91/0x1e0
 [<ffffffff813d3ecf>] kjournald2+0x19f/0x6a0
 [<ffffffff810ad630>] ? wake_up_bit+0x40/0x40
 [<ffffffff813d3d30>] ? bit_spin_lock+0x80/0x80
 [<ffffffff810ac6be>] kthread+0x10e/0x120
 [<ffffffff810ac5b0>] ? __init_kthread_worker+0x70/0x70
 [<ffffffff818ff6ac>] ret_from_fork+0x7c/0xb0
 [<ffffffff810ac5b0>] ? __init_kthread_worker+0x70/0x70

This patch fix the issue as follows:
- ext4_journal_commit_callback() make list truly traversial safe
  simply by always starting from list_head
- fix race between two ext4_journal_callback_del() and
  ext4_journal_callback_try_del()

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: stable@vger.kernel.com
2013-04-03 22:08:52 -04:00
..
Kconfig ext4: fix configuration dependencies for ext4 ACLs and security labels 2013-01-06 23:38:44 -05:00
Makefile ext4: Remove CONFIG_EXT4_FS_XATTR 2012-12-10 16:30:43 -05:00
acl.c ext4: fix the number of credits needed for acl ops with inline data 2013-02-09 15:23:03 -05:00
acl.h fs: take the ACL checks to common code 2011-07-25 14:30:23 -04:00
balloc.c ext4: convert number of blocks to clusters properly 2013-03-02 17:18:58 -05:00
bitmap.c ext4: Checksum the block bitmap properly with bigalloc enabled 2012-10-22 00:34:32 -04:00
block_validity.c ext2/3/4: delete unneeded includes of module.h 2012-01-09 13:52:10 +01:00
dir.c Various bug fixes for ext4. The most important is a fix for the new 2013-03-02 19:33:21 -08:00
ext4.h ext4: support simple conversion of extent-mapped inodes to use i_blocks 2013-04-03 22:04:52 -04:00
ext4_extents.h ext4: remove single extent cache 2013-02-18 00:31:07 -05:00
ext4_jbd2.c ext4: add might_sleep() annotations 2013-04-03 22:00:52 -04:00
ext4_jbd2.h ext4: fix journal callback list traversal 2013-04-03 22:08:52 -04:00
extents.c ext4: support simple conversion of extent-mapped inodes to use i_blocks 2013-04-03 22:04:52 -04:00
extents_status.c ext4: update extent status tree after an extent is zeroed out 2013-03-10 21:13:05 -04:00
extents_status.h ext4: update extent status tree after an extent is zeroed out 2013-03-10 21:13:05 -04:00
file.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-02-26 20:16:07 -08:00
fsync.c ext4/jbd2: don't wait (forever) for stale tid caused by wraparound 2013-04-03 22:02:52 -04:00
hash.c ext4: reduce one "if" comparison in ext4_dirhash() 2013-02-01 22:33:21 -05:00
ialloc.c ext4: use atomic64_t for the per-flexbg free_clusters count 2013-03-11 23:39:59 -04:00
indirect.c ext4: refactor truncate code 2013-04-03 12:47:17 -04:00
inline.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-02-26 20:16:07 -08:00
inode.c ext4/jbd2: don't wait (forever) for stale tid caused by wraparound 2013-04-03 22:02:52 -04:00
ioctl.c ext4: support simple conversion of extent-mapped inodes to use i_blocks 2013-04-03 22:04:52 -04:00
mballoc.c ext4: fix journal callback list traversal 2013-04-03 22:08:52 -04:00
mballoc.h ext4: use module parameters instead of debugfs for mballoc_debug 2013-02-09 16:28:20 -05:00
migrate.c ext4: fix the number of credits needed for ext4_ext_migrate() 2013-02-09 12:50:27 -05:00
mmp.c ext4: use unlikely to improve the efficiency of the kernel 2013-01-12 16:28:47 -05:00
move_extent.c Fix a number of regression and other bugs in ext4, most of which were 2013-03-21 17:56:10 -07:00
namei.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-02-26 20:16:07 -08:00
page-io.c ext4: fix ext4_evict_inode() racing against workqueue processing code 2013-03-20 09:39:42 -04:00
resize.c ext4: use atomic64_t for the per-flexbg free_clusters count 2013-03-11 23:39:59 -04:00
super.c ext4: fix journal callback list traversal 2013-04-03 22:08:52 -04:00
symlink.c ext4: Remove CONFIG_EXT4_FS_XATTR 2012-12-10 16:30:43 -05:00
truncate.h ext4: move common truncate functions to header file 2011-06-27 19:16:04 -04:00
xattr.c ext4: fix xattr block allocation/release with bigalloc 2013-02-18 12:12:07 -05:00
xattr.h ext4: fix the number of credits needed for acl ops with inline data 2013-02-09 15:23:03 -05:00
xattr_security.c Merge branch 'for_linus' into for_linus_merged 2012-01-10 11:54:07 -05:00
xattr_trusted.c ext2/3/4: delete unneeded includes of module.h 2012-01-09 13:52:10 +01:00
xattr_user.c ext2/3/4: delete unneeded includes of module.h 2012-01-09 13:52:10 +01:00