Btrfs: generic data structure to build unique lists
[cascardo/linux.git] / fs / btrfs / volumes.h
index 7c12d61..78f2d4d 100644 (file)
@@ -48,6 +48,7 @@ struct btrfs_device {
        int writeable;
        int in_fs_metadata;
        int missing;
+       int can_discard;
 
        spinlock_t io_lock;
 
@@ -91,6 +92,20 @@ struct btrfs_device {
        struct btrfs_work work;
        struct rcu_head rcu;
        struct work_struct rcu_work;
+
+       /* readahead state */
+       spinlock_t reada_lock;
+       atomic_t reada_in_flight;
+       u64 reada_next;
+       struct reada_zone *reada_curr_zone;
+       struct radix_tree_root reada_zones;
+       struct radix_tree_root reada_extents;
+
+       /* for sending down flush barriers */
+       struct bio *flush_bio;
+       struct completion flush_wait;
+       int nobarriers;
+
 };
 
 struct btrfs_fs_devices {
@@ -104,6 +119,7 @@ struct btrfs_fs_devices {
        u64 rw_devices;
        u64 missing_devices;
        u64 total_rw_bytes;
+       u64 num_can_discard;
        struct block_device *latest_bdev;
 
        /* all of the devices in the FS, protected by a mutex
@@ -134,7 +150,10 @@ struct btrfs_bio_stripe {
        u64 length; /* only used for discard mappings */
 };
 
-struct btrfs_multi_bio {
+struct btrfs_bio;
+typedef void (btrfs_bio_end_io_t) (struct btrfs_bio *bio, int err);
+
+struct btrfs_bio {
        atomic_t stripes_pending;
        bio_end_io_t *end_io;
        struct bio *orig_bio;
@@ -142,6 +161,7 @@ struct btrfs_multi_bio {
        atomic_t error;
        int max_errors;
        int num_stripes;
+       int mirror_num;
        struct btrfs_bio_stripe stripes[];
 };
 
@@ -169,7 +189,7 @@ struct map_lookup {
 int btrfs_account_dev_extents_size(struct btrfs_device *device, u64 start,
                                   u64 end, u64 *length);
 
-#define btrfs_multi_bio_size(n) (sizeof(struct btrfs_multi_bio) + \
+#define btrfs_bio_size(n) (sizeof(struct btrfs_bio) + \
                            (sizeof(struct btrfs_bio_stripe) * (n)))
 
 int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,
@@ -178,7 +198,7 @@ int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,
                           u64 chunk_offset, u64 start, u64 num_bytes);
 int btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,
                    u64 logical, u64 *length,
-                   struct btrfs_multi_bio **multi_ret, int mirror_num);
+                   struct btrfs_bio **bbio_ret, int mirror_num);
 int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree,
                     u64 chunk_start, u64 physical, u64 devid,
                     u64 **logical, int *naddrs, int *stripe_len);