diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-29 13:27:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-01-29 13:27:37 -0500 |
commit | 67f15b06c1a7e5417b7042b515ca2695de30beda (patch) | |
tree | ba93b80b40ba2a6d89adc74ed4be54b4626c56a3 /fs | |
parent | 94673e968cbcce07fa78dac4b0ae05d24b5816e1 (diff) | |
parent | 035fe03a7ad56982b30ab3a522b7b08d58feccd0 (diff) |
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
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/acl.c | 1 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 1 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 6 | ||||
-rw-r--r-- | fs/btrfs/extent_map.c | 14 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 22 | ||||
-rw-r--r-- | fs/btrfs/super.c | 9 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 13 |
7 files changed, 36 insertions, 30 deletions
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 54f4798ab46a..6df6d6ed74fd 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c | |||
@@ -244,6 +244,7 @@ int btrfs_init_acl(struct btrfs_trans_handle *trans, | |||
244 | ACL_TYPE_ACCESS); | 244 | ACL_TYPE_ACCESS); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | posix_acl_release(clone); | ||
247 | } | 248 | } |
248 | failed: | 249 | failed: |
249 | posix_acl_release(acl); | 250 | posix_acl_release(acl); |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 9f806dd04c27..2aa8ec6a0981 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -1161,6 +1161,7 @@ struct btrfs_root { | |||
1161 | #define BTRFS_MOUNT_SSD_SPREAD (1 << 8) | 1161 | #define BTRFS_MOUNT_SSD_SPREAD (1 << 8) |
1162 | #define BTRFS_MOUNT_NOSSD (1 << 9) | 1162 | #define BTRFS_MOUNT_NOSSD (1 << 9) |
1163 | #define BTRFS_MOUNT_DISCARD (1 << 10) | 1163 | #define BTRFS_MOUNT_DISCARD (1 << 10) |
1164 | #define BTRFS_MOUNT_FORCE_COMPRESS (1 << 11) | ||
1164 | 1165 | ||
1165 | #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) | 1166 | #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) |
1166 | #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) | 1167 | #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 009e3bd18f23..87b25543d7d1 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1993,6 +1993,12 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1993 | if (!fs_info->fs_root) | 1993 | if (!fs_info->fs_root) |
1994 | goto fail_trans_kthread; | 1994 | goto fail_trans_kthread; |
1995 | 1995 | ||
1996 | if (!(sb->s_flags & MS_RDONLY)) { | ||
1997 | down_read(&fs_info->cleanup_work_sem); | ||
1998 | btrfs_orphan_cleanup(fs_info->fs_root); | ||
1999 | up_read(&fs_info->cleanup_work_sem); | ||
2000 | } | ||
2001 | |||
1996 | return tree_root; | 2002 | return tree_root; |
1997 | 2003 | ||
1998 | fail_trans_kthread: | 2004 | fail_trans_kthread: |
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c index 46bea0f4dc7b..428fcac45f90 100644 --- a/fs/btrfs/extent_map.c +++ b/fs/btrfs/extent_map.c | |||
@@ -155,20 +155,6 @@ static struct rb_node *__tree_search(struct rb_root *root, u64 offset, | |||
155 | return NULL; | 155 | return NULL; |
156 | } | 156 | } |
157 | 157 | ||
158 | /* | ||
159 | * look for an offset in the tree, and if it can't be found, return | ||
160 | * the first offset we can find smaller than 'offset'. | ||
161 | */ | ||
162 | static inline struct rb_node *tree_search(struct rb_root *root, u64 offset) | ||
163 | { | ||
164 | struct rb_node *prev; | ||
165 | struct rb_node *ret; | ||
166 | ret = __tree_search(root, offset, &prev, NULL); | ||
167 | if (!ret) | ||
168 | return prev; | ||
169 | return ret; | ||
170 | } | ||
171 | |||
172 | /* check to see if two extent_map structs are adjacent and safe to merge */ | 158 | /* check to see if two extent_map structs are adjacent and safe to merge */ |
173 | static int mergable_maps(struct extent_map *prev, struct extent_map *next) | 159 | static int mergable_maps(struct extent_map *prev, struct extent_map *next) |
174 | { | 160 | { |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index b330e27c2d8b..8cd109972fa6 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -483,7 +483,8 @@ again: | |||
483 | nr_pages_ret = 0; | 483 | nr_pages_ret = 0; |
484 | 484 | ||
485 | /* flag the file so we don't compress in the future */ | 485 | /* flag the file so we don't compress in the future */ |
486 | BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS; | 486 | if (!btrfs_test_opt(root, FORCE_COMPRESS)) |
487 | BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS; | ||
487 | } | 488 | } |
488 | if (will_compress) { | 489 | if (will_compress) { |
489 | *num_added += 1; | 490 | *num_added += 1; |
@@ -3796,12 +3797,6 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) | |||
3796 | 3797 | ||
3797 | if (location.type == BTRFS_INODE_ITEM_KEY) { | 3798 | if (location.type == BTRFS_INODE_ITEM_KEY) { |
3798 | inode = btrfs_iget(dir->i_sb, &location, root); | 3799 | inode = btrfs_iget(dir->i_sb, &location, root); |
3799 | if (unlikely(root->clean_orphans) && | ||
3800 | !(inode->i_sb->s_flags & MS_RDONLY)) { | ||
3801 | down_read(&root->fs_info->cleanup_work_sem); | ||
3802 | btrfs_orphan_cleanup(root); | ||
3803 | up_read(&root->fs_info->cleanup_work_sem); | ||
3804 | } | ||
3805 | return inode; | 3800 | return inode; |
3806 | } | 3801 | } |
3807 | 3802 | ||
@@ -5799,7 +5794,7 @@ out_fail: | |||
5799 | } | 5794 | } |
5800 | 5795 | ||
5801 | static int prealloc_file_range(struct inode *inode, u64 start, u64 end, | 5796 | static int prealloc_file_range(struct inode *inode, u64 start, u64 end, |
5802 | u64 alloc_hint, int mode) | 5797 | u64 alloc_hint, int mode, loff_t actual_len) |
5803 | { | 5798 | { |
5804 | struct btrfs_trans_handle *trans; | 5799 | struct btrfs_trans_handle *trans; |
5805 | struct btrfs_root *root = BTRFS_I(inode)->root; | 5800 | struct btrfs_root *root = BTRFS_I(inode)->root; |
@@ -5808,6 +5803,7 @@ static int prealloc_file_range(struct inode *inode, u64 start, u64 end, | |||
5808 | u64 cur_offset = start; | 5803 | u64 cur_offset = start; |
5809 | u64 num_bytes = end - start; | 5804 | u64 num_bytes = end - start; |
5810 | int ret = 0; | 5805 | int ret = 0; |
5806 | u64 i_size; | ||
5811 | 5807 | ||
5812 | while (num_bytes > 0) { | 5808 | while (num_bytes > 0) { |
5813 | alloc_size = min(num_bytes, root->fs_info->max_extent); | 5809 | 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, | |||
5846 | BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC; | 5842 | BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC; |
5847 | if (!(mode & FALLOC_FL_KEEP_SIZE) && | 5843 | if (!(mode & FALLOC_FL_KEEP_SIZE) && |
5848 | cur_offset > inode->i_size) { | 5844 | cur_offset > inode->i_size) { |
5849 | i_size_write(inode, cur_offset); | 5845 | if (cur_offset > actual_len) |
5850 | btrfs_ordered_update_i_size(inode, cur_offset, NULL); | 5846 | i_size = actual_len; |
5847 | else | ||
5848 | i_size = cur_offset; | ||
5849 | i_size_write(inode, i_size); | ||
5850 | btrfs_ordered_update_i_size(inode, i_size, NULL); | ||
5851 | } | 5851 | } |
5852 | 5852 | ||
5853 | ret = btrfs_update_inode(trans, root, inode); | 5853 | ret = btrfs_update_inode(trans, root, inode); |
@@ -5940,7 +5940,7 @@ static long btrfs_fallocate(struct inode *inode, int mode, | |||
5940 | !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { | 5940 | !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { |
5941 | ret = prealloc_file_range(inode, | 5941 | ret = prealloc_file_range(inode, |
5942 | cur_offset, last_byte, | 5942 | cur_offset, last_byte, |
5943 | alloc_hint, mode); | 5943 | alloc_hint, mode, offset+len); |
5944 | if (ret < 0) { | 5944 | if (ret < 0) { |
5945 | free_extent_map(em); | 5945 | free_extent_map(em); |
5946 | break; | 5946 | break; |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 3f9b45704fcd..8a1ea6e64575 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -66,7 +66,8 @@ enum { | |||
66 | Opt_degraded, Opt_subvol, Opt_device, Opt_nodatasum, Opt_nodatacow, | 66 | Opt_degraded, Opt_subvol, Opt_device, Opt_nodatasum, Opt_nodatacow, |
67 | Opt_max_extent, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, | 67 | Opt_max_extent, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, |
68 | Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, | 68 | Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, |
69 | Opt_compress, Opt_notreelog, Opt_ratio, Opt_flushoncommit, | 69 | Opt_compress, Opt_compress_force, Opt_notreelog, Opt_ratio, |
70 | Opt_flushoncommit, | ||
70 | Opt_discard, Opt_err, | 71 | Opt_discard, Opt_err, |
71 | }; | 72 | }; |
72 | 73 | ||
@@ -82,6 +83,7 @@ static match_table_t tokens = { | |||
82 | {Opt_alloc_start, "alloc_start=%s"}, | 83 | {Opt_alloc_start, "alloc_start=%s"}, |
83 | {Opt_thread_pool, "thread_pool=%d"}, | 84 | {Opt_thread_pool, "thread_pool=%d"}, |
84 | {Opt_compress, "compress"}, | 85 | {Opt_compress, "compress"}, |
86 | {Opt_compress_force, "compress-force"}, | ||
85 | {Opt_ssd, "ssd"}, | 87 | {Opt_ssd, "ssd"}, |
86 | {Opt_ssd_spread, "ssd_spread"}, | 88 | {Opt_ssd_spread, "ssd_spread"}, |
87 | {Opt_nossd, "nossd"}, | 89 | {Opt_nossd, "nossd"}, |
@@ -173,6 +175,11 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
173 | printk(KERN_INFO "btrfs: use compression\n"); | 175 | printk(KERN_INFO "btrfs: use compression\n"); |
174 | btrfs_set_opt(info->mount_opt, COMPRESS); | 176 | btrfs_set_opt(info->mount_opt, COMPRESS); |
175 | break; | 177 | break; |
178 | case Opt_compress_force: | ||
179 | printk(KERN_INFO "btrfs: forcing compression\n"); | ||
180 | btrfs_set_opt(info->mount_opt, FORCE_COMPRESS); | ||
181 | btrfs_set_opt(info->mount_opt, COMPRESS); | ||
182 | break; | ||
176 | case Opt_ssd: | 183 | case Opt_ssd: |
177 | printk(KERN_INFO "btrfs: use ssd allocation scheme\n"); | 184 | printk(KERN_INFO "btrfs: use ssd allocation scheme\n"); |
178 | btrfs_set_opt(info->mount_opt, SSD); | 185 | btrfs_set_opt(info->mount_opt, SSD); |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 220dad5db017..41ecbb2347f2 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -1135,7 +1135,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1135 | root->fs_info->avail_metadata_alloc_bits; | 1135 | root->fs_info->avail_metadata_alloc_bits; |
1136 | 1136 | ||
1137 | if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) && | 1137 | if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) && |
1138 | root->fs_info->fs_devices->rw_devices <= 4) { | 1138 | root->fs_info->fs_devices->num_devices <= 4) { |
1139 | printk(KERN_ERR "btrfs: unable to go below four devices " | 1139 | printk(KERN_ERR "btrfs: unable to go below four devices " |
1140 | "on raid10\n"); | 1140 | "on raid10\n"); |
1141 | ret = -EINVAL; | 1141 | ret = -EINVAL; |
@@ -1143,7 +1143,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) && | 1145 | if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) && |
1146 | root->fs_info->fs_devices->rw_devices <= 2) { | 1146 | root->fs_info->fs_devices->num_devices <= 2) { |
1147 | printk(KERN_ERR "btrfs: unable to go below two " | 1147 | printk(KERN_ERR "btrfs: unable to go below two " |
1148 | "devices on raid1\n"); | 1148 | "devices on raid1\n"); |
1149 | ret = -EINVAL; | 1149 | ret = -EINVAL; |
@@ -1434,8 +1434,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
1434 | return -EINVAL; | 1434 | return -EINVAL; |
1435 | 1435 | ||
1436 | bdev = open_bdev_exclusive(device_path, 0, root->fs_info->bdev_holder); | 1436 | bdev = open_bdev_exclusive(device_path, 0, root->fs_info->bdev_holder); |
1437 | if (!bdev) | 1437 | if (IS_ERR(bdev)) |
1438 | return -EIO; | 1438 | return PTR_ERR(bdev); |
1439 | 1439 | ||
1440 | if (root->fs_info->fs_devices->seeding) { | 1440 | if (root->fs_info->fs_devices->seeding) { |
1441 | seeding_dev = 1; | 1441 | seeding_dev = 1; |
@@ -2538,6 +2538,11 @@ int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset) | |||
2538 | if (!em) | 2538 | if (!em) |
2539 | return 1; | 2539 | return 1; |
2540 | 2540 | ||
2541 | if (btrfs_test_opt(root, DEGRADED)) { | ||
2542 | free_extent_map(em); | ||
2543 | return 0; | ||
2544 | } | ||
2545 | |||
2541 | map = (struct map_lookup *)em->bdev; | 2546 | map = (struct map_lookup *)em->bdev; |
2542 | for (i = 0; i < map->num_stripes; i++) { | 2547 | for (i = 0; i < map->num_stripes; i++) { |
2543 | if (!map->stripes[i].dev->writeable) { | 2548 | if (!map->stripes[i].dev->writeable) { |