1. 29 Nov, 2010 2 commits
  2. 27 Nov, 2010 6 commits
    • Josef Bacik's avatar
      Btrfs: setup blank root and fs_info for mount time · 450ba0ea
      Josef Bacik authored
      There is a problem with how we use sget, it searches through the list of supers
      attached to the fs_type looking for a super with the same fs_devices as what
      we're trying to mount.  This depends on sb->s_fs_info being filled, but we don't
      fill that in until we get to btrfs_fill_super, so we could hit supers on the
      fs_type super list that have a null s_fs_info.  In order to fix that we need to
      go ahead and setup a blank root with a blank fs_info to hold fs_devices, that
      way our test will work out right and then we can set s_fs_info in
      btrfs_set_super, and then open_ctree will simply use our pre-allocated root and
      fs_info when setting everything up.  Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      450ba0ea
    • Josef Bacik's avatar
      Btrfs: fix fiemap · 975f84fe
      Josef Bacik authored
      There are two big problems currently with FIEMAP
      
      1) We return extents for holes.  This isn't supposed to happen, we just don't
      return extents for holes and then userspace interprets the lack of an extent as
      a hole.
      
      2) We sometimes don't set FIEMAP_EXTENT_LAST properly.  This is because we wait
      to see a EXTENT_FLAG_VACANCY flag on the em, but this won't happen if say we ask
      fiemap to map up to the last extent in a file, and there is nothing but holes up
      to the i_size.  To fix this we need to lookup the last extent in this file and
      save the logical offset, so if we happen to try and map that extent we can be
      sure to set FIEMAP_EXTENT_LAST.
      
      With this patch we now pass xfstest 225, which we never have before.
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      975f84fe
    • Ian Kent's avatar
      Btrfs - fix race between btrfs_get_sb() and umount · 619c8c76
      Ian Kent authored
      When mounting a btrfs file system btrfs_test_super() may attempt to
      use sb->s_fs_info, the btrfs root, of a super block that is going away
      and that has had the btrfs root set to NULL in its ->put_super(). But
      if the super block is going away it cannot be an existing super block
      so we can return false in this case.
      Signed-off-by: default avatarIan Kent <raven@themaw.net>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      619c8c76
    • Josef Bacik's avatar
      Btrfs: update inode ctime when using links · bc1cbf1f
      Josef Bacik authored
      Currently we fail xfstest 236 because we're not updating the inode ctime on
      link.  This is a simple fix, and makes it so we pass 236 now.
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      bc1cbf1f
    • Josef Bacik's avatar
      Btrfs: make sure new inode size is ok in fallocate · 0ed42a63
      Josef Bacik authored
      We have been failing xfstest 228 forever, because we don't check to make sure
      the new inode size is acceptable as far as RLIMIT is concerned.  Just check to
      make sure it's ok to create a inode with this new size and error out if not.
      With this patch we now pass 228.
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      0ed42a63
    • Josef Bacik's avatar
      Btrfs: fix typo in fallocate to make it honor actual size · 55a61d1d
      Josef Bacik authored
      There is a typo in __btrfs_prealloc_file_range() where we set the i_size to
      actual_len/cur_offset, and then just set it to cur_offset again, and do the same
      with btrfs_ordered_update_i_size().  This fixes it back to keeping i_size in a
      local variable and then updating i_size properly.  Tested this with
      
      xfs_io -F -f -c "falloc 0 1" -c "pwrite 0 1" foo
      
      stat'ing foo gives us a size of 1 instead of 4096 like it was.  Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      55a61d1d
  3. 22 Nov, 2010 16 commits
  4. 30 Oct, 2010 4 commits
  5. 29 Oct, 2010 12 commits
    • Sage Weil's avatar
      Btrfs: add START_SYNC, WAIT_SYNC ioctls · 46204592
      Sage Weil authored
      START_SYNC will start a sync/commit, but not wait for it to
      complete.  Any modification started after the ioctl returns is
      guaranteed not to be included in the commit.  If a non-NULL
      pointer is passed, the transaction id will be returned to
      userspace.
      
      WAIT_SYNC will wait for any in-progress commit to complete.  If a
      transaction id is specified, the ioctl will block and then
      return (success) when the specified transaction has committed.
      If it has already committed when we call the ioctl, it returns
      immediately.  If the specified transaction doesn't exist, it
      returns EINVAL.
      
      If no transaction id is specified, WAIT_SYNC will wait for the
      currently committing transaction to finish it's commit to disk.
      If there is no currently committing transaction, it returns
      success.
      
      These ioctls are useful for applications which want to impose an
      ordering on when fs modifications reach disk, but do not want to
      wait for the full (slow) commit process to do so.
      
      Picky callers can take the transid returned by START_SYNC and
      feed it to WAIT_SYNC, and be certain to wait only as long as
      necessary for the transaction _they_ started to reach disk.
      
      Sloppy callers can START_SYNC and WAIT_SYNC without a transid,
      and provided they didn't wait too long between the calls, they
      will get the same result.  However, if a second commit starts
      before they call WAIT_SYNC, they may end up waiting longer for
      it to commit as well.  Even so, a START_SYNC+WAIT_SYNC still
      guarantees that any operation completed before the START_SYNC
      reaches disk.
      Signed-off-by: default avatarSage Weil <sage@newdream.net>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      46204592
    • Sage Weil's avatar
      Btrfs: async transaction commit · bb9c12c9
      Sage Weil authored
      Add support for an async transaction commit that is ordered such that any
      subsequent operations will join the following transaction, but does not
      wait until the current commit is fully on disk.  This avoids much of the
      latency associated with the btrfs_commit_transaction for callers concerned
      with serialization and not safety.
      
      The wait_for_unblock flag controls whether we wait for the 'middle' portion
      of commit_transaction to complete, which is necessary if the caller expects
      some of the modifications contained in the commit to be available (this is
      the case for subvol/snapshot creation).
      Signed-off-by: default avatarSage Weil <sage@newdream.net>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      bb9c12c9
    • Sage Weil's avatar
      Btrfs: fix deadlock in btrfs_commit_transaction · 99d16cbc
      Sage Weil authored
      We calculate timeout (either 1 or MAX_SCHEDULE_TIMEOUT) based on whether
      num_writers > 1 or should_grow at the top of the loop.  Then, much much
      later, we wait for that timeout if either num_writers or should_grow is
      true.  However, it's possible for a racing process (calling
      btrfs_end_transaction()) to decrement num_writers such that we wait
      forever instead of for 1.
      
      Fix this by deciding how long to wait when we wait.  Include a smp_mb()
      before checking if the waitqueue is active to ensure the num_writers
      is visible.
      Signed-off-by: default avatarSage Weil <sage@newdream.net>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      99d16cbc
    • Sage Weil's avatar
      Btrfs: fix lockdep warning on clone ioctl · fccdae43
      Sage Weil authored
      I'm no lockdep expert, but this appears to make the lockdep warning go
      away for the i_mutex locking in the clone ioctl.
      Signed-off-by: default avatarSage Weil <sage@newdream.net>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      fccdae43
    • Sage Weil's avatar
      Btrfs: fix clone ioctl where range is adjacent to extent · 050006a7
      Sage Weil authored
      We had an edge case issue where the requested range was just
      following an existing extent. Instead of skipping to the next
      extent, we used the previous one which lead to having zero
      sized extents.
      Signed-off-by: default avatarYehuda Sadeh <yehuda@hq.newdream.net>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      050006a7
    • Sage Weil's avatar
      Btrfs: fix delalloc checks in clone ioctl · 9a019196
      Sage Weil authored
      The lookup_first_ordered_extent() was done on the wrong inode, and the
      ->delalloc_bytes test was wrong, as the following
      btrfs_wait_ordered_range() would only invoke a range write and wouldn't
      write the entire file data range. Also, a bad parameter was passed to
      btrfs_wait_ordered_range().
      Signed-off-by: default avatarYehuda Sadeh <yehuda@hq.newdream.net>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      9a019196
    • Chris Mason's avatar
      Btrfs: drop unused variable in block_alloc_rsv · d8e39c45
      Chris Mason authored
      The alloc_target variable is not really used.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      d8e39c45
    • Andi Kleen's avatar
      Btrfs: cleanup warnings from gcc 4.6 (nonbugs) · 559af821
      Andi Kleen authored
      These are all the cases where a variable is set, but not read which are
      not bugs as far as I can see, but simply leftovers.
      
      Still needs more review.
      
      Found by gcc 4.6's new warnings
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Chris Mason <chris.mason@oracle.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      559af821
    • Andi Kleen's avatar
      Btrfs: Fix variables set but not read (bugs found by gcc 4.6) · 411fc6bc
      Andi Kleen authored
      These are all the cases where a variable is set, but not
      read which are really bugs.
      
      - Couple of incorrect error handling fixed.
      - One incorrect use of a allocation policy
      - Some other things
      
      Still needs more review.
      
      Found by gcc 4.6's new warnings.
      
      [akpm@linux-foundation.org: fix build.  Might have been bitrot]
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Chris Mason <chris.mason@oracle.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      411fc6bc
    • Julia Lawall's avatar
      Btrfs: Use ERR_CAST helpers · d0b678cb
      Julia Lawall authored
      Use ERR_CAST(x) rather than ERR_PTR(PTR_ERR(x)).  The former makes more
      clear what is the purpose of the operation, which otherwise looks like a
      no-op.
      
      The semantic patch that makes this change is as follows:
      (http://coccinelle.lip6.fr/)
      
      // <smpl>
      @@
      type T;
      T x;
      identifier f;
      @@
      
      T f (...) { <+...
      - ERR_PTR(PTR_ERR(x))
      + x
       ...+> }
      
      @@
      expression x;
      @@
      
      - ERR_PTR(PTR_ERR(x))
      + ERR_CAST(x)
      // </smpl>
      Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
      Cc: Chris Mason <chris.mason@oracle.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      d0b678cb
    • Julia Lawall's avatar
      Btrfs: use memdup_user helpers · 2354d08f
      Julia Lawall authored
      Use memdup_user when user data is immediately copied into the
      allocated region.
      
      The semantic patch that makes this change is as follows:
      (http://coccinelle.lip6.fr/)
      
      // <smpl>
      @@
      expression from,to,size,flag;
      position p;
      identifier l1,l2;
      @@
      
      -  to = \(kmalloc@p\|kzalloc@p\)(size,flag);
      +  to = memdup_user(from,size);
         if (
      -      to==NULL
      +      IS_ERR(to)
                       || ...) {
         <+... when != goto l1;
      -  -ENOMEM
      +  PTR_ERR(to)
         ...+>
         }
      -  if (copy_from_user(to, from, size) != 0) {
      -    <+... when != goto l2;
      -    -EFAULT
      -    ...+>
      -  }
      // </smpl>
      Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
      Cc: Chris Mason <chris.mason@oracle.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      2354d08f
    • Chris Mason's avatar
      Btrfs: fix raid code for removing missing drives · 18e503d6
      Chris Mason authored
      When btrfs is mounted in degraded mode, it has some internal structures
      to track the missing devices.  This missing device is setup as readonly,
      but the mapping code can get upset when we try to write to it.
      
      This changes the mapping code to return -EIO instead of oops when we try
      to write to the readonly device.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      18e503d6