1. 29 Oct, 2010 21 commits
  2. 28 Oct, 2010 1 commit
    • Josef Bacik's avatar
      Btrfs: create special free space cache inode · 0af3d00b
      Josef Bacik authored
      
      
      In order to save free space cache, we need an inode to hold the data, and we
      need a special item to point at the right inode for the right block group.  So
      first, create a special item that will point to the right inode, and the number
      of extent entries we will have and the number of bitmaps we will have.  We
      truncate and pre-allocate space everytime to make sure it's uptodate.
      
      This feature will be turned on as soon as you mount with -o space_cache, however
      it is safe to boot into old kernels, they will just generate the cache the old
      fashion way.  When you boot back into a newer kernel we will notice that we
      modified and not the cache and automatically discard the cache.
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      0af3d00b
  3. 26 Oct, 2010 2 commits
    • Josef Bacik's avatar
      Btrfs: remove warn_on from use_block_rsv · e9bb7f10
      Josef Bacik authored
      
      
      Because btrfs_dirty_inode does a btrfs_join_transaction, it doesn't actually
      reserve space.  It does this so we can try and dirty the inode quickly without
      having to deal with the ENOSPC problems.  But if it does get back ENOSPC it
      handles it properly.  The problem is use_block_rsv does a WARN_ON whenever this
      case happens, even tho btrfs_dirty_inode takes it into account and actually
      expects to get -ENOSPC if things are particularly tight.  So instead just remove
      the warning.  Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      e9bb7f10
    • Josef Bacik's avatar
      Btrfs: set trans to null in reserve_metadata_bytes if we commit the transaction · 38227933
      Josef Bacik authored
      
      
      btrfs_commit_transaction will free our trans, but because we pass trans to
      shrink_delalloc we could possibly have a use after free situation.  So instead
      if we commit the transaction, set trans to null and set committed to true so we
      don't keep trying to commit a transaction.  This fixes a panic I could reproduce
      at will.  Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      38227933
  4. 22 Oct, 2010 8 commits
    • Josef Bacik's avatar
      Btrfs: fix error handling in btrfs_get_sb · 0e78340f
      Josef Bacik authored
      
      
      If we failed to find the root subvol id, or the subvol=<name>, we would
      deactivate the locked super and close the devices.  The problem is at this point
      we have gotten the SB all setup, which includes setting super_operations, so
      when we'd deactiveate the super, we'd do a close_ctree() which closes the
      devices, so we'd end up closing the devices twice.  So if you do something like
      this
      
      mount /dev/sda1 /mnt/test1
      mount /dev/sda1 /mnt/test2 -o subvol=xxx
      umount /mnt/test1
      
      it would blow up (if subvol xxx doesn't exist).  This patch fixes that problem.
      Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      0e78340f
    • Josef Bacik's avatar
      Btrfs: rework how we reserve metadata bytes · 8bb8ab2e
      Josef Bacik authored
      
      
      With multi-threaded writes we were getting ENOSPC early because somebody would
      come in, start flushing delalloc because they couldn't make their reservation,
      and in the meantime other threads would come in and use the space that was
      getting freed up, so when the original thread went to check to see if they had
      space they didn't and they'd return ENOSPC.  So instead if we have some free
      space but not enough for our reservation, take the reservation and then start
      doing the flushing.  The only time we don't take reservations is when we've
      already overcommitted our space, that way we don't have people who come late to
      the party way overcommitting ourselves.  This also moves all of the retrying and
      flushing code into reserve_metdata_bytes so it's all uniform.  This keeps my
      fs_mark test from returning -ENOSPC as soon as it starts and actually lets me
      fill up the disk.  Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      8bb8ab2e
    • Josef Bacik's avatar
      Btrfs: don't allocate chunks as aggressively · 14ed0ca6
      Josef Bacik authored
      
      
      Because the ENOSPC code over reserves super aggressively we end up allocating
      chunks way more often than we should.  For example with my fs_mark tests on a
      2gb fs I can end up reserved 1gb just for metadata, when only 34mb of that is
      being used.  So instead check to see if the amount of space actually used is
      less than 30% of the total space, and if so don't allocate a chunk, but only if
      we have at least 256mb of free space to make sure we don't put too much pressure
      on free space.
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      14ed0ca6
    • Josef Bacik's avatar
      Btrfs: re-work delalloc flushing · 0019f10d
      Josef Bacik authored
      
      
      Currently we try and flush delalloc, but we only do that in a sort of weak way,
      which works fine in most cases but if we're under heavy pressure we need to be
      able to wait for flushing to happen.  Also instead of checking the bytes
      reserved in the block_rsv, check the space info since it is more accurate.  The
      sync option will be used in a future patch.
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      0019f10d
    • Josef Bacik's avatar
      Btrfs: fix reservation code for mixed block groups · 6d48755d
      Josef Bacik authored
      
      
      The global reservation stuff tries to add together DATA and METADATA used in
      order to figure out how much to reserve for everything, but this doesn't work
      right for mixed block groups.  Instead if we have mixed block groups just set
      data used to 0.  Also with mixed block groups we will use bytes_may_use for
      keeping track of delalloc bytes, so we need to take that into account in our
      reservation calculations.
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      6d48755d
    • Josef Bacik's avatar
      Btrfs: fix df regression · 89a55897
      Josef Bacik authored
      
      
      The new ENOSPC stuff breaks out the raid types which breaks the way we were
      reporting df to the system.  This fixes it back so that Available is the total
      space available to data and used is the actual bytes used by the filesystem.
      This means that Available is Total - data used - all of the metadata space.
      Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      89a55897
    • Josef Bacik's avatar
      Btrfs: fix the df ioctl to report raid types · bf5fc093
      Josef Bacik authored
      
      
      The new ENOSPC stuff broke the df ioctl since we no longer create seperate space
      info's for each RAID type.  So instead, loop through each space info's raid
      lists so we can get the right RAID information which will allow the df ioctl to
      tell us RAID types again.  Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      bf5fc093
    • Josef Bacik's avatar
      Btrfs: stop trying to shrink delalloc if there are no inodes to reclaim · a1f76506
      Josef Bacik authored
      
      
      In very severe ENOSPC cases we can run out of inodes to do delalloc on, which
      means we'll just keep looping trying to shrink delalloc.  Instead, if we fail to
      shrink delalloc 3 times in a row break out since we're not likely to make any
      progress.  Tested this with a 100mb fs an xfstests test 13.  Before the patch it
      would hang the box, with the patch we get -ENOSPC like we should.  Thanks,
      Signed-off-by: default avatarJosef Bacik <josef@redhat.com>
      a1f76506
  5. 20 Oct, 2010 5 commits
  6. 19 Oct, 2010 3 commits