All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org, Eryu Guan <eguan@redhat.com>,
	Dave Chinner <david@fromorbit.com>
Subject: Re: [PATCH 5/5] xfs: wait on new inodes during quotaoff dquot release
Date: Thu, 27 Apr 2017 14:17:53 -0700	[thread overview]
Message-ID: <20170427211753.GC22884@birch.djwong.org> (raw)
In-Reply-To: <1487173247-5965-6-git-send-email-bfoster@redhat.com>

On Wed, Feb 15, 2017 at 10:40:47AM -0500, Brian Foster wrote:
> The quotaoff operation has a race with inode allocation that results
> in a livelock. An inode allocation that occurs before the quota
> status flags are updated acquires the appropriate dquots for the
> inode via xfs_qm_vop_dqalloc(). It then inserts the XFS_INEW inode
> into the perag radix tree, sometime later attaches the dquots to the
> inode and finally clears the XFS_INEW flag. Quotaoff expects to
> release the dquots from all inodes in the filesystem via
> xfs_qm_dqrele_all_inodes(). This invokes the AG inode iterator,
> which skips inodes in the XFS_INEW state because they are not fully
> constructed. If the scan occurs after dquots have been attached to
> an inode, but before XFS_INEW is cleared, the newly allocated inode
> will continue to hold a reference to the applicable dquots. When
> quotaoff invokes xfs_qm_dqpurge_all(), the reference count of those
> dquot(s) remain elevated and the dqpurge scan spins indefinitely.
> 
> To address this problem, update the xfs_qm_dqrele_all_inodes() scan
> to wait on inodes marked on the XFS_INEW state. We wait on the
> inodes explicitly rather than skip and retry to avoid continuous
> retry loops due to a parallel inode allocation workload. Since
> quotaoff updates the quota state flags and uses a synchronous
> transaction before the dqrele scan, and dquots are attached to
> inodes after radix tree insertion iff quota is enabled, one INEW
> waiting pass through the AG guarantees that the scan has processed
> all inodes that could possibly hold dquot references.
> 
> Reported-by: Eryu Guan <eguan@redhat.com>
> Signed-off-by: Brian Foster <bfoster@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_qm_syscalls.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
> index dbb6802..40b7c3f 100644
> --- a/fs/xfs/xfs_qm_syscalls.c
> +++ b/fs/xfs/xfs_qm_syscalls.c
> @@ -765,5 +765,6 @@ xfs_qm_dqrele_all_inodes(
>  	uint		 flags)
>  {
>  	ASSERT(mp->m_quotainfo);
> -	xfs_inode_ag_iterator(mp, xfs_dqrele_inode, flags, NULL);
> +	xfs_inode_ag_iterator_flags(mp, xfs_dqrele_inode, flags, NULL,
> +				    XFS_AGITER_INEW_WAIT);
>  }
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-04-27 21:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15 15:40 [PATCH 0/5] xfs: quota deadlock fixes Brian Foster
2017-02-15 15:40 ` [PATCH 1/5] xfs: bypass dquot reclaim to avoid quotacheck deadlock Brian Foster
2017-02-16 22:37   ` Dave Chinner
2017-02-17 18:30     ` Brian Foster
2017-02-17 23:12       ` Dave Chinner
2017-02-18 12:55         ` Brian Foster
2017-02-15 15:40 ` [PATCH 2/5] xfs: allocate quotaoff transactions up front to avoid log deadlock Brian Foster
2017-04-26 21:23   ` Darrick J. Wong
2017-04-27 12:03     ` Brian Foster
2017-04-27 15:47       ` Darrick J. Wong
2017-02-15 15:40 ` [PATCH 3/5] xfs: support ability to wait on new inodes Brian Foster
2017-04-27 21:15   ` Darrick J. Wong
2017-02-15 15:40 ` [PATCH 4/5] xfs: update ag iterator to support " Brian Foster
2017-04-27 21:17   ` Darrick J. Wong
2017-02-15 15:40 ` [PATCH 5/5] xfs: wait on new inodes during quotaoff dquot release Brian Foster
2017-04-27 21:17   ` Darrick J. Wong [this message]
2017-02-16  7:42 ` [PATCH 0/5] xfs: quota deadlock fixes Eryu Guan
2017-02-16 12:01   ` Brian Foster
2017-02-17  6:53 ` Eryu Guan
2017-02-17 17:54   ` Brian Foster
2017-02-20  3:52     ` Eryu Guan
2017-02-20 13:25       ` Brian Foster
2017-02-22 15:35         ` Brian Foster

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=20170427211753.GC22884@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=bfoster@redhat.com \
    --cc=david@fromorbit.com \
    --cc=eguan@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    /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 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.