Skip to content

Commit cf79ffb

Browse files
author
Josef Bacik
committed
Btrfs: fix infinite loop when we abort on mount
Testing my enospc log code I managed to abort a transaction during mount, which put me into an infinite loop. This is because of two things, first we don't reset trans_no_join if we abort during transaction commit, which will force anybody trying to start a transaction to just loop endlessly waiting for it to be set to 0. But this is still just a symptom, the second issue is we don't set the fs state to error during errors on mount. This is because we don't want to do the flip read only thing during mount, but we still really want to set the fs state to an error to keep us from even getting to the trans_no_join check. So fix both of these things, make sure to reset trans_no_join if we abort during a commit, and make sure we set the fs state to error no matter if we're mounting or not. This should keep us from getting into this infinite loop again. Thanks, Signed-off-by: Josef Bacik <[email protected]>
1 parent c9a9dbf commit cf79ffb

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

fs/btrfs/super.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,9 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
161161
}
162162

163163
/* Don't go through full error handling during mount */
164-
if (sb->s_flags & MS_BORN) {
165-
save_error_info(fs_info);
164+
save_error_info(fs_info);
165+
if (sb->s_flags & MS_BORN)
166166
btrfs_handle_error(fs_info);
167-
}
168167
}
169168

170169
static const char * const logtypes[] = {

fs/btrfs/transaction.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,10 @@ static void cleanup_transaction(struct btrfs_trans_handle *trans,
14871487
current->journal_info = NULL;
14881488

14891489
kmem_cache_free(btrfs_trans_handle_cachep, trans);
1490+
1491+
spin_lock(&root->fs_info->trans_lock);
1492+
root->fs_info->trans_no_join = 0;
1493+
spin_unlock(&root->fs_info->trans_lock);
14901494
}
14911495

14921496
static int btrfs_flush_all_pending_stuffs(struct btrfs_trans_handle *trans,

0 commit comments

Comments
 (0)