1. 29 Sep, 2008 3 commits
    • Chris Mason's avatar
      Btrfs: add and improve comments · d352ac68
      Chris Mason authored
      This improves the comments at the top of many functions.  It didn't
      dive into the guts of functions because I was trying to
      avoid merging problems with the new allocator and back reference work.
      
      extent-tree.c and volumes.c were both skipped, and there is definitely
      more work todo in cleaning and commenting the code.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      d352ac68
    • Chris Mason's avatar
      Btrfs: drop WARN_ON from btrfs_add_leaf_ref · 9a5e1ea1
      Chris Mason authored
      btrfs_add_leaf_ref was doing checks on the objects it found in the
      rbtree to make sure they were properly linked into the tree.  But, the field
      it was checking can be safely changed outside of the tree spin lock.
      
      The WARN_ON was for debugging the initial implementation and can be
      safely removed.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      9a5e1ea1
    • Chris Mason's avatar
      Btrfs: Wait for IO on the block device inodes of newly added devices · 8c8bee1d
      Chris Mason authored
      btrfs-vol -a /dev/xxx will zero the first and last two MB of the device.
      The kernel code needs to wait for this IO to finish before it adds
      the device.
      
      btrfs metadata IO does not happen through the block device inode.  A
      separate address space is used, allowing the zero filled buffer heads in
      the block device inode to be written to disk after FS metadata starts
      going down to the disk via the btrfs metadata inode.
      
      The end result is zero filled metadata blocks after adding new devices
      into the filesystem.
      
      The fix is a simple filemap_write_and_wait on the block device inode
      before actually inserting it into the pool of available devices.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      8c8bee1d
  2. 26 Sep, 2008 4 commits
    • Zheng Yan's avatar
      Btrfs: update space balancing code · 1a40e23b
      Zheng Yan authored
      This patch updates the space balancing code to utilize the new
      backref format.  Before, btrfs-vol -b would break any COW links
      on data blocks or metadata.  This was slow and caused the amount
      of space used to explode if a large number of snapshots were present.
      
      The new code can keeps the sharing of all data extents and
      most of the tree blocks.
      
      To maintain the sharing of data extents, the space balance code uses
      a seperate inode hold data extent pointers, then updates the references
      to point to the new location.
      
      To maintain the sharing of tree blocks, the space balance code uses
      reloc trees to relocate tree blocks in reference counted roots.
      There is one reloc tree for each subvol, and all reloc trees share
      same root key objectid. Reloc trees are snapshots of the latest
      committed roots of subvols (root->commit_root).
      
      To relocate a tree block referenced by a subvol, there are two steps.
      COW the block through subvol's reloc tree, then update block pointer in
      the subvol to point to the new block. Since all reloc trees share
      same root key objectid, doing special handing for tree blocks
      owned by them is easy. Once a tree block has been COWed in one
      reloc tree, we can use the resulting new block directly when the
      same block is required to COW again through other reloc trees.
      In this way, relocated tree blocks are shared between reloc trees,
      so they are also shared between subvols.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      1a40e23b
    • Zheng Yan's avatar
      Btrfs: extent_map and data=ordered fixes for space balancing · 5b21f2ed
      Zheng Yan authored
      * Add an EXTENT_BOUNDARY state bit to keep the writepage code
      from merging data extents that are in the process of being
      relocated.  This allows us to do accounting for them properly.
      
      * The balancing code relocates data extents indepdent of the underlying
      inode.  The extent_map code was modified to properly account for
      things moving around (invalidating extent_map caches in the inode).
      
      * Don't take the drop_mutex in the create_subvol ioctl.  It isn't
      required.
      
      * Fix walking of the ordered extent list to avoid races with sys_unlink
      
      * Change the lock ordering rules.  Transaction start goes outside
      the drop_mutex.  This allows btrfs_commit_transaction to directly
      drop the relocation trees.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      5b21f2ed
    • Zheng Yan's avatar
      Btrfs: Add shared reference cache · e4657689
      Zheng Yan authored
      Btrfs has a cache of reference counts in leaves, allowing it to
      avoid reading tree leaves while deleting snapshots.  To reduce
      contention with multiple subvolumes, this cache is private to each
      subvolume.
      
      This patch adds shared reference cache support. The new space
      balancing code plays with multiple subvols at the same time, So
      the old per-subvol reference cache is not well suited.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      e4657689
    • Zheng Yan's avatar
      Btrfs: allocator fixes for space balancing update · e8569813
      Zheng Yan authored
      * Reserved extent accounting:  reserved extents have been
      allocated in the rbtrees that track free space but have not
      been allocated on disk.  They were never properly accounted for
      in the past, making it hard to know how much space was really free.
      
      * btrfs_find_block_group used to return NULL for block groups that
      had been removed by the space balancing code.  This made it hard
      to account for space during the final stages of a balance run.
      Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
      e8569813
  3. 25 Sep, 2008 33 commits