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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull btrfs fixes from David Sterba:
"A few more code and warning fixes.

There's one feature ioctl removal patch slated for 5.18 that did not
make it to the main pull request. It's just a one-liner and the ioctl
has a v2 that's in use for a long time, no point to postpone it to
5.19.

Late update:

- remove balance v1 ioctl, superseded by v2 in 2012

Fixes:

- add back cgroup attribution for compressed writes

- add super block write start/end annotations to asynchronous balance

- fix root reference count on an error handling path

- in zoned mode, activate zone at the chunk allocation time to avoid
ENOSPC due to timing issues

- fix delayed allocation accounting for direct IO

Warning fixes:

- simplify assertion condition in zoned check

- remove an unused variable"

* tag 'for-5.18-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
btrfs: fix btrfs_submit_compressed_write cgroup attribution
btrfs: fix root ref counts in error handling in btrfs_get_root_ref
btrfs: zoned: activate block group only for extent allocation
btrfs: return allocated block group from do_chunk_alloc()
btrfs: mark resumed async balance as writing
btrfs: remove support of balance v1 ioctl
btrfs: release correct delalloc amount in direct IO write path
btrfs: remove unused variable in btrfs_{start,write}_dirty_block_groups()
btrfs: zoned: remove redundant condition in btrfs_run_delalloc_range

+49 -23
+27 -13
fs/btrfs/block-group.c
··· 2503 2503 return ERR_PTR(ret); 2504 2504 } 2505 2505 2506 - /* 2507 - * New block group is likely to be used soon. Try to activate it now. 2508 - * Failure is OK for now. 2509 - */ 2510 - btrfs_zone_activate(cache); 2511 - 2512 2506 ret = exclude_super_stripes(cache); 2513 2507 if (ret) { 2514 2508 /* We may have excluded something, so call this just in case */ ··· 2940 2946 struct btrfs_path *path = NULL; 2941 2947 LIST_HEAD(dirty); 2942 2948 struct list_head *io = &cur_trans->io_bgs; 2943 - int num_started = 0; 2944 2949 int loops = 0; 2945 2950 2946 2951 spin_lock(&cur_trans->dirty_bgs_lock); ··· 3005 3012 cache->io_ctl.inode = NULL; 3006 3013 ret = btrfs_write_out_cache(trans, cache, path); 3007 3014 if (ret == 0 && cache->io_ctl.inode) { 3008 - num_started++; 3009 3015 should_put = 0; 3010 3016 3011 3017 /* ··· 3105 3113 int should_put; 3106 3114 struct btrfs_path *path; 3107 3115 struct list_head *io = &cur_trans->io_bgs; 3108 - int num_started = 0; 3109 3116 3110 3117 path = btrfs_alloc_path(); 3111 3118 if (!path) ··· 3162 3171 cache->io_ctl.inode = NULL; 3163 3172 ret = btrfs_write_out_cache(trans, cache, path); 3164 3173 if (ret == 0 && cache->io_ctl.inode) { 3165 - num_started++; 3166 3174 should_put = 0; 3167 3175 list_add_tail(&cache->io_list, io); 3168 3176 } else { ··· 3445 3455 return btrfs_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE); 3446 3456 } 3447 3457 3448 - static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags) 3458 + static struct btrfs_block_group *do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags) 3449 3459 { 3450 3460 struct btrfs_block_group *bg; 3451 3461 int ret; ··· 3532 3542 out: 3533 3543 btrfs_trans_release_chunk_metadata(trans); 3534 3544 3535 - return ret; 3545 + if (ret) 3546 + return ERR_PTR(ret); 3547 + 3548 + btrfs_get_block_group(bg); 3549 + return bg; 3536 3550 } 3537 3551 3538 3552 /* ··· 3651 3657 { 3652 3658 struct btrfs_fs_info *fs_info = trans->fs_info; 3653 3659 struct btrfs_space_info *space_info; 3660 + struct btrfs_block_group *ret_bg; 3654 3661 bool wait_for_alloc = false; 3655 3662 bool should_alloc = false; 3663 + bool from_extent_allocation = false; 3656 3664 int ret = 0; 3665 + 3666 + if (force == CHUNK_ALLOC_FORCE_FOR_EXTENT) { 3667 + from_extent_allocation = true; 3668 + force = CHUNK_ALLOC_FORCE; 3669 + } 3657 3670 3658 3671 /* Don't re-enter if we're already allocating a chunk */ 3659 3672 if (trans->allocating_chunk) ··· 3751 3750 force_metadata_allocation(fs_info); 3752 3751 } 3753 3752 3754 - ret = do_chunk_alloc(trans, flags); 3753 + ret_bg = do_chunk_alloc(trans, flags); 3755 3754 trans->allocating_chunk = false; 3755 + 3756 + if (IS_ERR(ret_bg)) { 3757 + ret = PTR_ERR(ret_bg); 3758 + } else if (from_extent_allocation) { 3759 + /* 3760 + * New block group is likely to be used soon. Try to activate 3761 + * it now. Failure is OK for now. 3762 + */ 3763 + btrfs_zone_activate(ret_bg); 3764 + } 3765 + 3766 + if (!ret) 3767 + btrfs_put_block_group(ret_bg); 3756 3768 3757 3769 spin_lock(&space_info->lock); 3758 3770 if (ret < 0) {
+4
fs/btrfs/block-group.h
··· 35 35 * the FS with empty chunks 36 36 * 37 37 * CHUNK_ALLOC_FORCE means it must try to allocate one 38 + * 39 + * CHUNK_ALLOC_FORCE_FOR_EXTENT like CHUNK_ALLOC_FORCE but called from 40 + * find_free_extent() that also activaes the zone 38 41 */ 39 42 enum btrfs_chunk_alloc_enum { 40 43 CHUNK_ALLOC_NO_FORCE, 41 44 CHUNK_ALLOC_LIMITED, 42 45 CHUNK_ALLOC_FORCE, 46 + CHUNK_ALLOC_FORCE_FOR_EXTENT, 43 47 }; 44 48 45 49 struct btrfs_caching_control {
+8
fs/btrfs/compression.c
··· 537 537 cb->orig_bio = NULL; 538 538 cb->nr_pages = nr_pages; 539 539 540 + if (blkcg_css) 541 + kthread_associate_blkcg(blkcg_css); 542 + 540 543 while (cur_disk_bytenr < disk_start + compressed_len) { 541 544 u64 offset = cur_disk_bytenr - disk_start; 542 545 unsigned int index = offset >> PAGE_SHIFT; ··· 558 555 bio = NULL; 559 556 goto finish_cb; 560 557 } 558 + if (blkcg_css) 559 + bio->bi_opf |= REQ_CGROUP_PUNT; 561 560 } 562 561 /* 563 562 * We should never reach next_stripe_start start as we will ··· 617 612 return 0; 618 613 619 614 finish_cb: 615 + if (blkcg_css) 616 + kthread_associate_blkcg(NULL); 617 + 620 618 if (bio) { 621 619 bio->bi_status = ret; 622 620 bio_endio(bio);
+3 -2
fs/btrfs/disk-io.c
··· 1850 1850 1851 1851 ret = btrfs_insert_fs_root(fs_info, root); 1852 1852 if (ret) { 1853 - btrfs_put_root(root); 1854 - if (ret == -EEXIST) 1853 + if (ret == -EEXIST) { 1854 + btrfs_put_root(root); 1855 1855 goto again; 1856 + } 1856 1857 goto fail; 1857 1858 } 1858 1859 return root;
+1 -1
fs/btrfs/extent-tree.c
··· 4082 4082 } 4083 4083 4084 4084 ret = btrfs_chunk_alloc(trans, ffe_ctl->flags, 4085 - CHUNK_ALLOC_FORCE); 4085 + CHUNK_ALLOC_FORCE_FOR_EXTENT); 4086 4086 4087 4087 /* Do not bail out on ENOSPC since we can do more. */ 4088 4088 if (ret == -ENOSPC)
+4 -5
fs/btrfs/inode.c
··· 2016 2016 * to use run_delalloc_nocow() here, like for regular 2017 2017 * preallocated inodes. 2018 2018 */ 2019 - ASSERT(!zoned || 2020 - (zoned && btrfs_is_data_reloc_root(inode->root))); 2019 + ASSERT(!zoned || btrfs_is_data_reloc_root(inode->root)); 2021 2020 ret = run_delalloc_nocow(inode, locked_page, start, end, 2022 2021 page_started, nr_written); 2023 2022 } else if (!inode_can_compress(inode) || ··· 7443 7444 u64 block_start, orig_start, orig_block_len, ram_bytes; 7444 7445 bool can_nocow = false; 7445 7446 bool space_reserved = false; 7447 + u64 prev_len; 7446 7448 int ret = 0; 7447 7449 7448 7450 /* ··· 7471 7471 can_nocow = true; 7472 7472 } 7473 7473 7474 + prev_len = len; 7474 7475 if (can_nocow) { 7475 7476 struct extent_map *em2; 7476 7477 ··· 7501 7500 goto out; 7502 7501 } 7503 7502 } else { 7504 - const u64 prev_len = len; 7505 - 7506 7503 /* Our caller expects us to free the input extent map. */ 7507 7504 free_extent_map(em); 7508 7505 *map = NULL; ··· 7531 7532 * We have created our ordered extent, so we can now release our reservation 7532 7533 * for an outstanding extent. 7533 7534 */ 7534 - btrfs_delalloc_release_extents(BTRFS_I(inode), len); 7535 + btrfs_delalloc_release_extents(BTRFS_I(inode), prev_len); 7535 7536 7536 7537 /* 7537 7538 * Need to update the i_size under the extent lock so buffered
-2
fs/btrfs/ioctl.c
··· 5456 5456 return btrfs_ioctl_fs_info(fs_info, argp); 5457 5457 case BTRFS_IOC_DEV_INFO: 5458 5458 return btrfs_ioctl_dev_info(fs_info, argp); 5459 - case BTRFS_IOC_BALANCE: 5460 - return btrfs_ioctl_balance(file, NULL); 5461 5459 case BTRFS_IOC_TREE_SEARCH: 5462 5460 return btrfs_ioctl_tree_search(inode, argp); 5463 5461 case BTRFS_IOC_TREE_SEARCH_V2:
+2
fs/btrfs/volumes.c
··· 4430 4430 struct btrfs_fs_info *fs_info = data; 4431 4431 int ret = 0; 4432 4432 4433 + sb_start_write(fs_info->sb); 4433 4434 mutex_lock(&fs_info->balance_mutex); 4434 4435 if (fs_info->balance_ctl) 4435 4436 ret = btrfs_balance(fs_info, fs_info->balance_ctl, NULL); 4436 4437 mutex_unlock(&fs_info->balance_mutex); 4438 + sb_end_write(fs_info->sb); 4437 4439 4438 4440 return ret; 4439 4441 }