Pull btrfs fixes from Chris Mason: "Some fixes that Dave Sterba collected. We held off on these last week because I was focused on the memory corruption testing" * 'for-4.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: fix WARNING in btrfs_select_ref_head() Btrfs: remove some no-op casts btrfs: pass correct args to btrfs_async_run_delayed_refs() btrfs: make file clone aware of fatal signals btrfs: qgroup: Prevent qgroup->reserved from going subzero Btrfs: kill BUG_ON in do_relocation
Unified · Split
| @@ -2647,7 +2647,10 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, · 2646 unmodified lines | ||
| 2647 | 2647 | |
| 2648 | 2648 | btrfs_free_delayed_extent_op(extent_op); |
| 2649 | 2649 | if (ret) { |
| 2650 | + spin_lock(&delayed_refs->lock); | |
| 2650 | 2651 | locked_ref->processing = 0; |
| 2652 | + delayed_refs->num_heads_ready++; | |
| 2653 | + spin_unlock(&delayed_refs->lock); | |
| 2651 | 2654 | btrfs_delayed_ref_unlock(locked_ref); |
| 2652 | 2655 | btrfs_put_delayed_ref(ref); |
| 2653 | 2656 | btrfs_debug(fs_info, "run_one_delayed_ref returned %d", |
| @@ -5569,7 +5569,7 @@ void le_bitmap_set(u8 *map, unsigned int start, int len) · 5568 unmodified lines | ||
| 5569 | 5569 | *p |= mask_to_set; |
| 5570 | 5570 | len -= bits_to_set; |
| 5571 | 5571 | bits_to_set = BITS_PER_BYTE; |
| 5572 | − mask_to_set = ~(u8)0; | |
| 5572 | + mask_to_set = ~0; | |
| 5573 | 5573 | p++; |
| 5574 | 5574 | } |
| 5575 | 5575 | if (len) { |
| @@ -5589,7 +5589,7 @@ void le_bitmap_clear(u8 *map, unsigned int start, int len) · 13 unmodified lines | ||
| 5589 | 5589 | *p &= ~mask_to_clear; |
| 5590 | 5590 | len -= bits_to_clear; |
| 5591 | 5591 | bits_to_clear = BITS_PER_BYTE; |
| 5592 | − mask_to_clear = ~(u8)0; | |
| 5592 | + mask_to_clear = ~0; | |
| 5593 | 5593 | p++; |
| 5594 | 5594 | } |
| 5595 | 5595 | if (len) { |
| @@ -5679,7 +5679,7 @@ void extent_buffer_bitmap_set(struct extent_buffer *eb, unsigned long start, · 83 unmodified lines | ||
| 5679 | 5679 | kaddr[offset] |= mask_to_set; |
| 5680 | 5680 | len -= bits_to_set; |
| 5681 | 5681 | bits_to_set = BITS_PER_BYTE; |
| 5682 | − mask_to_set = ~(u8)0; | |
| 5682 | + mask_to_set = ~0; | |
| 5683 | 5683 | if (++offset >= PAGE_SIZE && len > 0) { |
| 5684 | 5684 | offset = 0; |
| 5685 | 5685 | page = eb->pages[++i]; |
| @@ -5721,7 +5721,7 @@ void extent_buffer_bitmap_clear(struct extent_buffer *eb, unsigned long start, · 35 unmodified lines | ||
| 5721 | 5721 | kaddr[offset] &= ~mask_to_clear; |
| 5722 | 5722 | len -= bits_to_clear; |
| 5723 | 5723 | bits_to_clear = BITS_PER_BYTE; |
| 5724 | − mask_to_clear = ~(u8)0; | |
| 5724 | + mask_to_clear = ~0; | |
| 5725 | 5725 | if (++offset >= PAGE_SIZE && len > 0) { |
| 5726 | 5726 | offset = 0; |
| 5727 | 5727 | page = eb->pages[++i]; |
| @@ -4605,8 +4605,8 @@ delete: · 4604 unmodified lines | ||
| 4605 | 4605 | BUG_ON(ret); |
| 4606 | 4606 | if (btrfs_should_throttle_delayed_refs(trans, root)) |
| 4607 | 4607 | btrfs_async_run_delayed_refs(root, |
| 4608 | − trans->transid, | |
| 4609 | − trans->delayed_ref_updates * 2, 0); | |
| 4608 | + trans->delayed_ref_updates * 2, | |
| 4609 | + trans->transid, 0); | |
| 4610 | 4610 | if (be_nice) { |
| 4611 | 4611 | if (truncate_space_check(trans, root, |
| 4612 | 4612 | extent_num_bytes)) { |
| @@ -8931,9 +8931,14 @@ again: · 4318 unmodified lines | ||
| 8931 | 8931 | * So even we call qgroup_free_data(), it won't decrease reserved |
| 8932 | 8932 | * space. |
| 8933 | 8933 | * 2) Not written to disk |
| 8934 | − * This means the reserved space should be freed here. | |
| 8934 | + * This means the reserved space should be freed here. However, | |
| 8935 | + * if a truncate invalidates the page (by clearing PageDirty) | |
| 8936 | + * and the page is accounted for while allocating extent | |
| 8937 | + * in btrfs_check_data_free_space() we let delayed_ref to | |
| 8938 | + * free the entire extent. | |
| 8935 | 8939 | */ |
| 8936 | − btrfs_qgroup_free_data(inode, page_start, PAGE_SIZE); | |
| 8940 | + if (PageDirty(page)) | |
| 8941 | + btrfs_qgroup_free_data(inode, page_start, PAGE_SIZE); | |
| 8937 | 8942 | if (!inode_evicting) { |
| 8938 | 8943 | clear_extent_bit(tree, page_start, page_end, |
| 8939 | 8944 | EXTENT_LOCKED | EXTENT_DIRTY | |
| @@ -3814,6 +3814,11 @@ process_slot: · 3813 unmodified lines | ||
| 3814 | 3814 | } |
| 3815 | 3815 | btrfs_release_path(path); |
| 3816 | 3816 | key.offset = next_key_min_offset; |
| 3817 | + | |
| 3818 | + if (fatal_signal_pending(current)) { | |
| 3819 | + ret = -EINTR; | |
| 3820 | + goto out; | |
| 3821 | + } | |
| 3817 | 3822 | } |
| 3818 | 3823 | ret = 0; |
| 3819 | 3824 | |
| @@ -2728,7 +2728,14 @@ static int do_relocation(struct btrfs_trans_handle *trans, · 2727 unmodified lines | ||
| 2728 | 2728 | |
| 2729 | 2729 | bytenr = btrfs_node_blockptr(upper->eb, slot); |
| 2730 | 2730 | if (lowest) { |
| 2731 | − BUG_ON(bytenr != node->bytenr); | |
| 2731 | + if (bytenr != node->bytenr) { | |
| 2732 | + btrfs_err(root->fs_info, | |
| 2733 | + "lowest leaf/node mismatch: bytenr %llu node->bytenr %llu slot %d upper %llu", | |
| 2734 | + bytenr, node->bytenr, slot, | |
| 2735 | + upper->eb->start); | |
| 2736 | + err = -EIO; | |
| 2737 | + goto next; | |
| 2738 | + } | |
| 2732 | 2739 | } else { |
| 2733 | 2740 | if (node->eb->start == bytenr) |
| 2734 | 2741 | goto next; |