Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-5.16-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux

Pull btrfs fixes from David Sterba:
"A few more regression fixes and stable patches, mostly one-liners.

Regression fixes:

- fix pointer/ERR_PTR mismatch returned from memdup_user

- reset dedicated zoned mode relocation block group to avoid using it
and filling it without any recourse

Fixes:

- handle a case to FITRIM range (also to make fstests/generic/260
work)

- fix warning when extent buffer state and pages get out of sync
after an IO error

- fix transaction abort when syncing due to missing mapping error set
on metadata inode after inlining a compressed file

- fix transaction abort due to tree-log and zoned mode interacting in
an unexpected way

- fix memory leak of additional extent data when qgroup reservation
fails

- do proper handling of slot search call when deleting root refs"

* tag 'for-5.16-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
btrfs: replace the BUG_ON in btrfs_del_root_ref with proper error handling
btrfs: zoned: clear data relocation bg on zone finish
btrfs: free exchange changeset on failures
btrfs: fix re-dirty process of tree-log nodes
btrfs: call mapping_set_error() on btree inode with a write error
btrfs: clear extent buffer uptodate when we fail to write it
btrfs: fail if fstrim_range->start == U64_MAX
btrfs: fix error pointer dereference in btrfs_ioctl_rm_dev_v2()

+35 -10
+9 -3
fs/btrfs/delalloc-space.c
··· 143 143 144 144 /* Use new btrfs_qgroup_reserve_data to reserve precious data space. */ 145 145 ret = btrfs_qgroup_reserve_data(inode, reserved, start, len); 146 - if (ret < 0) 146 + if (ret < 0) { 147 147 btrfs_free_reserved_data_space_noquota(fs_info, len); 148 - else 148 + extent_changeset_free(*reserved); 149 + *reserved = NULL; 150 + } else { 149 151 ret = 0; 152 + } 150 153 return ret; 151 154 } 152 155 ··· 455 452 if (ret < 0) 456 453 return ret; 457 454 ret = btrfs_delalloc_reserve_metadata(inode, len); 458 - if (ret < 0) 455 + if (ret < 0) { 459 456 btrfs_free_reserved_data_space(inode, *reserved, start, len); 457 + extent_changeset_free(*reserved); 458 + *reserved = NULL; 459 + } 460 460 return ret; 461 461 } 462 462
+3
fs/btrfs/extent-tree.c
··· 6051 6051 int dev_ret = 0; 6052 6052 int ret = 0; 6053 6053 6054 + if (range->start == U64_MAX) 6055 + return -EINVAL; 6056 + 6054 6057 /* 6055 6058 * Check range overflow if range->len is set. 6056 6059 * The default range->len is U64_MAX.
+14
fs/btrfs/extent_io.c
··· 4314 4314 return; 4315 4315 4316 4316 /* 4317 + * A read may stumble upon this buffer later, make sure that it gets an 4318 + * error and knows there was an error. 4319 + */ 4320 + clear_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags); 4321 + 4322 + /* 4323 + * We need to set the mapping with the io error as well because a write 4324 + * error will flip the file system readonly, and then syncfs() will 4325 + * return a 0 because we are readonly if we don't modify the err seq for 4326 + * the superblock. 4327 + */ 4328 + mapping_set_error(page->mapping, -EIO); 4329 + 4330 + /* 4317 4331 * If we error out, we should add back the dirty_metadata_bytes 4318 4332 * to make it consistent. 4319 4333 */
+2 -4
fs/btrfs/ioctl.c
··· 3187 3187 return -EPERM; 3188 3188 3189 3189 vol_args = memdup_user(arg, sizeof(*vol_args)); 3190 - if (IS_ERR(vol_args)) { 3191 - ret = PTR_ERR(vol_args); 3192 - goto out; 3193 - } 3190 + if (IS_ERR(vol_args)) 3191 + return PTR_ERR(vol_args); 3194 3192 3195 3193 if (vol_args->flags & ~BTRFS_DEVICE_REMOVE_ARGS_MASK) { 3196 3194 ret = -EOPNOTSUPP;
+2 -1
fs/btrfs/root-tree.c
··· 334 334 key.offset = ref_id; 335 335 again: 336 336 ret = btrfs_search_slot(trans, tree_root, &key, path, -1, 1); 337 - BUG_ON(ret < 0); 337 + if (ret < 0) 338 + goto out; 338 339 if (ret == 0) { 339 340 leaf = path->nodes[0]; 340 341 ref = btrfs_item_ptr(leaf, path->slots[0],
+3 -2
fs/btrfs/tree-log.c
··· 2908 2908 path->nodes[*level]->len); 2909 2909 if (ret) 2910 2910 return ret; 2911 + btrfs_redirty_list_add(trans->transaction, 2912 + next); 2911 2913 } else { 2912 2914 if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags)) 2913 2915 clear_extent_buffer_dirty(next); ··· 2990 2988 next->start, next->len); 2991 2989 if (ret) 2992 2990 goto out; 2991 + btrfs_redirty_list_add(trans->transaction, next); 2993 2992 } else { 2994 2993 if (test_and_clear_bit(EXTENT_BUFFER_DIRTY, &next->bflags)) 2995 2994 clear_extent_buffer_dirty(next); ··· 3441 3438 EXTENT_DIRTY | EXTENT_NEW | EXTENT_NEED_WAIT); 3442 3439 extent_io_tree_release(&log->log_csum_range); 3443 3440 3444 - if (trans && log->node) 3445 - btrfs_redirty_list_add(trans->transaction, log->node); 3446 3441 btrfs_put_root(log); 3447 3442 } 3448 3443
+2
fs/btrfs/zoned.c
··· 1860 1860 block_group->alloc_offset = block_group->zone_capacity; 1861 1861 block_group->free_space_ctl->free_space = 0; 1862 1862 btrfs_clear_treelog_bg(block_group); 1863 + btrfs_clear_data_reloc_bg(block_group); 1863 1864 spin_unlock(&block_group->lock); 1864 1865 1865 1866 ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_FINISH, ··· 1943 1942 ASSERT(block_group->alloc_offset == block_group->zone_capacity); 1944 1943 ASSERT(block_group->free_space_ctl->free_space == 0); 1945 1944 btrfs_clear_treelog_bg(block_group); 1945 + btrfs_clear_data_reloc_bg(block_group); 1946 1946 spin_unlock(&block_group->lock); 1947 1947 1948 1948 map = block_group->physical_map;