0001
0002
0003
0004
0005
0006
0007 #ifndef BTRFS_RAID56_H
0008 #define BTRFS_RAID56_H
0009
0010 #include <linux/workqueue.h>
0011 #include "volumes.h"
0012
0013 enum btrfs_rbio_ops {
0014 BTRFS_RBIO_WRITE,
0015 BTRFS_RBIO_READ_REBUILD,
0016 BTRFS_RBIO_PARITY_SCRUB,
0017 BTRFS_RBIO_REBUILD_MISSING,
0018 };
0019
0020 struct btrfs_raid_bio {
0021 struct btrfs_io_context *bioc;
0022
0023
0024
0025
0026
0027 struct list_head hash_list;
0028
0029
0030 struct list_head stripe_cache;
0031
0032
0033 struct work_struct work;
0034
0035
0036
0037
0038
0039 struct bio_list bio_list;
0040 spinlock_t bio_list_lock;
0041
0042
0043
0044
0045
0046
0047
0048 struct list_head plug_list;
0049
0050
0051 unsigned long flags;
0052
0053
0054
0055
0056
0057 enum btrfs_rbio_ops operation;
0058
0059
0060 u16 nr_pages;
0061
0062
0063 u16 nr_sectors;
0064
0065
0066 u8 nr_data;
0067
0068
0069 u8 real_stripes;
0070
0071
0072 u8 stripe_npages;
0073
0074
0075 u8 stripe_nsectors;
0076
0077
0078 s8 faila;
0079
0080
0081 s8 failb;
0082
0083
0084 u8 scrubp;
0085
0086
0087
0088
0089
0090 int bio_list_bytes;
0091
0092 int generic_bio_cnt;
0093
0094 refcount_t refs;
0095
0096 atomic_t stripes_pending;
0097
0098 atomic_t error;
0099
0100 struct work_struct end_io_work;
0101
0102
0103 unsigned long dbitmap;
0104
0105
0106 unsigned long finish_pbitmap;
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118 struct page **stripe_pages;
0119
0120
0121 struct sector_ptr *bio_sectors;
0122
0123
0124
0125
0126
0127 struct sector_ptr *stripe_sectors;
0128
0129
0130 void **finish_pointers;
0131 };
0132
0133
0134
0135
0136
0137
0138
0139
0140 struct raid56_bio_trace_info {
0141 u64 devid;
0142
0143
0144 u32 offset;
0145
0146
0147
0148
0149
0150
0151
0152 u8 stripe_nr;
0153 };
0154
0155 static inline int nr_data_stripes(const struct map_lookup *map)
0156 {
0157 return map->num_stripes - btrfs_nr_parity_stripes(map->type);
0158 }
0159
0160 #define RAID5_P_STRIPE ((u64)-2)
0161 #define RAID6_Q_STRIPE ((u64)-1)
0162
0163 #define is_parity_stripe(x) (((x) == RAID5_P_STRIPE) || \
0164 ((x) == RAID6_Q_STRIPE))
0165
0166 struct btrfs_device;
0167
0168 void raid56_parity_recover(struct bio *bio, struct btrfs_io_context *bioc,
0169 int mirror_num, bool generic_io);
0170 void raid56_parity_write(struct bio *bio, struct btrfs_io_context *bioc);
0171
0172 void raid56_add_scrub_pages(struct btrfs_raid_bio *rbio, struct page *page,
0173 unsigned int pgoff, u64 logical);
0174
0175 struct btrfs_raid_bio *raid56_parity_alloc_scrub_rbio(struct bio *bio,
0176 struct btrfs_io_context *bioc,
0177 struct btrfs_device *scrub_dev,
0178 unsigned long *dbitmap, int stripe_nsectors);
0179 void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio);
0180
0181 struct btrfs_raid_bio *
0182 raid56_alloc_missing_rbio(struct bio *bio, struct btrfs_io_context *bioc);
0183 void raid56_submit_missing_rbio(struct btrfs_raid_bio *rbio);
0184
0185 int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info);
0186 void btrfs_free_stripe_hash_table(struct btrfs_fs_info *info);
0187
0188 #endif