diff mbox series

[1/2] btrfs: check if the transaction was aborted at btrfs_wait_for_commit()

Message ID ef39d239a3d444a4a9788d5690c7f570ba6b8d52.1689932501.git.fdmanana@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: fixes for missing error reporting when attaching to a transaction | expand

Commit Message

Filipe Manana July 21, 2023, 9:49 a.m. UTC
From: Filipe Manana <fdmanana@suse.com>

At btrfs_wait_for_commit() we wait for a transaction to finish and then
always return 0 (success) without checking if it was aborted, in which
case the transaction didn't happen due to some critical error. Fix this
by checking if the transaction was aborted.

Fixes: 462045928bda ("Btrfs: add START_SYNC, WAIT_SYNC ioctls")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/transaction.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Qu Wenruo July 21, 2023, 10:18 a.m. UTC | #1
On 2023/7/21 17:49, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> At btrfs_wait_for_commit() we wait for a transaction to finish and then
> always return 0 (success) without checking if it was aborted, in which
> case the transaction didn't happen due to some critical error. Fix this
> by checking if the transaction was aborted.
>
> Fixes: 462045928bda ("Btrfs: add START_SYNC, WAIT_SYNC ioctls")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>   fs/btrfs/transaction.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
> index 4743882fa94b..8ab85465cdaa 100644
> --- a/fs/btrfs/transaction.c
> +++ b/fs/btrfs/transaction.c
> @@ -931,6 +931,7 @@ int btrfs_wait_for_commit(struct btrfs_fs_info *fs_info, u64 transid)
>   	}
>
>   	wait_for_commit(cur_trans, TRANS_STATE_COMPLETED);
> +	ret = cur_trans->aborted;
>   	btrfs_put_transaction(cur_trans);
>   out:
>   	return ret;
diff mbox series

Patch

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 4743882fa94b..8ab85465cdaa 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -931,6 +931,7 @@  int btrfs_wait_for_commit(struct btrfs_fs_info *fs_info, u64 transid)
 	}
 
 	wait_for_commit(cur_trans, TRANS_STATE_COMPLETED);
+	ret = cur_trans->aborted;
 	btrfs_put_transaction(cur_trans);
 out:
 	return ret;