aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2013-01-29 18:40:14 -0500
committerChris Mason <chris.mason@fusionio.com>2013-02-01 14:24:23 -0500
commit53b381b3abeb86f12787a6c40fee9b2f71edc23b (patch)
treec1018ba2157778f0200d2ede0c0df48fe5df8f14 /fs/btrfs/ctree.h
parent64a167011bcabc1e855658387c8a4464b71f3138 (diff)
Btrfs: RAID5 and RAID6
This builds on David Woodhouse's original Btrfs raid5/6 implementation. The code has changed quite a bit, blame Chris Mason for any bugs. Read/modify/write is done after the higher levels of the filesystem have prepared a given bio. This means the higher layers are not responsible for building full stripes, and they don't need to query for the topology of the extents that may get allocated during delayed allocation runs. It also means different files can easily share the same stripe. But, it does expose us to incorrect parity if we crash or lose power while doing a read/modify/write cycle. This will be addressed in a later commit. Scrub is unable to repair crc errors on raid5/6 chunks. Discard does not work on raid5/6 (yet) The stripe size is fixed at 64KiB per disk. This will be tunable in a later commit. Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 0ab51be6879f..0cce3aafbd62 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -502,6 +502,7 @@ struct btrfs_super_block {
502#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5) 502#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5)
503 503
504#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6) 504#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)
505#define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7)
505 506
506#define BTRFS_FEATURE_COMPAT_SUPP 0ULL 507#define BTRFS_FEATURE_COMPAT_SUPP 0ULL
507#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL 508#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
@@ -511,6 +512,7 @@ struct btrfs_super_block {
511 BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \ 512 BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \
512 BTRFS_FEATURE_INCOMPAT_BIG_METADATA | \ 513 BTRFS_FEATURE_INCOMPAT_BIG_METADATA | \
513 BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \ 514 BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \
515 BTRFS_FEATURE_INCOMPAT_RAID56 | \
514 BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF) 516 BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF)
515 517
516/* 518/*
@@ -952,8 +954,10 @@ struct btrfs_dev_replace_item {
952#define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4) 954#define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4)
953#define BTRFS_BLOCK_GROUP_DUP (1ULL << 5) 955#define BTRFS_BLOCK_GROUP_DUP (1ULL << 5)
954#define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6) 956#define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
957#define BTRFS_BLOCK_GROUP_RAID5 (1 << 7)
958#define BTRFS_BLOCK_GROUP_RAID6 (1 << 8)
955#define BTRFS_BLOCK_GROUP_RESERVED BTRFS_AVAIL_ALLOC_BIT_SINGLE 959#define BTRFS_BLOCK_GROUP_RESERVED BTRFS_AVAIL_ALLOC_BIT_SINGLE
956#define BTRFS_NR_RAID_TYPES 5 960#define BTRFS_NR_RAID_TYPES 7
957 961
958#define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | \ 962#define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | \
959 BTRFS_BLOCK_GROUP_SYSTEM | \ 963 BTRFS_BLOCK_GROUP_SYSTEM | \
@@ -961,6 +965,8 @@ struct btrfs_dev_replace_item {
961 965
962#define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | \ 966#define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | \
963 BTRFS_BLOCK_GROUP_RAID1 | \ 967 BTRFS_BLOCK_GROUP_RAID1 | \
968 BTRFS_BLOCK_GROUP_RAID5 | \
969 BTRFS_BLOCK_GROUP_RAID6 | \
964 BTRFS_BLOCK_GROUP_DUP | \ 970 BTRFS_BLOCK_GROUP_DUP | \
965 BTRFS_BLOCK_GROUP_RAID10) 971 BTRFS_BLOCK_GROUP_RAID10)
966/* 972/*
@@ -1185,6 +1191,10 @@ struct btrfs_block_group_cache {
1185 u64 flags; 1191 u64 flags;
1186 u64 sectorsize; 1192 u64 sectorsize;
1187 u64 cache_generation; 1193 u64 cache_generation;
1194
1195 /* for raid56, this is a full stripe, without parity */
1196 unsigned long full_stripe_len;
1197
1188 unsigned int ro:1; 1198 unsigned int ro:1;
1189 unsigned int dirty:1; 1199 unsigned int dirty:1;
1190 unsigned int iref:1; 1200 unsigned int iref:1;
@@ -1225,6 +1235,20 @@ struct seq_list {
1225 u64 seq; 1235 u64 seq;
1226}; 1236};
1227 1237
1238/* used by the raid56 code to lock stripes for read/modify/write */
1239struct btrfs_stripe_hash {
1240 struct list_head hash_list;
1241 wait_queue_head_t wait;
1242 spinlock_t lock;
1243};
1244
1245/* used by the raid56 code to lock stripes for read/modify/write */
1246struct btrfs_stripe_hash_table {
1247 struct btrfs_stripe_hash *table;
1248};
1249
1250#define BTRFS_STRIPE_HASH_TABLE_BITS 11
1251
1228/* fs_info */ 1252/* fs_info */
1229struct reloc_control; 1253struct reloc_control;
1230struct btrfs_device; 1254struct btrfs_device;
@@ -1307,6 +1331,13 @@ struct btrfs_fs_info {
1307 struct mutex cleaner_mutex; 1331 struct mutex cleaner_mutex;
1308 struct mutex chunk_mutex; 1332 struct mutex chunk_mutex;
1309 struct mutex volume_mutex; 1333 struct mutex volume_mutex;
1334
1335 /* this is used during read/modify/write to make sure
1336 * no two ios are trying to mod the same stripe at the same
1337 * time
1338 */
1339 struct btrfs_stripe_hash_table *stripe_hash_table;
1340
1310 /* 1341 /*
1311 * this protects the ordered operations list only while we are 1342 * this protects the ordered operations list only while we are
1312 * processing all of the entries on it. This way we make 1343 * processing all of the entries on it. This way we make
@@ -1395,6 +1426,8 @@ struct btrfs_fs_info {
1395 struct btrfs_workers flush_workers; 1426 struct btrfs_workers flush_workers;
1396 struct btrfs_workers endio_workers; 1427 struct btrfs_workers endio_workers;
1397 struct btrfs_workers endio_meta_workers; 1428 struct btrfs_workers endio_meta_workers;
1429 struct btrfs_workers endio_raid56_workers;
1430 struct btrfs_workers rmw_workers;
1398 struct btrfs_workers endio_meta_write_workers; 1431 struct btrfs_workers endio_meta_write_workers;
1399 struct btrfs_workers endio_write_workers; 1432 struct btrfs_workers endio_write_workers;
1400 struct btrfs_workers endio_freespace_worker; 1433 struct btrfs_workers endio_freespace_worker;