mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
Merge branch 'cleanups/for-4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.4
This commit is contained in:
commit
a0d58e48db
16 changed files with 216 additions and 207 deletions
|
@ -667,7 +667,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
|
||||||
selected_super = kzalloc(sizeof(*selected_super), GFP_NOFS);
|
selected_super = kzalloc(sizeof(*selected_super), GFP_NOFS);
|
||||||
if (NULL == selected_super) {
|
if (NULL == selected_super) {
|
||||||
printk(KERN_INFO "btrfsic: error, kmalloc failed!\n");
|
printk(KERN_INFO "btrfsic: error, kmalloc failed!\n");
|
||||||
return -1;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_entry(device, dev_head, dev_list) {
|
list_for_each_entry(device, dev_head, dev_list) {
|
||||||
|
@ -1660,7 +1660,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
|
||||||
sizeof(*block_ctx->pagev)) *
|
sizeof(*block_ctx->pagev)) *
|
||||||
num_pages, GFP_NOFS);
|
num_pages, GFP_NOFS);
|
||||||
if (!block_ctx->mem_to_free)
|
if (!block_ctx->mem_to_free)
|
||||||
return -1;
|
return -ENOMEM;
|
||||||
block_ctx->datav = block_ctx->mem_to_free;
|
block_ctx->datav = block_ctx->mem_to_free;
|
||||||
block_ctx->pagev = (struct page **)(block_ctx->datav + num_pages);
|
block_ctx->pagev = (struct page **)(block_ctx->datav + num_pages);
|
||||||
for (i = 0; i < num_pages; i++) {
|
for (i = 0; i < num_pages; i++) {
|
||||||
|
|
|
@ -745,11 +745,13 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct list_head comp_idle_workspace[BTRFS_COMPRESS_TYPES];
|
static struct {
|
||||||
static spinlock_t comp_workspace_lock[BTRFS_COMPRESS_TYPES];
|
struct list_head idle_ws;
|
||||||
static int comp_num_workspace[BTRFS_COMPRESS_TYPES];
|
spinlock_t ws_lock;
|
||||||
static atomic_t comp_alloc_workspace[BTRFS_COMPRESS_TYPES];
|
int num_ws;
|
||||||
static wait_queue_head_t comp_workspace_wait[BTRFS_COMPRESS_TYPES];
|
atomic_t alloc_ws;
|
||||||
|
wait_queue_head_t ws_wait;
|
||||||
|
} btrfs_comp_ws[BTRFS_COMPRESS_TYPES];
|
||||||
|
|
||||||
static const struct btrfs_compress_op * const btrfs_compress_op[] = {
|
static const struct btrfs_compress_op * const btrfs_compress_op[] = {
|
||||||
&btrfs_zlib_compress,
|
&btrfs_zlib_compress,
|
||||||
|
@ -761,10 +763,10 @@ void __init btrfs_init_compress(void)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < BTRFS_COMPRESS_TYPES; i++) {
|
for (i = 0; i < BTRFS_COMPRESS_TYPES; i++) {
|
||||||
INIT_LIST_HEAD(&comp_idle_workspace[i]);
|
INIT_LIST_HEAD(&btrfs_comp_ws[i].idle_ws);
|
||||||
spin_lock_init(&comp_workspace_lock[i]);
|
spin_lock_init(&btrfs_comp_ws[i].ws_lock);
|
||||||
atomic_set(&comp_alloc_workspace[i], 0);
|
atomic_set(&btrfs_comp_ws[i].alloc_ws, 0);
|
||||||
init_waitqueue_head(&comp_workspace_wait[i]);
|
init_waitqueue_head(&btrfs_comp_ws[i].ws_wait);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -778,38 +780,38 @@ static struct list_head *find_workspace(int type)
|
||||||
int cpus = num_online_cpus();
|
int cpus = num_online_cpus();
|
||||||
int idx = type - 1;
|
int idx = type - 1;
|
||||||
|
|
||||||
struct list_head *idle_workspace = &comp_idle_workspace[idx];
|
struct list_head *idle_ws = &btrfs_comp_ws[idx].idle_ws;
|
||||||
spinlock_t *workspace_lock = &comp_workspace_lock[idx];
|
spinlock_t *ws_lock = &btrfs_comp_ws[idx].ws_lock;
|
||||||
atomic_t *alloc_workspace = &comp_alloc_workspace[idx];
|
atomic_t *alloc_ws = &btrfs_comp_ws[idx].alloc_ws;
|
||||||
wait_queue_head_t *workspace_wait = &comp_workspace_wait[idx];
|
wait_queue_head_t *ws_wait = &btrfs_comp_ws[idx].ws_wait;
|
||||||
int *num_workspace = &comp_num_workspace[idx];
|
int *num_ws = &btrfs_comp_ws[idx].num_ws;
|
||||||
again:
|
again:
|
||||||
spin_lock(workspace_lock);
|
spin_lock(ws_lock);
|
||||||
if (!list_empty(idle_workspace)) {
|
if (!list_empty(idle_ws)) {
|
||||||
workspace = idle_workspace->next;
|
workspace = idle_ws->next;
|
||||||
list_del(workspace);
|
list_del(workspace);
|
||||||
(*num_workspace)--;
|
(*num_ws)--;
|
||||||
spin_unlock(workspace_lock);
|
spin_unlock(ws_lock);
|
||||||
return workspace;
|
return workspace;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (atomic_read(alloc_workspace) > cpus) {
|
if (atomic_read(alloc_ws) > cpus) {
|
||||||
DEFINE_WAIT(wait);
|
DEFINE_WAIT(wait);
|
||||||
|
|
||||||
spin_unlock(workspace_lock);
|
spin_unlock(ws_lock);
|
||||||
prepare_to_wait(workspace_wait, &wait, TASK_UNINTERRUPTIBLE);
|
prepare_to_wait(ws_wait, &wait, TASK_UNINTERRUPTIBLE);
|
||||||
if (atomic_read(alloc_workspace) > cpus && !*num_workspace)
|
if (atomic_read(alloc_ws) > cpus && !*num_ws)
|
||||||
schedule();
|
schedule();
|
||||||
finish_wait(workspace_wait, &wait);
|
finish_wait(ws_wait, &wait);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
atomic_inc(alloc_workspace);
|
atomic_inc(alloc_ws);
|
||||||
spin_unlock(workspace_lock);
|
spin_unlock(ws_lock);
|
||||||
|
|
||||||
workspace = btrfs_compress_op[idx]->alloc_workspace();
|
workspace = btrfs_compress_op[idx]->alloc_workspace();
|
||||||
if (IS_ERR(workspace)) {
|
if (IS_ERR(workspace)) {
|
||||||
atomic_dec(alloc_workspace);
|
atomic_dec(alloc_ws);
|
||||||
wake_up(workspace_wait);
|
wake_up(ws_wait);
|
||||||
}
|
}
|
||||||
return workspace;
|
return workspace;
|
||||||
}
|
}
|
||||||
|
@ -821,30 +823,30 @@ static struct list_head *find_workspace(int type)
|
||||||
static void free_workspace(int type, struct list_head *workspace)
|
static void free_workspace(int type, struct list_head *workspace)
|
||||||
{
|
{
|
||||||
int idx = type - 1;
|
int idx = type - 1;
|
||||||
struct list_head *idle_workspace = &comp_idle_workspace[idx];
|
struct list_head *idle_ws = &btrfs_comp_ws[idx].idle_ws;
|
||||||
spinlock_t *workspace_lock = &comp_workspace_lock[idx];
|
spinlock_t *ws_lock = &btrfs_comp_ws[idx].ws_lock;
|
||||||
atomic_t *alloc_workspace = &comp_alloc_workspace[idx];
|
atomic_t *alloc_ws = &btrfs_comp_ws[idx].alloc_ws;
|
||||||
wait_queue_head_t *workspace_wait = &comp_workspace_wait[idx];
|
wait_queue_head_t *ws_wait = &btrfs_comp_ws[idx].ws_wait;
|
||||||
int *num_workspace = &comp_num_workspace[idx];
|
int *num_ws = &btrfs_comp_ws[idx].num_ws;
|
||||||
|
|
||||||
spin_lock(workspace_lock);
|
spin_lock(ws_lock);
|
||||||
if (*num_workspace < num_online_cpus()) {
|
if (*num_ws < num_online_cpus()) {
|
||||||
list_add(workspace, idle_workspace);
|
list_add(workspace, idle_ws);
|
||||||
(*num_workspace)++;
|
(*num_ws)++;
|
||||||
spin_unlock(workspace_lock);
|
spin_unlock(ws_lock);
|
||||||
goto wake;
|
goto wake;
|
||||||
}
|
}
|
||||||
spin_unlock(workspace_lock);
|
spin_unlock(ws_lock);
|
||||||
|
|
||||||
btrfs_compress_op[idx]->free_workspace(workspace);
|
btrfs_compress_op[idx]->free_workspace(workspace);
|
||||||
atomic_dec(alloc_workspace);
|
atomic_dec(alloc_ws);
|
||||||
wake:
|
wake:
|
||||||
/*
|
/*
|
||||||
* Make sure counter is updated before we wake up waiters.
|
* Make sure counter is updated before we wake up waiters.
|
||||||
*/
|
*/
|
||||||
smp_mb();
|
smp_mb();
|
||||||
if (waitqueue_active(workspace_wait))
|
if (waitqueue_active(ws_wait))
|
||||||
wake_up(workspace_wait);
|
wake_up(ws_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -856,11 +858,11 @@ static void free_workspaces(void)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < BTRFS_COMPRESS_TYPES; i++) {
|
for (i = 0; i < BTRFS_COMPRESS_TYPES; i++) {
|
||||||
while (!list_empty(&comp_idle_workspace[i])) {
|
while (!list_empty(&btrfs_comp_ws[i].idle_ws)) {
|
||||||
workspace = comp_idle_workspace[i].next;
|
workspace = btrfs_comp_ws[i].idle_ws.next;
|
||||||
list_del(workspace);
|
list_del(workspace);
|
||||||
btrfs_compress_op[i]->free_workspace(workspace);
|
btrfs_compress_op[i]->free_workspace(workspace);
|
||||||
atomic_dec(&comp_alloc_workspace[i]);
|
atomic_dec(&btrfs_comp_ws[i].alloc_ws);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4940,8 +4940,8 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
|
||||||
{
|
{
|
||||||
struct extent_buffer *leaf;
|
struct extent_buffer *leaf;
|
||||||
struct btrfs_item *item;
|
struct btrfs_item *item;
|
||||||
int last_off;
|
u32 last_off;
|
||||||
int dsize = 0;
|
u32 dsize = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int wret;
|
int wret;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -3476,22 +3476,31 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
|
||||||
|
|
||||||
int btrfs_get_num_tolerated_disk_barrier_failures(u64 flags)
|
int btrfs_get_num_tolerated_disk_barrier_failures(u64 flags)
|
||||||
{
|
{
|
||||||
if ((flags & (BTRFS_BLOCK_GROUP_DUP |
|
int raid_type;
|
||||||
BTRFS_BLOCK_GROUP_RAID0 |
|
int min_tolerated = INT_MAX;
|
||||||
BTRFS_AVAIL_ALLOC_BIT_SINGLE)) ||
|
|
||||||
((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (flags & (BTRFS_BLOCK_GROUP_RAID1 |
|
if ((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0 ||
|
||||||
BTRFS_BLOCK_GROUP_RAID5 |
|
(flags & BTRFS_AVAIL_ALLOC_BIT_SINGLE))
|
||||||
BTRFS_BLOCK_GROUP_RAID10))
|
min_tolerated = min(min_tolerated,
|
||||||
return 1;
|
btrfs_raid_array[BTRFS_RAID_SINGLE].
|
||||||
|
tolerated_failures);
|
||||||
|
|
||||||
if (flags & BTRFS_BLOCK_GROUP_RAID6)
|
for (raid_type = 0; raid_type < BTRFS_NR_RAID_TYPES; raid_type++) {
|
||||||
return 2;
|
if (raid_type == BTRFS_RAID_SINGLE)
|
||||||
|
continue;
|
||||||
|
if (!(flags & btrfs_raid_group[raid_type]))
|
||||||
|
continue;
|
||||||
|
min_tolerated = min(min_tolerated,
|
||||||
|
btrfs_raid_array[raid_type].
|
||||||
|
tolerated_failures);
|
||||||
|
}
|
||||||
|
|
||||||
pr_warn("BTRFS: unknown raid type: %llu\n", flags);
|
if (min_tolerated == INT_MAX) {
|
||||||
return 0;
|
pr_warn("BTRFS: unknown raid flag: %llu\n", flags);
|
||||||
|
min_tolerated = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return min_tolerated;
|
||||||
}
|
}
|
||||||
|
|
||||||
int btrfs_calc_num_tolerated_disk_barrier_failures(
|
int btrfs_calc_num_tolerated_disk_barrier_failures(
|
||||||
|
|
|
@ -3822,7 +3822,8 @@ static u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags)
|
||||||
{
|
{
|
||||||
u64 num_devices = root->fs_info->fs_devices->rw_devices;
|
u64 num_devices = root->fs_info->fs_devices->rw_devices;
|
||||||
u64 target;
|
u64 target;
|
||||||
u64 tmp;
|
u64 raid_type;
|
||||||
|
u64 allowed = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* see if restripe for this chunk_type is in progress, if so
|
* see if restripe for this chunk_type is in progress, if so
|
||||||
|
@ -3840,31 +3841,26 @@ static u64 btrfs_reduce_alloc_profile(struct btrfs_root *root, u64 flags)
|
||||||
spin_unlock(&root->fs_info->balance_lock);
|
spin_unlock(&root->fs_info->balance_lock);
|
||||||
|
|
||||||
/* First, mask out the RAID levels which aren't possible */
|
/* First, mask out the RAID levels which aren't possible */
|
||||||
if (num_devices == 1)
|
for (raid_type = 0; raid_type < BTRFS_NR_RAID_TYPES; raid_type++) {
|
||||||
flags &= ~(BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID0 |
|
if (num_devices >= btrfs_raid_array[raid_type].devs_min)
|
||||||
BTRFS_BLOCK_GROUP_RAID5);
|
allowed |= btrfs_raid_group[raid_type];
|
||||||
if (num_devices < 3)
|
}
|
||||||
flags &= ~BTRFS_BLOCK_GROUP_RAID6;
|
allowed &= flags;
|
||||||
if (num_devices < 4)
|
|
||||||
flags &= ~BTRFS_BLOCK_GROUP_RAID10;
|
|
||||||
|
|
||||||
tmp = flags & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID0 |
|
if (allowed & BTRFS_BLOCK_GROUP_RAID6)
|
||||||
BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID5 |
|
allowed = BTRFS_BLOCK_GROUP_RAID6;
|
||||||
BTRFS_BLOCK_GROUP_RAID6 | BTRFS_BLOCK_GROUP_RAID10);
|
else if (allowed & BTRFS_BLOCK_GROUP_RAID5)
|
||||||
flags &= ~tmp;
|
allowed = BTRFS_BLOCK_GROUP_RAID5;
|
||||||
|
else if (allowed & BTRFS_BLOCK_GROUP_RAID10)
|
||||||
|
allowed = BTRFS_BLOCK_GROUP_RAID10;
|
||||||
|
else if (allowed & BTRFS_BLOCK_GROUP_RAID1)
|
||||||
|
allowed = BTRFS_BLOCK_GROUP_RAID1;
|
||||||
|
else if (allowed & BTRFS_BLOCK_GROUP_RAID0)
|
||||||
|
allowed = BTRFS_BLOCK_GROUP_RAID0;
|
||||||
|
|
||||||
if (tmp & BTRFS_BLOCK_GROUP_RAID6)
|
flags &= ~BTRFS_BLOCK_GROUP_PROFILE_MASK;
|
||||||
tmp = BTRFS_BLOCK_GROUP_RAID6;
|
|
||||||
else if (tmp & BTRFS_BLOCK_GROUP_RAID5)
|
|
||||||
tmp = BTRFS_BLOCK_GROUP_RAID5;
|
|
||||||
else if (tmp & BTRFS_BLOCK_GROUP_RAID10)
|
|
||||||
tmp = BTRFS_BLOCK_GROUP_RAID10;
|
|
||||||
else if (tmp & BTRFS_BLOCK_GROUP_RAID1)
|
|
||||||
tmp = BTRFS_BLOCK_GROUP_RAID1;
|
|
||||||
else if (tmp & BTRFS_BLOCK_GROUP_RAID0)
|
|
||||||
tmp = BTRFS_BLOCK_GROUP_RAID0;
|
|
||||||
|
|
||||||
return extended_to_chunk(flags | tmp);
|
return extended_to_chunk(flags | allowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 get_alloc_profile(struct btrfs_root *root, u64 orig_flags)
|
static u64 get_alloc_profile(struct btrfs_root *root, u64 orig_flags)
|
||||||
|
@ -4891,13 +4887,9 @@ static struct btrfs_block_rsv *get_block_rsv(
|
||||||
{
|
{
|
||||||
struct btrfs_block_rsv *block_rsv = NULL;
|
struct btrfs_block_rsv *block_rsv = NULL;
|
||||||
|
|
||||||
if (test_bit(BTRFS_ROOT_REF_COWS, &root->state))
|
if (test_bit(BTRFS_ROOT_REF_COWS, &root->state) ||
|
||||||
block_rsv = trans->block_rsv;
|
(root == root->fs_info->csum_root && trans->adding_csums) ||
|
||||||
|
(root == root->fs_info->uuid_root))
|
||||||
if (root == root->fs_info->csum_root && trans->adding_csums)
|
|
||||||
block_rsv = trans->block_rsv;
|
|
||||||
|
|
||||||
if (root == root->fs_info->uuid_root)
|
|
||||||
block_rsv = trans->block_rsv;
|
block_rsv = trans->block_rsv;
|
||||||
|
|
||||||
if (!block_rsv)
|
if (!block_rsv)
|
||||||
|
|
|
@ -1469,7 +1469,6 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
|
||||||
u64 release_bytes = 0;
|
u64 release_bytes = 0;
|
||||||
u64 lockstart;
|
u64 lockstart;
|
||||||
u64 lockend;
|
u64 lockend;
|
||||||
unsigned long first_index;
|
|
||||||
size_t num_written = 0;
|
size_t num_written = 0;
|
||||||
int nrptrs;
|
int nrptrs;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -1485,8 +1484,6 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
|
||||||
if (!pages)
|
if (!pages)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
first_index = pos >> PAGE_CACHE_SHIFT;
|
|
||||||
|
|
||||||
while (iov_iter_count(i) > 0) {
|
while (iov_iter_count(i) > 0) {
|
||||||
size_t offset = pos & (PAGE_CACHE_SIZE - 1);
|
size_t offset = pos & (PAGE_CACHE_SIZE - 1);
|
||||||
size_t write_bytes = min(iov_iter_count(i),
|
size_t write_bytes = min(iov_iter_count(i),
|
||||||
|
@ -2266,7 +2263,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
|
||||||
u64 drop_end;
|
u64 drop_end;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int rsv_count;
|
unsigned int rsv_count;
|
||||||
bool same_page;
|
bool same_page;
|
||||||
bool no_holes = btrfs_fs_incompat(root->fs_info, NO_HOLES);
|
bool no_holes = btrfs_fs_incompat(root->fs_info, NO_HOLES);
|
||||||
u64 ino_size;
|
u64 ino_size;
|
||||||
|
|
|
@ -1215,7 +1215,7 @@ int btrfs_wait_cache_io(struct btrfs_root *root,
|
||||||
* @offset - the offset for the key we'll insert
|
* @offset - the offset for the key we'll insert
|
||||||
*
|
*
|
||||||
* This function writes out a free space cache struct to disk for quick recovery
|
* This function writes out a free space cache struct to disk for quick recovery
|
||||||
* on mount. This will return 0 if it was successfull in writing the cache out,
|
* on mount. This will return 0 if it was successful in writing the cache out,
|
||||||
* or an errno if it was not.
|
* or an errno if it was not.
|
||||||
*/
|
*/
|
||||||
static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
|
static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
|
||||||
|
|
|
@ -1864,15 +1864,15 @@ static int btrfs_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
|
||||||
u64 bio_offset)
|
u64 bio_offset)
|
||||||
{
|
{
|
||||||
struct btrfs_root *root = BTRFS_I(inode)->root;
|
struct btrfs_root *root = BTRFS_I(inode)->root;
|
||||||
|
enum btrfs_wq_endio_type metadata = BTRFS_WQ_ENDIO_DATA;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int skip_sum;
|
int skip_sum;
|
||||||
int metadata = 0;
|
|
||||||
int async = !atomic_read(&BTRFS_I(inode)->sync_writers);
|
int async = !atomic_read(&BTRFS_I(inode)->sync_writers);
|
||||||
|
|
||||||
skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
|
skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
|
||||||
|
|
||||||
if (btrfs_is_free_space_inode(inode))
|
if (btrfs_is_free_space_inode(inode))
|
||||||
metadata = 2;
|
metadata = BTRFS_WQ_ENDIO_FREE_SPACE;
|
||||||
|
|
||||||
if (!(rw & REQ_WRITE)) {
|
if (!(rw & REQ_WRITE)) {
|
||||||
ret = btrfs_bio_wq_end_io(root->fs_info, bio, metadata);
|
ret = btrfs_bio_wq_end_io(root->fs_info, bio, metadata);
|
||||||
|
@ -2602,7 +2602,6 @@ static void free_sa_defrag_extent(struct new_sa_defrag_extent *new)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
list_for_each_entry_safe(old, tmp, &new->head, list) {
|
list_for_each_entry_safe(old, tmp, &new->head, list) {
|
||||||
list_del(&old->list);
|
|
||||||
kfree(old);
|
kfree(old);
|
||||||
}
|
}
|
||||||
kfree(new);
|
kfree(new);
|
||||||
|
|
|
@ -2699,7 +2699,6 @@ static long btrfs_ioctl_fs_info(struct btrfs_root *root, void __user *arg)
|
||||||
{
|
{
|
||||||
struct btrfs_ioctl_fs_info_args *fi_args;
|
struct btrfs_ioctl_fs_info_args *fi_args;
|
||||||
struct btrfs_device *device;
|
struct btrfs_device *device;
|
||||||
struct btrfs_device *next;
|
|
||||||
struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
|
struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
@ -2711,7 +2710,7 @@ static long btrfs_ioctl_fs_info(struct btrfs_root *root, void __user *arg)
|
||||||
fi_args->num_devices = fs_devices->num_devices;
|
fi_args->num_devices = fs_devices->num_devices;
|
||||||
memcpy(&fi_args->fsid, root->fs_info->fsid, sizeof(fi_args->fsid));
|
memcpy(&fi_args->fsid, root->fs_info->fsid, sizeof(fi_args->fsid));
|
||||||
|
|
||||||
list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) {
|
list_for_each_entry(device, &fs_devices->devices, dev_list) {
|
||||||
if (device->devid > fi_args->max_id)
|
if (device->devid > fi_args->max_id)
|
||||||
fi_args->max_id = device->devid;
|
fi_args->max_id = device->devid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,18 +49,16 @@ static struct prop_handler prop_handlers[] = {
|
||||||
.extract = prop_compression_extract,
|
.extract = prop_compression_extract,
|
||||||
.inheritable = 1
|
.inheritable = 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
.xattr_name = NULL
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void __init btrfs_props_init(void)
|
void __init btrfs_props_init(void)
|
||||||
{
|
{
|
||||||
struct prop_handler *p;
|
int i;
|
||||||
|
|
||||||
hash_init(prop_handlers_ht);
|
hash_init(prop_handlers_ht);
|
||||||
|
|
||||||
for (p = &prop_handlers[0]; p->xattr_name; p++) {
|
for (i = 0; i < ARRAY_SIZE(prop_handlers); i++) {
|
||||||
|
struct prop_handler *p = &prop_handlers[i];
|
||||||
u64 h = btrfs_name_hash(p->xattr_name, strlen(p->xattr_name));
|
u64 h = btrfs_name_hash(p->xattr_name, strlen(p->xattr_name));
|
||||||
|
|
||||||
hash_add(prop_handlers_ht, &p->node, h);
|
hash_add(prop_handlers_ht, &p->node, h);
|
||||||
|
@ -301,15 +299,16 @@ static int inherit_props(struct btrfs_trans_handle *trans,
|
||||||
struct inode *inode,
|
struct inode *inode,
|
||||||
struct inode *parent)
|
struct inode *parent)
|
||||||
{
|
{
|
||||||
const struct prop_handler *h;
|
|
||||||
struct btrfs_root *root = BTRFS_I(inode)->root;
|
struct btrfs_root *root = BTRFS_I(inode)->root;
|
||||||
int ret;
|
int ret;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (!test_bit(BTRFS_INODE_HAS_PROPS,
|
if (!test_bit(BTRFS_INODE_HAS_PROPS,
|
||||||
&BTRFS_I(parent)->runtime_flags))
|
&BTRFS_I(parent)->runtime_flags))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (h = &prop_handlers[0]; h->xattr_name; h++) {
|
for (i = 0; i < ARRAY_SIZE(prop_handlers); i++) {
|
||||||
|
const struct prop_handler *h = &prop_handlers[i];
|
||||||
const char *value;
|
const char *value;
|
||||||
u64 num_bytes;
|
u64 num_bytes;
|
||||||
|
|
||||||
|
|
|
@ -569,7 +569,7 @@ static int reada_add_block(struct reada_control *rc, u64 logical,
|
||||||
rec = kzalloc(sizeof(*rec), GFP_NOFS);
|
rec = kzalloc(sizeof(*rec), GFP_NOFS);
|
||||||
if (!rec) {
|
if (!rec) {
|
||||||
reada_extent_put(root->fs_info, re);
|
reada_extent_put(root->fs_info, re);
|
||||||
return -1;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
rec->rc = rc;
|
rec->rc = rc;
|
||||||
|
@ -918,6 +918,7 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,
|
||||||
u64 start;
|
u64 start;
|
||||||
u64 generation;
|
u64 generation;
|
||||||
int level;
|
int level;
|
||||||
|
int ret;
|
||||||
struct extent_buffer *node;
|
struct extent_buffer *node;
|
||||||
static struct btrfs_key max_key = {
|
static struct btrfs_key max_key = {
|
||||||
.objectid = (u64)-1,
|
.objectid = (u64)-1,
|
||||||
|
@ -943,9 +944,10 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,
|
||||||
generation = btrfs_header_generation(node);
|
generation = btrfs_header_generation(node);
|
||||||
free_extent_buffer(node);
|
free_extent_buffer(node);
|
||||||
|
|
||||||
if (reada_add_block(rc, start, &max_key, level, generation)) {
|
ret = reada_add_block(rc, start, &max_key, level, generation);
|
||||||
|
if (ret) {
|
||||||
kfree(rc);
|
kfree(rc);
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
reada_start_machine(root->fs_info);
|
reada_start_machine(root->fs_info);
|
||||||
|
|
|
@ -142,7 +142,7 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
|
||||||
int ret;
|
int ret;
|
||||||
int slot;
|
int slot;
|
||||||
unsigned long ptr;
|
unsigned long ptr;
|
||||||
int old_len;
|
u32 old_len;
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
if (!path)
|
if (!path)
|
||||||
|
|
|
@ -242,15 +242,11 @@ static noinline int join_transaction(struct btrfs_root *root, unsigned int type)
|
||||||
cur_trans->start_time = get_seconds();
|
cur_trans->start_time = get_seconds();
|
||||||
cur_trans->dirty_bg_run = 0;
|
cur_trans->dirty_bg_run = 0;
|
||||||
|
|
||||||
|
memset(&cur_trans->delayed_refs, 0, sizeof(cur_trans->delayed_refs));
|
||||||
|
|
||||||
cur_trans->delayed_refs.href_root = RB_ROOT;
|
cur_trans->delayed_refs.href_root = RB_ROOT;
|
||||||
cur_trans->delayed_refs.dirty_extent_root = RB_ROOT;
|
cur_trans->delayed_refs.dirty_extent_root = RB_ROOT;
|
||||||
atomic_set(&cur_trans->delayed_refs.num_entries, 0);
|
atomic_set(&cur_trans->delayed_refs.num_entries, 0);
|
||||||
cur_trans->delayed_refs.num_heads_ready = 0;
|
|
||||||
cur_trans->delayed_refs.pending_csums = 0;
|
|
||||||
cur_trans->delayed_refs.num_heads = 0;
|
|
||||||
cur_trans->delayed_refs.flushing = 0;
|
|
||||||
cur_trans->delayed_refs.run_delayed_start = 0;
|
|
||||||
cur_trans->delayed_refs.qgroup_to_skip = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* although the tree mod log is per file system and not per transaction,
|
* although the tree mod log is per file system and not per transaction,
|
||||||
|
@ -453,8 +449,8 @@ static inline bool need_reserve_reloc_root(struct btrfs_root *root)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct btrfs_trans_handle *
|
static struct btrfs_trans_handle *
|
||||||
start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type,
|
start_transaction(struct btrfs_root *root, unsigned int num_items,
|
||||||
enum btrfs_reserve_flush_enum flush)
|
unsigned int type, enum btrfs_reserve_flush_enum flush)
|
||||||
{
|
{
|
||||||
struct btrfs_trans_handle *h;
|
struct btrfs_trans_handle *h;
|
||||||
struct btrfs_transaction *cur_trans;
|
struct btrfs_transaction *cur_trans;
|
||||||
|
@ -508,7 +504,7 @@ start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type,
|
||||||
goto reserve_fail;
|
goto reserve_fail;
|
||||||
}
|
}
|
||||||
again:
|
again:
|
||||||
h = kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS);
|
h = kmem_cache_zalloc(btrfs_trans_handle_cachep, GFP_NOFS);
|
||||||
if (!h) {
|
if (!h) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto alloc_fail;
|
goto alloc_fail;
|
||||||
|
@ -549,23 +545,10 @@ start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type,
|
||||||
|
|
||||||
h->transid = cur_trans->transid;
|
h->transid = cur_trans->transid;
|
||||||
h->transaction = cur_trans;
|
h->transaction = cur_trans;
|
||||||
h->blocks_used = 0;
|
|
||||||
h->bytes_reserved = 0;
|
|
||||||
h->chunk_bytes_reserved = 0;
|
|
||||||
h->root = root;
|
h->root = root;
|
||||||
h->delayed_ref_updates = 0;
|
|
||||||
h->use_count = 1;
|
h->use_count = 1;
|
||||||
h->adding_csums = 0;
|
|
||||||
h->block_rsv = NULL;
|
|
||||||
h->orig_rsv = NULL;
|
|
||||||
h->aborted = 0;
|
|
||||||
h->qgroup_reserved = 0;
|
|
||||||
h->delayed_ref_elem.seq = 0;
|
|
||||||
h->type = type;
|
h->type = type;
|
||||||
h->allocating_chunk = false;
|
|
||||||
h->can_flush_pending_bgs = true;
|
h->can_flush_pending_bgs = true;
|
||||||
h->reloc_reserved = false;
|
|
||||||
h->sync = false;
|
|
||||||
INIT_LIST_HEAD(&h->qgroup_ref_list);
|
INIT_LIST_HEAD(&h->qgroup_ref_list);
|
||||||
INIT_LIST_HEAD(&h->new_bgs);
|
INIT_LIST_HEAD(&h->new_bgs);
|
||||||
INIT_LIST_HEAD(&h->ordered);
|
INIT_LIST_HEAD(&h->ordered);
|
||||||
|
@ -609,14 +592,15 @@ start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
|
struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
|
||||||
int num_items)
|
unsigned int num_items)
|
||||||
{
|
{
|
||||||
return start_transaction(root, num_items, TRANS_START,
|
return start_transaction(root, num_items, TRANS_START,
|
||||||
BTRFS_RESERVE_FLUSH_ALL);
|
BTRFS_RESERVE_FLUSH_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct btrfs_trans_handle *btrfs_start_transaction_lflush(
|
struct btrfs_trans_handle *btrfs_start_transaction_lflush(
|
||||||
struct btrfs_root *root, int num_items)
|
struct btrfs_root *root,
|
||||||
|
unsigned int num_items)
|
||||||
{
|
{
|
||||||
return start_transaction(root, num_items, TRANS_START,
|
return start_transaction(root, num_items, TRANS_START,
|
||||||
BTRFS_RESERVE_FLUSH_LIMIT);
|
BTRFS_RESERVE_FLUSH_LIMIT);
|
||||||
|
|
|
@ -185,9 +185,10 @@ static inline void btrfs_clear_skip_qgroup(struct btrfs_trans_handle *trans)
|
||||||
int btrfs_end_transaction(struct btrfs_trans_handle *trans,
|
int btrfs_end_transaction(struct btrfs_trans_handle *trans,
|
||||||
struct btrfs_root *root);
|
struct btrfs_root *root);
|
||||||
struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
|
struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
|
||||||
int num_items);
|
unsigned int num_items);
|
||||||
struct btrfs_trans_handle *btrfs_start_transaction_lflush(
|
struct btrfs_trans_handle *btrfs_start_transaction_lflush(
|
||||||
struct btrfs_root *root, int num_items);
|
struct btrfs_root *root,
|
||||||
|
unsigned int num_items);
|
||||||
struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root);
|
struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root);
|
||||||
struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root);
|
struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root);
|
||||||
struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root);
|
struct btrfs_trans_handle *btrfs_attach_transaction(struct btrfs_root *root);
|
||||||
|
|
|
@ -42,6 +42,82 @@
|
||||||
#include "dev-replace.h"
|
#include "dev-replace.h"
|
||||||
#include "sysfs.h"
|
#include "sysfs.h"
|
||||||
|
|
||||||
|
const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
|
||||||
|
[BTRFS_RAID_RAID10] = {
|
||||||
|
.sub_stripes = 2,
|
||||||
|
.dev_stripes = 1,
|
||||||
|
.devs_max = 0, /* 0 == as many as possible */
|
||||||
|
.devs_min = 4,
|
||||||
|
.tolerated_failures = 1,
|
||||||
|
.devs_increment = 2,
|
||||||
|
.ncopies = 2,
|
||||||
|
},
|
||||||
|
[BTRFS_RAID_RAID1] = {
|
||||||
|
.sub_stripes = 1,
|
||||||
|
.dev_stripes = 1,
|
||||||
|
.devs_max = 2,
|
||||||
|
.devs_min = 2,
|
||||||
|
.tolerated_failures = 1,
|
||||||
|
.devs_increment = 2,
|
||||||
|
.ncopies = 2,
|
||||||
|
},
|
||||||
|
[BTRFS_RAID_DUP] = {
|
||||||
|
.sub_stripes = 1,
|
||||||
|
.dev_stripes = 2,
|
||||||
|
.devs_max = 1,
|
||||||
|
.devs_min = 1,
|
||||||
|
.tolerated_failures = 0,
|
||||||
|
.devs_increment = 1,
|
||||||
|
.ncopies = 2,
|
||||||
|
},
|
||||||
|
[BTRFS_RAID_RAID0] = {
|
||||||
|
.sub_stripes = 1,
|
||||||
|
.dev_stripes = 1,
|
||||||
|
.devs_max = 0,
|
||||||
|
.devs_min = 2,
|
||||||
|
.tolerated_failures = 0,
|
||||||
|
.devs_increment = 1,
|
||||||
|
.ncopies = 1,
|
||||||
|
},
|
||||||
|
[BTRFS_RAID_SINGLE] = {
|
||||||
|
.sub_stripes = 1,
|
||||||
|
.dev_stripes = 1,
|
||||||
|
.devs_max = 1,
|
||||||
|
.devs_min = 1,
|
||||||
|
.tolerated_failures = 0,
|
||||||
|
.devs_increment = 1,
|
||||||
|
.ncopies = 1,
|
||||||
|
},
|
||||||
|
[BTRFS_RAID_RAID5] = {
|
||||||
|
.sub_stripes = 1,
|
||||||
|
.dev_stripes = 1,
|
||||||
|
.devs_max = 0,
|
||||||
|
.devs_min = 2,
|
||||||
|
.tolerated_failures = 1,
|
||||||
|
.devs_increment = 1,
|
||||||
|
.ncopies = 2,
|
||||||
|
},
|
||||||
|
[BTRFS_RAID_RAID6] = {
|
||||||
|
.sub_stripes = 1,
|
||||||
|
.dev_stripes = 1,
|
||||||
|
.devs_max = 0,
|
||||||
|
.devs_min = 3,
|
||||||
|
.tolerated_failures = 2,
|
||||||
|
.devs_increment = 1,
|
||||||
|
.ncopies = 3,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const u64 const btrfs_raid_group[BTRFS_NR_RAID_TYPES] = {
|
||||||
|
[BTRFS_RAID_RAID10] = BTRFS_BLOCK_GROUP_RAID10,
|
||||||
|
[BTRFS_RAID_RAID1] = BTRFS_BLOCK_GROUP_RAID1,
|
||||||
|
[BTRFS_RAID_DUP] = BTRFS_BLOCK_GROUP_DUP,
|
||||||
|
[BTRFS_RAID_RAID0] = BTRFS_BLOCK_GROUP_RAID0,
|
||||||
|
[BTRFS_RAID_SINGLE] = 0,
|
||||||
|
[BTRFS_RAID_RAID5] = BTRFS_BLOCK_GROUP_RAID5,
|
||||||
|
[BTRFS_RAID_RAID6] = BTRFS_BLOCK_GROUP_RAID6,
|
||||||
|
};
|
||||||
|
|
||||||
static int init_first_rw_device(struct btrfs_trans_handle *trans,
|
static int init_first_rw_device(struct btrfs_trans_handle *trans,
|
||||||
struct btrfs_root *root,
|
struct btrfs_root *root,
|
||||||
struct btrfs_device *device);
|
struct btrfs_device *device);
|
||||||
|
@ -3440,6 +3516,15 @@ static void __cancel_balance(struct btrfs_fs_info *fs_info)
|
||||||
atomic_set(&fs_info->mutually_exclusive_operation_running, 0);
|
atomic_set(&fs_info->mutually_exclusive_operation_running, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Non-zero return value signifies invalidity */
|
||||||
|
static inline int validate_convert_profile(struct btrfs_balance_args *bctl_arg,
|
||||||
|
u64 allowed)
|
||||||
|
{
|
||||||
|
return ((bctl_arg->flags & BTRFS_BALANCE_ARGS_CONVERT) &&
|
||||||
|
(!alloc_profile_is_valid(bctl_arg->target, 1) ||
|
||||||
|
(bctl_arg->target & ~allowed)));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Should be called with both balance and volume mutexes held
|
* Should be called with both balance and volume mutexes held
|
||||||
*/
|
*/
|
||||||
|
@ -3497,27 +3582,21 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
|
||||||
if (num_devices > 3)
|
if (num_devices > 3)
|
||||||
allowed |= (BTRFS_BLOCK_GROUP_RAID10 |
|
allowed |= (BTRFS_BLOCK_GROUP_RAID10 |
|
||||||
BTRFS_BLOCK_GROUP_RAID6);
|
BTRFS_BLOCK_GROUP_RAID6);
|
||||||
if ((bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT) &&
|
if (validate_convert_profile(&bctl->data, allowed)) {
|
||||||
(!alloc_profile_is_valid(bctl->data.target, 1) ||
|
|
||||||
(bctl->data.target & ~allowed))) {
|
|
||||||
btrfs_err(fs_info, "unable to start balance with target "
|
btrfs_err(fs_info, "unable to start balance with target "
|
||||||
"data profile %llu",
|
"data profile %llu",
|
||||||
bctl->data.target);
|
bctl->data.target);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if ((bctl->meta.flags & BTRFS_BALANCE_ARGS_CONVERT) &&
|
if (validate_convert_profile(&bctl->meta, allowed)) {
|
||||||
(!alloc_profile_is_valid(bctl->meta.target, 1) ||
|
|
||||||
(bctl->meta.target & ~allowed))) {
|
|
||||||
btrfs_err(fs_info,
|
btrfs_err(fs_info,
|
||||||
"unable to start balance with target metadata profile %llu",
|
"unable to start balance with target metadata profile %llu",
|
||||||
bctl->meta.target);
|
bctl->meta.target);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if ((bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) &&
|
if (validate_convert_profile(&bctl->sys, allowed)) {
|
||||||
(!alloc_profile_is_valid(bctl->sys.target, 1) ||
|
|
||||||
(bctl->sys.target & ~allowed))) {
|
|
||||||
btrfs_err(fs_info,
|
btrfs_err(fs_info,
|
||||||
"unable to start balance with target system profile %llu",
|
"unable to start balance with target system profile %llu",
|
||||||
bctl->sys.target);
|
bctl->sys.target);
|
||||||
|
@ -4259,65 +4338,6 @@ static int btrfs_cmp_device_info(const void *a, const void *b)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
|
|
||||||
[BTRFS_RAID_RAID10] = {
|
|
||||||
.sub_stripes = 2,
|
|
||||||
.dev_stripes = 1,
|
|
||||||
.devs_max = 0, /* 0 == as many as possible */
|
|
||||||
.devs_min = 4,
|
|
||||||
.devs_increment = 2,
|
|
||||||
.ncopies = 2,
|
|
||||||
},
|
|
||||||
[BTRFS_RAID_RAID1] = {
|
|
||||||
.sub_stripes = 1,
|
|
||||||
.dev_stripes = 1,
|
|
||||||
.devs_max = 2,
|
|
||||||
.devs_min = 2,
|
|
||||||
.devs_increment = 2,
|
|
||||||
.ncopies = 2,
|
|
||||||
},
|
|
||||||
[BTRFS_RAID_DUP] = {
|
|
||||||
.sub_stripes = 1,
|
|
||||||
.dev_stripes = 2,
|
|
||||||
.devs_max = 1,
|
|
||||||
.devs_min = 1,
|
|
||||||
.devs_increment = 1,
|
|
||||||
.ncopies = 2,
|
|
||||||
},
|
|
||||||
[BTRFS_RAID_RAID0] = {
|
|
||||||
.sub_stripes = 1,
|
|
||||||
.dev_stripes = 1,
|
|
||||||
.devs_max = 0,
|
|
||||||
.devs_min = 2,
|
|
||||||
.devs_increment = 1,
|
|
||||||
.ncopies = 1,
|
|
||||||
},
|
|
||||||
[BTRFS_RAID_SINGLE] = {
|
|
||||||
.sub_stripes = 1,
|
|
||||||
.dev_stripes = 1,
|
|
||||||
.devs_max = 1,
|
|
||||||
.devs_min = 1,
|
|
||||||
.devs_increment = 1,
|
|
||||||
.ncopies = 1,
|
|
||||||
},
|
|
||||||
[BTRFS_RAID_RAID5] = {
|
|
||||||
.sub_stripes = 1,
|
|
||||||
.dev_stripes = 1,
|
|
||||||
.devs_max = 0,
|
|
||||||
.devs_min = 2,
|
|
||||||
.devs_increment = 1,
|
|
||||||
.ncopies = 2,
|
|
||||||
},
|
|
||||||
[BTRFS_RAID_RAID6] = {
|
|
||||||
.sub_stripes = 1,
|
|
||||||
.dev_stripes = 1,
|
|
||||||
.devs_max = 0,
|
|
||||||
.devs_min = 3,
|
|
||||||
.devs_increment = 1,
|
|
||||||
.ncopies = 3,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
static u32 find_raid56_stripe_len(u32 data_devices, u32 dev_stripe_target)
|
static u32 find_raid56_stripe_len(u32 data_devices, u32 dev_stripe_target)
|
||||||
{
|
{
|
||||||
/* TODO allow them to set a preferred stripe size */
|
/* TODO allow them to set a preferred stripe size */
|
||||||
|
|
|
@ -334,10 +334,15 @@ struct btrfs_raid_attr {
|
||||||
int dev_stripes; /* stripes per dev */
|
int dev_stripes; /* stripes per dev */
|
||||||
int devs_max; /* max devs to use */
|
int devs_max; /* max devs to use */
|
||||||
int devs_min; /* min devs needed */
|
int devs_min; /* min devs needed */
|
||||||
|
int tolerated_failures; /* max tolerated fail devs */
|
||||||
int devs_increment; /* ndevs has to be a multiple of this */
|
int devs_increment; /* ndevs has to be a multiple of this */
|
||||||
int ncopies; /* how many copies to data has */
|
int ncopies; /* how many copies to data has */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES];
|
||||||
|
|
||||||
|
extern const u64 btrfs_raid_group[BTRFS_NR_RAID_TYPES];
|
||||||
|
|
||||||
struct map_lookup {
|
struct map_lookup {
|
||||||
u64 type;
|
u64 type;
|
||||||
int io_align;
|
int io_align;
|
||||||
|
|
Loading…
Reference in a new issue