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-7.0-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux

Pull btrfs fixes from David Sterba:
"One-liner or short fixes for minor/moderate problems reported recently:

- fixes or level adjustments of error messages

- fix leaked transaction handles after aborted transactions, when
using the remap tree feature

- fix a few leaked chunk maps after errors

- fix leaked page array in io_uring encoded read if an error occurs
and the 'finished' is not called

- fix double release of reserved extents when doing a range COW

- don't commit super block when the filesystem is in shutdown state

- fix squota accounting condition when checking members vs parent
usage

- other error handling fixes"

* tag 'for-7.0-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
btrfs: check block group lookup in remove_range_from_remap_tree()
btrfs: fix transaction handle leaks in btrfs_last_identity_remap_gone()
btrfs: fix chunk map leak in btrfs_map_block() after btrfs_translate_remap()
btrfs: fix chunk map leak in btrfs_map_block() after btrfs_chunk_map_num_copies()
btrfs: fix compat mask in error messages in btrfs_check_features()
btrfs: print correct subvol num if active swapfile prevents deletion
btrfs: fix warning in scrub_verify_one_metadata()
btrfs: fix objectid value in error message in check_extent_data_ref()
btrfs: fix incorrect key offset in error message in check_dev_extent_item()
btrfs: fix error message order of parameters in btrfs_delete_delayed_dir_index()
btrfs: don't commit the super block when unmounting a shutdown filesystem
btrfs: free pages on error in btrfs_uring_read_extent()
btrfs: fix referenced/exclusive check in squota_check_parent_usage()
btrfs: remove pointless WARN_ON() in cache_save_setup()
btrfs: convert log messages to error level in btrfs_replay_log()
btrfs: remove btrfs_handle_fs_error() after failure to recover log trees
btrfs: remove redundant warning message in btrfs_check_uuid_tree()
btrfs: change warning messages to error level in open_ctree()
btrfs: fix a double release on reserved extents in cow_one_range()
btrfs: handle discard errors in in btrfs_finish_extent_commit()

+67 -28
-1
fs/btrfs/block-group.c
··· 3340 3340 btrfs_abort_transaction(trans, ret); 3341 3341 goto out_put; 3342 3342 } 3343 - WARN_ON(ret); 3344 3343 3345 3344 /* We've already setup this transaction, go ahead and exit */ 3346 3345 if (block_group->cache_generation == trans->transid &&
+1 -1
fs/btrfs/delayed-inode.c
··· 1657 1657 if (unlikely(ret)) { 1658 1658 btrfs_err(trans->fs_info, 1659 1659 "failed to add delayed dir index item, root: %llu, inode: %llu, index: %llu, error: %d", 1660 - index, btrfs_root_id(node->root), node->inode_id, ret); 1660 + btrfs_root_id(node->root), node->inode_id, index, ret); 1661 1661 btrfs_delayed_item_release_metadata(dir->root, item); 1662 1662 btrfs_release_delayed_item(item); 1663 1663 }
+21 -15
fs/btrfs/disk-io.c
··· 1994 1994 int level = btrfs_super_log_root_level(disk_super); 1995 1995 1996 1996 if (unlikely(fs_devices->rw_devices == 0)) { 1997 - btrfs_warn(fs_info, "log replay required on RO media"); 1997 + btrfs_err(fs_info, "log replay required on RO media"); 1998 1998 return -EIO; 1999 1999 } 2000 2000 ··· 2008 2008 check.owner_root = BTRFS_TREE_LOG_OBJECTID; 2009 2009 log_tree_root->node = read_tree_block(fs_info, bytenr, &check); 2010 2010 if (IS_ERR(log_tree_root->node)) { 2011 - btrfs_warn(fs_info, "failed to read log tree"); 2012 2011 ret = PTR_ERR(log_tree_root->node); 2013 2012 log_tree_root->node = NULL; 2013 + btrfs_err(fs_info, "failed to read log tree with error: %d", ret); 2014 2014 btrfs_put_root(log_tree_root); 2015 2015 return ret; 2016 2016 } ··· 2023 2023 /* returns with log_tree_root freed on success */ 2024 2024 ret = btrfs_recover_log_trees(log_tree_root); 2025 2025 btrfs_put_root(log_tree_root); 2026 - if (ret) { 2027 - btrfs_handle_fs_error(fs_info, ret, 2028 - "Failed to recover log tree"); 2026 + if (unlikely(ret)) { 2027 + ASSERT(BTRFS_FS_ERROR(fs_info) != 0); 2028 + btrfs_err(fs_info, "failed to recover log trees with error: %d", ret); 2029 2029 return ret; 2030 2030 } 2031 2031 ··· 2972 2972 task = kthread_run(btrfs_uuid_rescan_kthread, fs_info, "btrfs-uuid"); 2973 2973 if (IS_ERR(task)) { 2974 2974 /* fs_info->update_uuid_tree_gen remains 0 in all error case */ 2975 - btrfs_warn(fs_info, "failed to start uuid_rescan task"); 2976 2975 up(&fs_info->uuid_tree_rescan_sem); 2977 2976 return PTR_ERR(task); 2978 2977 } ··· 3187 3188 if (incompat & ~BTRFS_FEATURE_INCOMPAT_SUPP) { 3188 3189 btrfs_err(fs_info, 3189 3190 "cannot mount because of unknown incompat features (0x%llx)", 3190 - incompat); 3191 + incompat & ~BTRFS_FEATURE_INCOMPAT_SUPP); 3191 3192 return -EINVAL; 3192 3193 } 3193 3194 ··· 3219 3220 if (compat_ro_unsupp && is_rw_mount) { 3220 3221 btrfs_err(fs_info, 3221 3222 "cannot mount read-write because of unknown compat_ro features (0x%llx)", 3222 - compat_ro); 3223 + compat_ro_unsupp); 3223 3224 return -EINVAL; 3224 3225 } 3225 3226 ··· 3232 3233 !btrfs_test_opt(fs_info, NOLOGREPLAY)) { 3233 3234 btrfs_err(fs_info, 3234 3235 "cannot replay dirty log with unsupported compat_ro features (0x%llx), try rescue=nologreplay", 3235 - compat_ro); 3236 + compat_ro_unsupp); 3236 3237 return -EINVAL; 3237 3238 } 3238 3239 ··· 3641 3642 fs_info->fs_root = btrfs_get_fs_root(fs_info, BTRFS_FS_TREE_OBJECTID, true); 3642 3643 if (IS_ERR(fs_info->fs_root)) { 3643 3644 ret = PTR_ERR(fs_info->fs_root); 3644 - btrfs_warn(fs_info, "failed to read fs tree: %d", ret); 3645 + btrfs_err(fs_info, "failed to read fs tree: %d", ret); 3645 3646 fs_info->fs_root = NULL; 3646 3647 goto fail_qgroup; 3647 3648 } ··· 3662 3663 btrfs_info(fs_info, "checking UUID tree"); 3663 3664 ret = btrfs_check_uuid_tree(fs_info); 3664 3665 if (ret) { 3665 - btrfs_warn(fs_info, 3666 - "failed to check the UUID tree: %d", ret); 3666 + btrfs_err(fs_info, "failed to check the UUID tree: %d", ret); 3667 3667 close_ctree(fs_info); 3668 3668 return ret; 3669 3669 } ··· 4397 4399 */ 4398 4400 btrfs_flush_workqueue(fs_info->delayed_workers); 4399 4401 4400 - ret = btrfs_commit_super(fs_info); 4401 - if (ret) 4402 - btrfs_err(fs_info, "commit super ret %d", ret); 4402 + /* 4403 + * If the filesystem is shutdown, then an attempt to commit the 4404 + * super block (or any write) will just fail. Since we freeze 4405 + * the filesystem before shutting it down, the filesystem is in 4406 + * a consistent state and we don't need to commit super blocks. 4407 + */ 4408 + if (!btrfs_is_shutdown(fs_info)) { 4409 + ret = btrfs_commit_super(fs_info); 4410 + if (ret) 4411 + btrfs_err(fs_info, "commit super block returned %d", ret); 4412 + } 4403 4413 } 4404 4414 4405 4415 kthread_stop(fs_info->transaction_kthread);
+7 -1
fs/btrfs/extent-tree.c
··· 2933 2933 while (!TRANS_ABORTED(trans) && cached_state) { 2934 2934 struct extent_state *next_state; 2935 2935 2936 - if (btrfs_test_opt(fs_info, DISCARD_SYNC)) 2936 + if (btrfs_test_opt(fs_info, DISCARD_SYNC)) { 2937 2937 ret = btrfs_discard_extent(fs_info, start, 2938 2938 end + 1 - start, NULL, true); 2939 + if (ret) { 2940 + btrfs_warn(fs_info, 2941 + "discard failed for extent [%llu, %llu]: errno=%d %s", 2942 + start, end, ret, btrfs_decode_error(ret)); 2943 + } 2944 + } 2939 2945 2940 2946 next_state = btrfs_next_extent_state(unpin, cached_state); 2941 2947 btrfs_clear_extent_dirty(unpin, start, end, &cached_state);
+17 -2
fs/btrfs/inode.c
··· 1392 1392 return ret; 1393 1393 1394 1394 free_reserved: 1395 + /* 1396 + * If we have reserved an extent for the current range and failed to 1397 + * create the respective extent map or ordered extent, it means that 1398 + * when we reserved the extent we decremented the extent's size from 1399 + * the data space_info's bytes_may_use counter and 1400 + * incremented the space_info's bytes_reserved counter by the same 1401 + * amount. 1402 + * 1403 + * We must make sure extent_clear_unlock_delalloc() does not try 1404 + * to decrement again the data space_info's bytes_may_use counter, which 1405 + * will be handled by btrfs_free_reserved_extent(). 1406 + * 1407 + * Therefore we do not pass it the flag EXTENT_CLEAR_DATA_RESV, but only 1408 + * EXTENT_CLEAR_META_RESV. 1409 + */ 1395 1410 extent_clear_unlock_delalloc(inode, file_offset, cur_end, locked_folio, cached, 1396 1411 EXTENT_LOCKED | EXTENT_DELALLOC | 1397 1412 EXTENT_DELALLOC_NEW | 1398 - EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING, 1413 + EXTENT_DEFRAG | EXTENT_CLEAR_META_RESV, 1399 1414 PAGE_UNLOCK | PAGE_START_WRITEBACK | 1400 1415 PAGE_END_WRITEBACK); 1401 1416 btrfs_qgroup_free_data(inode, NULL, file_offset, cur_len, NULL); ··· 4779 4764 spin_unlock(&dest->root_item_lock); 4780 4765 btrfs_warn(fs_info, 4781 4766 "attempt to delete subvolume %llu with active swapfile", 4782 - btrfs_root_id(root)); 4767 + btrfs_root_id(dest)); 4783 4768 ret = -EPERM; 4784 4769 goto out_up_write; 4785 4770 }
+6 -1
fs/btrfs/ioctl.c
··· 4581 4581 { 4582 4582 struct btrfs_inode *inode = BTRFS_I(file_inode(iocb->ki_filp)); 4583 4583 struct extent_io_tree *io_tree = &inode->io_tree; 4584 - struct page **pages; 4584 + struct page **pages = NULL; 4585 4585 struct btrfs_uring_priv *priv = NULL; 4586 4586 unsigned long nr_pages; 4587 4587 int ret; ··· 4639 4639 btrfs_unlock_extent(io_tree, start, lockend, &cached_state); 4640 4640 btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED); 4641 4641 kfree(priv); 4642 + for (int i = 0; i < nr_pages; i++) { 4643 + if (pages[i]) 4644 + __free_page(pages[i]); 4645 + } 4646 + kfree(pages); 4642 4647 return ret; 4643 4648 } 4644 4649
+1 -1
fs/btrfs/qgroup.c
··· 370 370 nr_members++; 371 371 } 372 372 mismatch = (parent->excl != excl_sum || parent->rfer != rfer_sum || 373 - parent->excl_cmpr != excl_cmpr_sum || parent->rfer_cmpr != excl_cmpr_sum); 373 + parent->excl_cmpr != excl_cmpr_sum || parent->rfer_cmpr != rfer_cmpr_sum); 374 374 375 375 WARN(mismatch, 376 376 "parent squota qgroup %hu/%llu has mismatched usage from its %d members. "
+6
fs/btrfs/relocation.c
··· 4723 4723 ret = btrfs_remove_dev_extents(trans, chunk_map); 4724 4724 if (unlikely(ret)) { 4725 4725 btrfs_abort_transaction(trans, ret); 4726 + btrfs_end_transaction(trans); 4726 4727 return ret; 4727 4728 } 4728 4729 ··· 4733 4732 if (unlikely(ret)) { 4734 4733 mutex_unlock(&trans->fs_info->chunk_mutex); 4735 4734 btrfs_abort_transaction(trans, ret); 4735 + btrfs_end_transaction(trans); 4736 4736 return ret; 4737 4737 } 4738 4738 } ··· 4752 4750 ret = remove_chunk_stripes(trans, chunk_map, path); 4753 4751 if (unlikely(ret)) { 4754 4752 btrfs_abort_transaction(trans, ret); 4753 + btrfs_end_transaction(trans); 4755 4754 return ret; 4756 4755 } 4757 4756 ··· 5985 5982 struct btrfs_block_group *dest_bg; 5986 5983 5987 5984 dest_bg = btrfs_lookup_block_group(fs_info, new_addr); 5985 + if (unlikely(!dest_bg)) 5986 + return -EUCLEAN; 5987 + 5988 5988 adjust_block_group_remap_bytes(trans, dest_bg, -overlap_length); 5989 5989 btrfs_put_block_group(dest_bg); 5990 5990 ret = btrfs_add_to_free_space_tree(trans,
+1 -1
fs/btrfs/scrub.c
··· 743 743 btrfs_warn_rl(fs_info, 744 744 "scrub: tree block %llu mirror %u has bad fsid, has %pU want %pU", 745 745 logical, stripe->mirror_num, 746 - header->fsid, fs_info->fs_devices->fsid); 746 + header->fsid, fs_info->fs_devices->metadata_uuid); 747 747 return; 748 748 } 749 749 if (memcmp(header->chunk_tree_uuid, fs_info->chunk_tree_uuid,
+2 -2
fs/btrfs/tree-checker.c
··· 1740 1740 objectid > BTRFS_LAST_FREE_OBJECTID)) { 1741 1741 extent_err(leaf, slot, 1742 1742 "invalid extent data backref objectid value %llu", 1743 - root); 1743 + objectid); 1744 1744 return -EUCLEAN; 1745 1745 } 1746 1746 if (unlikely(!IS_ALIGNED(offset, leaf->fs_info->sectorsize))) { ··· 1921 1921 if (unlikely(prev_key->offset + prev_len > key->offset)) { 1922 1922 generic_err(leaf, slot, 1923 1923 "dev extent overlap, prev offset %llu len %llu current offset %llu", 1924 - prev_key->objectid, prev_len, key->offset); 1924 + prev_key->offset, prev_len, key->offset); 1925 1925 return -EUCLEAN; 1926 1926 } 1927 1927 }
+5 -3
fs/btrfs/volumes.c
··· 6907 6907 6908 6908 ret = btrfs_translate_remap(fs_info, &new_logical, length); 6909 6909 if (ret) 6910 - return ret; 6910 + goto out; 6911 6911 6912 6912 if (new_logical != logical) { 6913 6913 btrfs_free_chunk_map(map); ··· 6921 6921 } 6922 6922 6923 6923 num_copies = btrfs_chunk_map_num_copies(map); 6924 - if (io_geom.mirror_num > num_copies) 6925 - return -EINVAL; 6924 + if (io_geom.mirror_num > num_copies) { 6925 + ret = -EINVAL; 6926 + goto out; 6927 + } 6926 6928 6927 6929 map_offset = logical - map->start; 6928 6930 io_geom.raid56_full_stripe_start = (u64)-1;