Skip to content

Commit 92514ef

Browse files
committed
Merge tag 'for-6.14-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: - add lockdep annotation for relocation root to fix a splat warning while merging roots - fix assertion failure when splitting ordered extent after transaction abort - don't print 'qgroup inconsistent' message when rescan process updates qgroup data sooner than the subvolume deletion process - fix use-after-free (accessing the error number) when attempting to join an aborted transaction - avoid starting new transaction if not necessary when cleaning qgroup during subvolume drop * tag 'for-6.14-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: avoid starting new transaction when cleaning qgroup during subvolume drop btrfs: fix use-after-free when attempting to join an aborted transaction btrfs: do not output error message if a qgroup has been already cleaned up btrfs: fix assertion failure when splitting ordered extent after transaction abort btrfs: fix lockdep splat while merging a relocation root
2 parents 5c8c229 + fdef89c commit 92514ef

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

fs/btrfs/ctree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,7 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p,
14961496

14971497
if (!p->skip_locking) {
14981498
btrfs_unlock_up_safe(p, parent_level + 1);
1499+
btrfs_maybe_reset_lockdep_class(root, tmp);
14991500
tmp_locked = true;
15001501
btrfs_tree_read_lock(tmp);
15011502
btrfs_release_path(p);
@@ -1539,6 +1540,7 @@ read_block_for_search(struct btrfs_root *root, struct btrfs_path *p,
15391540

15401541
if (!p->skip_locking) {
15411542
ASSERT(ret == -EAGAIN);
1543+
btrfs_maybe_reset_lockdep_class(root, tmp);
15421544
tmp_locked = true;
15431545
btrfs_tree_read_lock(tmp);
15441546
btrfs_release_path(p);

fs/btrfs/ordered-data.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,18 @@ struct btrfs_ordered_extent *btrfs_split_ordered_extent(
12291229
*/
12301230
if (WARN_ON_ONCE(len >= ordered->num_bytes))
12311231
return ERR_PTR(-EINVAL);
1232+
/*
1233+
* If our ordered extent had an error there's no point in continuing.
1234+
* The error may have come from a transaction abort done either by this
1235+
* task or some other concurrent task, and the transaction abort path
1236+
* iterates over all existing ordered extents and sets the flag
1237+
* BTRFS_ORDERED_IOERR on them.
1238+
*/
1239+
if (unlikely(flags & (1U << BTRFS_ORDERED_IOERR))) {
1240+
const int fs_error = BTRFS_FS_ERROR(fs_info);
1241+
1242+
return fs_error ? ERR_PTR(fs_error) : ERR_PTR(-EIO);
1243+
}
12321244
/* We cannot split partially completed ordered extents. */
12331245
if (ordered->bytes_left) {
12341246
ASSERT(!(flags & ~BTRFS_ORDERED_TYPE_FLAGS));

fs/btrfs/qgroup.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,11 +1880,7 @@ int btrfs_qgroup_cleanup_dropped_subvolume(struct btrfs_fs_info *fs_info, u64 su
18801880
* Commit current transaction to make sure all the rfer/excl numbers
18811881
* get updated.
18821882
*/
1883-
trans = btrfs_start_transaction(fs_info->quota_root, 0);
1884-
if (IS_ERR(trans))
1885-
return PTR_ERR(trans);
1886-
1887-
ret = btrfs_commit_transaction(trans);
1883+
ret = btrfs_commit_current_transaction(fs_info->quota_root);
18881884
if (ret < 0)
18891885
return ret;
18901886

@@ -1897,8 +1893,11 @@ int btrfs_qgroup_cleanup_dropped_subvolume(struct btrfs_fs_info *fs_info, u64 su
18971893
/*
18981894
* It's squota and the subvolume still has numbers needed for future
18991895
* accounting, in this case we can not delete it. Just skip it.
1896+
*
1897+
* Or the qgroup is already removed by a qgroup rescan. For both cases we're
1898+
* safe to ignore them.
19001899
*/
1901-
if (ret == -EBUSY)
1900+
if (ret == -EBUSY || ret == -ENOENT)
19021901
ret = 0;
19031902
return ret;
19041903
}

fs/btrfs/transaction.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,10 @@ static noinline int join_transaction(struct btrfs_fs_info *fs_info,
274274
cur_trans = fs_info->running_transaction;
275275
if (cur_trans) {
276276
if (TRANS_ABORTED(cur_trans)) {
277+
const int abort_error = cur_trans->aborted;
278+
277279
spin_unlock(&fs_info->trans_lock);
278-
return cur_trans->aborted;
280+
return abort_error;
279281
}
280282
if (btrfs_blocked_trans_types[cur_trans->state] & type) {
281283
spin_unlock(&fs_info->trans_lock);

0 commit comments

Comments
 (0)