-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE8rQSAMVO+zA4DBdWxWXV+ddtWDsFAmFM79wACgkQxWXV+ddt
 WDtdZQ/+K7NNEutg4JEH7n2KiXxwj8P23NwVK66a+XwH6/ZBe9xz5TQpnTJQ+D13
 +3mhthTJG7Wbcv+FlUVbfTSp5q8m2IH7CKox43o4JCZEEGtFfRPHrBGHLlGKMk3P
 ap2TZ3rvo0Sb21rx978HCQY824wdJvhv0SmWSScmvWzlTQEKaJHz1OFJgFxhUsMp
 Cy9y7mtIy+Ei4qJglU88iFNXhNL6YvwqXxDFY5LwN9rlCaV+rLk476aPfIBvvyf8
 4f34FHJOe1w9Jlk3KfydIwWefRBbq2dm0zNqNrMHNjl8zXbvfn8+ETOvf54HbjIz
 GGgKiZlBgNh2Na+p0SLoloEvBUdD5lSUCXis8099oUWZ+MporIwsyy4jAvtAeWR/
 QxBkZyxvTNFlXLamSo6oS58K9BNuxFYO7nLGSXQFEoYvb8/fu18rRt/A/rmNS8TU
 2vxpYacNKbggoULiGDzB74JY7MHdHRcMcAhmfDeG1bvNESPHfyLnpHfWamBVoUO6
 0eQOr78f1UpBlqJAGAGtfBefN1kMDnORyX0npGkGLFrKYiZbMgsxdjkNhiHnsufl
 9gsNVJ6baCeB1d5qS2vpZXeOLw0ln5iYZa5Yqz0eh/yc/9Wlj/YCsKRuAbaPMR1i
 i2ppHo3/na4K6L0EgSi6SU3xaUT+4LLzEEcBlJJuWZEwUTeYwiM=
 =VJFC
 -----END PGP SIGNATURE-----

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

Pull btrfs fixes from David Sterba:

 - regression fix for leak of transaction handle after verity rollback
   failure

 - properly reset device last error between mounts

 - improve one error handling case when checksumming bios

 - fixup confusing displayed size of space info free space

* tag 'for-5.15-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: prevent __btrfs_dump_space_info() to underflow its free space
  btrfs: fix mount failure due to past and transient device flush error
  btrfs: fix transaction handle leak after verity rollback failure
  btrfs: replace BUG_ON() in btrfs_csum_one_bio() with proper error handling
This commit is contained in:
Linus Torvalds 2021-09-23 14:39:41 -07:00
Родитель 831c9bd3da 0619b79014
Коммит f9e36107ec
4 изменённых файлов: 32 добавлений и 5 удалений

Просмотреть файл

@ -665,7 +665,18 @@ blk_status_t btrfs_csum_one_bio(struct btrfs_inode *inode, struct bio *bio,
if (!ordered) { if (!ordered) {
ordered = btrfs_lookup_ordered_extent(inode, offset); ordered = btrfs_lookup_ordered_extent(inode, offset);
BUG_ON(!ordered); /* Logic error */ /*
* The bio range is not covered by any ordered extent,
* must be a code logic error.
*/
if (unlikely(!ordered)) {
WARN(1, KERN_WARNING
"no ordered extent for root %llu ino %llu offset %llu\n",
inode->root->root_key.objectid,
btrfs_ino(inode), offset);
kvfree(sums);
return BLK_STS_IOERR;
}
} }
nr_sectors = BTRFS_BYTES_TO_BLKS(fs_info, nr_sectors = BTRFS_BYTES_TO_BLKS(fs_info,

Просмотреть файл

@ -414,9 +414,10 @@ static void __btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
{ {
lockdep_assert_held(&info->lock); lockdep_assert_held(&info->lock);
btrfs_info(fs_info, "space_info %llu has %llu free, is %sfull", /* The free space could be negative in case of overcommit */
btrfs_info(fs_info, "space_info %llu has %lld free, is %sfull",
info->flags, info->flags,
info->total_bytes - btrfs_space_info_used(info, true), (s64)(info->total_bytes - btrfs_space_info_used(info, true)),
info->full ? "" : "not "); info->full ? "" : "not ");
btrfs_info(fs_info, btrfs_info(fs_info,
"space_info total=%llu, used=%llu, pinned=%llu, reserved=%llu, may_use=%llu, readonly=%llu zone_unusable=%llu", "space_info total=%llu, used=%llu, pinned=%llu, reserved=%llu, may_use=%llu, readonly=%llu zone_unusable=%llu",

Просмотреть файл

@ -451,7 +451,7 @@ static int del_orphan(struct btrfs_trans_handle *trans, struct btrfs_inode *inod
*/ */
static int rollback_verity(struct btrfs_inode *inode) static int rollback_verity(struct btrfs_inode *inode)
{ {
struct btrfs_trans_handle *trans; struct btrfs_trans_handle *trans = NULL;
struct btrfs_root *root = inode->root; struct btrfs_root *root = inode->root;
int ret; int ret;
@ -473,6 +473,7 @@ static int rollback_verity(struct btrfs_inode *inode)
trans = btrfs_start_transaction(root, 2); trans = btrfs_start_transaction(root, 2);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
ret = PTR_ERR(trans); ret = PTR_ERR(trans);
trans = NULL;
btrfs_handle_fs_error(root->fs_info, ret, btrfs_handle_fs_error(root->fs_info, ret,
"failed to start transaction in verity rollback %llu", "failed to start transaction in verity rollback %llu",
(u64)inode->vfs_inode.i_ino); (u64)inode->vfs_inode.i_ino);
@ -490,8 +491,9 @@ static int rollback_verity(struct btrfs_inode *inode)
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
btrfs_end_transaction(trans);
out: out:
if (trans)
btrfs_end_transaction(trans);
return ret; return ret;
} }

Просмотреть файл

@ -1137,6 +1137,19 @@ static void btrfs_close_one_device(struct btrfs_device *device)
atomic_set(&device->dev_stats_ccnt, 0); atomic_set(&device->dev_stats_ccnt, 0);
extent_io_tree_release(&device->alloc_state); extent_io_tree_release(&device->alloc_state);
/*
* Reset the flush error record. We might have a transient flush error
* in this mount, and if so we aborted the current transaction and set
* the fs to an error state, guaranteeing no super blocks can be further
* committed. However that error might be transient and if we unmount the
* filesystem and mount it again, we should allow the mount to succeed
* (btrfs_check_rw_degradable() should not fail) - if after mounting the
* filesystem again we still get flush errors, then we will again abort
* any transaction and set the error state, guaranteeing no commits of
* unsafe super blocks.
*/
device->last_flush_error = 0;
/* Verify the device is back in a pristine state */ /* Verify the device is back in a pristine state */
ASSERT(!test_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state)); ASSERT(!test_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state));
ASSERT(!test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state)); ASSERT(!test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state));