1. 11 Nov, 2011 7 commits
    • Miao Xie's avatar
      Btrfs: fix orphan backref nodes · 76b9e23d
      Miao Xie authored
      If the root node of a fs/file tree is in the block group that is
      being relocated, but the others are not in the other block groups.
      when we create a snapshot for this tree between the relocation tree
      creation ends and ->create_reloc_tree is set to 0, Btrfs will create
      some backref nodes that are the lowest nodes of the backrefs cache.
      But we forget to add them into ->leaves list of the backref cache
      and deal with them, and at last, they will triggered BUG_ON().
      
        kernel BUG at fs/btrfs/relocation.c:239!
      
      This patch fixes it by adding them into ->leaves list of backref cache.
      Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      76b9e23d
    • Miao Xie's avatar
      Btrfs: Abstract similar code for btrfs_block_rsv_add{, _noflush} · 61b520a9
      Miao Xie authored
      btrfs_block_rsv_add{, _noflush}() have similar code, so abstract that code.
      Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      61b520a9
    • Miao Xie's avatar
      Btrfs: fix unreleased path in btrfs_orphan_cleanup() · 3254c876
      Miao Xie authored
      When we did stress test for the space relocation, the deadlock happened.
      By debugging, We found it was caused by the carelessness that we forgot
      to unlock the read lock of the extent buffers in btrfs_orphan_cleanup()
      before we end the transaction handle, so the transaction commit task waited
      the task, which called btrfs_orphan_cleanup(), to unlock the extent buffer,
      but that task waited the commit task to end the transaction commit, and
      the deadlock happened. Fix it.
      Signed-ff-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      3254c876
    • Miao Xie's avatar
      Btrfs: fix no reserved space for writing out inode cache · ba38eb4d
      Miao Xie authored
      I-node cache forgets to reserve the space when writing out it. And when
      we do some stress test, such as synctest, it will trigger WARN_ON() in
      use_block_rsv().
      
      WARNING: at fs/btrfs/extent-tree.c:5718 btrfs_alloc_free_block+0xbf/0x281 [btrfs]()
      ...
      Call Trace:
       [<ffffffff8104df86>] warn_slowpath_common+0x80/0x98
       [<ffffffff8104dfb3>] warn_slowpath_null+0x15/0x17
       [<ffffffffa0369c60>] btrfs_alloc_free_block+0xbf/0x281 [btrfs]
       [<ffffffff810cbcb8>] ? __set_page_dirty_nobuffers+0xfe/0x108
       [<ffffffffa035c040>] __btrfs_cow_block+0x118/0x3b5 [btrfs]
       [<ffffffffa035c7ba>] btrfs_cow_block+0x103/0x14e [btrfs]
       [<ffffffffa035e4c4>] btrfs_search_slot+0x249/0x6a4 [btrfs]
       [<ffffffffa036d086>] btrfs_lookup_inode+0x2a/0x8a [btrfs]
       [<ffffffffa03788b7>] btrfs_update_inode+0xaa/0x141 [btrfs]
       [<ffffffffa036d7ec>] btrfs_save_ino_cache+0xea/0x202 [btrfs]
       [<ffffffffa03a761e>] ? btrfs_update_reloc_root+0x17e/0x197 [btrfs]
       [<ffffffffa0373867>] commit_fs_roots+0xaa/0x158 [btrfs]
       [<ffffffffa03746a6>] btrfs_commit_transaction+0x405/0x731 [btrfs]
       [<ffffffff810690df>] ? wake_up_bit+0x25/0x25
       [<ffffffffa039d652>] ? btrfs_log_dentry_safe+0x43/0x51 [btrfs]
       [<ffffffffa0381c5f>] btrfs_sync_file+0x16a/0x198 [btrfs]
       [<ffffffff81122806>] ? mntput+0x21/0x23
       [<ffffffff8112d150>] vfs_fsync_range+0x18/0x21
       [<ffffffff8112d170>] vfs_fsync+0x17/0x19
       [<ffffffff8112d316>] do_fsync+0x29/0x3e
       [<ffffffff8112d348>] sys_fsync+0xb/0xf
       [<ffffffff81468352>] system_call_fastpath+0x16/0x1b
      
      Sometimes it causes BUG_ON() in the reservation code of the delayed inode
      is triggered.
      
      So we must reserve enough space for inode cache.
      
      Note: If we can not reserve the enough space for inode cache, we will
      give up writing out it.
      Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      ba38eb4d
    • Miao Xie's avatar
      Btrfs: fix nocow when deleting the item · 924cd8fb
      Miao Xie authored
      btrfs_previous_item() just search the b+ tree, do not COW the nodes or leaves,
      if we modify the result of it, the meta-data will be broken. fix it.
      Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      924cd8fb
    • Chris Mason's avatar
    • Chris Mason's avatar
      Btrfs: tweak the delayed inode reservations again · 2115133f
      Chris Mason authored
      Josef sent along an incremental to the inode reservation
      code to make sure we try and fall back to directly updating
      the inode item if things go horribly wrong.
      
      This reworks that patch slightly, adding a fallback function
      that will always try to update the inode item directly without
      going through the delayed_inode code.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      2115133f
  2. 09 Nov, 2011 5 commits
  3. 08 Nov, 2011 2 commits
    • Josef Bacik's avatar
      Btrfs: fix our reservations for updating an inode when completing io · 7fd2ae21
      Josef Bacik authored
      People have been reporting ENOSPC crashes in finish_ordered_io.  This is because
      we try to steal from the delalloc block rsv to satisfy a reservation to update
      the inode.  The problem with this is we don't explicitly save space for updating
      the inode when doing delalloc.  This is kind of a problem and we've gotten away
      with this because way back when we just stole from the delalloc reserve without
      any questions, and this worked out fine because generally speaking the leaf had
      been modified either by the mtime update when we did the original write or
      because we just updated the leaf when we inserted the file extent item, only on
      rare occasions had the leaf not actually been modified, and that was still ok
      because we'd just use a block or two out of the over-reservation that is
      delalloc.
      
      Then came the delayed inode stuff.  This is amazing, except it wants a full
      reservation for updating the inode since it may do it at some point down the
      road after we've written the blocks and we have to recow everything again.  This
      worked out because the delayed inode stuff just stole from the global reserve,
      that is until recently when I changed that because it caused other problems.
      
      So here we are, we're doing everything right and being screwed for it.  So take
      an extra reservation for the inode at delalloc reservation time and carry it
      through the life of the delalloc reservation.  If we need it we can steal it in
      the delayed inode stuff.  If we have already stolen it try and do a normal
      metadata reservation.  If that fails try to steal from the delalloc reservation.
      If _that_ fails we'll get a WARN_ON() so I can start thinking of a better way to
      solve this and in the meantime we'll steal from the global reserve.
      
      With this patch I ran xfstests 13 in a loop for a couple of hours and didn't see
      any problems.
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      7fd2ae21
    • Chris Mason's avatar
      Btrfs: fix oops on NULL trans handle in btrfs_truncate · 917c16b2
      Chris Mason authored
      If we fail to reserve space in the transaction during truncate, we can
      error out with a NULL trans handle.  The cleanup code needs an extra
      check to make sure we aren't trying to use the bad handle.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      917c16b2
  4. 07 Nov, 2011 1 commit
    • slyich@gmail.com's avatar
      btrfs: fix double-free 'tree_root' in 'btrfs_mount()' · 45ea6095
      slyich@gmail.com authored
      On error path 'tree_root' is treed in 'free_fs_info()'.
      No need to free it explicitely. Noticed by SLUB in debug mode:
      
      Complete reproducer under usermode linux (discovered on real
      machine):
      
          bdev=/dev/ubda
          btr_root=/btr
          /mkfs.btrfs $bdev
          mount $bdev $btr_root
          mkdir $btr_root/subvols/
          cd $btr_root/subvols/
          /btrfs su cr foo
          /btrfs su cr bar
          mount $bdev -osubvol=subvols/foo $btr_root/subvols/bar
          umount $btr_root/subvols/bar
      
      which gives
      
      device fsid 4d55aa28-45b1-474b-b4ec-da912322195e devid 1 transid 7 /dev/ubda
      =============================================================================
      BUG kmalloc-2048: Object already free
      -----------------------------------------------------------------------------
      
      INFO: Allocated in btrfs_mount+0x389/0x7f0 age=0 cpu=0 pid=277
      INFO: Freed in btrfs_mount+0x51c/0x7f0 age=0 cpu=0 pid=277
      INFO: Slab 0x0000000062886200 objects=15 used=9 fp=0x0000000070b4d2d0 flags=0x4081
      INFO: Object 0x0000000070b4d2d0 @offset=21200 fp=0x0000000070b4a968
      ...
      Call Trace:
      70b31948:  [<6008c522>] print_trailer+0xe2/0x130
      70b31978:  [<6008c5aa>] object_err+0x3a/0x50
      70b319a8:  [<6008e242>] free_debug_processing+0x142/0x2a0
      70b319e0:  [<600ebf6f>] btrfs_mount+0x55f/0x7f0
      70b319f8:  [<6008e5c1>] __slab_free+0x221/0x2d0
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      Cc: Arne Jansen <sensille@gmx.net>
      Cc: Chris Mason <chris.mason@oracle.com>
      Cc: David Sterba <dsterba@suse.cz>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      45ea6095
  5. 06 Nov, 2011 22 commits
  6. 24 Oct, 2011 3 commits