public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Wengang Wang <wen.gang.wang@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: fix AGFL allocation dead lock
Date: Tue, 11 Apr 2023 12:06:24 +1000	[thread overview]
Message-ID: <20230411020624.GY3223426@dread.disaster.area> (raw)
In-Reply-To: <20230330204610.23546-1-wen.gang.wang@oracle.com>

On Thu, Mar 30, 2023 at 01:46:10PM -0700, Wengang Wang wrote:
> There is deadlock with calltrace on process 10133:
> 
> PID 10133 not sceduled for 4403385ms (was on CPU[10])
> 	#0	context_switch() kernel/sched/core.c:3881
> 	#1	__schedule() kernel/sched/core.c:5111
> 	#2	schedule() kernel/sched/core.c:5186
> 	#3	xfs_extent_busy_flush() fs/xfs/xfs_extent_busy.c:598
> 	#4	xfs_alloc_ag_vextent_size() fs/xfs/libxfs/xfs_alloc.c:1641
> 	#5	xfs_alloc_ag_vextent() fs/xfs/libxfs/xfs_alloc.c:828
> 	#6	xfs_alloc_fix_freelist() fs/xfs/libxfs/xfs_alloc.c:2362
> 	#7	xfs_free_extent_fix_freelist() fs/xfs/libxfs/xfs_alloc.c:3029
> 	#8	__xfs_free_extent() fs/xfs/libxfs/xfs_alloc.c:3067
> 	#9	xfs_trans_free_extent() fs/xfs/xfs_extfree_item.c:370
> 	#10	xfs_efi_recover() fs/xfs/xfs_extfree_item.c:626
> 	#11	xlog_recover_process_efi() fs/xfs/xfs_log_recover.c:4605
> 	#12	xlog_recover_process_intents() fs/xfs/xfs_log_recover.c:4893
> 	#13	xlog_recover_finish() fs/xfs/xfs_log_recover.c:5824
> 	#14	xfs_log_mount_finish() fs/xfs/xfs_log.c:764
> 	#15	xfs_mountfs() fs/xfs/xfs_mount.c:978
> 	#16	xfs_fs_fill_super() fs/xfs/xfs_super.c:1908
> 	#17	mount_bdev() fs/super.c:1417
> 	#18	xfs_fs_mount() fs/xfs/xfs_super.c:1985
> 	#19	legacy_get_tree() fs/fs_context.c:647
> 	#20	vfs_get_tree() fs/super.c:1547
> 	#21	do_new_mount() fs/namespace.c:2843
> 	#22	do_mount() fs/namespace.c:3163
> 	#23	ksys_mount() fs/namespace.c:3372
> 	#24	__do_sys_mount() fs/namespace.c:3386
> 	#25	__se_sys_mount() fs/namespace.c:3383
> 	#26	__x64_sys_mount() fs/namespace.c:3383
> 	#27	do_syscall_64() arch/x86/entry/common.c:296
> 	#28	entry_SYSCALL_64() arch/x86/entry/entry_64.S:180
> 
> It's waiting xfs_perag.pagb_gen to increase (busy extent clearing happen).
> From the vmcore, it's waiting on AG 1. And the ONLY busy extent for AG 1 is
> with the transaction (in xfs_trans.t_busy) for process 10133. That busy extent
> is created in a previous EFI with the same transaction. Process 10133 is
> waiting, it has no change to commit that that transaction. So busy extent
> clearing can't happen and pagb_gen remain unchanged. So dead lock formed.

We've talked about this "busy extent in transaction" issue before:

https://lore.kernel.org/linux-xfs/20210428065152.77280-1-chandanrlinux@gmail.com/

and we were closing in on a practical solution before it went silent.

I'm not sure if there's a different fix we can apply here - maybe
free one extent per transaction instead of all the extents in an EFI
in one transaction and relog the EFD at the end of each extent free
transaction roll?

> commit 06058bc40534530e617e5623775c53bb24f032cb disallowed using busy extents
> for any path that calls xfs_extent_busy_trim(). That looks over-killing.
> For AGFL block allocation, it just use the first extent that satisfies, it won't
> try another extent for choose a "better" one. So it's safe to reuse busy extent
> for AGFL.

AGFL block allocation is not "for immediate use". The blocks get
placed on the AGFL for -later- use, and not necessarily even within
the current transaction. Hence a freelist block is still considered
free space, not as used space. The difference is that we assume AGFL
blocks can always be used immediately and they aren't constrained by
being busy or have pending discards.

Also, we have to keep in mind that we can allocate data blocks from
the AGFL in low space situations. Hence it is not safe to place busy
or discard-pending blocks on the AGFL, as this can result in them
being allocated for user data and overwritten before the checkpoint
that marked them busy has been committed to the journal....

As such, I don't think it is be safe to ignore busy extent state
just because we are filling the AGFL from the current free space
tree.

Cheers,

Dave.

-- 
Dave Chinner
david@fromorbit.com

  parent reply	other threads:[~2023-04-11  2:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30 20:46 [PATCH] xfs: fix AGFL allocation dead lock Wengang Wang
2023-04-05 15:26 ` Wengang Wang
2023-04-11  2:06 ` Dave Chinner [this message]
2023-04-12  8:23   ` Chandan Babu R
2023-04-12 23:59     ` Dave Chinner
2023-04-13 10:16       ` Chandan Babu R
2023-04-13 21:38         ` Dave Chinner
2023-04-14  8:44           ` Chandan Babu R
2023-04-14 23:15             ` Wengang Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230411020624.GY3223426@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=wen.gang.wang@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox