Pull btrfs fixes from David Sterba: "Two regression fixes and one fix for stable" * tag 'for-4.17-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: Btrfs: send, fix missing truncate for inode with prealloc extent past eof btrfs: Take trans lock before access running trans in check_delayed_ref btrfs: Fix wrong first_key parameter in replace_path
Unified · Split
| @@ -3142,7 +3142,11 @@ static noinline int check_delayed_ref(struct btrfs_root *root, · 3141 unmodified lines | ||
| 3142 | 3142 | struct rb_node *node; |
| 3143 | 3143 | int ret = 0; |
| 3144 | 3144 | |
| 3145 | + spin_lock(&root->fs_info->trans_lock); | |
| 3145 | 3146 | cur_trans = root->fs_info->running_transaction; |
| 3147 | + if (cur_trans) | |
| 3148 | + refcount_inc(&cur_trans->use_count); | |
| 3149 | + spin_unlock(&root->fs_info->trans_lock); | |
| 3146 | 3150 | if (!cur_trans) |
| 3147 | 3151 | return 0; |
| 3148 | 3152 | |
| @@ -3151,6 +3155,7 @@ static noinline int check_delayed_ref(struct btrfs_root *root, · 2 unmodified lines | ||
| 3151 | 3155 | head = btrfs_find_delayed_ref_head(delayed_refs, bytenr); |
| 3152 | 3156 | if (!head) { |
| 3153 | 3157 | spin_unlock(&delayed_refs->lock); |
| 3158 | + btrfs_put_transaction(cur_trans); | |
| 3154 | 3159 | return 0; |
| 3155 | 3160 | } |
| 3156 | 3161 | |
| @@ -3167,6 +3172,7 @@ static noinline int check_delayed_ref(struct btrfs_root *root, · 10 unmodified lines | ||
| 3167 | 3172 | mutex_lock(&head->mutex); |
| 3168 | 3173 | mutex_unlock(&head->mutex); |
| 3169 | 3174 | btrfs_put_delayed_ref_head(head); |
| 3175 | + btrfs_put_transaction(cur_trans); | |
| 3170 | 3176 | return -EAGAIN; |
| 3171 | 3177 | } |
| 3172 | 3178 | spin_unlock(&delayed_refs->lock); |
| @@ -3199,6 +3205,7 @@ static noinline int check_delayed_ref(struct btrfs_root *root, · 26 unmodified lines | ||
| 3199 | 3205 | } |
| 3200 | 3206 | spin_unlock(&head->lock); |
| 3201 | 3207 | mutex_unlock(&head->mutex); |
| 3208 | + btrfs_put_transaction(cur_trans); | |
| 3202 | 3209 | return ret; |
| 3203 | 3210 | } |
| 3204 | 3211 | |
| @@ -1841,7 +1841,7 @@ again: · 1840 unmodified lines | ||
| 1841 | 1841 | old_bytenr = btrfs_node_blockptr(parent, slot); |
| 1842 | 1842 | blocksize = fs_info->nodesize; |
| 1843 | 1843 | old_ptr_gen = btrfs_node_ptr_generation(parent, slot); |
| 1844 | − btrfs_node_key_to_cpu(parent, &key, slot); | |
| 1844 | + btrfs_node_key_to_cpu(parent, &first_key, slot); | |
| 1845 | 1845 | |
| 1846 | 1846 | if (level <= max_level) { |
| 1847 | 1847 | eb = path->nodes[level]; |
| @@ -5236,6 +5236,10 @@ static int send_write_or_clone(struct send_ctx *sctx, · 5235 unmodified lines | ||
| 5236 | 5236 | len = btrfs_file_extent_num_bytes(path->nodes[0], ei); |
| 5237 | 5237 | } |
| 5238 | 5238 | |
| 5239 | + if (offset >= sctx->cur_inode_size) { | |
| 5240 | + ret = 0; | |
| 5241 | + goto out; | |
| 5242 | + } | |
| 5239 | 5243 | if (offset + len > sctx->cur_inode_size) |
| 5240 | 5244 | len = sctx->cur_inode_size - offset; |
| 5241 | 5245 | if (len == 0) { |