1. 12 12月, 2012 1 次提交
  2. 26 10月, 2012 1 次提交
    • M
      Btrfs: fix deadlock caused by the nested chunk allocation · 671415b7
      Miao Xie 提交于
      Steps to reproduce:
       # mkfs.btrfs -m raid1 <disk1> <disk2>
       # btrfstune -S 1 <disk1>
       # mount <disk1> <mnt>
       # btrfs device add <disk3> <disk4> <mnt>
       # mount -o remount,rw <mnt>
       # dd if=/dev/zero of=<mnt>/tmpfile bs=1M count=1
       Deadlock happened.
      
      It is because of the nested chunk allocation. When we wrote the data
      into the filesystem, we would allocate the data chunk because there was
      no data chunk in the filesystem. At the end of the data chunk allocation,
      we should insert the metadata of the data chunk into the extent tree, but
      there was no raid1 chunk, so we tried to lock the chunk allocation mutex to
      allocate the new chunk, but we had held the mutex, the deadlock happened.
      
      By rights, we would allocate the raid1 chunk when we added the second device
      because the profile of the seed filesystem is raid1 and we had two devices.
      But we didn't do that in fact. It is because the last step of the first device
      insertion didn't commit the transaction. So when we added the second device,
      we didn't cow the tree, and just inserted the relative metadata into the leaves
      which were generated by the first device insertion, and its profile was dup.
      
      So, I fix this problem by commiting the transaction at the end of the first
      device insertion.
      Signed-off-by: NMiao Xie <miaox@cn.fujitsu.com>
      671415b7
  3. 09 10月, 2012 3 次提交
    • S
      Btrfs: make filesystem read-only when submitting barrier fails · 5af3e8cc
      Stefan Behrens 提交于
      So far the return code of barrier_all_devices() is ignored, which
      means that errors are ignored. The result can be a corrupt
      filesystem which is not consistent.
      This commit adds code to evaluate the return code of
      barrier_all_devices(). The normal btrfs_error() mechanism is used to
      switch the filesystem into read-only mode when errors are detected.
      
      In order to decide whether barrier_all_devices() should return
      error or success, the number of disks that are allowed to fail the
      barrier submission is calculated. This calculation accounts for the
      worst RAID level of metadata, system and data. If single, dup or
      RAID0 is in use, a single disk error is already considered to be
      fatal. Otherwise a single disk error is tolerated.
      
      The calculation of the number of disks that are tolerated to fail
      the barrier operation is performed when the filesystem gets mounted,
      when a balance operation is started and finished, and when devices
      are added or removed.
      Signed-off-by: NStefan Behrens <sbehrens@giantdisaster.de>
      5af3e8cc
    • D
      btrfs: fix message printing · 48940662
      Daniel J Blueman 提交于
      Fix various messages to include newline and module prefix.
      Signed-off-by: NDaniel J Blueman <daniel@quora.org>
      48940662
    • D
      btrfs: move transaction aborts to the point of failure · 005d6427
      David Sterba 提交于
      Call btrfs_abort_transaction as early as possible when an error
      condition is detected, that way the line number reported is useful
      and we're not clueless anymore which error path led to the abort.
      Signed-off-by: NDavid Sterba <dsterba@suse.cz>
      005d6427
  4. 29 8月, 2012 3 次提交
    • S
      Btrfs: revert checksum error statistic which can cause a BUG() · 5ee0844d
      Stefan Behrens 提交于
      Commit 442a4f63 added btrfs device
      statistic counters for detected IO and checksum errors to Linux 3.5.
      The statistic part that counts checksum errors in
      end_bio_extent_readpage() can cause a BUG() in a subfunction:
      "kernel BUG at fs/btrfs/volumes.c:3762!"
      That part is reverted with the current patch.
      However, the counting of checksum errors in the scrub context remains
      active, and the counting of detected IO errors (read, write or flush
      errors) in all contexts remains active.
      
      Cc: stable <stable@vger.kernel.org> # 3.5
      Signed-off-by: NStefan Behrens <sbehrens@giantdisaster.de>
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      5ee0844d
    • J
      Btrfs: barrier before waitqueue_active · 66657b31
      Josef Bacik 提交于
      We need a barrir before calling waitqueue_active otherwise we will miss
      wakeups.  So in places that do atomic_dec(); then atomic_read() use
      atomic_dec_return() which imply a memory barrier (see memory-barriers.txt)
      and then add an explicit memory barrier everywhere else that need them.
      Thanks,
      Signed-off-by: NJosef Bacik <jbacik@fusionio.com>
      66657b31
    • J
      Btrfs: do not strdup non existent strings · 99f5944b
      Josef Bacik 提交于
      When we close devices we add back empty devices for some reason that escapes
      me.  In the case of a missing dev we don't allocate an rcu_string for it's
      name, so check to see if the device has a name and if it doesn't don't
      bother strdup()'ing it.  Thanks,
      Signed-off-by: NJosef Bacik <jbacik@fusionio.com>
      99f5944b
  5. 04 8月, 2012 1 次提交
  6. 24 7月, 2012 4 次提交
  7. 03 7月, 2012 3 次提交
  8. 15 6月, 2012 1 次提交
    • J
      Btrfs: use rcu to protect device->name · 606686ee
      Josef Bacik 提交于
      Al pointed out that we can just toss out the old name on a device and add a
      new one arbitrarily, so anybody who uses device->name in printk could
      possibly use free'd memory.  Instead of adding locking around all of this he
      suggested doing it with RCU, so I've introduced a struct rcu_string that
      does just that and have gone through and protected all accesses to
      device->name that aren't under the uuid_mutex with rcu_read_lock().  This
      protects us and I will use it for dealing with removing the device that we
      used to mount the file system in a later patch.  Thanks,
      Reviewed-by: NDavid Sterba <dsterba@suse.cz>
      Signed-off-by: NJosef Bacik <josef@redhat.com>
      606686ee
  9. 30 5月, 2012 4 次提交
  10. 28 4月, 2012 1 次提交
  11. 19 4月, 2012 2 次提交
  12. 13 4月, 2012 1 次提交
  13. 29 3月, 2012 1 次提交
    • C
      Btrfs: flush out and clean up any block device pages during mount · 3c4bb26b
      Chris Mason 提交于
      Btrfs puts the filesystem metadata into its own address space, and
      somehow the block device address space isn't getting onto disk properly
      before a mount.  The end result is that a loop of mkfs and mounting the
      filesystem will sometimes find stale or incorrect data.
      
      This commit should fix it by sprinkling fdatawrites and invalidate_bdev
      calls around.  This is a short term measure to make sure it is fixed.
      The block devices really should be flushed and cleaned up higher in the
      stack.
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      3c4bb26b
  14. 27 3月, 2012 7 次提交
  15. 22 3月, 2012 6 次提交
  16. 23 2月, 2012 1 次提交
    • C
      Btrfs: make sure we update latest_bdev · a6b0d5c8
      Chris Mason 提交于
      When we are setting up the mount, we close all the
      devices that were not actually part of the metadata we found.
      
      But, we don't make sure that one of those devices wasn't
      fs_devices->latest_bdev, which means we can do a use after free
      on the one we closed.
      
      This updates latest_bdev as it goes.
      Signed-off-by: NChris Mason <chris.mason@oracle.com>
      a6b0d5c8