<feed xmlns='http://www.w3.org/2005/Atom'>
<title>BMC/Intel-BMC/linux.git/fs/btrfs/disk-io.c, branch dev</title>
<subtitle>Intel OpenBMC Linux kernel source tree (mirror)</subtitle>
<id>https://git.radix-linux.su/BMC/Intel-BMC/linux.git/atom?h=dev</id>
<link rel='self' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/atom?h=dev'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/'/>
<updated>2015-08-01T00:05:37+00:00</updated>
<entry>
<title>Merge branch 'for-linus-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs</title>
<updated>2015-08-01T00:05:37+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2015-08-01T00:05:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=acea568fa9eaeffbf949d15b2f7c9c346e16aae3'/>
<id>urn:sha1:acea568fa9eaeffbf949d15b2f7c9c346e16aae3</id>
<content type='text'>
Pull btrfs fixes from Chris Mason:
 "Filipe fixed up a hard to trigger ENOSPC regression from our merge
  window pull, and we have a few other smaller fixes"

* 'for-linus-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  Btrfs: fix quick exhaustion of the system array in the superblock
  btrfs: its btrfs_err() instead of btrfs_error()
  btrfs: Avoid NULL pointer dereference of free_extent_buffer when read_tree_block() fail
  btrfs: Fix lockdep warning of btrfs_run_delayed_iputs()
</content>
</entry>
<entry>
<title>btrfs: Avoid NULL pointer dereference of free_extent_buffer when read_tree_block() fail</title>
<updated>2015-07-23T01:20:52+00:00</updated>
<author>
<name>Zhao Lei</name>
<email>zhaolei@cn.fujitsu.com</email>
</author>
<published>2015-07-15T13:02:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=95ab1f64908795a2edd6b847eca94a0c63a44be4'/>
<id>urn:sha1:95ab1f64908795a2edd6b847eca94a0c63a44be4</id>
<content type='text'>
When read_tree_block() failed, we can see following dmesg:
 [  134.371389] BUG: unable to handle kernel NULL pointer dereference at 0000000000000063
 [  134.372236] IP: [&lt;ffffffff813a4a51&gt;] free_extent_buffer+0x21/0x90
 [  134.372236] PGD 0
 [  134.372236] Oops: 0000 [#1] SMP
 [  134.372236] Modules linked in:
 [  134.372236] CPU: 0 PID: 2289 Comm: mount Not tainted 4.2.0-rc1_HEAD_c65b99f046843d2455aa231747b5a07a999a9f3d_+ #115
 [  134.372236] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5.1-0-g8936dbb-20141113_115728-nilsson.home.kraxel.org 04/01/2014
 [  134.372236] task: ffff88003b6e1a00 ti: ffff880011e60000 task.ti: ffff880011e60000
 [  134.372236] RIP: 0010:[&lt;ffffffff813a4a51&gt;]  [&lt;ffffffff813a4a51&gt;] free_extent_buffer+0x21/0x90
 ...
 [  134.372236] Call Trace:
 [  134.372236]  [&lt;ffffffff81379aa1&gt;] free_root_extent_buffers+0x91/0xb0
 [  134.372236]  [&lt;ffffffff81379c3d&gt;] free_root_pointers+0x17d/0x190
 [  134.372236]  [&lt;ffffffff813801b0&gt;] open_ctree+0x1ca0/0x25b0
 [  134.372236]  [&lt;ffffffff8144d017&gt;] ? disk_name+0x97/0xb0
 [  134.372236]  [&lt;ffffffff813558aa&gt;] btrfs_mount+0x8fa/0xab0
 ...

Reason:
 read_tree_block() changed to return error number on fail,
 and this value(not NULL) is set to tree_root-&gt;node, then subsequent
 code will run to:
  free_root_pointers()
  -&gt;free_root_extent_buffers()
  -&gt;free_extent_buffer()
  -&gt;atomic_read((extent_buffer *)(-E_XXX)-&gt;refs);
 and trigger above error.

Fix:
 Set tree_root-&gt;node to NULL on fail to make error_handle code
 happy.

Signed-off-by: Zhao Lei &lt;zhaolei@cn.fujitsu.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-linus-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs</title>
<updated>2015-07-11T17:26:34+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2015-07-11T17:26:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=31b7a57c9eb3d90c87b6c2b855720ec709d2f6be'/>
<id>urn:sha1:31b7a57c9eb3d90c87b6c2b855720ec709d2f6be</id>
<content type='text'>
Pull btrfs fixes from Chris Mason:
 "This is an assortment of fixes.  Most of the commits are from Filipe
  (fsync, the inode allocation cache and a few others).  Mark kicked in
  a series fixing corners in the extent sharing ioctls, and everyone
  else fixed up on assorted other problems"

* 'for-linus-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
  Btrfs: fix wrong check for btrfs_force_chunk_alloc()
  Btrfs: fix warning of bytes_may_use
  Btrfs: fix hang when failing to submit bio of directIO
  Btrfs: fix a comment in inode.c:evict_inode_truncate_pages()
  Btrfs: fix memory corruption on failure to submit bio for direct IO
  btrfs: don't update mtime/ctime on deduped inodes
  btrfs: allow dedupe of same inode
  btrfs: fix deadlock with extent-same and readpage
  btrfs: pass unaligned length to btrfs_cmp_data()
  Btrfs: fix fsync after truncate when no_holes feature is enabled
  Btrfs: fix fsync xattr loss in the fast fsync path
  Btrfs: fix fsync data loss after append write
  Btrfs: fix crash on close_ctree() if cleaner starts new transaction
  Btrfs: fix race between caching kthread and returning inode to inode cache
  Btrfs: use kmem_cache_free when freeing entry in inode cache
  Btrfs: fix race between balance and unused block group deletion
  btrfs: add error handling for scrub_workers_get()
  btrfs: cleanup noused initialization of dev in btrfs_end_bio()
  btrfs: qgroup: allow user to clear the limitation on qgroup
</content>
</entry>
<entry>
<title>Merge branch 'for-linus-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs</title>
<updated>2015-07-01T03:07:45+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2015-07-01T03:07:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=043cd04950431f206f784d1ed9b3fcc5993045f2'/>
<id>urn:sha1:043cd04950431f206f784d1ed9b3fcc5993045f2</id>
<content type='text'>
Pull btrfs updates from Chris Mason:
 "Outside of our usual batch of fixes, this integrates the subvolume
  quota updates that Qu Wenruo from Fujitsu has been working on for a
  few releases now.  He gets an extra gold star for making btrfs smaller
  this time, and fixing a number of quota corners in the process.

  Dave Sterba tested and integrated Anand Jain's sysfs improvements.
  Outside of exporting a symbol (ack'd by Greg) these are all internal
  to btrfs and it's mostly cleanups and fixes.  Anand also attached some
  of our sysfs objects to our internal device management structs instead
  of an object off the super block.  It will make device management
  easier overall and it's a better fit for how the sysfs files are used.
  None of the existing sysfs files are moved around.

  Thanks for all the fixes everyone"

* 'for-linus-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: (87 commits)
  btrfs: delayed-ref: double free in btrfs_add_delayed_tree_ref()
  Btrfs: Check if kobject is initialized before put
  lib: export symbol kobject_move()
  Btrfs: sysfs: add support to show replacing target in the sysfs
  Btrfs: free the stale device
  Btrfs: use received_uuid of parent during send
  Btrfs: fix use-after-free in btrfs_replay_log
  btrfs: wait for delayed iputs on no space
  btrfs: qgroup: Make snapshot accounting work with new extent-oriented qgroup.
  btrfs: qgroup: Add the ability to skip given qgroup for old/new_roots.
  btrfs: ulist: Add ulist_del() function.
  btrfs: qgroup: Cleanup the old ref_node-oriented mechanism.
  btrfs: qgroup: Switch self test to extent-oriented qgroup mechanism.
  btrfs: qgroup: Switch to new extent-oriented qgroup mechanism.
  btrfs: qgroup: Switch rescan to new mechanism.
  btrfs: qgroup: Add new qgroup calculation function btrfs_qgroup_account_extents().
  btrfs: backref: Add special time_seq == (u64)-1 case for btrfs_find_all_roots().
  btrfs: qgroup: Add new function to record old_roots.
  btrfs: qgroup: Record possible quota-related extent for qgroup.
  btrfs: qgroup: Add function qgroup_update_counters().
  ...
</content>
</entry>
<entry>
<title>Btrfs: fix crash on close_ctree() if cleaner starts new transaction</title>
<updated>2015-06-30T21:36:46+00:00</updated>
<author>
<name>Filipe Manana</name>
<email>fdmanana@suse.com</email>
</author>
<published>2015-06-13T05:55:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=da288d280d16f4d7e4ada331cb33d381b408b10c'/>
<id>urn:sha1:da288d280d16f4d7e4ada331cb33d381b408b10c</id>
<content type='text'>
Often when running fstests btrfs/079 I was running into the following
trace during umount on one of my qemu/kvm test vms:

[ 8245.682441] WARNING: CPU: 8 PID: 25064 at fs/btrfs/extent-tree.c:138 btrfs_put_block_group+0x51/0x69 [btrfs]()
[ 8245.685039] Modules linked in: btrfs dm_flakey dm_mod crc32c_generic xor raid6_pq nfsd auth_rpcgss oid_registry nfs_acl nfs lockd grace fscache sunrpc loop fuse parport_pc i2c_piix4 acpi_cpufreq processor psmouse i2c_core thermal_sys parport evdev serio_raw button pcspkr microcode ext4 crc16 jbd2 mbcache sg sr_mod cdrom sd_mod ata_generic virtio_scsi ata_piix libata floppy virtio_pci virtio_ring scsi_mod virtio e1000 [last unloaded: btrfs]
[ 8245.693860] CPU: 8 PID: 25064 Comm: umount Tainted: G        W       4.1.0-rc5-btrfs-next-10+ #1
[ 8245.695081] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.1-0-g4adadbd-20150316_085822-nilsson.home.kraxel.org 04/01/2014
[ 8245.697583]  0000000000000009 ffff88020d047ce8 ffffffff8145eec7 ffffffff81095dce
[ 8245.699234]  0000000000000000 ffff88020d047d28 ffffffff8104b399 0000000000000028
[ 8245.700995]  ffffffffa04db07b ffff8801c6036c00 ffff8801c6036d68 ffff880202eb40b0
[ 8245.702510] Call Trace:
[ 8245.703006]  [&lt;ffffffff8145eec7&gt;] dump_stack+0x4f/0x7b
[ 8245.705393]  [&lt;ffffffff81095dce&gt;] ? console_unlock+0x356/0x3a2
[ 8245.706569]  [&lt;ffffffff8104b399&gt;] warn_slowpath_common+0xa1/0xbb
[ 8245.707747]  [&lt;ffffffffa04db07b&gt;] ? btrfs_put_block_group+0x51/0x69 [btrfs]
[ 8245.709101]  [&lt;ffffffff8104b456&gt;] warn_slowpath_null+0x1a/0x1c
[ 8245.710274]  [&lt;ffffffffa04db07b&gt;] btrfs_put_block_group+0x51/0x69 [btrfs]
[ 8245.711823]  [&lt;ffffffffa04e3473&gt;] btrfs_free_block_groups+0x145/0x322 [btrfs]
[ 8245.713251]  [&lt;ffffffffa04ef31a&gt;] close_ctree+0x1ef/0x325 [btrfs]
[ 8245.714448]  [&lt;ffffffff8117d26e&gt;] ? evict_inodes+0xdc/0xeb
[ 8245.715539]  [&lt;ffffffffa04cb3ad&gt;] btrfs_put_super+0x19/0x1b [btrfs]
[ 8245.716835]  [&lt;ffffffff81167607&gt;] generic_shutdown_super+0x73/0xef
[ 8245.718015]  [&lt;ffffffff81167a3a&gt;] kill_anon_super+0x13/0x1e
[ 8245.719101]  [&lt;ffffffffa04cb1b6&gt;] btrfs_kill_super+0x17/0x23 [btrfs]
[ 8245.720316]  [&lt;ffffffff81167544&gt;] deactivate_locked_super+0x3b/0x68
[ 8245.721517]  [&lt;ffffffff81167dd6&gt;] deactivate_super+0x3f/0x43
[ 8245.722581]  [&lt;ffffffff8117fbb9&gt;] cleanup_mnt+0x59/0x78
[ 8245.723538]  [&lt;ffffffff8117fc18&gt;] __cleanup_mnt+0x12/0x14
[ 8245.724572]  [&lt;ffffffff81065371&gt;] task_work_run+0x8f/0xbc
[ 8245.725598]  [&lt;ffffffff810028fb&gt;] do_notify_resume+0x45/0x53
[ 8245.726892]  [&lt;ffffffff814651ac&gt;] int_signal+0x12/0x17
[ 8245.737887] ---[ end trace a01d038397e99b92 ]---
[ 8245.769363] general protection fault: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
[ 8245.770737] Modules linked in: btrfs dm_flakey dm_mod crc32c_generic xor raid6_pq nfsd auth_rpcgss oid_registry nfs_acl nfs lockd grace fscache sunrpc loop fuse parport_pc i2c_piix4 acpi_cpufreq processor psmouse i2c_core thermal_sys parport evdev serio_raw button pcspkr microcode ext4 crc16 jbd2 mbcache sg sr_mod cdrom sd_mod ata_generic virtio_scsi ata_piix libata floppy virtio_pci virtio_ring scsi_mod virtio e1000 [last unloaded: btrfs]
[ 8245.772641] CPU: 2 PID: 25064 Comm: umount Tainted: G        W       4.1.0-rc5-btrfs-next-10+ #1
[ 8245.772641] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.1-0-g4adadbd-20150316_085822-nilsson.home.kraxel.org 04/01/2014
[ 8245.772641] task: ffff880013005810 ti: ffff88020d044000 task.ti: ffff88020d044000
[ 8245.772641] RIP: 0010:[&lt;ffffffffa051c8e6&gt;]  [&lt;ffffffffa051c8e6&gt;] btrfs_queue_work+0x2c/0x14d [btrfs]
[ 8245.772641] RSP: 0018:ffff88020d0478b8  EFLAGS: 00010202
[ 8245.772641] RAX: 0000000000000004 RBX: 6b6b6b6b6b6b6b6b RCX: ffffffffa0581488
[ 8245.772641] RDX: 0000000000000000 RSI: ffff880194b7bf48 RDI: ffff880144b6a7a0
[ 8245.772641] RBP: ffff88020d0478d8 R08: 0000000000000000 R09: 000000000000ffff
[ 8245.772641] R10: 0000000000000004 R11: 0000000000000005 R12: ffff880194b7bf48
[ 8245.772641] R13: ffff880194b7bf48 R14: 0000000000000410 R15: 0000000000000000
[ 8245.772641] FS:  00007f991e77d840(0000) GS:ffff88023e280000(0000) knlGS:0000000000000000
[ 8245.772641] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[ 8245.772641] CR2: 00007fbbd325ee68 CR3: 000000021de8e000 CR4: 00000000000006e0
[ 8245.772641] Stack:
[ 8245.772641]  ffff880194b7bf00 ffff880202eb4000 ffff880194b7bf48 0000000000000410
[ 8245.772641]  ffff88020d047958 ffffffffa04ec6d5 ffff8801629b2ee8 0000000082987570
[ 8245.772641]  0000000000a5813f 0000000000000001 ffff880013006100 0000000000000002
[ 8245.772641] Call Trace:
[ 8245.772641]  [&lt;ffffffffa04ec6d5&gt;] btrfs_wq_submit_bio+0xe1/0x17b [btrfs]
[ 8245.772641]  [&lt;ffffffff81086bff&gt;] ? check_irq_usage+0x76/0x87
[ 8245.772641]  [&lt;ffffffffa04ec825&gt;] btree_submit_bio_hook+0xb6/0xd9 [btrfs]
[ 8245.772641]  [&lt;ffffffffa04ebb7c&gt;] ? btree_csum_one_bio+0xad/0xad [btrfs]
[ 8245.772641]  [&lt;ffffffffa04eb1a6&gt;] ? btree_io_failed_hook+0x5e/0x5e [btrfs]
[ 8245.772641]  [&lt;ffffffffa050a6e7&gt;] submit_one_bio+0x8c/0xc7 [btrfs]
[ 8245.772641]  [&lt;ffffffffa050d75b&gt;] submit_extent_page.isra.18+0x9d/0x186 [btrfs]
[ 8245.772641]  [&lt;ffffffffa050d95b&gt;] write_one_eb+0x117/0x1ae [btrfs]
[ 8245.772641]  [&lt;ffffffffa050a79b&gt;] ? end_extent_buffer_writeback+0x21/0x21 [btrfs]
[ 8245.772641]  [&lt;ffffffffa0510510&gt;] btree_write_cache_pages+0x2ab/0x385 [btrfs]
[ 8245.772641]  [&lt;ffffffffa04eb2b8&gt;] btree_writepages+0x23/0x5c [btrfs]
[ 8245.772641]  [&lt;ffffffff8111c661&gt;] do_writepages+0x23/0x2c
[ 8245.772641]  [&lt;ffffffff81189cd4&gt;] __writeback_single_inode+0xda/0x5bd
[ 8245.772641]  [&lt;ffffffff8118aa60&gt;] ? writeback_single_inode+0x2b/0x173
[ 8245.772641]  [&lt;ffffffff8118aafd&gt;] writeback_single_inode+0xc8/0x173
[ 8245.772641]  [&lt;ffffffff8118ac95&gt;] write_inode_now+0x8a/0x95
[ 8245.772641]  [&lt;ffffffff81247bf0&gt;] ? _atomic_dec_and_lock+0x30/0x4e
[ 8245.772641]  [&lt;ffffffff8117cc5e&gt;] iput+0x17d/0x26a
[ 8245.772641]  [&lt;ffffffffa04ef355&gt;] close_ctree+0x22a/0x325 [btrfs]
[ 8245.772641]  [&lt;ffffffff8117d26e&gt;] ? evict_inodes+0xdc/0xeb
[ 8245.772641]  [&lt;ffffffffa04cb3ad&gt;] btrfs_put_super+0x19/0x1b [btrfs]
[ 8245.772641]  [&lt;ffffffff81167607&gt;] generic_shutdown_super+0x73/0xef
[ 8245.772641]  [&lt;ffffffff81167a3a&gt;] kill_anon_super+0x13/0x1e
[ 8245.772641]  [&lt;ffffffffa04cb1b6&gt;] btrfs_kill_super+0x17/0x23 [btrfs]
[ 8245.772641]  [&lt;ffffffff81167544&gt;] deactivate_locked_super+0x3b/0x68
[ 8245.772641]  [&lt;ffffffff81167dd6&gt;] deactivate_super+0x3f/0x43
[ 8245.772641]  [&lt;ffffffff8117fbb9&gt;] cleanup_mnt+0x59/0x78
[ 8245.772641]  [&lt;ffffffff8117fc18&gt;] __cleanup_mnt+0x12/0x14
[ 8245.772641]  [&lt;ffffffff81065371&gt;] task_work_run+0x8f/0xbc
[ 8245.772641]  [&lt;ffffffff810028fb&gt;] do_notify_resume+0x45/0x53
[ 8245.772641]  [&lt;ffffffff814651ac&gt;] int_signal+0x12/0x17
[ 8245.772641] Code: 1f 44 00 00 55 48 89 e5 41 56 41 55 41 54 53 49 89 f4 48 8b 46 70 a8 04 74 09 48 8b 5f 08 48 85 db 75 03 48 8b 1f 49 89 5c 24 68 &lt;83&gt; 7b 5c ff 74 04 f0 ff 43 50 49 83 7c 24 08 00 74 2c 4c 8d 6b
[ 8245.772641] RIP  [&lt;ffffffffa051c8e6&gt;] btrfs_queue_work+0x2c/0x14d [btrfs]
[ 8245.772641]  RSP &lt;ffff88020d0478b8&gt;
[ 8245.845040] ---[ end trace a01d038397e99b93 ]---

For logical reasons such as the phase of the moon, this happened more
often with "-o inode_cache" than without any mount options.

After some debugging it turned out to be simple to understand what was
happening:

1) close_ctree() is called;

2) It then stops the transaction kthread, which commits the current
   transaction;

3) It asks the cleaner kthread to stop, which is currently running
   btrfs_delete_unused_bgs();

4) btrfs_delete_unused_bgs() finds an unused block group, starts a new
   transaction, deletes the block group, which implies COWing some
   tree nodes and leafs and dirtying their respective pages, and then
   finally it ends the transaction it started, without committing it;

5) The cleaner kthread stops;

6) close_ctree() releases (from memory) the block group objects, which
   produces the warning in the trace pasted above;

7) Then it invalidates all pages of the btree inode, by calling
   invalidate_inode_pages2(), which waits for any pages under writeback,
   and releases any non-dirty pages;

8) All work queues are destroyed (waiting first for their current tasks
   to finish execution);

9) A final iput() is called against the btree inode;

10) This iput triggers a writeback of the btree inode because it still
    has dirty pages;

11) This starts the whole chain of callbacks for the btree inode until
    it eventually reaches btrfs_wq_submit_bio() where it leads to a
    NULL pointer dereference because the work queues were already
    destroyed.

Fix this by making the cleaner commit any transaction that it started
after the transaction kthread was stopped.

Signed-off-by: Filipe Manana &lt;fdmanana@suse.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
</entry>
<entry>
<title>Btrfs: fix race between balance and unused block group deletion</title>
<updated>2015-06-30T21:36:46+00:00</updated>
<author>
<name>Filipe Manana</name>
<email>fdmanana@suse.com</email>
</author>
<published>2015-06-10T23:58:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=67c5e7d464bc466471b05e027abe8a6b29687ebd'/>
<id>urn:sha1:67c5e7d464bc466471b05e027abe8a6b29687ebd</id>
<content type='text'>
We have a race between deleting an unused block group and balancing the
same block group that leads to an assertion failure/BUG(), producing the
following trace:

[181631.208236] BTRFS: assertion failed: 0, file: fs/btrfs/volumes.c, line: 2622
[181631.220591] ------------[ cut here ]------------
[181631.222959] kernel BUG at fs/btrfs/ctree.h:4062!
[181631.223932] invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
[181631.224566] Modules linked in: btrfs dm_flakey dm_mod crc32c_generic xor raid6_pq nfsd auth_rpcgss oid_registry nfs_acl nfs lockd grace fscache sunrpc loop fuse acpi_cpufreq parpor$
[181631.224566] CPU: 8 PID: 17451 Comm: btrfs Tainted: G        W       4.1.0-rc5-btrfs-next-10+ #1
[181631.224566] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.8.1-0-g4adadbd-20150316_085822-nilsson.home.kraxel.org 04/01/2014
[181631.224566] task: ffff880127e09590 ti: ffff8800b5824000 task.ti: ffff8800b5824000
[181631.224566] RIP: 0010:[&lt;ffffffffa03f19f6&gt;]  [&lt;ffffffffa03f19f6&gt;] assfail.constprop.50+0x1e/0x20 [btrfs]
[181631.224566] RSP: 0018:ffff8800b5827ae8  EFLAGS: 00010246
[181631.224566] RAX: 0000000000000040 RBX: ffff8800109fc218 RCX: ffffffff81095dce
[181631.224566] RDX: 0000000000005124 RSI: ffffffff81464819 RDI: 00000000ffffffff
[181631.224566] RBP: ffff8800b5827ae8 R08: 0000000000000001 R09: 0000000000000000
[181631.224566] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8800109fc200
[181631.224566] R13: ffff880020095000 R14: ffff8800b1a13f38 R15: ffff880020095000
[181631.224566] FS:  00007f70ca0b0c80(0000) GS:ffff88013ec00000(0000) knlGS:0000000000000000
[181631.224566] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[181631.224566] CR2: 00007f2872ab6e68 CR3: 00000000a717c000 CR4: 00000000000006e0
[181631.224566] Stack:
[181631.224566]  ffff8800b5827ba8 ffffffffa03f3916 ffff8800b5827b38 ffffffffa03d080e
[181631.224566]  ffffffffa03d1423 ffff880020095000 ffff88001233c000 0000000000000001
[181631.224566]  ffff880020095000 ffff8800b1a13f38 0000000a69c00000 0000000000000000
[181631.224566] Call Trace:
[181631.224566]  [&lt;ffffffffa03f3916&gt;] btrfs_remove_chunk+0xa4/0x6bb [btrfs]
[181631.224566]  [&lt;ffffffffa03d080e&gt;] ? join_transaction.isra.8+0xb9/0x3ba [btrfs]
[181631.224566]  [&lt;ffffffffa03d1423&gt;] ? wait_current_trans.isra.13+0x22/0xfc [btrfs]
[181631.224566]  [&lt;ffffffffa03f3fbc&gt;] btrfs_relocate_chunk.isra.29+0x8f/0xa7 [btrfs]
[181631.224566]  [&lt;ffffffffa03f54df&gt;] btrfs_balance+0xaa4/0xc52 [btrfs]
[181631.224566]  [&lt;ffffffffa03fd388&gt;] btrfs_ioctl_balance+0x23f/0x2b0 [btrfs]
[181631.224566]  [&lt;ffffffff810872f9&gt;] ? trace_hardirqs_on+0xd/0xf
[181631.224566]  [&lt;ffffffffa04019a3&gt;] btrfs_ioctl+0xfe2/0x2220 [btrfs]
[181631.224566]  [&lt;ffffffff812603ed&gt;] ? __this_cpu_preempt_check+0x13/0x15
[181631.224566]  [&lt;ffffffff81084669&gt;] ? arch_local_irq_save+0x9/0xc
[181631.224566]  [&lt;ffffffff81138def&gt;] ? handle_mm_fault+0x834/0xcd2
[181631.224566]  [&lt;ffffffff81138def&gt;] ? handle_mm_fault+0x834/0xcd2
[181631.224566]  [&lt;ffffffff8103e48c&gt;] ? __do_page_fault+0x211/0x424
[181631.224566]  [&lt;ffffffff811755e6&gt;] do_vfs_ioctl+0x3c6/0x479
(...)

The sequence of steps leading to this are:

           CPU 0                                         CPU 1

  btrfs_balance()
    btrfs_relocate_chunk()

      btrfs_relocate_block_group(bg X)
        btrfs_lookup_block_group(bg X)

                                               cleaner_kthread
                                                  locks fs_info-&gt;cleaner_mutex

                                                  btrfs_delete_unused_bgs()
                                                    finds bg X, which became
                                                    unused in the previous
                                                    transaction

                                                    checks bg X -&gt;ro == 0,
                                                    so it proceeds
        sets bg X -&gt;ro to 1
        (btrfs_set_block_group_ro(bg X))

        blocks on fs_info-&gt;cleaner_mutex
                                                    btrfs_remove_chunk(bg X)
                                                  unlocks fs_info-&gt;cleaner_mutex

        acquires fs_info-&gt;cleaner_mutex
        relocate_block_group()
          --&gt; does nothing, no extents found in
              the extent tree from bg X
        unlocks fs_info-&gt;cleaner_mutex

      btrfs_relocate_block_group(bg X) returns

    btrfs_remove_chunk(bg X)
       extent map not found
          --&gt; ASSERT(0)

Fix this by using a new mutex to make sure these 2 operations, block
group relocation and removal, are serialized.

This issue is reproducible by running fstests generic/038 (which stresses
chunk allocation and automatic removal of unused block groups) together
with the following balance loop:

    while true; do btrfs balance start -dusage=0 &lt;mountpoint&gt; ; done

Signed-off-by: Filipe Manana &lt;fdmanana@suse.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'sysfs-fsdevices-4.2-part1' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into anand</title>
<updated>2015-06-23T12:34:39+00:00</updated>
<author>
<name>Chris Mason</name>
<email>clm@fb.com</email>
</author>
<published>2015-06-23T12:34:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=c40b7b064f6159df3a080595a498613d08206e59'/>
<id>urn:sha1:c40b7b064f6159df3a080595a498613d08206e59</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Btrfs: fix use-after-free in btrfs_replay_log</title>
<updated>2015-06-12T18:03:21+00:00</updated>
<author>
<name>Liu Bo</name>
<email>bo.li.liu@oracle.com</email>
</author>
<published>2015-06-11T06:16:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=0eeff2362b829b5e80f8b69f86b60b8094bc742d'/>
<id>urn:sha1:0eeff2362b829b5e80f8b69f86b60b8094bc742d</id>
<content type='text'>
@log_root_tree should not be referenced after kfree.

Signed-off-by: Liu Bo &lt;bo.li.liu@oracle.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.cz&gt;
Reported-by: Julia Lawall &lt;julia.lawall@lip6.fr&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
</entry>
<entry>
<title>btrfs: delayed-ref: Use list to replace the ref_root in ref_head.</title>
<updated>2015-06-10T16:25:03+00:00</updated>
<author>
<name>Qu Wenruo</name>
<email>quwenruo@cn.fujitsu.com</email>
</author>
<published>2015-03-30T09:03:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=c6fc24549960f26910cd0c6e4b5f48f2f306b11d'/>
<id>urn:sha1:c6fc24549960f26910cd0c6e4b5f48f2f306b11d</id>
<content type='text'>
This patch replace the rbtree used in ref_head to list.
This has the following advantage:
1) Easier merge logic.
With the new list implement, we only need to care merging the tail
ref_node with the new ref_node.
And this can be done quite easy at insert time, no need to do a
indicated merge at run_delayed_refs().

Signed-off-by: Qu Wenruo &lt;quwenruo@cn.fujitsu.com&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
</entry>
<entry>
<title>Btrfs: fix up read_tree_block to return proper error</title>
<updated>2015-06-03T11:03:08+00:00</updated>
<author>
<name>Liu Bo</name>
<email>bo.li.liu@oracle.com</email>
</author>
<published>2015-05-25T09:30:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=64c043de466d5746e7ca306dab9d418cd871cefc'/>
<id>urn:sha1:64c043de466d5746e7ca306dab9d418cd871cefc</id>
<content type='text'>
The return value of read_tree_block() can confuse callers as it always
returns NULL for either -ENOMEM or -EIO, so it's likely that callers
parse it to a wrong error, for instance, in btrfs_read_tree_root().

This fixes the above issue.

Signed-off-by: Liu Bo &lt;bo.li.liu@oracle.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.cz&gt;
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
</entry>
</feed>
