diff options
| author | Ingo Molnar <mingo@kernel.org> | 2013-12-17 09:27:08 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2013-12-17 09:27:08 -0500 |
| commit | bb799d3b980eb803ca2da4a4eefbd9308f8d988a (patch) | |
| tree | 69fbe0cd6d47b23a50f5e1d87bf7489532fae149 /fs/btrfs | |
| parent | 919fc6e34831d1c2b58bfb5ae261dc3facc9b269 (diff) | |
| parent | 319e2e3f63c348a9b66db4667efa73178e18b17d (diff) | |
Merge tag 'v3.13-rc4' into core/locking
Merge Linux 3.13-rc4, to refresh this rather old tree with the latest fixes.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'fs/btrfs')
| -rw-r--r-- | fs/btrfs/Kconfig | 15 | ||||
| -rw-r--r-- | fs/btrfs/async-thread.c | 1 | ||||
| -rw-r--r-- | fs/btrfs/check-integrity.c | 57 | ||||
| -rw-r--r-- | fs/btrfs/check-integrity.h | 2 | ||||
| -rw-r--r-- | fs/btrfs/ctree.h | 6 | ||||
| -rw-r--r-- | fs/btrfs/dev-replace.c | 2 | ||||
| -rw-r--r-- | fs/btrfs/disk-io.c | 21 | ||||
| -rw-r--r-- | fs/btrfs/extent-tree.c | 22 | ||||
| -rw-r--r-- | fs/btrfs/extent_io.c | 23 | ||||
| -rw-r--r-- | fs/btrfs/inode.c | 6 | ||||
| -rw-r--r-- | fs/btrfs/ioctl.c | 3 | ||||
| -rw-r--r-- | fs/btrfs/ordered-data.c | 3 | ||||
| -rw-r--r-- | fs/btrfs/relocation.c | 81 | ||||
| -rw-r--r-- | fs/btrfs/scrub.c | 39 | ||||
| -rw-r--r-- | fs/btrfs/send.c | 4 | ||||
| -rw-r--r-- | fs/btrfs/super.c | 5 | ||||
| -rw-r--r-- | fs/btrfs/transaction.c | 4 | ||||
| -rw-r--r-- | fs/btrfs/tree-log.c | 5 | ||||
| -rw-r--r-- | fs/btrfs/volumes.c | 2 |
19 files changed, 146 insertions, 155 deletions
diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig index f9d5094e1029..aa976eced2d2 100644 --- a/fs/btrfs/Kconfig +++ b/fs/btrfs/Kconfig | |||
| @@ -9,12 +9,17 @@ config BTRFS_FS | |||
| 9 | select XOR_BLOCKS | 9 | select XOR_BLOCKS |
| 10 | 10 | ||
| 11 | help | 11 | help |
| 12 | Btrfs is a new filesystem with extents, writable snapshotting, | 12 | Btrfs is a general purpose copy-on-write filesystem with extents, |
| 13 | support for multiple devices and many more features. | 13 | writable snapshotting, support for multiple devices and many more |
| 14 | features focused on fault tolerance, repair and easy administration. | ||
| 14 | 15 | ||
| 15 | Btrfs is highly experimental, and THE DISK FORMAT IS NOT YET | 16 | The filesystem disk format is no longer unstable, and it's not |
| 16 | FINALIZED. You should say N here unless you are interested in | 17 | expected to change unless there are strong reasons to do so. If there |
| 17 | testing Btrfs with non-critical data. | 18 | is a format change, file systems with a unchanged format will |
| 19 | continue to be mountable and usable by newer kernels. | ||
| 20 | |||
| 21 | For more information, please see the web pages at | ||
| 22 | http://btrfs.wiki.kernel.org. | ||
| 18 | 23 | ||
| 19 | To compile this file system support as a module, choose M here. The | 24 | To compile this file system support as a module, choose M here. The |
| 20 | module will be called btrfs. | 25 | module will be called btrfs. |
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index 8aec751fa464..c1e0b0caf9cc 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c | |||
| @@ -495,6 +495,7 @@ static int __btrfs_start_workers(struct btrfs_workers *workers) | |||
| 495 | spin_lock_irq(&workers->lock); | 495 | spin_lock_irq(&workers->lock); |
| 496 | if (workers->stopping) { | 496 | if (workers->stopping) { |
| 497 | spin_unlock_irq(&workers->lock); | 497 | spin_unlock_irq(&workers->lock); |
| 498 | ret = -EINVAL; | ||
| 498 | goto fail_kthread; | 499 | goto fail_kthread; |
| 499 | } | 500 | } |
| 500 | list_add_tail(&worker->worker_list, &workers->idle_list); | 501 | list_add_tail(&worker->worker_list, &workers->idle_list); |
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index e0aab4456974..131d82800b3a 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c | |||
| @@ -77,6 +77,15 @@ | |||
| 77 | * the integrity of (super)-block write requests, do not | 77 | * the integrity of (super)-block write requests, do not |
| 78 | * enable the config option BTRFS_FS_CHECK_INTEGRITY to | 78 | * enable the config option BTRFS_FS_CHECK_INTEGRITY to |
| 79 | * include and compile the integrity check tool. | 79 | * include and compile the integrity check tool. |
| 80 | * | ||
| 81 | * Expect millions of lines of information in the kernel log with an | ||
| 82 | * enabled check_int_print_mask. Therefore set LOG_BUF_SHIFT in the | ||
| 83 | * kernel config to at least 26 (which is 64MB). Usually the value is | ||
| 84 | * limited to 21 (which is 2MB) in init/Kconfig. The file needs to be | ||
| 85 | * changed like this before LOG_BUF_SHIFT can be set to a high value: | ||
| 86 | * config LOG_BUF_SHIFT | ||
| 87 | * int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" | ||
| 88 | * range 12 30 | ||
| 80 | */ | 89 | */ |
| 81 | 90 | ||
| 82 | #include <linux/sched.h> | 91 | #include <linux/sched.h> |
| @@ -124,6 +133,7 @@ | |||
| 124 | #define BTRFSIC_PRINT_MASK_INITIAL_DATABASE 0x00000400 | 133 | #define BTRFSIC_PRINT_MASK_INITIAL_DATABASE 0x00000400 |
| 125 | #define BTRFSIC_PRINT_MASK_NUM_COPIES 0x00000800 | 134 | #define BTRFSIC_PRINT_MASK_NUM_COPIES 0x00000800 |
| 126 | #define BTRFSIC_PRINT_MASK_TREE_WITH_ALL_MIRRORS 0x00001000 | 135 | #define BTRFSIC_PRINT_MASK_TREE_WITH_ALL_MIRRORS 0x00001000 |
| 136 | #define BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH_VERBOSE 0x00002000 | ||
| 127 | 137 | ||
| 128 | struct btrfsic_dev_state; | 138 | struct btrfsic_dev_state; |
| 129 | struct btrfsic_state; | 139 | struct btrfsic_state; |
| @@ -323,7 +333,6 @@ static void btrfsic_release_block_ctx(struct btrfsic_block_data_ctx *block_ctx); | |||
| 323 | static int btrfsic_read_block(struct btrfsic_state *state, | 333 | static int btrfsic_read_block(struct btrfsic_state *state, |
| 324 | struct btrfsic_block_data_ctx *block_ctx); | 334 | struct btrfsic_block_data_ctx *block_ctx); |
| 325 | static void btrfsic_dump_database(struct btrfsic_state *state); | 335 | static void btrfsic_dump_database(struct btrfsic_state *state); |
| 326 | static void btrfsic_complete_bio_end_io(struct bio *bio, int err); | ||
| 327 | static int btrfsic_test_for_metadata(struct btrfsic_state *state, | 336 | static int btrfsic_test_for_metadata(struct btrfsic_state *state, |
| 328 | char **datav, unsigned int num_pages); | 337 | char **datav, unsigned int num_pages); |
| 329 | static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, | 338 | static void btrfsic_process_written_block(struct btrfsic_dev_state *dev_state, |
| @@ -1677,7 +1686,6 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
| 1677 | for (i = 0; i < num_pages;) { | 1686 | for (i = 0; i < num_pages;) { |
| 1678 | struct bio *bio; | 1687 | struct bio *bio; |
| 1679 | unsigned int j; | 1688 | unsigned int j; |
| 1680 | DECLARE_COMPLETION_ONSTACK(complete); | ||
| 1681 | 1689 | ||
| 1682 | bio = btrfs_io_bio_alloc(GFP_NOFS, num_pages - i); | 1690 | bio = btrfs_io_bio_alloc(GFP_NOFS, num_pages - i); |
| 1683 | if (!bio) { | 1691 | if (!bio) { |
| @@ -1688,8 +1696,6 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
| 1688 | } | 1696 | } |
| 1689 | bio->bi_bdev = block_ctx->dev->bdev; | 1697 | bio->bi_bdev = block_ctx->dev->bdev; |
| 1690 | bio->bi_sector = dev_bytenr >> 9; | 1698 | bio->bi_sector = dev_bytenr >> 9; |
| 1691 | bio->bi_end_io = btrfsic_complete_bio_end_io; | ||
| 1692 | bio->bi_private = &complete; | ||
| 1693 | 1699 | ||
| 1694 | for (j = i; j < num_pages; j++) { | 1700 | for (j = i; j < num_pages; j++) { |
| 1695 | ret = bio_add_page(bio, block_ctx->pagev[j], | 1701 | ret = bio_add_page(bio, block_ctx->pagev[j], |
| @@ -1702,12 +1708,7 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
| 1702 | "btrfsic: error, failed to add a single page!\n"); | 1708 | "btrfsic: error, failed to add a single page!\n"); |
| 1703 | return -1; | 1709 | return -1; |
| 1704 | } | 1710 | } |
| 1705 | submit_bio(READ, bio); | 1711 | if (submit_bio_wait(READ, bio)) { |
| 1706 | |||
| 1707 | /* this will also unplug the queue */ | ||
| 1708 | wait_for_completion(&complete); | ||
| 1709 | |||
| 1710 | if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) { | ||
| 1711 | printk(KERN_INFO | 1712 | printk(KERN_INFO |
| 1712 | "btrfsic: read error at logical %llu dev %s!\n", | 1713 | "btrfsic: read error at logical %llu dev %s!\n", |
| 1713 | block_ctx->start, block_ctx->dev->name); | 1714 | block_ctx->start, block_ctx->dev->name); |
| @@ -1730,11 +1731,6 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
| 1730 | return block_ctx->len; | 1731 | return block_ctx->len; |
| 1731 | } | 1732 | } |
| 1732 | 1733 | ||
| 1733 | static void btrfsic_complete_bio_end_io(struct bio *bio, int err) | ||
| 1734 | { | ||
| 1735 | complete((struct completion *)bio->bi_private); | ||
| 1736 | } | ||
| 1737 | |||
| 1738 | static void btrfsic_dump_database(struct btrfsic_state *state) | 1734 | static void btrfsic_dump_database(struct btrfsic_state *state) |
| 1739 | { | 1735 | { |
| 1740 | struct list_head *elem_all; | 1736 | struct list_head *elem_all; |
| @@ -2998,14 +2994,12 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh) | |||
| 2998 | return submit_bh(rw, bh); | 2994 | return submit_bh(rw, bh); |
| 2999 | } | 2995 | } |
| 3000 | 2996 | ||
| 3001 | void btrfsic_submit_bio(int rw, struct bio *bio) | 2997 | static void __btrfsic_submit_bio(int rw, struct bio *bio) |
| 3002 | { | 2998 | { |
| 3003 | struct btrfsic_dev_state *dev_state; | 2999 | struct btrfsic_dev_state *dev_state; |
| 3004 | 3000 | ||
| 3005 | if (!btrfsic_is_initialized) { | 3001 | if (!btrfsic_is_initialized) |
| 3006 | submit_bio(rw, bio); | ||
| 3007 | return; | 3002 | return; |
| 3008 | } | ||
| 3009 | 3003 | ||
| 3010 | mutex_lock(&btrfsic_mutex); | 3004 | mutex_lock(&btrfsic_mutex); |
| 3011 | /* since btrfsic_submit_bio() is also called before | 3005 | /* since btrfsic_submit_bio() is also called before |
| @@ -3015,6 +3009,7 @@ void btrfsic_submit_bio(int rw, struct bio *bio) | |||
| 3015 | (rw & WRITE) && NULL != bio->bi_io_vec) { | 3009 | (rw & WRITE) && NULL != bio->bi_io_vec) { |
| 3016 | unsigned int i; | 3010 | unsigned int i; |
| 3017 | u64 dev_bytenr; | 3011 | u64 dev_bytenr; |
| 3012 | u64 cur_bytenr; | ||
| 3018 | int bio_is_patched; | 3013 | int bio_is_patched; |
| 3019 | char **mapped_datav; | 3014 | char **mapped_datav; |
| 3020 | 3015 | ||
| @@ -3033,6 +3028,7 @@ void btrfsic_submit_bio(int rw, struct bio *bio) | |||
| 3033 | GFP_NOFS); | 3028 | GFP_NOFS); |
| 3034 | if (!mapped_datav) | 3029 | if (!mapped_datav) |
| 3035 | goto leave; | 3030 | goto leave; |
| 3031 | cur_bytenr = dev_bytenr; | ||
| 3036 | for (i = 0; i < bio->bi_vcnt; i++) { | 3032 | for (i = 0; i < bio->bi_vcnt; i++) { |
| 3037 | BUG_ON(bio->bi_io_vec[i].bv_len != PAGE_CACHE_SIZE); | 3033 | BUG_ON(bio->bi_io_vec[i].bv_len != PAGE_CACHE_SIZE); |
| 3038 | mapped_datav[i] = kmap(bio->bi_io_vec[i].bv_page); | 3034 | mapped_datav[i] = kmap(bio->bi_io_vec[i].bv_page); |
| @@ -3044,16 +3040,13 @@ void btrfsic_submit_bio(int rw, struct bio *bio) | |||
| 3044 | kfree(mapped_datav); | 3040 | kfree(mapped_datav); |
| 3045 | goto leave; | 3041 | goto leave; |
| 3046 | } | 3042 | } |
| 3047 | if ((BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH | | 3043 | if (dev_state->state->print_mask & |
| 3048 | BTRFSIC_PRINT_MASK_VERBOSE) == | 3044 | BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH_VERBOSE) |
| 3049 | (dev_state->state->print_mask & | ||
| 3050 | (BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH | | ||
| 3051 | BTRFSIC_PRINT_MASK_VERBOSE))) | ||
| 3052 | printk(KERN_INFO | 3045 | printk(KERN_INFO |
| 3053 | "#%u: page=%p, len=%u, offset=%u\n", | 3046 | "#%u: bytenr=%llu, len=%u, offset=%u\n", |
| 3054 | i, bio->bi_io_vec[i].bv_page, | 3047 | i, cur_bytenr, bio->bi_io_vec[i].bv_len, |
| 3055 | bio->bi_io_vec[i].bv_len, | ||
| 3056 | bio->bi_io_vec[i].bv_offset); | 3048 | bio->bi_io_vec[i].bv_offset); |
| 3049 | cur_bytenr += bio->bi_io_vec[i].bv_len; | ||
| 3057 | } | 3050 | } |
| 3058 | btrfsic_process_written_block(dev_state, dev_bytenr, | 3051 | btrfsic_process_written_block(dev_state, dev_bytenr, |
| 3059 | mapped_datav, bio->bi_vcnt, | 3052 | mapped_datav, bio->bi_vcnt, |
| @@ -3097,10 +3090,20 @@ void btrfsic_submit_bio(int rw, struct bio *bio) | |||
| 3097 | } | 3090 | } |
| 3098 | leave: | 3091 | leave: |
| 3099 | mutex_unlock(&btrfsic_mutex); | 3092 | mutex_unlock(&btrfsic_mutex); |
| 3093 | } | ||
| 3100 | 3094 | ||
| 3095 | void btrfsic_submit_bio(int rw, struct bio *bio) | ||
| 3096 | { | ||
| 3097 | __btrfsic_submit_bio(rw, bio); | ||
| 3101 | submit_bio(rw, bio); | 3098 | submit_bio(rw, bio); |
| 3102 | } | 3099 | } |
| 3103 | 3100 | ||
| 3101 | int btrfsic_submit_bio_wait(int rw, struct bio *bio) | ||
| 3102 | { | ||
| 3103 | __btrfsic_submit_bio(rw, bio); | ||
| 3104 | return submit_bio_wait(rw, bio); | ||
| 3105 | } | ||
| 3106 | |||
| 3104 | int btrfsic_mount(struct btrfs_root *root, | 3107 | int btrfsic_mount(struct btrfs_root *root, |
| 3105 | struct btrfs_fs_devices *fs_devices, | 3108 | struct btrfs_fs_devices *fs_devices, |
| 3106 | int including_extent_data, u32 print_mask) | 3109 | int including_extent_data, u32 print_mask) |
diff --git a/fs/btrfs/check-integrity.h b/fs/btrfs/check-integrity.h index 8b59175cc502..13b8566c97ab 100644 --- a/fs/btrfs/check-integrity.h +++ b/fs/btrfs/check-integrity.h | |||
| @@ -22,9 +22,11 @@ | |||
| 22 | #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY | 22 | #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY |
| 23 | int btrfsic_submit_bh(int rw, struct buffer_head *bh); | 23 | int btrfsic_submit_bh(int rw, struct buffer_head *bh); |
| 24 | void btrfsic_submit_bio(int rw, struct bio *bio); | 24 | void btrfsic_submit_bio(int rw, struct bio *bio); |
| 25 | int btrfsic_submit_bio_wait(int rw, struct bio *bio); | ||
| 25 | #else | 26 | #else |
| 26 | #define btrfsic_submit_bh submit_bh | 27 | #define btrfsic_submit_bh submit_bh |
| 27 | #define btrfsic_submit_bio submit_bio | 28 | #define btrfsic_submit_bio submit_bio |
| 29 | #define btrfsic_submit_bio_wait submit_bio_wait | ||
| 28 | #endif | 30 | #endif |
| 29 | 31 | ||
| 30 | int btrfsic_mount(struct btrfs_root *root, | 32 | int btrfsic_mount(struct btrfs_root *root, |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index f9aeb2759a64..54ab86127f7a 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
| @@ -3613,9 +3613,6 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, | |||
| 3613 | struct btrfs_ordered_sum *sums); | 3613 | struct btrfs_ordered_sum *sums); |
| 3614 | int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode, | 3614 | int btrfs_csum_one_bio(struct btrfs_root *root, struct inode *inode, |
| 3615 | struct bio *bio, u64 file_start, int contig); | 3615 | struct bio *bio, u64 file_start, int contig); |
| 3616 | int btrfs_csum_truncate(struct btrfs_trans_handle *trans, | ||
| 3617 | struct btrfs_root *root, struct btrfs_path *path, | ||
| 3618 | u64 isize); | ||
| 3619 | int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end, | 3616 | int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end, |
| 3620 | struct list_head *list, int search_commit); | 3617 | struct list_head *list, int search_commit); |
| 3621 | /* inode.c */ | 3618 | /* inode.c */ |
| @@ -3744,9 +3741,6 @@ void btrfs_cleanup_defrag_inodes(struct btrfs_fs_info *fs_info); | |||
| 3744 | int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync); | 3741 | int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync); |
| 3745 | void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, | 3742 | void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, |
| 3746 | int skip_pinned); | 3743 | int skip_pinned); |
| 3747 | int btrfs_replace_extent_cache(struct inode *inode, struct extent_map *replace, | ||
| 3748 | u64 start, u64 end, int skip_pinned, | ||
| 3749 | int modified); | ||
| 3750 | extern const struct file_operations btrfs_file_operations; | 3744 | extern const struct file_operations btrfs_file_operations; |
| 3751 | int __btrfs_drop_extents(struct btrfs_trans_handle *trans, | 3745 | int __btrfs_drop_extents(struct btrfs_trans_handle *trans, |
| 3752 | struct btrfs_root *root, struct inode *inode, | 3746 | struct btrfs_root *root, struct inode *inode, |
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 342f9fd411e3..2cfc3dfff64f 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
| @@ -366,7 +366,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root, | |||
| 366 | dev_replace->tgtdev = tgt_device; | 366 | dev_replace->tgtdev = tgt_device; |
| 367 | 367 | ||
| 368 | printk_in_rcu(KERN_INFO | 368 | printk_in_rcu(KERN_INFO |
| 369 | "btrfs: dev_replace from %s (devid %llu) to %s) started\n", | 369 | "btrfs: dev_replace from %s (devid %llu) to %s started\n", |
| 370 | src_device->missing ? "<missing disk>" : | 370 | src_device->missing ? "<missing disk>" : |
| 371 | rcu_str_deref(src_device->name), | 371 | rcu_str_deref(src_device->name), |
| 372 | src_device->devid, | 372 | src_device->devid, |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 4c4ed0bb3da1..8072cfa8a3b1 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
| @@ -3517,7 +3517,6 @@ int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info) | |||
| 3517 | int btrfs_commit_super(struct btrfs_root *root) | 3517 | int btrfs_commit_super(struct btrfs_root *root) |
| 3518 | { | 3518 | { |
| 3519 | struct btrfs_trans_handle *trans; | 3519 | struct btrfs_trans_handle *trans; |
| 3520 | int ret; | ||
| 3521 | 3520 | ||
| 3522 | mutex_lock(&root->fs_info->cleaner_mutex); | 3521 | mutex_lock(&root->fs_info->cleaner_mutex); |
| 3523 | btrfs_run_delayed_iputs(root); | 3522 | btrfs_run_delayed_iputs(root); |
| @@ -3531,25 +3530,7 @@ int btrfs_commit_super(struct btrfs_root *root) | |||
| 3531 | trans = btrfs_join_transaction(root); | 3530 | trans = btrfs_join_transaction(root); |
| 3532 | if (IS_ERR(trans)) | 3531 | if (IS_ERR(trans)) |
| 3533 | return PTR_ERR(trans); | 3532 | return PTR_ERR(trans); |
| 3534 | ret = btrfs_commit_transaction(trans, root); | 3533 | return btrfs_commit_transaction(trans, root); |
| 3535 | if (ret) | ||
| 3536 | return ret; | ||
| 3537 | /* run commit again to drop the original snapshot */ | ||
| 3538 | trans = btrfs_join_transaction(root); | ||
| 3539 | if (IS_ERR(trans)) | ||
| 3540 | return PTR_ERR(trans); | ||
| 3541 | ret = btrfs_commit_transaction(trans, root); | ||
| 3542 | if (ret) | ||
| 3543 | return ret; | ||
| 3544 | ret = btrfs_write_and_wait_transaction(NULL, root); | ||
| 3545 | if (ret) { | ||
| 3546 | btrfs_error(root->fs_info, ret, | ||
| 3547 | "Failed to sync btree inode to disk."); | ||
| 3548 | return ret; | ||
| 3549 | } | ||
| 3550 | |||
| 3551 | ret = write_ctree_super(NULL, root, 0); | ||
| 3552 | return ret; | ||
| 3553 | } | 3534 | } |
| 3554 | 3535 | ||
| 3555 | int close_ctree(struct btrfs_root *root) | 3536 | int close_ctree(struct btrfs_root *root) |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 45d98d01028f..9c01509dd8ab 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
| @@ -767,20 +767,19 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, | |||
| 767 | if (!path) | 767 | if (!path) |
| 768 | return -ENOMEM; | 768 | return -ENOMEM; |
| 769 | 769 | ||
| 770 | if (metadata) { | ||
| 771 | key.objectid = bytenr; | ||
| 772 | key.type = BTRFS_METADATA_ITEM_KEY; | ||
| 773 | key.offset = offset; | ||
| 774 | } else { | ||
| 775 | key.objectid = bytenr; | ||
| 776 | key.type = BTRFS_EXTENT_ITEM_KEY; | ||
| 777 | key.offset = offset; | ||
| 778 | } | ||
| 779 | |||
| 780 | if (!trans) { | 770 | if (!trans) { |
| 781 | path->skip_locking = 1; | 771 | path->skip_locking = 1; |
| 782 | path->search_commit_root = 1; | 772 | path->search_commit_root = 1; |
| 783 | } | 773 | } |
| 774 | |||
| 775 | search_again: | ||
| 776 | key.objectid = bytenr; | ||
| 777 | key.offset = offset; | ||
| 778 | if (metadata) | ||
| 779 | key.type = BTRFS_METADATA_ITEM_KEY; | ||
| 780 | else | ||
| 781 | key.type = BTRFS_EXTENT_ITEM_KEY; | ||
| 782 | |||
| 784 | again: | 783 | again: |
| 785 | ret = btrfs_search_slot(trans, root->fs_info->extent_root, | 784 | ret = btrfs_search_slot(trans, root->fs_info->extent_root, |
| 786 | &key, path, 0, 0); | 785 | &key, path, 0, 0); |
| @@ -788,7 +787,6 @@ again: | |||
| 788 | goto out_free; | 787 | goto out_free; |
| 789 | 788 | ||
| 790 | if (ret > 0 && metadata && key.type == BTRFS_METADATA_ITEM_KEY) { | 789 | if (ret > 0 && metadata && key.type == BTRFS_METADATA_ITEM_KEY) { |
| 791 | metadata = 0; | ||
| 792 | if (path->slots[0]) { | 790 | if (path->slots[0]) { |
| 793 | path->slots[0]--; | 791 | path->slots[0]--; |
| 794 | btrfs_item_key_to_cpu(path->nodes[0], &key, | 792 | btrfs_item_key_to_cpu(path->nodes[0], &key, |
| @@ -855,7 +853,7 @@ again: | |||
| 855 | mutex_lock(&head->mutex); | 853 | mutex_lock(&head->mutex); |
| 856 | mutex_unlock(&head->mutex); | 854 | mutex_unlock(&head->mutex); |
| 857 | btrfs_put_delayed_ref(&head->node); | 855 | btrfs_put_delayed_ref(&head->node); |
| 858 | goto again; | 856 | goto search_again; |
| 859 | } | 857 | } |
| 860 | if (head->extent_op && head->extent_op->update_flags) | 858 | if (head->extent_op && head->extent_op->update_flags) |
| 861 | extent_flags |= head->extent_op->flags_to_set; | 859 | extent_flags |= head->extent_op->flags_to_set; |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 856bc2b2192c..ff43802a7c88 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
| @@ -1952,11 +1952,6 @@ static int free_io_failure(struct inode *inode, struct io_failure_record *rec, | |||
| 1952 | return err; | 1952 | return err; |
| 1953 | } | 1953 | } |
| 1954 | 1954 | ||
| 1955 | static void repair_io_failure_callback(struct bio *bio, int err) | ||
| 1956 | { | ||
| 1957 | complete(bio->bi_private); | ||
| 1958 | } | ||
| 1959 | |||
| 1960 | /* | 1955 | /* |
| 1961 | * this bypasses the standard btrfs submit functions deliberately, as | 1956 | * this bypasses the standard btrfs submit functions deliberately, as |
| 1962 | * the standard behavior is to write all copies in a raid setup. here we only | 1957 | * the standard behavior is to write all copies in a raid setup. here we only |
| @@ -1973,13 +1968,13 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start, | |||
| 1973 | { | 1968 | { |
| 1974 | struct bio *bio; | 1969 | struct bio *bio; |
| 1975 | struct btrfs_device *dev; | 1970 | struct btrfs_device *dev; |
| 1976 | DECLARE_COMPLETION_ONSTACK(compl); | ||
| 1977 | u64 map_length = 0; | 1971 | u64 map_length = 0; |
| 1978 | u64 sector; | 1972 | u64 sector; |
| 1979 | struct btrfs_bio *bbio = NULL; | 1973 | struct btrfs_bio *bbio = NULL; |
| 1980 | struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree; | 1974 | struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree; |
| 1981 | int ret; | 1975 | int ret; |
| 1982 | 1976 | ||
| 1977 | ASSERT(!(fs_info->sb->s_flags & MS_RDONLY)); | ||
| 1983 | BUG_ON(!mirror_num); | 1978 | BUG_ON(!mirror_num); |
| 1984 | 1979 | ||
| 1985 | /* we can't repair anything in raid56 yet */ | 1980 | /* we can't repair anything in raid56 yet */ |
| @@ -1989,8 +1984,6 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start, | |||
| 1989 | bio = btrfs_io_bio_alloc(GFP_NOFS, 1); | 1984 | bio = btrfs_io_bio_alloc(GFP_NOFS, 1); |
| 1990 | if (!bio) | 1985 | if (!bio) |
| 1991 | return -EIO; | 1986 | return -EIO; |
| 1992 | bio->bi_private = &compl; | ||
| 1993 | bio->bi_end_io = repair_io_failure_callback; | ||
| 1994 | bio->bi_size = 0; | 1987 | bio->bi_size = 0; |
| 1995 | map_length = length; | 1988 | map_length = length; |
| 1996 | 1989 | ||
| @@ -2011,10 +2004,8 @@ int repair_io_failure(struct btrfs_fs_info *fs_info, u64 start, | |||
| 2011 | } | 2004 | } |
| 2012 | bio->bi_bdev = dev->bdev; | 2005 | bio->bi_bdev = dev->bdev; |
| 2013 | bio_add_page(bio, page, length, start - page_offset(page)); | 2006 | bio_add_page(bio, page, length, start - page_offset(page)); |
| 2014 | btrfsic_submit_bio(WRITE_SYNC, bio); | ||
| 2015 | wait_for_completion(&compl); | ||
| 2016 | 2007 | ||
| 2017 | if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) { | 2008 | if (btrfsic_submit_bio_wait(WRITE_SYNC, bio)) { |
| 2018 | /* try to remap that extent elsewhere? */ | 2009 | /* try to remap that extent elsewhere? */ |
| 2019 | bio_put(bio); | 2010 | bio_put(bio); |
| 2020 | btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS); | 2011 | btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS); |
| @@ -2036,6 +2027,9 @@ int repair_eb_io_failure(struct btrfs_root *root, struct extent_buffer *eb, | |||
| 2036 | unsigned long i, num_pages = num_extent_pages(eb->start, eb->len); | 2027 | unsigned long i, num_pages = num_extent_pages(eb->start, eb->len); |
| 2037 | int ret = 0; | 2028 | int ret = 0; |
| 2038 | 2029 | ||
| 2030 | if (root->fs_info->sb->s_flags & MS_RDONLY) | ||
| 2031 | return -EROFS; | ||
| 2032 | |||
| 2039 | for (i = 0; i < num_pages; i++) { | 2033 | for (i = 0; i < num_pages; i++) { |
| 2040 | struct page *p = extent_buffer_page(eb, i); | 2034 | struct page *p = extent_buffer_page(eb, i); |
| 2041 | ret = repair_io_failure(root->fs_info, start, PAGE_CACHE_SIZE, | 2035 | ret = repair_io_failure(root->fs_info, start, PAGE_CACHE_SIZE, |
| @@ -2057,12 +2051,12 @@ static int clean_io_failure(u64 start, struct page *page) | |||
| 2057 | u64 private; | 2051 | u64 private; |
| 2058 | u64 private_failure; | 2052 | u64 private_failure; |
| 2059 | struct io_failure_record *failrec; | 2053 | struct io_failure_record *failrec; |
| 2060 | struct btrfs_fs_info *fs_info; | 2054 | struct inode *inode = page->mapping->host; |
| 2055 | struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info; | ||
| 2061 | struct extent_state *state; | 2056 | struct extent_state *state; |
| 2062 | int num_copies; | 2057 | int num_copies; |
| 2063 | int did_repair = 0; | 2058 | int did_repair = 0; |
| 2064 | int ret; | 2059 | int ret; |
| 2065 | struct inode *inode = page->mapping->host; | ||
| 2066 | 2060 | ||
| 2067 | private = 0; | 2061 | private = 0; |
| 2068 | ret = count_range_bits(&BTRFS_I(inode)->io_failure_tree, &private, | 2062 | ret = count_range_bits(&BTRFS_I(inode)->io_failure_tree, &private, |
| @@ -2085,6 +2079,8 @@ static int clean_io_failure(u64 start, struct page *page) | |||
| 2085 | did_repair = 1; | 2079 | did_repair = 1; |
| 2086 | goto out; | 2080 | goto out; |
| 2087 | } | 2081 | } |
| 2082 | if (fs_info->sb->s_flags & MS_RDONLY) | ||
| 2083 | goto out; | ||
| 2088 | 2084 | ||
| 2089 | spin_lock(&BTRFS_I(inode)->io_tree.lock); | 2085 | spin_lock(&BTRFS_I(inode)->io_tree.lock); |
| 2090 | state = find_first_extent_bit_state(&BTRFS_I(inode)->io_tree, | 2086 | state = find_first_extent_bit_state(&BTRFS_I(inode)->io_tree, |
| @@ -2094,7 +2090,6 @@ static int clean_io_failure(u64 start, struct page *page) | |||
| 2094 | 2090 | ||
| 2095 | if (state && state->start <= failrec->start && | 2091 | if (state && state->start <= failrec->start && |
| 2096 | state->end >= failrec->start + failrec->len - 1) { | 2092 | state->end >= failrec->start + failrec->len - 1) { |
| 2097 | fs_info = BTRFS_I(inode)->root->fs_info; | ||
| 2098 | num_copies = btrfs_num_copies(fs_info, failrec->logical, | 2093 | num_copies = btrfs_num_copies(fs_info, failrec->logical, |
| 2099 | failrec->len); | 2094 | failrec->len); |
| 2100 | if (num_copies > 1) { | 2095 | if (num_copies > 1) { |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index da8d2f696ac5..f1a77449d032 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -2129,7 +2129,8 @@ static noinline bool record_extent_backrefs(struct btrfs_path *path, | |||
| 2129 | old->extent_offset, fs_info, | 2129 | old->extent_offset, fs_info, |
| 2130 | path, record_one_backref, | 2130 | path, record_one_backref, |
| 2131 | old); | 2131 | old); |
| 2132 | BUG_ON(ret < 0 && ret != -ENOENT); | 2132 | if (ret < 0 && ret != -ENOENT) |
| 2133 | return false; | ||
| 2133 | 2134 | ||
| 2134 | /* no backref to be processed for this extent */ | 2135 | /* no backref to be processed for this extent */ |
| 2135 | if (!old->count) { | 2136 | if (!old->count) { |
| @@ -6186,8 +6187,7 @@ insert: | |||
| 6186 | write_unlock(&em_tree->lock); | 6187 | write_unlock(&em_tree->lock); |
| 6187 | out: | 6188 | out: |
| 6188 | 6189 | ||
| 6189 | if (em) | 6190 | trace_btrfs_get_extent(root, em); |
| 6190 | trace_btrfs_get_extent(root, em); | ||
| 6191 | 6191 | ||
| 6192 | if (path) | 6192 | if (path) |
| 6193 | btrfs_free_path(path); | 6193 | btrfs_free_path(path); |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index a111622598b0..21da5762b0b1 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
| @@ -2121,7 +2121,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, | |||
| 2121 | 2121 | ||
| 2122 | err = mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT); | 2122 | err = mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT); |
| 2123 | if (err == -EINTR) | 2123 | if (err == -EINTR) |
| 2124 | goto out; | 2124 | goto out_drop_write; |
| 2125 | dentry = lookup_one_len(vol_args->name, parent, namelen); | 2125 | dentry = lookup_one_len(vol_args->name, parent, namelen); |
| 2126 | if (IS_ERR(dentry)) { | 2126 | if (IS_ERR(dentry)) { |
| 2127 | err = PTR_ERR(dentry); | 2127 | err = PTR_ERR(dentry); |
| @@ -2284,6 +2284,7 @@ out_dput: | |||
| 2284 | dput(dentry); | 2284 | dput(dentry); |
| 2285 | out_unlock_dir: | 2285 | out_unlock_dir: |
| 2286 | mutex_unlock(&dir->i_mutex); | 2286 | mutex_unlock(&dir->i_mutex); |
| 2287 | out_drop_write: | ||
| 2287 | mnt_drop_write_file(file); | 2288 | mnt_drop_write_file(file); |
| 2288 | out: | 2289 | out: |
| 2289 | kfree(vol_args); | 2290 | kfree(vol_args); |
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 25a8f3812f14..69582d5b69d1 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c | |||
| @@ -638,6 +638,7 @@ void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, int nr) | |||
| 638 | WARN_ON(nr < 0); | 638 | WARN_ON(nr < 0); |
| 639 | } | 639 | } |
| 640 | } | 640 | } |
| 641 | list_splice_tail(&splice, &fs_info->ordered_roots); | ||
| 641 | spin_unlock(&fs_info->ordered_root_lock); | 642 | spin_unlock(&fs_info->ordered_root_lock); |
| 642 | } | 643 | } |
| 643 | 644 | ||
| @@ -803,7 +804,7 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len) | |||
| 803 | btrfs_put_ordered_extent(ordered); | 804 | btrfs_put_ordered_extent(ordered); |
| 804 | break; | 805 | break; |
| 805 | } | 806 | } |
| 806 | if (ordered->file_offset + ordered->len < start) { | 807 | if (ordered->file_offset + ordered->len <= start) { |
| 807 | btrfs_put_ordered_extent(ordered); | 808 | btrfs_put_ordered_extent(ordered); |
| 808 | break; | 809 | break; |
| 809 | } | 810 | } |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index ce459a7cb16d..429c73c374b8 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
| @@ -571,7 +571,9 @@ static int is_cowonly_root(u64 root_objectid) | |||
| 571 | root_objectid == BTRFS_CHUNK_TREE_OBJECTID || | 571 | root_objectid == BTRFS_CHUNK_TREE_OBJECTID || |
| 572 | root_objectid == BTRFS_DEV_TREE_OBJECTID || | 572 | root_objectid == BTRFS_DEV_TREE_OBJECTID || |
| 573 | root_objectid == BTRFS_TREE_LOG_OBJECTID || | 573 | root_objectid == BTRFS_TREE_LOG_OBJECTID || |
| 574 | root_objectid == BTRFS_CSUM_TREE_OBJECTID) | 574 | root_objectid == BTRFS_CSUM_TREE_OBJECTID || |
| 575 | root_objectid == BTRFS_UUID_TREE_OBJECTID || | ||
| 576 | root_objectid == BTRFS_QUOTA_TREE_OBJECTID) | ||
| 575 | return 1; | 577 | return 1; |
| 576 | return 0; | 578 | return 0; |
| 577 | } | 579 | } |
| @@ -1264,10 +1266,10 @@ static int __must_check __add_reloc_root(struct btrfs_root *root) | |||
| 1264 | } | 1266 | } |
| 1265 | 1267 | ||
| 1266 | /* | 1268 | /* |
| 1267 | * helper to update/delete the 'address of tree root -> reloc tree' | 1269 | * helper to delete the 'address of tree root -> reloc tree' |
| 1268 | * mapping | 1270 | * mapping |
| 1269 | */ | 1271 | */ |
| 1270 | static int __update_reloc_root(struct btrfs_root *root, int del) | 1272 | static void __del_reloc_root(struct btrfs_root *root) |
| 1271 | { | 1273 | { |
| 1272 | struct rb_node *rb_node; | 1274 | struct rb_node *rb_node; |
| 1273 | struct mapping_node *node = NULL; | 1275 | struct mapping_node *node = NULL; |
| @@ -1275,7 +1277,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del) | |||
| 1275 | 1277 | ||
| 1276 | spin_lock(&rc->reloc_root_tree.lock); | 1278 | spin_lock(&rc->reloc_root_tree.lock); |
| 1277 | rb_node = tree_search(&rc->reloc_root_tree.rb_root, | 1279 | rb_node = tree_search(&rc->reloc_root_tree.rb_root, |
| 1278 | root->commit_root->start); | 1280 | root->node->start); |
| 1279 | if (rb_node) { | 1281 | if (rb_node) { |
| 1280 | node = rb_entry(rb_node, struct mapping_node, rb_node); | 1282 | node = rb_entry(rb_node, struct mapping_node, rb_node); |
| 1281 | rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root); | 1283 | rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root); |
| @@ -1283,23 +1285,45 @@ static int __update_reloc_root(struct btrfs_root *root, int del) | |||
| 1283 | spin_unlock(&rc->reloc_root_tree.lock); | 1285 | spin_unlock(&rc->reloc_root_tree.lock); |
| 1284 | 1286 | ||
| 1285 | if (!node) | 1287 | if (!node) |
| 1286 | return 0; | 1288 | return; |
| 1287 | BUG_ON((struct btrfs_root *)node->data != root); | 1289 | BUG_ON((struct btrfs_root *)node->data != root); |
| 1288 | 1290 | ||
| 1289 | if (!del) { | 1291 | spin_lock(&root->fs_info->trans_lock); |
| 1290 | spin_lock(&rc->reloc_root_tree.lock); | 1292 | list_del_init(&root->root_list); |
| 1291 | node->bytenr = root->node->start; | 1293 | spin_unlock(&root->fs_info->trans_lock); |
| 1292 | rb_node = tree_insert(&rc->reloc_root_tree.rb_root, | 1294 | kfree(node); |
| 1293 | node->bytenr, &node->rb_node); | 1295 | } |
| 1294 | spin_unlock(&rc->reloc_root_tree.lock); | 1296 | |
| 1295 | if (rb_node) | 1297 | /* |
| 1296 | backref_tree_panic(rb_node, -EEXIST, node->bytenr); | 1298 | * helper to update the 'address of tree root -> reloc tree' |
| 1297 | } else { | 1299 | * mapping |
| 1298 | spin_lock(&root->fs_info->trans_lock); | 1300 | */ |
| 1299 | list_del_init(&root->root_list); | 1301 | static int __update_reloc_root(struct btrfs_root *root, u64 new_bytenr) |
| 1300 | spin_unlock(&root->fs_info->trans_lock); | 1302 | { |
| 1301 | kfree(node); | 1303 | struct rb_node *rb_node; |
| 1304 | struct mapping_node *node = NULL; | ||
| 1305 | struct reloc_control *rc = root->fs_info->reloc_ctl; | ||
| 1306 | |||
| 1307 | spin_lock(&rc->reloc_root_tree.lock); | ||
| 1308 | rb_node = tree_search(&rc->reloc_root_tree.rb_root, | ||
| 1309 | root->node->start); | ||
| 1310 | if (rb_node) { | ||
| 1311 | node = rb_entry(rb_node, struct mapping_node, rb_node); | ||
| 1312 | rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root); | ||
| 1302 | } | 1313 | } |
| 1314 | spin_unlock(&rc->reloc_root_tree.lock); | ||
| 1315 | |||
| 1316 | if (!node) | ||
| 1317 | return 0; | ||
| 1318 | BUG_ON((struct btrfs_root *)node->data != root); | ||
| 1319 | |||
| 1320 | spin_lock(&rc->reloc_root_tree.lock); | ||
| 1321 | node->bytenr = new_bytenr; | ||
| 1322 | rb_node = tree_insert(&rc->reloc_root_tree.rb_root, | ||
| 1323 | node->bytenr, &node->rb_node); | ||
| 1324 | spin_unlock(&rc->reloc_root_tree.lock); | ||
| 1325 | if (rb_node) | ||
| 1326 | backref_tree_panic(rb_node, -EEXIST, node->bytenr); | ||
| 1303 | return 0; | 1327 | return 0; |
| 1304 | } | 1328 | } |
| 1305 | 1329 | ||
| @@ -1420,7 +1444,6 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans, | |||
| 1420 | { | 1444 | { |
| 1421 | struct btrfs_root *reloc_root; | 1445 | struct btrfs_root *reloc_root; |
| 1422 | struct btrfs_root_item *root_item; | 1446 | struct btrfs_root_item *root_item; |
| 1423 | int del = 0; | ||
| 1424 | int ret; | 1447 | int ret; |
| 1425 | 1448 | ||
| 1426 | if (!root->reloc_root) | 1449 | if (!root->reloc_root) |
| @@ -1432,11 +1455,9 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans, | |||
| 1432 | if (root->fs_info->reloc_ctl->merge_reloc_tree && | 1455 | if (root->fs_info->reloc_ctl->merge_reloc_tree && |
| 1433 | btrfs_root_refs(root_item) == 0) { | 1456 | btrfs_root_refs(root_item) == 0) { |
| 1434 | root->reloc_root = NULL; | 1457 | root->reloc_root = NULL; |
| 1435 | del = 1; | 1458 | __del_reloc_root(reloc_root); |
| 1436 | } | 1459 | } |
| 1437 | 1460 | ||
| 1438 | __update_reloc_root(reloc_root, del); | ||
| 1439 | |||
| 1440 | if (reloc_root->commit_root != reloc_root->node) { | 1461 | if (reloc_root->commit_root != reloc_root->node) { |
| 1441 | btrfs_set_root_node(root_item, reloc_root->node); | 1462 | btrfs_set_root_node(root_item, reloc_root->node); |
| 1442 | free_extent_buffer(reloc_root->commit_root); | 1463 | free_extent_buffer(reloc_root->commit_root); |
| @@ -2287,7 +2308,7 @@ void free_reloc_roots(struct list_head *list) | |||
| 2287 | while (!list_empty(list)) { | 2308 | while (!list_empty(list)) { |
| 2288 | reloc_root = list_entry(list->next, struct btrfs_root, | 2309 | reloc_root = list_entry(list->next, struct btrfs_root, |
| 2289 | root_list); | 2310 | root_list); |
| 2290 | __update_reloc_root(reloc_root, 1); | 2311 | __del_reloc_root(reloc_root); |
| 2291 | free_extent_buffer(reloc_root->node); | 2312 | free_extent_buffer(reloc_root->node); |
| 2292 | free_extent_buffer(reloc_root->commit_root); | 2313 | free_extent_buffer(reloc_root->commit_root); |
| 2293 | kfree(reloc_root); | 2314 | kfree(reloc_root); |
| @@ -2332,7 +2353,7 @@ again: | |||
| 2332 | 2353 | ||
| 2333 | ret = merge_reloc_root(rc, root); | 2354 | ret = merge_reloc_root(rc, root); |
| 2334 | if (ret) { | 2355 | if (ret) { |
| 2335 | __update_reloc_root(reloc_root, 1); | 2356 | __del_reloc_root(reloc_root); |
| 2336 | free_extent_buffer(reloc_root->node); | 2357 | free_extent_buffer(reloc_root->node); |
| 2337 | free_extent_buffer(reloc_root->commit_root); | 2358 | free_extent_buffer(reloc_root->commit_root); |
| 2338 | kfree(reloc_root); | 2359 | kfree(reloc_root); |
| @@ -2388,6 +2409,13 @@ out: | |||
| 2388 | btrfs_std_error(root->fs_info, ret); | 2409 | btrfs_std_error(root->fs_info, ret); |
| 2389 | if (!list_empty(&reloc_roots)) | 2410 | if (!list_empty(&reloc_roots)) |
| 2390 | free_reloc_roots(&reloc_roots); | 2411 | free_reloc_roots(&reloc_roots); |
| 2412 | |||
| 2413 | /* new reloc root may be added */ | ||
| 2414 | mutex_lock(&root->fs_info->reloc_mutex); | ||
| 2415 | list_splice_init(&rc->reloc_roots, &reloc_roots); | ||
| 2416 | mutex_unlock(&root->fs_info->reloc_mutex); | ||
| 2417 | if (!list_empty(&reloc_roots)) | ||
| 2418 | free_reloc_roots(&reloc_roots); | ||
| 2391 | } | 2419 | } |
| 2392 | 2420 | ||
| 2393 | BUG_ON(!RB_EMPTY_ROOT(&rc->reloc_root_tree.rb_root)); | 2421 | BUG_ON(!RB_EMPTY_ROOT(&rc->reloc_root_tree.rb_root)); |
| @@ -4522,6 +4550,11 @@ int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans, | |||
| 4522 | BUG_ON(rc->stage == UPDATE_DATA_PTRS && | 4550 | BUG_ON(rc->stage == UPDATE_DATA_PTRS && |
| 4523 | root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID); | 4551 | root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID); |
| 4524 | 4552 | ||
| 4553 | if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) { | ||
| 4554 | if (buf == root->node) | ||
| 4555 | __update_reloc_root(root, cow->start); | ||
| 4556 | } | ||
| 4557 | |||
| 4525 | level = btrfs_header_level(buf); | 4558 | level = btrfs_header_level(buf); |
| 4526 | if (btrfs_header_generation(buf) <= | 4559 | if (btrfs_header_generation(buf) <= |
| 4527 | btrfs_root_last_snapshot(&root->root_item)) | 4560 | btrfs_root_last_snapshot(&root->root_item)) |
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 2544805544f0..1fd3f33c330a 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c | |||
| @@ -208,7 +208,6 @@ static void scrub_recheck_block_checksum(struct btrfs_fs_info *fs_info, | |||
| 208 | int is_metadata, int have_csum, | 208 | int is_metadata, int have_csum, |
| 209 | const u8 *csum, u64 generation, | 209 | const u8 *csum, u64 generation, |
| 210 | u16 csum_size); | 210 | u16 csum_size); |
| 211 | static void scrub_complete_bio_end_io(struct bio *bio, int err); | ||
| 212 | static int scrub_repair_block_from_good_copy(struct scrub_block *sblock_bad, | 211 | static int scrub_repair_block_from_good_copy(struct scrub_block *sblock_bad, |
| 213 | struct scrub_block *sblock_good, | 212 | struct scrub_block *sblock_good, |
| 214 | int force_write); | 213 | int force_write); |
| @@ -938,8 +937,10 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check) | |||
| 938 | BTRFS_DEV_STAT_CORRUPTION_ERRS); | 937 | BTRFS_DEV_STAT_CORRUPTION_ERRS); |
| 939 | } | 938 | } |
| 940 | 939 | ||
| 941 | if (sctx->readonly && !sctx->is_dev_replace) | 940 | if (sctx->readonly) { |
| 942 | goto did_not_correct_error; | 941 | ASSERT(!sctx->is_dev_replace); |
| 942 | goto out; | ||
| 943 | } | ||
| 943 | 944 | ||
| 944 | if (!is_metadata && !have_csum) { | 945 | if (!is_metadata && !have_csum) { |
| 945 | struct scrub_fixup_nodatasum *fixup_nodatasum; | 946 | struct scrub_fixup_nodatasum *fixup_nodatasum; |
| @@ -1292,7 +1293,6 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info, | |||
| 1292 | for (page_num = 0; page_num < sblock->page_count; page_num++) { | 1293 | for (page_num = 0; page_num < sblock->page_count; page_num++) { |
| 1293 | struct bio *bio; | 1294 | struct bio *bio; |
| 1294 | struct scrub_page *page = sblock->pagev[page_num]; | 1295 | struct scrub_page *page = sblock->pagev[page_num]; |
| 1295 | DECLARE_COMPLETION_ONSTACK(complete); | ||
| 1296 | 1296 | ||
| 1297 | if (page->dev->bdev == NULL) { | 1297 | if (page->dev->bdev == NULL) { |
| 1298 | page->io_error = 1; | 1298 | page->io_error = 1; |
| @@ -1309,18 +1309,11 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info, | |||
| 1309 | } | 1309 | } |
| 1310 | bio->bi_bdev = page->dev->bdev; | 1310 | bio->bi_bdev = page->dev->bdev; |
| 1311 | bio->bi_sector = page->physical >> 9; | 1311 | bio->bi_sector = page->physical >> 9; |
| 1312 | bio->bi_end_io = scrub_complete_bio_end_io; | ||
| 1313 | bio->bi_private = &complete; | ||
| 1314 | 1312 | ||
| 1315 | bio_add_page(bio, page->page, PAGE_SIZE, 0); | 1313 | bio_add_page(bio, page->page, PAGE_SIZE, 0); |
| 1316 | btrfsic_submit_bio(READ, bio); | 1314 | if (btrfsic_submit_bio_wait(READ, bio)) |
| 1317 | |||
| 1318 | /* this will also unplug the queue */ | ||
| 1319 | wait_for_completion(&complete); | ||
| 1320 | |||
| 1321 | page->io_error = !test_bit(BIO_UPTODATE, &bio->bi_flags); | ||
| 1322 | if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) | ||
| 1323 | sblock->no_io_error_seen = 0; | 1315 | sblock->no_io_error_seen = 0; |
| 1316 | |||
| 1324 | bio_put(bio); | 1317 | bio_put(bio); |
| 1325 | } | 1318 | } |
| 1326 | 1319 | ||
| @@ -1389,11 +1382,6 @@ static void scrub_recheck_block_checksum(struct btrfs_fs_info *fs_info, | |||
| 1389 | sblock->checksum_error = 1; | 1382 | sblock->checksum_error = 1; |
| 1390 | } | 1383 | } |
| 1391 | 1384 | ||
| 1392 | static void scrub_complete_bio_end_io(struct bio *bio, int err) | ||
| 1393 | { | ||
| 1394 | complete((struct completion *)bio->bi_private); | ||
| 1395 | } | ||
| 1396 | |||
| 1397 | static int scrub_repair_block_from_good_copy(struct scrub_block *sblock_bad, | 1385 | static int scrub_repair_block_from_good_copy(struct scrub_block *sblock_bad, |
| 1398 | struct scrub_block *sblock_good, | 1386 | struct scrub_block *sblock_good, |
| 1399 | int force_write) | 1387 | int force_write) |
| @@ -1428,7 +1416,6 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad, | |||
| 1428 | sblock_bad->checksum_error || page_bad->io_error) { | 1416 | sblock_bad->checksum_error || page_bad->io_error) { |
| 1429 | struct bio *bio; | 1417 | struct bio *bio; |
| 1430 | int ret; | 1418 | int ret; |
| 1431 | DECLARE_COMPLETION_ONSTACK(complete); | ||
| 1432 | 1419 | ||
| 1433 | if (!page_bad->dev->bdev) { | 1420 | if (!page_bad->dev->bdev) { |
| 1434 | printk_ratelimited(KERN_WARNING | 1421 | printk_ratelimited(KERN_WARNING |
| @@ -1441,19 +1428,14 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad, | |||
| 1441 | return -EIO; | 1428 | return -EIO; |
| 1442 | bio->bi_bdev = page_bad->dev->bdev; | 1429 | bio->bi_bdev = page_bad->dev->bdev; |
| 1443 | bio->bi_sector = page_bad->physical >> 9; | 1430 | bio->bi_sector = page_bad->physical >> 9; |
| 1444 | bio->bi_end_io = scrub_complete_bio_end_io; | ||
| 1445 | bio->bi_private = &complete; | ||
| 1446 | 1431 | ||
| 1447 | ret = bio_add_page(bio, page_good->page, PAGE_SIZE, 0); | 1432 | ret = bio_add_page(bio, page_good->page, PAGE_SIZE, 0); |
| 1448 | if (PAGE_SIZE != ret) { | 1433 | if (PAGE_SIZE != ret) { |
| 1449 | bio_put(bio); | 1434 | bio_put(bio); |
| 1450 | return -EIO; | 1435 | return -EIO; |
| 1451 | } | 1436 | } |
| 1452 | btrfsic_submit_bio(WRITE, bio); | ||
| 1453 | 1437 | ||
| 1454 | /* this will also unplug the queue */ | 1438 | if (btrfsic_submit_bio_wait(WRITE, bio)) { |
| 1455 | wait_for_completion(&complete); | ||
| 1456 | if (!bio_flagged(bio, BIO_UPTODATE)) { | ||
| 1457 | btrfs_dev_stat_inc_and_print(page_bad->dev, | 1439 | btrfs_dev_stat_inc_and_print(page_bad->dev, |
| 1458 | BTRFS_DEV_STAT_WRITE_ERRS); | 1440 | BTRFS_DEV_STAT_WRITE_ERRS); |
| 1459 | btrfs_dev_replace_stats_inc( | 1441 | btrfs_dev_replace_stats_inc( |
| @@ -3373,7 +3355,6 @@ static int write_page_nocow(struct scrub_ctx *sctx, | |||
| 3373 | struct bio *bio; | 3355 | struct bio *bio; |
| 3374 | struct btrfs_device *dev; | 3356 | struct btrfs_device *dev; |
| 3375 | int ret; | 3357 | int ret; |
| 3376 | DECLARE_COMPLETION_ONSTACK(compl); | ||
| 3377 | 3358 | ||
| 3378 | dev = sctx->wr_ctx.tgtdev; | 3359 | dev = sctx->wr_ctx.tgtdev; |
| 3379 | if (!dev) | 3360 | if (!dev) |
| @@ -3390,8 +3371,6 @@ static int write_page_nocow(struct scrub_ctx *sctx, | |||
| 3390 | spin_unlock(&sctx->stat_lock); | 3371 | spin_unlock(&sctx->stat_lock); |
| 3391 | return -ENOMEM; | 3372 | return -ENOMEM; |
| 3392 | } | 3373 | } |
| 3393 | bio->bi_private = &compl; | ||
| 3394 | bio->bi_end_io = scrub_complete_bio_end_io; | ||
| 3395 | bio->bi_size = 0; | 3374 | bio->bi_size = 0; |
| 3396 | bio->bi_sector = physical_for_dev_replace >> 9; | 3375 | bio->bi_sector = physical_for_dev_replace >> 9; |
| 3397 | bio->bi_bdev = dev->bdev; | 3376 | bio->bi_bdev = dev->bdev; |
| @@ -3402,10 +3381,8 @@ leave_with_eio: | |||
| 3402 | btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS); | 3381 | btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_WRITE_ERRS); |
| 3403 | return -EIO; | 3382 | return -EIO; |
| 3404 | } | 3383 | } |
| 3405 | btrfsic_submit_bio(WRITE_SYNC, bio); | ||
| 3406 | wait_for_completion(&compl); | ||
| 3407 | 3384 | ||
| 3408 | if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) | 3385 | if (btrfsic_submit_bio_wait(WRITE_SYNC, bio)) |
| 3409 | goto leave_with_eio; | 3386 | goto leave_with_eio; |
| 3410 | 3387 | ||
| 3411 | bio_put(bio); | 3388 | bio_put(bio); |
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 6837fe87f3a6..945d1db98f26 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c | |||
| @@ -4723,8 +4723,8 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_) | |||
| 4723 | } | 4723 | } |
| 4724 | 4724 | ||
| 4725 | if (!access_ok(VERIFY_READ, arg->clone_sources, | 4725 | if (!access_ok(VERIFY_READ, arg->clone_sources, |
| 4726 | sizeof(*arg->clone_sources * | 4726 | sizeof(*arg->clone_sources) * |
| 4727 | arg->clone_sources_count))) { | 4727 | arg->clone_sources_count)) { |
| 4728 | ret = -EFAULT; | 4728 | ret = -EFAULT; |
| 4729 | goto out; | 4729 | goto out; |
| 4730 | } | 4730 | } |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 2d8ac1bf0cf9..d71a11d13dfa 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
| @@ -432,7 +432,6 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
| 432 | } else { | 432 | } else { |
| 433 | printk(KERN_INFO "btrfs: setting nodatacow\n"); | 433 | printk(KERN_INFO "btrfs: setting nodatacow\n"); |
| 434 | } | 434 | } |
| 435 | info->compress_type = BTRFS_COMPRESS_NONE; | ||
| 436 | btrfs_clear_opt(info->mount_opt, COMPRESS); | 435 | btrfs_clear_opt(info->mount_opt, COMPRESS); |
| 437 | btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); | 436 | btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); |
| 438 | btrfs_set_opt(info->mount_opt, NODATACOW); | 437 | btrfs_set_opt(info->mount_opt, NODATACOW); |
| @@ -461,7 +460,6 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
| 461 | btrfs_set_fs_incompat(info, COMPRESS_LZO); | 460 | btrfs_set_fs_incompat(info, COMPRESS_LZO); |
| 462 | } else if (strncmp(args[0].from, "no", 2) == 0) { | 461 | } else if (strncmp(args[0].from, "no", 2) == 0) { |
| 463 | compress_type = "no"; | 462 | compress_type = "no"; |
| 464 | info->compress_type = BTRFS_COMPRESS_NONE; | ||
| 465 | btrfs_clear_opt(info->mount_opt, COMPRESS); | 463 | btrfs_clear_opt(info->mount_opt, COMPRESS); |
| 466 | btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); | 464 | btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); |
| 467 | compress_force = false; | 465 | compress_force = false; |
| @@ -474,9 +472,10 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
| 474 | btrfs_set_opt(info->mount_opt, FORCE_COMPRESS); | 472 | btrfs_set_opt(info->mount_opt, FORCE_COMPRESS); |
| 475 | pr_info("btrfs: force %s compression\n", | 473 | pr_info("btrfs: force %s compression\n", |
| 476 | compress_type); | 474 | compress_type); |
| 477 | } else | 475 | } else if (btrfs_test_opt(root, COMPRESS)) { |
| 478 | pr_info("btrfs: use %s compression\n", | 476 | pr_info("btrfs: use %s compression\n", |
| 479 | compress_type); | 477 | compress_type); |
| 478 | } | ||
| 480 | break; | 479 | break; |
| 481 | case Opt_ssd: | 480 | case Opt_ssd: |
| 482 | printk(KERN_INFO "btrfs: use ssd allocation scheme\n"); | 481 | printk(KERN_INFO "btrfs: use ssd allocation scheme\n"); |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 57c16b46afbd..c6a872a8a468 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
| @@ -1480,7 +1480,7 @@ static void do_async_commit(struct work_struct *work) | |||
| 1480 | * We've got freeze protection passed with the transaction. | 1480 | * We've got freeze protection passed with the transaction. |
| 1481 | * Tell lockdep about it. | 1481 | * Tell lockdep about it. |
| 1482 | */ | 1482 | */ |
| 1483 | if (ac->newtrans->type < TRANS_JOIN_NOLOCK) | 1483 | if (ac->newtrans->type & __TRANS_FREEZABLE) |
| 1484 | rwsem_acquire_read( | 1484 | rwsem_acquire_read( |
| 1485 | &ac->root->fs_info->sb->s_writers.lock_map[SB_FREEZE_FS-1], | 1485 | &ac->root->fs_info->sb->s_writers.lock_map[SB_FREEZE_FS-1], |
| 1486 | 0, 1, _THIS_IP_); | 1486 | 0, 1, _THIS_IP_); |
| @@ -1521,7 +1521,7 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans, | |||
| 1521 | * Tell lockdep we've released the freeze rwsem, since the | 1521 | * Tell lockdep we've released the freeze rwsem, since the |
| 1522 | * async commit thread will be the one to unlock it. | 1522 | * async commit thread will be the one to unlock it. |
| 1523 | */ | 1523 | */ |
| 1524 | if (trans->type < TRANS_JOIN_NOLOCK) | 1524 | if (ac->newtrans->type & __TRANS_FREEZABLE) |
| 1525 | rwsem_release( | 1525 | rwsem_release( |
| 1526 | &root->fs_info->sb->s_writers.lock_map[SB_FREEZE_FS-1], | 1526 | &root->fs_info->sb->s_writers.lock_map[SB_FREEZE_FS-1], |
| 1527 | 1, _THIS_IP_); | 1527 | 1, _THIS_IP_); |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 744553c83fe2..9f7fc51ca334 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
| @@ -3697,7 +3697,8 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
| 3697 | ret = btrfs_truncate_inode_items(trans, log, | 3697 | ret = btrfs_truncate_inode_items(trans, log, |
| 3698 | inode, 0, 0); | 3698 | inode, 0, 0); |
| 3699 | } else if (test_and_clear_bit(BTRFS_INODE_COPY_EVERYTHING, | 3699 | } else if (test_and_clear_bit(BTRFS_INODE_COPY_EVERYTHING, |
| 3700 | &BTRFS_I(inode)->runtime_flags)) { | 3700 | &BTRFS_I(inode)->runtime_flags) || |
| 3701 | inode_only == LOG_INODE_EXISTS) { | ||
| 3701 | if (inode_only == LOG_INODE_ALL) | 3702 | if (inode_only == LOG_INODE_ALL) |
| 3702 | fast_search = true; | 3703 | fast_search = true; |
| 3703 | max_key.type = BTRFS_XATTR_ITEM_KEY; | 3704 | max_key.type = BTRFS_XATTR_ITEM_KEY; |
| @@ -3801,7 +3802,7 @@ log_extents: | |||
| 3801 | err = ret; | 3802 | err = ret; |
| 3802 | goto out_unlock; | 3803 | goto out_unlock; |
| 3803 | } | 3804 | } |
| 3804 | } else { | 3805 | } else if (inode_only == LOG_INODE_ALL) { |
| 3805 | struct extent_map_tree *tree = &BTRFS_I(inode)->extent_tree; | 3806 | struct extent_map_tree *tree = &BTRFS_I(inode)->extent_tree; |
| 3806 | struct extent_map *em, *n; | 3807 | struct extent_map *em, *n; |
| 3807 | 3808 | ||
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0db637097862..92303f42baaa 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
| @@ -5394,7 +5394,7 @@ static int bio_size_ok(struct block_device *bdev, struct bio *bio, | |||
| 5394 | { | 5394 | { |
| 5395 | struct bio_vec *prev; | 5395 | struct bio_vec *prev; |
| 5396 | struct request_queue *q = bdev_get_queue(bdev); | 5396 | struct request_queue *q = bdev_get_queue(bdev); |
| 5397 | unsigned short max_sectors = queue_max_sectors(q); | 5397 | unsigned int max_sectors = queue_max_sectors(q); |
| 5398 | struct bvec_merge_data bvm = { | 5398 | struct bvec_merge_data bvm = { |
| 5399 | .bi_bdev = bdev, | 5399 | .bi_bdev = bdev, |
| 5400 | .bi_sector = sector, | 5400 | .bi_sector = sector, |
