diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-10-09 03:02:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-10-09 03:02:35 -0400 |
commit | 1236d6bb6e19fc72ffc6bbcdeb1bfefe450e54ee (patch) | |
tree | 47da3feee8e263e8c9352c85cf518e624be3c211 /fs/btrfs | |
parent | 750b1a6894ecc9b178c6e3d0a1170122971b2036 (diff) | |
parent | 8a5776a5f49812d29fe4b2d0a2d71675c3facf3f (diff) |
Merge 4.14-rc4 into staging-next
We want the staging/iio fixes in here as well to handle merge issues.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/compression.c | 18 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 3 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 9 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 10 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 27 | ||||
-rw-r--r-- | fs/btrfs/ioctl.c | 12 | ||||
-rw-r--r-- | fs/btrfs/qgroup.c | 6 | ||||
-rw-r--r-- | fs/btrfs/relocation.c | 2 | ||||
-rw-r--r-- | fs/btrfs/send.c | 2 | ||||
-rw-r--r-- | fs/btrfs/tree-log.c | 12 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 2 |
11 files changed, 74 insertions, 29 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index b51d23f5cafa..280384bf34f1 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c | |||
@@ -107,7 +107,8 @@ static void end_compressed_bio_read(struct bio *bio) | |||
107 | struct inode *inode; | 107 | struct inode *inode; |
108 | struct page *page; | 108 | struct page *page; |
109 | unsigned long index; | 109 | unsigned long index; |
110 | int ret; | 110 | unsigned int mirror = btrfs_io_bio(bio)->mirror_num; |
111 | int ret = 0; | ||
111 | 112 | ||
112 | if (bio->bi_status) | 113 | if (bio->bi_status) |
113 | cb->errors = 1; | 114 | cb->errors = 1; |
@@ -118,6 +119,21 @@ static void end_compressed_bio_read(struct bio *bio) | |||
118 | if (!refcount_dec_and_test(&cb->pending_bios)) | 119 | if (!refcount_dec_and_test(&cb->pending_bios)) |
119 | goto out; | 120 | goto out; |
120 | 121 | ||
122 | /* | ||
123 | * Record the correct mirror_num in cb->orig_bio so that | ||
124 | * read-repair can work properly. | ||
125 | */ | ||
126 | ASSERT(btrfs_io_bio(cb->orig_bio)); | ||
127 | btrfs_io_bio(cb->orig_bio)->mirror_num = mirror; | ||
128 | cb->mirror_num = mirror; | ||
129 | |||
130 | /* | ||
131 | * Some IO in this cb have failed, just skip checksum as there | ||
132 | * is no way it could be correct. | ||
133 | */ | ||
134 | if (cb->errors == 1) | ||
135 | goto csum_failed; | ||
136 | |||
121 | inode = cb->inode; | 137 | inode = cb->inode; |
122 | ret = check_compressed_csum(BTRFS_I(inode), cb, | 138 | ret = check_compressed_csum(BTRFS_I(inode), cb, |
123 | (u64)bio->bi_iter.bi_sector << 9); | 139 | (u64)bio->bi_iter.bi_sector << 9); |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 5a8933da39a7..8fc690384c58 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -709,7 +709,6 @@ struct btrfs_delayed_root; | |||
709 | #define BTRFS_FS_OPEN 5 | 709 | #define BTRFS_FS_OPEN 5 |
710 | #define BTRFS_FS_QUOTA_ENABLED 6 | 710 | #define BTRFS_FS_QUOTA_ENABLED 6 |
711 | #define BTRFS_FS_QUOTA_ENABLING 7 | 711 | #define BTRFS_FS_QUOTA_ENABLING 7 |
712 | #define BTRFS_FS_QUOTA_DISABLING 8 | ||
713 | #define BTRFS_FS_UPDATE_UUID_TREE_GEN 9 | 712 | #define BTRFS_FS_UPDATE_UUID_TREE_GEN 9 |
714 | #define BTRFS_FS_CREATING_FREE_SPACE_TREE 10 | 713 | #define BTRFS_FS_CREATING_FREE_SPACE_TREE 10 |
715 | #define BTRFS_FS_BTREE_ERR 11 | 714 | #define BTRFS_FS_BTREE_ERR 11 |
@@ -723,7 +722,7 @@ struct btrfs_delayed_root; | |||
723 | * Indicate that a whole-filesystem exclusive operation is running | 722 | * Indicate that a whole-filesystem exclusive operation is running |
724 | * (device replace, resize, device add/delete, balance) | 723 | * (device replace, resize, device add/delete, balance) |
725 | */ | 724 | */ |
726 | #define BTRFS_FS_EXCL_OP 14 | 725 | #define BTRFS_FS_EXCL_OP 16 |
727 | 726 | ||
728 | struct btrfs_fs_info { | 727 | struct btrfs_fs_info { |
729 | u8 fsid[BTRFS_FSID_SIZE]; | 728 | u8 fsid[BTRFS_FSID_SIZE]; |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 487bbe4fb3c6..dfdab849037b 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -3643,7 +3643,14 @@ int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors) | |||
3643 | u64 flags; | 3643 | u64 flags; |
3644 | 3644 | ||
3645 | do_barriers = !btrfs_test_opt(fs_info, NOBARRIER); | 3645 | do_barriers = !btrfs_test_opt(fs_info, NOBARRIER); |
3646 | backup_super_roots(fs_info); | 3646 | |
3647 | /* | ||
3648 | * max_mirrors == 0 indicates we're from commit_transaction, | ||
3649 | * not from fsync where the tree roots in fs_info have not | ||
3650 | * been consistent on disk. | ||
3651 | */ | ||
3652 | if (max_mirrors == 0) | ||
3653 | backup_super_roots(fs_info); | ||
3647 | 3654 | ||
3648 | sb = fs_info->super_for_commit; | 3655 | sb = fs_info->super_for_commit; |
3649 | dev_item = &sb->dev_item; | 3656 | dev_item = &sb->dev_item; |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 3e5bb0cdd3cd..970190cd347e 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -2801,7 +2801,7 @@ static int submit_extent_page(unsigned int opf, struct extent_io_tree *tree, | |||
2801 | } | 2801 | } |
2802 | } | 2802 | } |
2803 | 2803 | ||
2804 | bio = btrfs_bio_alloc(bdev, sector << 9); | 2804 | bio = btrfs_bio_alloc(bdev, (u64)sector << 9); |
2805 | bio_add_page(bio, page, page_size, offset); | 2805 | bio_add_page(bio, page, page_size, offset); |
2806 | bio->bi_end_io = end_io_func; | 2806 | bio->bi_end_io = end_io_func; |
2807 | bio->bi_private = tree; | 2807 | bio->bi_private = tree; |
@@ -3471,8 +3471,7 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc, | |||
3471 | unsigned int write_flags = 0; | 3471 | unsigned int write_flags = 0; |
3472 | unsigned long nr_written = 0; | 3472 | unsigned long nr_written = 0; |
3473 | 3473 | ||
3474 | if (wbc->sync_mode == WB_SYNC_ALL) | 3474 | write_flags = wbc_to_write_flags(wbc); |
3475 | write_flags = REQ_SYNC; | ||
3476 | 3475 | ||
3477 | trace___extent_writepage(page, inode, wbc); | 3476 | trace___extent_writepage(page, inode, wbc); |
3478 | 3477 | ||
@@ -3718,7 +3717,7 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb, | |||
3718 | unsigned long i, num_pages; | 3717 | unsigned long i, num_pages; |
3719 | unsigned long bio_flags = 0; | 3718 | unsigned long bio_flags = 0; |
3720 | unsigned long start, end; | 3719 | unsigned long start, end; |
3721 | unsigned int write_flags = (epd->sync_io ? REQ_SYNC : 0) | REQ_META; | 3720 | unsigned int write_flags = wbc_to_write_flags(wbc) | REQ_META; |
3722 | int ret = 0; | 3721 | int ret = 0; |
3723 | 3722 | ||
3724 | clear_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags); | 3723 | clear_bit(EXTENT_BUFFER_WRITE_ERR, &eb->bflags); |
@@ -4063,9 +4062,6 @@ static void flush_epd_write_bio(struct extent_page_data *epd) | |||
4063 | if (epd->bio) { | 4062 | if (epd->bio) { |
4064 | int ret; | 4063 | int ret; |
4065 | 4064 | ||
4066 | bio_set_op_attrs(epd->bio, REQ_OP_WRITE, | ||
4067 | epd->sync_io ? REQ_SYNC : 0); | ||
4068 | |||
4069 | ret = submit_one_bio(epd->bio, 0, epd->bio_flags); | 4065 | ret = submit_one_bio(epd->bio, 0, epd->bio_flags); |
4070 | BUG_ON(ret < 0); /* -ENOMEM */ | 4066 | BUG_ON(ret < 0); /* -ENOMEM */ |
4071 | epd->bio = NULL; | 4067 | epd->bio = NULL; |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 128f3e58634f..d94e3f68b9b1 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -135,6 +135,18 @@ static inline void btrfs_cleanup_ordered_extents(struct inode *inode, | |||
135 | const u64 offset, | 135 | const u64 offset, |
136 | const u64 bytes) | 136 | const u64 bytes) |
137 | { | 137 | { |
138 | unsigned long index = offset >> PAGE_SHIFT; | ||
139 | unsigned long end_index = (offset + bytes - 1) >> PAGE_SHIFT; | ||
140 | struct page *page; | ||
141 | |||
142 | while (index <= end_index) { | ||
143 | page = find_get_page(inode->i_mapping, index); | ||
144 | index++; | ||
145 | if (!page) | ||
146 | continue; | ||
147 | ClearPagePrivate2(page); | ||
148 | put_page(page); | ||
149 | } | ||
138 | return __endio_write_update_ordered(inode, offset + PAGE_SIZE, | 150 | return __endio_write_update_ordered(inode, offset + PAGE_SIZE, |
139 | bytes - PAGE_SIZE, false); | 151 | bytes - PAGE_SIZE, false); |
140 | } | 152 | } |
@@ -8357,11 +8369,8 @@ static void btrfs_endio_direct_read(struct bio *bio) | |||
8357 | struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); | 8369 | struct btrfs_io_bio *io_bio = btrfs_io_bio(bio); |
8358 | blk_status_t err = bio->bi_status; | 8370 | blk_status_t err = bio->bi_status; |
8359 | 8371 | ||
8360 | if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED) { | 8372 | if (dip->flags & BTRFS_DIO_ORIG_BIO_SUBMITTED) |
8361 | err = btrfs_subio_endio_read(inode, io_bio, err); | 8373 | err = btrfs_subio_endio_read(inode, io_bio, err); |
8362 | if (!err) | ||
8363 | bio->bi_status = 0; | ||
8364 | } | ||
8365 | 8374 | ||
8366 | unlock_extent(&BTRFS_I(inode)->io_tree, dip->logical_offset, | 8375 | unlock_extent(&BTRFS_I(inode)->io_tree, dip->logical_offset, |
8367 | dip->logical_offset + dip->bytes - 1); | 8376 | dip->logical_offset + dip->bytes - 1); |
@@ -8369,7 +8378,7 @@ static void btrfs_endio_direct_read(struct bio *bio) | |||
8369 | 8378 | ||
8370 | kfree(dip); | 8379 | kfree(dip); |
8371 | 8380 | ||
8372 | dio_bio->bi_status = bio->bi_status; | 8381 | dio_bio->bi_status = err; |
8373 | dio_end_io(dio_bio); | 8382 | dio_end_io(dio_bio); |
8374 | 8383 | ||
8375 | if (io_bio->end_io) | 8384 | if (io_bio->end_io) |
@@ -8387,6 +8396,7 @@ static void __endio_write_update_ordered(struct inode *inode, | |||
8387 | btrfs_work_func_t func; | 8396 | btrfs_work_func_t func; |
8388 | u64 ordered_offset = offset; | 8397 | u64 ordered_offset = offset; |
8389 | u64 ordered_bytes = bytes; | 8398 | u64 ordered_bytes = bytes; |
8399 | u64 last_offset; | ||
8390 | int ret; | 8400 | int ret; |
8391 | 8401 | ||
8392 | if (btrfs_is_free_space_inode(BTRFS_I(inode))) { | 8402 | if (btrfs_is_free_space_inode(BTRFS_I(inode))) { |
@@ -8398,6 +8408,7 @@ static void __endio_write_update_ordered(struct inode *inode, | |||
8398 | } | 8408 | } |
8399 | 8409 | ||
8400 | again: | 8410 | again: |
8411 | last_offset = ordered_offset; | ||
8401 | ret = btrfs_dec_test_first_ordered_pending(inode, &ordered, | 8412 | ret = btrfs_dec_test_first_ordered_pending(inode, &ordered, |
8402 | &ordered_offset, | 8413 | &ordered_offset, |
8403 | ordered_bytes, | 8414 | ordered_bytes, |
@@ -8409,6 +8420,12 @@ again: | |||
8409 | btrfs_queue_work(wq, &ordered->work); | 8420 | btrfs_queue_work(wq, &ordered->work); |
8410 | out_test: | 8421 | out_test: |
8411 | /* | 8422 | /* |
8423 | * If btrfs_dec_test_ordered_pending does not find any ordered extent | ||
8424 | * in the range, we can exit. | ||
8425 | */ | ||
8426 | if (ordered_offset == last_offset) | ||
8427 | return; | ||
8428 | /* | ||
8412 | * our bio might span multiple ordered extents. If we haven't | 8429 | * our bio might span multiple ordered extents. If we haven't |
8413 | * completed the accounting for the whole dio, go back and try again | 8430 | * completed the accounting for the whole dio, go back and try again |
8414 | */ | 8431 | */ |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index d6715c2bcdc4..6c7a49faf4e0 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -2773,9 +2773,9 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info, | |||
2773 | } | 2773 | } |
2774 | mutex_unlock(&fs_devices->device_list_mutex); | 2774 | mutex_unlock(&fs_devices->device_list_mutex); |
2775 | 2775 | ||
2776 | fi_args->nodesize = fs_info->super_copy->nodesize; | 2776 | fi_args->nodesize = fs_info->nodesize; |
2777 | fi_args->sectorsize = fs_info->super_copy->sectorsize; | 2777 | fi_args->sectorsize = fs_info->sectorsize; |
2778 | fi_args->clone_alignment = fs_info->super_copy->sectorsize; | 2778 | fi_args->clone_alignment = fs_info->sectorsize; |
2779 | 2779 | ||
2780 | if (copy_to_user(arg, fi_args, sizeof(*fi_args))) | 2780 | if (copy_to_user(arg, fi_args, sizeof(*fi_args))) |
2781 | ret = -EFAULT; | 2781 | ret = -EFAULT; |
@@ -3032,7 +3032,7 @@ static int btrfs_cmp_data_prepare(struct inode *src, u64 loff, | |||
3032 | out: | 3032 | out: |
3033 | if (ret) | 3033 | if (ret) |
3034 | btrfs_cmp_data_free(cmp); | 3034 | btrfs_cmp_data_free(cmp); |
3035 | return 0; | 3035 | return ret; |
3036 | } | 3036 | } |
3037 | 3037 | ||
3038 | static int btrfs_cmp_data(u64 len, struct cmp_pages *cmp) | 3038 | static int btrfs_cmp_data(u64 len, struct cmp_pages *cmp) |
@@ -4061,6 +4061,10 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) | |||
4061 | ret = PTR_ERR(new_root); | 4061 | ret = PTR_ERR(new_root); |
4062 | goto out; | 4062 | goto out; |
4063 | } | 4063 | } |
4064 | if (!is_fstree(new_root->objectid)) { | ||
4065 | ret = -ENOENT; | ||
4066 | goto out; | ||
4067 | } | ||
4064 | 4068 | ||
4065 | path = btrfs_alloc_path(); | 4069 | path = btrfs_alloc_path(); |
4066 | if (!path) { | 4070 | if (!path) { |
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 5c8b61c86e61..e172d4843eae 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
@@ -807,7 +807,6 @@ static int btrfs_clean_quota_tree(struct btrfs_trans_handle *trans, | |||
807 | } | 807 | } |
808 | ret = 0; | 808 | ret = 0; |
809 | out: | 809 | out: |
810 | set_bit(BTRFS_FS_QUOTA_DISABLING, &root->fs_info->flags); | ||
811 | btrfs_free_path(path); | 810 | btrfs_free_path(path); |
812 | return ret; | 811 | return ret; |
813 | } | 812 | } |
@@ -953,7 +952,6 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans, | |||
953 | if (!fs_info->quota_root) | 952 | if (!fs_info->quota_root) |
954 | goto out; | 953 | goto out; |
955 | clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); | 954 | clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); |
956 | set_bit(BTRFS_FS_QUOTA_DISABLING, &fs_info->flags); | ||
957 | btrfs_qgroup_wait_for_completion(fs_info, false); | 955 | btrfs_qgroup_wait_for_completion(fs_info, false); |
958 | spin_lock(&fs_info->qgroup_lock); | 956 | spin_lock(&fs_info->qgroup_lock); |
959 | quota_root = fs_info->quota_root; | 957 | quota_root = fs_info->quota_root; |
@@ -1307,6 +1305,8 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, | |||
1307 | } | 1305 | } |
1308 | } | 1306 | } |
1309 | ret = del_qgroup_item(trans, quota_root, qgroupid); | 1307 | ret = del_qgroup_item(trans, quota_root, qgroupid); |
1308 | if (ret && ret != -ENOENT) | ||
1309 | goto out; | ||
1310 | 1310 | ||
1311 | while (!list_empty(&qgroup->groups)) { | 1311 | while (!list_empty(&qgroup->groups)) { |
1312 | list = list_first_entry(&qgroup->groups, | 1312 | list = list_first_entry(&qgroup->groups, |
@@ -2086,8 +2086,6 @@ int btrfs_run_qgroups(struct btrfs_trans_handle *trans, | |||
2086 | 2086 | ||
2087 | if (test_and_clear_bit(BTRFS_FS_QUOTA_ENABLING, &fs_info->flags)) | 2087 | if (test_and_clear_bit(BTRFS_FS_QUOTA_ENABLING, &fs_info->flags)) |
2088 | set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); | 2088 | set_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); |
2089 | if (test_and_clear_bit(BTRFS_FS_QUOTA_DISABLING, &fs_info->flags)) | ||
2090 | clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags); | ||
2091 | 2089 | ||
2092 | spin_lock(&fs_info->qgroup_lock); | 2090 | spin_lock(&fs_info->qgroup_lock); |
2093 | while (!list_empty(&fs_info->dirty_qgroups)) { | 2091 | while (!list_empty(&fs_info->dirty_qgroups)) { |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 3a49a3c2fca4..9841faef08ea 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
@@ -2400,11 +2400,11 @@ void free_reloc_roots(struct list_head *list) | |||
2400 | while (!list_empty(list)) { | 2400 | while (!list_empty(list)) { |
2401 | reloc_root = list_entry(list->next, struct btrfs_root, | 2401 | reloc_root = list_entry(list->next, struct btrfs_root, |
2402 | root_list); | 2402 | root_list); |
2403 | __del_reloc_root(reloc_root); | ||
2403 | free_extent_buffer(reloc_root->node); | 2404 | free_extent_buffer(reloc_root->node); |
2404 | free_extent_buffer(reloc_root->commit_root); | 2405 | free_extent_buffer(reloc_root->commit_root); |
2405 | reloc_root->node = NULL; | 2406 | reloc_root->node = NULL; |
2406 | reloc_root->commit_root = NULL; | 2407 | reloc_root->commit_root = NULL; |
2407 | __del_reloc_root(reloc_root); | ||
2408 | } | 2408 | } |
2409 | } | 2409 | } |
2410 | 2410 | ||
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 32b043ef8ac9..8fd195cfe81b 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c | |||
@@ -2630,7 +2630,7 @@ static int send_create_inode(struct send_ctx *sctx, u64 ino) | |||
2630 | } else { | 2630 | } else { |
2631 | btrfs_warn(sctx->send_root->fs_info, "unexpected inode type %o", | 2631 | btrfs_warn(sctx->send_root->fs_info, "unexpected inode type %o", |
2632 | (int)(mode & S_IFMT)); | 2632 | (int)(mode & S_IFMT)); |
2633 | ret = -ENOTSUPP; | 2633 | ret = -EOPNOTSUPP; |
2634 | goto out; | 2634 | goto out; |
2635 | } | 2635 | } |
2636 | 2636 | ||
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index ad7f4bab640b..c800d067fcbf 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -4181,6 +4181,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, | |||
4181 | struct extent_map *em, *n; | 4181 | struct extent_map *em, *n; |
4182 | struct list_head extents; | 4182 | struct list_head extents; |
4183 | struct extent_map_tree *tree = &inode->extent_tree; | 4183 | struct extent_map_tree *tree = &inode->extent_tree; |
4184 | u64 logged_start, logged_end; | ||
4184 | u64 test_gen; | 4185 | u64 test_gen; |
4185 | int ret = 0; | 4186 | int ret = 0; |
4186 | int num = 0; | 4187 | int num = 0; |
@@ -4190,10 +4191,11 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, | |||
4190 | down_write(&inode->dio_sem); | 4191 | down_write(&inode->dio_sem); |
4191 | write_lock(&tree->lock); | 4192 | write_lock(&tree->lock); |
4192 | test_gen = root->fs_info->last_trans_committed; | 4193 | test_gen = root->fs_info->last_trans_committed; |
4194 | logged_start = start; | ||
4195 | logged_end = end; | ||
4193 | 4196 | ||
4194 | list_for_each_entry_safe(em, n, &tree->modified_extents, list) { | 4197 | list_for_each_entry_safe(em, n, &tree->modified_extents, list) { |
4195 | list_del_init(&em->list); | 4198 | list_del_init(&em->list); |
4196 | |||
4197 | /* | 4199 | /* |
4198 | * Just an arbitrary number, this can be really CPU intensive | 4200 | * Just an arbitrary number, this can be really CPU intensive |
4199 | * once we start getting a lot of extents, and really once we | 4201 | * once we start getting a lot of extents, and really once we |
@@ -4208,6 +4210,12 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, | |||
4208 | 4210 | ||
4209 | if (em->generation <= test_gen) | 4211 | if (em->generation <= test_gen) |
4210 | continue; | 4212 | continue; |
4213 | |||
4214 | if (em->start < logged_start) | ||
4215 | logged_start = em->start; | ||
4216 | if ((em->start + em->len - 1) > logged_end) | ||
4217 | logged_end = em->start + em->len - 1; | ||
4218 | |||
4211 | /* Need a ref to keep it from getting evicted from cache */ | 4219 | /* Need a ref to keep it from getting evicted from cache */ |
4212 | refcount_inc(&em->refs); | 4220 | refcount_inc(&em->refs); |
4213 | set_bit(EXTENT_FLAG_LOGGING, &em->flags); | 4221 | set_bit(EXTENT_FLAG_LOGGING, &em->flags); |
@@ -4216,7 +4224,7 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, | |||
4216 | } | 4224 | } |
4217 | 4225 | ||
4218 | list_sort(NULL, &extents, extent_cmp); | 4226 | list_sort(NULL, &extents, extent_cmp); |
4219 | btrfs_get_logged_extents(inode, logged_list, start, end); | 4227 | btrfs_get_logged_extents(inode, logged_list, logged_start, logged_end); |
4220 | /* | 4228 | /* |
4221 | * Some ordered extents started by fsync might have completed | 4229 | * Some ordered extents started by fsync might have completed |
4222 | * before we could collect them into the list logged_list, which | 4230 | * before we could collect them into the list logged_list, which |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0e8f16c305df..b39737568c22 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -6166,7 +6166,7 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio, | |||
6166 | map_length = length; | 6166 | map_length = length; |
6167 | 6167 | ||
6168 | btrfs_bio_counter_inc_blocked(fs_info); | 6168 | btrfs_bio_counter_inc_blocked(fs_info); |
6169 | ret = __btrfs_map_block(fs_info, bio_op(bio), logical, | 6169 | ret = __btrfs_map_block(fs_info, btrfs_op(bio), logical, |
6170 | &map_length, &bbio, mirror_num, 1); | 6170 | &map_length, &bbio, mirror_num, 1); |
6171 | if (ret) { | 6171 | if (ret) { |
6172 | btrfs_bio_counter_dec(fs_info); | 6172 | btrfs_bio_counter_dec(fs_info); |