btrfs-progs: fix missing parity stripe for raid6 in chunk-recover

When deal with the p & q stripes for data profile raid6, chunk-recover
forgets to insert them into the chunk record. Just insert them back
freely.
Also wrap the insert procedure into a new function, fill_chunk_up.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
Gui Hecheng 2014-06-12 10:24:59 +08:00 committed by David Sterba
parent 2100836188
commit 41b617ed73
1 changed files with 20 additions and 10 deletions

View File

@ -1785,6 +1785,23 @@ static inline int count_devext_records(struct list_head *record_list)
return num_of_records; return num_of_records;
} }
static int fill_chunk_up(struct chunk_record *chunk, struct list_head *devexts,
struct recover_control *rc)
{
int ret = 0;
int i;
for (i = 0; i < chunk->num_stripes; i++) {
if (!chunk->stripes[i].devid) {
ret = insert_stripe(devexts, rc, chunk, i);
if (ret)
break;
}
}
return ret;
}
#define EQUAL_STRIPE (1 << 0) #define EQUAL_STRIPE (1 << 0)
static int rebuild_raid_data_chunk_stripes(struct recover_control *rc, static int rebuild_raid_data_chunk_stripes(struct recover_control *rc,
@ -1918,9 +1935,9 @@ next_csum:
num_unordered = count_devext_records(&unordered); num_unordered = count_devext_records(&unordered);
if (chunk->type_flags & BTRFS_BLOCK_GROUP_RAID6 if (chunk->type_flags & BTRFS_BLOCK_GROUP_RAID6
&& num_unordered == 2) { && num_unordered == 2) {
list_splice_init(&unordered, &chunk->dextents);
btrfs_release_path(&path); btrfs_release_path(&path);
return 0; ret = fill_chunk_up(chunk, &unordered, rc);
return ret;
} }
goto next_stripe; goto next_stripe;
@ -1965,14 +1982,7 @@ out:
& BTRFS_BLOCK_GROUP_RAID5) & BTRFS_BLOCK_GROUP_RAID5)
|| (num_unordered == 3 && chunk->type_flags || (num_unordered == 3 && chunk->type_flags
& BTRFS_BLOCK_GROUP_RAID6)) { & BTRFS_BLOCK_GROUP_RAID6)) {
for (i = 0; i < chunk->num_stripes; i++) { ret = fill_chunk_up(chunk, &unordered, rc);
if (!chunk->stripes[i].devid) {
ret = insert_stripe(&unordered, rc,
chunk, i);
if (ret)
break;
}
}
} }
} }
fail_out: fail_out: