Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
* git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable: Btrfs: check total number of devices when removing missing Btrfs: check return value of open_bdev_exclusive properly Btrfs: do not mark the chunk as readonly if in degraded mode Btrfs: run orphan cleanup on default fs root Btrfs: fix a memory leak in btrfs_init_acl Btrfs: Use correct values when updating inode i_size on fallocate Btrfs: remove tree_search() in extent_map.c Btrfs: Add mount -o compress-force
This commit is contained in:
commit
67f15b06c1
7 changed files with 36 additions and 30 deletions
|
@ -244,6 +244,7 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans,
|
|||
ACL_TYPE_ACCESS);
|
||||
}
|
||||
}
|
||||
posix_acl_release(clone);
|
||||
}
|
||||
failed:
|
||||
posix_acl_release(acl);
|
||||
|
|
|
@ -1161,6 +1161,7 @@ struct btrfs_root {
|
|||
#define BTRFS_MOUNT_SSD_SPREAD (1 << 8)
|
||||
#define BTRFS_MOUNT_NOSSD (1 << 9)
|
||||
#define BTRFS_MOUNT_DISCARD (1 << 10)
|
||||
#define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11)
|
||||
|
||||
#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
|
||||
#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
|
||||
|
|
|
@ -1993,6 +1993,12 @@ struct btrfs_root *open_ctree(struct super_block *sb,
|
|||
if (!fs_info->fs_root)
|
||||
goto fail_trans_kthread;
|
||||
|
||||
if (!(sb->s_flags & MS_RDONLY)) {
|
||||
down_read(&fs_info->cleanup_work_sem);
|
||||
btrfs_orphan_cleanup(fs_info->fs_root);
|
||||
up_read(&fs_info->cleanup_work_sem);
|
||||
}
|
||||
|
||||
return tree_root;
|
||||
|
||||
fail_trans_kthread:
|
||||
|
|
|
@ -155,20 +155,6 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* look for an offset in the tree, and if it can't be found, return
|
||||
* the first offset we can find smaller than 'offset'.
|
||||
*/
|
||||
static inline struct rb_node *tree_search(struct rb_root *root, u64 offset)
|
||||
{
|
||||
struct rb_node *prev;
|
||||
struct rb_node *ret;
|
||||
ret = __tree_search(root, offset, &prev, NULL);
|
||||
if (!ret)
|
||||
return prev;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* check to see if two extent_map structs are adjacent and safe to merge */
|
||||
static int mergable_maps(struct extent_map *prev, struct extent_map *next)
|
||||
{
|
||||
|
|
|
@ -483,7 +483,8 @@ again:
|
|||
nr_pages_ret = 0;
|
||||
|
||||
/* flag the file so we don't compress in the future */
|
||||
BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
|
||||
if (!btrfs_test_opt(root, FORCE_COMPRESS))
|
||||
BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
|
||||
}
|
||||
if (will_compress) {
|
||||
*num_added += 1;
|
||||
|
@ -3796,12 +3797,6 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
|
|||
|
||||
if (location.type == BTRFS_INODE_ITEM_KEY) {
|
||||
inode = btrfs_iget(dir->i_sb, &location, root);
|
||||
if (unlikely(root->clean_orphans) &&
|
||||
!(inode->i_sb->s_flags & MS_RDONLY)) {
|
||||
down_read(&root->fs_info->cleanup_work_sem);
|
||||
btrfs_orphan_cleanup(root);
|
||||
up_read(&root->fs_info->cleanup_work_sem);
|
||||
}
|
||||
return inode;
|
||||
}
|
||||
|
||||
|
@ -5799,7 +5794,7 @@ out_fail:
|
|||
}
|
||||
|
||||
static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
|
||||
u64 alloc_hint, int mode)
|
||||
u64 alloc_hint, int mode, loff_t actual_len)
|
||||
{
|
||||
struct btrfs_trans_handle *trans;
|
||||
struct btrfs_root *root = BTRFS_I(inode)->root;
|
||||
|
@ -5808,6 +5803,7 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
|
|||
u64 cur_offset = start;
|
||||
u64 num_bytes = end - start;
|
||||
int ret = 0;
|
||||
u64 i_size;
|
||||
|
||||
while (num_bytes > 0) {
|
||||
alloc_size = min(num_bytes, root->fs_info->max_extent);
|
||||
|
@ -5846,8 +5842,12 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
|
|||
BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;
|
||||
if (!(mode & FALLOC_FL_KEEP_SIZE) &&
|
||||
cur_offset > inode->i_size) {
|
||||
i_size_write(inode, cur_offset);
|
||||
btrfs_ordered_update_i_size(inode, cur_offset, NULL);
|
||||
if (cur_offset > actual_len)
|
||||
i_size = actual_len;
|
||||
else
|
||||
i_size = cur_offset;
|
||||
i_size_write(inode, i_size);
|
||||
btrfs_ordered_update_i_size(inode, i_size, NULL);
|
||||
}
|
||||
|
||||
ret = btrfs_update_inode(trans, root, inode);
|
||||
|
@ -5940,7 +5940,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
|
|||
!test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) {
|
||||
ret = prealloc_file_range(inode,
|
||||
cur_offset, last_byte,
|
||||
alloc_hint, mode);
|
||||
alloc_hint, mode, offset+len);
|
||||
if (ret < 0) {
|
||||
free_extent_map(em);
|
||||
break;
|
||||
|
|
|
@ -66,7 +66,8 @@ enum {
|
|||
Opt_degraded, Opt_subvol, Opt_device, Opt_nodatasum, Opt_nodatacow,
|
||||
Opt_max_extent, Opt_max_inline, Opt_alloc_start, Opt_nobarrier,
|
||||
Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl,
|
||||
Opt_compress, Opt_notreelog, Opt_ratio, Opt_flushoncommit,
|
||||
Opt_compress, Opt_compress_force, Opt_notreelog, Opt_ratio,
|
||||
Opt_flushoncommit,
|
||||
Opt_discard, Opt_err,
|
||||
};
|
||||
|
||||
|
@ -82,6 +83,7 @@ static match_table_t tokens = {
|
|||
{Opt_alloc_start, "alloc_start=%s"},
|
||||
{Opt_thread_pool, "thread_pool=%d"},
|
||||
{Opt_compress, "compress"},
|
||||
{Opt_compress_force, "compress-force"},
|
||||
{Opt_ssd, "ssd"},
|
||||
{Opt_ssd_spread, "ssd_spread"},
|
||||
{Opt_nossd, "nossd"},
|
||||
|
@ -173,6 +175,11 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
|
|||
printk(KERN_INFO "btrfs: use compression\n");
|
||||
btrfs_set_opt(info->mount_opt, COMPRESS);
|
||||
break;
|
||||
case Opt_compress_force:
|
||||
printk(KERN_INFO "btrfs: forcing compression\n");
|
||||
btrfs_set_opt(info->mount_opt, FORCE_COMPRESS);
|
||||
btrfs_set_opt(info->mount_opt, COMPRESS);
|
||||
break;
|
||||
case Opt_ssd:
|
||||
printk(KERN_INFO "btrfs: use ssd allocation scheme\n");
|
||||
btrfs_set_opt(info->mount_opt, SSD);
|
||||
|
|
|
@ -1135,7 +1135,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
|
|||
root->fs_info->avail_metadata_alloc_bits;
|
||||
|
||||
if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) &&
|
||||
root->fs_info->fs_devices->rw_devices <= 4) {
|
||||
root->fs_info->fs_devices->num_devices <= 4) {
|
||||
printk(KERN_ERR "btrfs: unable to go below four devices "
|
||||
"on raid10\n");
|
||||
ret = -EINVAL;
|
||||
|
@ -1143,7 +1143,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
|
|||
}
|
||||
|
||||
if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) &&
|
||||
root->fs_info->fs_devices->rw_devices <= 2) {
|
||||
root->fs_info->fs_devices->num_devices <= 2) {
|
||||
printk(KERN_ERR "btrfs: unable to go below two "
|
||||
"devices on raid1\n");
|
||||
ret = -EINVAL;
|
||||
|
@ -1434,8 +1434,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
|
|||
return -EINVAL;
|
||||
|
||||
bdev = open_bdev_exclusive(device_path, 0, root->fs_info->bdev_holder);
|
||||
if (!bdev)
|
||||
return -EIO;
|
||||
if (IS_ERR(bdev))
|
||||
return PTR_ERR(bdev);
|
||||
|
||||
if (root->fs_info->fs_devices->seeding) {
|
||||
seeding_dev = 1;
|
||||
|
@ -2538,6 +2538,11 @@ int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset)
|
|||
if (!em)
|
||||
return 1;
|
||||
|
||||
if (btrfs_test_opt(root, DEGRADED)) {
|
||||
free_extent_map(em);
|
||||
return 0;
|
||||
}
|
||||
|
||||
map = (struct map_lookup *)em->bdev;
|
||||
for (i = 0; i < map->num_stripes; i++) {
|
||||
if (!map->stripes[i].dev->writeable) {
|
||||
|
|
Loading…
Reference in a new issue