public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: check for BTRFS_FS_ERROR in pending ordered assert
@ 2023-08-24 20:59 Josef Bacik
  2023-08-25 11:52 ` Filipe Manana
  2023-09-05 11:09 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Josef Bacik @ 2023-08-24 20:59 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

If we do fast tree logging we increment a counter on the current
transaction for every ordered extent we need to wait for.  This means we
expect the transaction to still be there when we clear pending on the
ordered extent.  However if we happen to abort the transaction and clean
it up, there could be no running transaction, and thus we'll trip the

ASSERT(trans)

check.  This is obviously incorrect, and the code properly deals with
the case that the trans doesn't exist.  Fix this ASSERT() to only fire
if there's no trans and we don't have BTRFS_FS_ERROR() set on the file
system.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/ordered-data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 09b274d9ba18..69a2cb50c197 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -659,7 +659,7 @@ void btrfs_remove_ordered_extent(struct btrfs_inode *btrfs_inode,
 			refcount_inc(&trans->use_count);
 		spin_unlock(&fs_info->trans_lock);
 
-		ASSERT(trans);
+		ASSERT(trans || BTRFS_FS_ERROR(fs_info));
 		if (trans) {
 			if (atomic_dec_and_test(&trans->pending_ordered))
 				wake_up(&trans->pending_wait);
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: check for BTRFS_FS_ERROR in pending ordered assert
  2023-08-24 20:59 [PATCH] btrfs: check for BTRFS_FS_ERROR in pending ordered assert Josef Bacik
@ 2023-08-25 11:52 ` Filipe Manana
  2023-09-05 11:09 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Filipe Manana @ 2023-08-25 11:52 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-btrfs, kernel-team

On Thu, Aug 24, 2023 at 04:59:04PM -0400, Josef Bacik wrote:
> If we do fast tree logging we increment a counter on the current
> transaction for every ordered extent we need to wait for.  This means we
> expect the transaction to still be there when we clear pending on the
> ordered extent.  However if we happen to abort the transaction and clean
> it up, there could be no running transaction, and thus we'll trip the
> 
> ASSERT(trans)
> 
> check.  This is obviously incorrect, and the code properly deals with
> the case that the trans doesn't exist.  Fix this ASSERT() to only fire
> if there's no trans and we don't have BTRFS_FS_ERROR() set on the file
> system.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good, thanks.

> ---
>  fs/btrfs/ordered-data.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
> index 09b274d9ba18..69a2cb50c197 100644
> --- a/fs/btrfs/ordered-data.c
> +++ b/fs/btrfs/ordered-data.c
> @@ -659,7 +659,7 @@ void btrfs_remove_ordered_extent(struct btrfs_inode *btrfs_inode,
>  			refcount_inc(&trans->use_count);
>  		spin_unlock(&fs_info->trans_lock);
>  
> -		ASSERT(trans);
> +		ASSERT(trans || BTRFS_FS_ERROR(fs_info));
>  		if (trans) {
>  			if (atomic_dec_and_test(&trans->pending_ordered))
>  				wake_up(&trans->pending_wait);
> -- 
> 2.26.3
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: check for BTRFS_FS_ERROR in pending ordered assert
  2023-08-24 20:59 [PATCH] btrfs: check for BTRFS_FS_ERROR in pending ordered assert Josef Bacik
  2023-08-25 11:52 ` Filipe Manana
@ 2023-09-05 11:09 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2023-09-05 11:09 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-btrfs, kernel-team

On Thu, Aug 24, 2023 at 04:59:04PM -0400, Josef Bacik wrote:
> If we do fast tree logging we increment a counter on the current
> transaction for every ordered extent we need to wait for.  This means we
> expect the transaction to still be there when we clear pending on the
> ordered extent.  However if we happen to abort the transaction and clean
> it up, there could be no running transaction, and thus we'll trip the
> 
> ASSERT(trans)
> 
> check.  This is obviously incorrect, and the code properly deals with
> the case that the trans doesn't exist.  Fix this ASSERT() to only fire
> if there's no trans and we don't have BTRFS_FS_ERROR() set on the file
> system.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-09-05 16:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-24 20:59 [PATCH] btrfs: check for BTRFS_FS_ERROR in pending ordered assert Josef Bacik
2023-08-25 11:52 ` Filipe Manana
2023-09-05 11:09 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox