1. 05 Apr, 2010 5 commits
    • Josef Bacik's avatar
      Btrfs: fix data enospc check overflow · ab6e2410
      Josef Bacik authored
      
      
      Because we account for reserved space we get from the allocator before we
      actually account for allocating delalloc space, we can have a small window where
      the amount of "used" space in a space_info is more than the total amount of
      space in the space_info.  This will cause a overflow in our check, so it will
      seem like we have _tons_ of free space, and we'll allow reservations to occur
      that will end up larger than the amount of space we have.  I've seen users
      report ENOSPC panic's in cow_file_range a few times recently, so I tried to
      reproduce this problem and found I could reproduce it if I ran one of my tests
      in a loop for like 20 minutes.  With this patch my test ran all night without
      issues.  Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      ab6e2410
    • Chris Mason's avatar
      Btrfs: add check for changed leaves in setup_leaf_for_split · 109f6aef
      Chris Mason authored
      
      
      setup_leaf_for_split needs to drop the path and search again, and has
      checks to see if the item we want to split changed size.  But, it misses
      the case where the leaf changed and now has enough room for the item
      we want to insert.
      
      This adds an extra check to make sure the leaf really needs splitting
      before we call btrfs_split_leaf(), which keeps us from trying to split
      a leaf with a single item.
      
      btrfs_split_leaf() will blindly split the single item leaf, leaving us
      with one good leaf and one empty leaf and then a crash.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      109f6aef
    • Sage Weil's avatar
      Btrfs: create snapshot references in same commit as snapshot · 6bdb72de
      Sage Weil authored
      
      
      This creates the reference to a new snapshot in the same commit as the
      snapshot itself.  This avoids the need for a second commit in order for a
      snapshot to be persistent, and also avoids the problem of "leaking" a
      new snapshot tree root if the host crashes before the second commit takes
      place.
      
      It is not at all clear to me why it wasn't always done this way.  If there
      is still a reason for the two-stage {create,finish}_pending_snapshots()
      approach I'm missing something!  :)
      
      I've been running this for a couple weeks under pretty heavy usage (a few
      snapshots per minute) without obvious problems.
      Signed-off-by: default avatarSage Weil <sage@newdream.net>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      6bdb72de
    • Josef Bacik's avatar
      Btrfs: fix small race with delalloc flushing waitqueue's · b5cb1600
      Josef Bacik authored
      
      
      Everytime we start a new flushing thread, we init the waitqueue if there isn't a
      flushing thread running.  The problem with this is we check
      space_info->flushing, which we clear right before doing a wake_up on the
      flushing waitqueue, which causes problems if we init the waitqueue in the middle
      of clearing the flushing flagh and calling wake_up.  This is hard to hit, but
      the code is wrong anyway, so init the flushing/allocating waitqueue when
      creating the space info and let it be.  I haven't seen the panic since I've been
      using this patch.  Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      b5cb1600
    • Nick Piggin's avatar
      Btrfs: use add_to_page_cache_lru, use __page_cache_alloc · 28ecb609
      Nick Piggin authored
      
      
      Pagecache pages should be allocated with __page_cache_alloc, so they
      obey pagecache memory policies.
      
      add_to_page_cache_lru is exported, so it should be used. Benefits over
      using a private pagevec: neater code, 128 bytes fewer stack used, percpu
      lru ordering is preserved, and finally don't need to flush pagevec
      before returning so batching may be shared with other LRU insertions.
      
      Signed-off-by: Nick Piggin <npiggin@suse.de>:
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      28ecb609
  2. 30 Mar, 2010 11 commits
  3. 18 Mar, 2010 4 commits
    • Chris Mason's avatar
      Btrfs: fix the inode ref searches done by btrfs_search_path_in_tree · 8ad6fcab
      Chris Mason authored
      
      
      This is used by the inode lookup ioctl to follow all the backrefs up
      to the subvol root.  But the search being done would sometimes land one
      past the last item in the leaf instead of finding the backref.
      
      This changes the search to look for the highest possible backref and hop
      back one item.  It also fixes a leaked path on failure to find the root.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      8ad6fcab
    • Chris Mason's avatar
      Btrfs: allow treeid==0 in the inode lookup ioctl · 1b53ac4d
      Chris Mason authored
      
      
      When a root id of 0 is sent to the inode lookup ioctl, it will
      use the root of the file we're ioctling and pass the root id
      back to userland along with the results.
      
      This allows userland to do searches based on that root later on.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      1b53ac4d
    • Chris Mason's avatar
      Btrfs: return keys for large items to the search ioctl · 90fdde14
      Chris Mason authored
      
      
      The search ioctl was skipping large items entirely (ones that are too
      big for the results buffer).  This changes things to at least copy
      the item header so that we can send information about the item back to
      userland.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      90fdde14
    • Chris Mason's avatar
      Btrfs: fix key checks and advance in the search ioctl · abc6e134
      Chris Mason authored
      
      
      The search ioctl was working well for finding tree roots, but using it for
      generic searches requires a few changes to how the keys are advanced.
      This treats the search control min fields for objectid, type and offset
      more like a key, where we drop the offset to zero once we bump the type,
      etc.
      
      The downside of this is that we are changing the min_type and min_offset
      fields during the search, and so the ioctl caller needs extra checks to make sure
      the keys in the result are the ones it wanted.
      
      This also changes key_in_sk to use btrfs_comp_cpu_keys, just to make
      things more readable.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      abc6e134
  4. 16 Mar, 2010 3 commits
  5. 15 Mar, 2010 17 commits