From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp1040.oracle.com ([156.151.31.81]:43423 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755451AbdD0VR7 (ORCPT ); Thu, 27 Apr 2017 17:17:59 -0400 Date: Thu, 27 Apr 2017 14:17:53 -0700 From: "Darrick J. Wong" Subject: Re: [PATCH 5/5] xfs: wait on new inodes during quotaoff dquot release Message-ID: <20170427211753.GC22884@birch.djwong.org> References: <1487173247-5965-1-git-send-email-bfoster@redhat.com> <1487173247-5965-6-git-send-email-bfoster@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1487173247-5965-6-git-send-email-bfoster@redhat.com> Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs To: Brian Foster Cc: linux-xfs@vger.kernel.org, Eryu Guan , Dave Chinner 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 > Signed-off-by: Brian Foster Looks ok, Reviewed-by: Darrick J. Wong --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