1. 25 Oct, 2012 7 commits
    • Miao Xie's avatar
      Btrfs: fix deadlock caused by the nested chunk allocation · 671415b7
      Miao Xie authored
      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: default avatarMiao Xie <miaox@cn.fujitsu.com>
      671415b7
    • Lukas Czerner's avatar
      btrfs: Return EINVAL when length to trim is less than FSB · e515c18b
      Lukas Czerner authored
      Currently if len argument in btrfs_ioctl_fitrim() is smaller than
      one FSB we will continue and finally return 0 bytes discarded.
      However if the length to discard is smaller then file system block
      we should really return EINVAL.
      Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
      e515c18b
    • Tsutomu Itoh's avatar
      Btrfs: fix memory leak in btrfs_quota_enable() · 5b7ff5b3
      Tsutomu Itoh authored
      We should free quota_root before returning from the error
      handling code.
      Signed-off-by: default avatarTsutomu Itoh <t-itoh@jp.fujitsu.com>
      5b7ff5b3
    • Arne Jansen's avatar
      Btrfs: send correct rdev and mode in btrfs-send · d79e5043
      Arne Jansen authored
      When sending a device file, the stream was missing the mode. Also the
      rdev was encoded wrongly.
      Signed-off-by: default avatarArne Jansen <sensille@gmx.net>
      d79e5043
    • Jan Schmidt's avatar
      Btrfs: extended inode refs support for send mechanism · 96b5bd77
      Jan Schmidt authored
      This adds support for the new extended inode refs to btrfs send.
      Signed-off-by: default avatarJan Schmidt <list.btrfs@jan-o-sch.net>
      96b5bd77
    • Stefan Behrens's avatar
      Btrfs: Fix wrong error handling code · 84167d19
      Stefan Behrens authored
      gcc says "warning: comparison of unsigned expression >= 0 is always
      true" because i is an unsigned long. And gcc is right this time.
      Signed-off-by: default avatarStefan Behrens <sbehrens@giantdisaster.de>
      84167d19
    • Gabriel de Perthuis's avatar
      Fix a sign bug causing invalid memory access in the ino_paths ioctl. · 661bec6b
      Gabriel de Perthuis authored
      To see the problem, create many hardlinks to the same file (120 should do it),
      then look up paths by inode with:
      
        ls -i
        btrfs inspect inode-resolve -v $ino /mnt/btrfs
      
      I noticed the memory layout of the fspath->val data had some irregularities
      (some unnecessary gaps that stop appearing about halfway),
      so I'm not sure there aren't any bugs left in it.
      661bec6b
  2. 09 Oct, 2012 33 commits