All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: do not try to handle a ticket for FLUSH_EMERGENCY
@ 2022-11-17 14:54 Josef Bacik
  2022-11-18 15:54 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2022-11-17 14:54 UTC (permalink / raw)
  To: linux-btrfs, kernel-team; +Cc: Johannes Thumshirn

Even though it is unlikely, we can still fail
BTRFS_RESERVE_FLUSH_EMERGENCY sometimes.  Unfortunately the condition to
check if we should just return the error only checks for NO_FLUSH, and
thus we could get into handle_reserve_ticket with FLUSH_EMERGENCY, which
has the equivalent assertion of ASSERT(flush != FLUSH_EMERGENCY && flush
!= NO_FLUSH).  Fix this by changing the condition at the end of
__reserve_bytes to check !can_ticket(flush) to handle both of these
cases properly.

Fixes: dfed100c66b2 ("btrfs: introduce BTRFS_RESERVE_FLUSH_EMERGENCY")
Reported-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/space-info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index a1384357f7a5..d28ee4e36f3d 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -1729,7 +1729,7 @@ static int __reserve_bytes(struct btrfs_fs_info *fs_info,
 		}
 	}
 	spin_unlock(&space_info->lock);
-	if (!ret || flush == BTRFS_RESERVE_NO_FLUSH)
+	if (!ret || !can_ticket(flush))
 		return ret;
 
 	return handle_reserve_ticket(fs_info, space_info, &ticket, start_ns,
-- 
2.26.3


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

* Re: [PATCH] btrfs: do not try to handle a ticket for FLUSH_EMERGENCY
  2022-11-17 14:54 [PATCH] btrfs: do not try to handle a ticket for FLUSH_EMERGENCY Josef Bacik
@ 2022-11-18 15:54 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2022-11-18 15:54 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-btrfs, kernel-team, Johannes Thumshirn

On Thu, Nov 17, 2022 at 09:54:56AM -0500, Josef Bacik wrote:
> Even though it is unlikely, we can still fail
> BTRFS_RESERVE_FLUSH_EMERGENCY sometimes.  Unfortunately the condition to
> check if we should just return the error only checks for NO_FLUSH, and
> thus we could get into handle_reserve_ticket with FLUSH_EMERGENCY, which
> has the equivalent assertion of ASSERT(flush != FLUSH_EMERGENCY && flush
> != NO_FLUSH).  Fix this by changing the condition at the end of
> __reserve_bytes to check !can_ticket(flush) to handle both of these
> cases properly.
> 
> Fixes: dfed100c66b2 ("btrfs: introduce BTRFS_RESERVE_FLUSH_EMERGENCY")
> Reported-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Folded to the patch, thanks.

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

end of thread, other threads:[~2022-11-18 15:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 14:54 [PATCH] btrfs: do not try to handle a ticket for FLUSH_EMERGENCY Josef Bacik
2022-11-18 15:54 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.