]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 3 Apr 2009 22:14:44 +0000 (15:14 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 3 Apr 2009 22:14:44 +0000 (15:14 -0700)
* git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable:
  Btrfs: BUG to BUG_ON changes
  Btrfs: remove dead code
  Btrfs: remove dead code
  Btrfs: fix typos in comments
  Btrfs: remove unused ftrace include
  Btrfs: fix __ucmpdi2 compile bug on 32 bit builds
  Btrfs: free inode struct when btrfs_new_inode fails
  Btrfs: fix race in worker_loop
  Btrfs: add flushoncommit mount option
  Btrfs: notreelog mount option
  Btrfs: introduce btrfs_show_options
  Btrfs: rework allocation clustering
  Btrfs: Optimize locking in btrfs_next_leaf()
  Btrfs: break up btrfs_search_slot into smaller pieces
  Btrfs: kill the pinned_mutex
  Btrfs: kill the block group alloc mutex
  Btrfs: clean up find_free_extent
  Btrfs: free space cache cleanups
  Btrfs: unplug in the async bio submission threads
  Btrfs: keep processing bios for a given bdev if our proc is batching

1  2 
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/inode.c

diff --combined fs/btrfs/ctree.h
index 9417713542a2a5867490d0308241f610832400ee,8f4e152bb11b71c0c8cf594efb37b1454ddc0084..ad96495dedc52f79a05cdbccfea20383b871164f
@@@ -143,12 -143,15 +143,15 @@@ static int btrfs_csum_sizes[] = { 4, 0 
  #define BTRFS_FT_MAX          9
  
  /*
-  * the key defines the order in the tree, and so it also defines (optimal)
-  * block layout.  objectid corresonds to the inode number.  The flags
-  * tells us things about the object, and is a kind of stream selector.
-  * so for a given inode, keys with flags of 1 might refer to the inode
-  * data, flags of 2 may point to file data in the btree and flags == 3
-  * may point to extents.
+  * The key defines the order in the tree, and so it also defines (optimal)
+  * block layout.
+  *
+  * objectid corresponds to the inode number.
+  *
+  * type tells us things about the object, and is a kind of stream selector.
+  * so for a given inode, keys with type of 1 might refer to the inode data,
+  * type of 2 may point to file data in the btree and type == 3 may point to
+  * extents.
   *
   * offset is the starting byte offset for this key in the stream.
   *
@@@ -200,7 -203,7 +203,7 @@@ struct btrfs_dev_item 
  
        /*
         * starting byte of this partition on the device,
-        * to allowr for stripe alignment in the future
+        * to allow for stripe alignment in the future
         */
        __le64 start_offset;
  
@@@ -633,18 -636,35 +636,35 @@@ struct btrfs_space_info 
        struct rw_semaphore groups_sem;
  };
  
- struct btrfs_free_space {
-       struct rb_node bytes_index;
-       struct rb_node offset_index;
-       u64 offset;
-       u64 bytes;
+ /*
+  * free clusters are used to claim free space in relatively large chunks,
+  * allowing us to do less seeky writes.  They are used for all metadata
+  * allocations and data allocations in ssd mode.
+  */
+ struct btrfs_free_cluster {
+       spinlock_t lock;
+       spinlock_t refill_lock;
+       struct rb_root root;
+       /* largest extent in this cluster */
+       u64 max_size;
+       /* first extent starting offset */
+       u64 window_start;
+       struct btrfs_block_group_cache *block_group;
+       /*
+        * when a cluster is allocated from a block group, we put the
+        * cluster onto a list in the block group so that it can
+        * be freed before the block group is freed.
+        */
+       struct list_head block_group_list;
  };
  
  struct btrfs_block_group_cache {
        struct btrfs_key key;
        struct btrfs_block_group_item item;
        spinlock_t lock;
-       struct mutex alloc_mutex;
        struct mutex cache_mutex;
        u64 pinned;
        u64 reserved;
        struct btrfs_space_info *space_info;
  
        /* free space cache stuff */
+       spinlock_t tree_lock;
        struct rb_root free_space_bytes;
        struct rb_root free_space_offset;
  
  
        /* usage count */
        atomic_t count;
+       /* List of struct btrfs_free_clusters for this block group.
+        * Today it will only have one thing on it, but that may change
+        */
+       struct list_head cluster_list;
  };
  
  struct btrfs_leaf_ref_tree {
@@@ -728,7 -754,6 +754,6 @@@ struct btrfs_fs_info 
        struct mutex tree_log_mutex;
        struct mutex transaction_kthread_mutex;
        struct mutex cleaner_mutex;
-       struct mutex pinned_mutex;
        struct mutex chunk_mutex;
        struct mutex drop_mutex;
        struct mutex volume_mutex;
        spinlock_t delalloc_lock;
        spinlock_t new_trans_lock;
        u64 delalloc_bytes;
-       u64 last_alloc;
-       u64 last_data_alloc;
+       /* data_alloc_cluster is only used in ssd mode */
+       struct btrfs_free_cluster data_alloc_cluster;
+       /* all metadata allocations go through this cluster */
+       struct btrfs_free_cluster meta_alloc_cluster;
  
        spinlock_t ref_cache_lock;
        u64 total_ref_cache_size;
@@@ -932,7 -961,6 +961,6 @@@ struct btrfs_root 
  };
  
  /*
   * inode items have the data typically returned from stat and store other
   * info about object characteristics.  There is one for every file and dir in
   * the FS
  #define BTRFS_EXTENT_CSUM_KEY 128
  
  /*
-  * root items point to tree roots.  There are typically in the root
+  * root items point to tree roots.  They are typically in the root
   * tree used by the super block to find all the other trees
   */
  #define BTRFS_ROOT_ITEM_KEY   132
  #define BTRFS_MOUNT_SSD                       (1 << 3)
  #define BTRFS_MOUNT_DEGRADED          (1 << 4)
  #define BTRFS_MOUNT_COMPRESS          (1 << 5)
+ #define BTRFS_MOUNT_NOTREELOG           (1 << 6)
+ #define BTRFS_MOUNT_FLUSHONCOMMIT       (1 << 7)
  
  #define btrfs_clear_opt(o, opt)               ((o) &= ~BTRFS_MOUNT_##opt)
  #define btrfs_set_opt(o, opt)         ((o) |= BTRFS_MOUNT_##opt)
@@@ -1748,6 -1778,7 +1778,7 @@@ static inline struct dentry *fdentry(st
  }
  
  /* extent-tree.c */
+ void btrfs_put_block_group(struct btrfs_block_group_cache *cache);
  int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
                           struct btrfs_root *root, unsigned long count);
  int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len);
@@@ -2101,7 -2132,7 +2132,7 @@@ int btrfs_merge_bio_hook(struct page *p
  unsigned long btrfs_force_ra(struct address_space *mapping,
                              struct file_ra_state *ra, struct file *file,
                              pgoff_t offset, pgoff_t last_index);
 -int btrfs_page_mkwrite(struct vm_area_struct *vma, struct page *page);
 +int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
  int btrfs_readpage(struct file *file, struct page *page);
  void btrfs_delete_inode(struct inode *inode);
  void btrfs_put_inode(struct inode *inode);
@@@ -2174,21 -2205,4 +2205,4 @@@ int btrfs_check_acl(struct inode *inode
  int btrfs_init_acl(struct inode *inode, struct inode *dir);
  int btrfs_acl_chmod(struct inode *inode);
  
- /* free-space-cache.c */
- int btrfs_add_free_space(struct btrfs_block_group_cache *block_group,
-                        u64 bytenr, u64 size);
- int btrfs_add_free_space_lock(struct btrfs_block_group_cache *block_group,
-                             u64 offset, u64 bytes);
- int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group,
-                           u64 bytenr, u64 size);
- int btrfs_remove_free_space_lock(struct btrfs_block_group_cache *block_group,
-                                u64 offset, u64 bytes);
- void btrfs_remove_free_space_cache(struct btrfs_block_group_cache
-                                  *block_group);
- struct btrfs_free_space *btrfs_find_free_space(struct btrfs_block_group_cache
-                                              *block_group, u64 offset,
-                                              u64 bytes);
- void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group,
-                          u64 bytes);
- u64 btrfs_block_group_free_space(struct btrfs_block_group_cache *block_group);
  #endif
diff --combined fs/btrfs/disk-io.c
index 92d73929d3814b50024196eb5e8688d2ee330222,a850c3ac196dace912b30276377bf12660628e8a..92caa8035f36f9beecc3c21551722a0eefdd911e
@@@ -38,6 -38,7 +38,7 @@@
  #include "locking.h"
  #include "ref-cache.h"
  #include "tree-log.h"
+ #include "free-space-cache.h"
  
  static struct extent_io_ops btree_extent_io_ops;
  static void end_workqueue_fn(struct btrfs_work *work);
@@@ -1412,8 -1413,6 +1413,6 @@@ static int bio_ready_for_csum(struct bi
  
        ret = extent_range_uptodate(io_tree, start + length,
                                    start + buf_len - 1);
-       if (ret == 1)
-               return ret;
        return ret;
  }
  
@@@ -1647,12 -1646,15 +1646,15 @@@ struct btrfs_root *open_ctree(struct su
        mutex_init(&fs_info->ordered_operations_mutex);
        mutex_init(&fs_info->tree_log_mutex);
        mutex_init(&fs_info->drop_mutex);
-       mutex_init(&fs_info->pinned_mutex);
        mutex_init(&fs_info->chunk_mutex);
        mutex_init(&fs_info->transaction_kthread_mutex);
        mutex_init(&fs_info->cleaner_mutex);
        mutex_init(&fs_info->volume_mutex);
        mutex_init(&fs_info->tree_reloc_mutex);
+       btrfs_init_free_cluster(&fs_info->meta_alloc_cluster);
+       btrfs_init_free_cluster(&fs_info->data_alloc_cluster);
        init_waitqueue_head(&fs_info->transaction_throttle);
        init_waitqueue_head(&fs_info->transaction_wait);
        init_waitqueue_head(&fs_info->async_submit_wait);
@@@ -2407,7 -2409,7 +2409,7 @@@ void btrfs_btree_balance_dirty(struct b
        unsigned long thresh = 32 * 1024 * 1024;
        tree = &BTRFS_I(root->fs_info->btree_inode)->io_tree;
  
 -      if (current_is_pdflush() || current->flags & PF_MEMALLOC)
 +      if (current->flags & PF_MEMALLOC)
                return;
  
        num_dirty = count_range_bits(tree, &start, (u64)-1,
diff --combined fs/btrfs/inode.c
index 06d8db5afb08ba8800dc776a64f421c1e9322780,0ecb3fa75dc311b701c17472bf088795d80b6749..a0d1dd492a58a57bdf23464340fd6312c192fca9
@@@ -3481,8 -3481,10 +3481,10 @@@ static struct inode *btrfs_new_inode(st
  
        if (dir) {
                ret = btrfs_set_inode_index(dir, index);
-               if (ret)
+               if (ret) {
+                       iput(inode);
                        return ERR_PTR(ret);
+               }
        }
        /*
         * index_cnt is ignored for everything but a dir,
@@@ -3565,6 -3567,7 +3567,7 @@@ fail
        if (dir)
                BTRFS_I(dir)->index_cnt--;
        btrfs_free_path(path);
+       iput(inode);
        return ERR_PTR(ret);
  }
  
@@@ -4365,9 -4368,8 +4368,9 @@@ static void btrfs_invalidatepage(struc
   * beyond EOF, then the page is guaranteed safe against truncation until we
   * unlock the page.
   */
 -int btrfs_page_mkwrite(struct vm_area_struct *vma, struct page *page)
 +int btrfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
  {
 +      struct page *page = vmf->page;
        struct inode *inode = fdentry(vma->vm_file)->d_inode;
        struct btrfs_root *root = BTRFS_I(inode)->root;
        struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
        u64 page_end;
  
        ret = btrfs_check_data_free_space(root, inode, PAGE_CACHE_SIZE);
 -      if (ret)
 +      if (ret) {
 +              if (ret == -ENOMEM)
 +                      ret = VM_FAULT_OOM;
 +              else /* -ENOSPC, -EIO, etc */
 +                      ret = VM_FAULT_SIGBUS;
                goto out;
 +      }
  
 -      ret = -EINVAL;
 +      ret = VM_FAULT_NOPAGE; /* make the VM retry the fault */
  again:
        lock_page(page);
        size = i_size_read(inode);