Received: by 10.223.148.5 with SMTP id 5csp6355843wrq; Wed, 17 Jan 2018 12:37:12 -0800 (PST) X-Google-Smtp-Source: ACJfBou3xMhgcV5HIrH37SVsugYRtW8OnrhbsS7ninoUkhv530YZk3WYLdwVmQcMFkm931Id9wTz X-Received: by 10.159.204.137 with SMTP id t9mr7724010plo.2.1516221432484; Wed, 17 Jan 2018 12:37:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516221432; cv=none; d=google.com; s=arc-20160816; b=k4VxkJoCtneZKACu6XQL3nWlGKznD2ZpwFZhm+TO6VTex4sxAQNmUC/fHYu2dYrBCN GcXV/dhhhDNXTISP+dktBfLt/TOWf7bg9XCkk6nuLGAMrbLSwkSxRHmTf1Js7bS3wyXi NHZjxgW6tTsc3PH3LvuHexJzlhAmdqgRpylRy7RD3P45UBob7AcxOjMQSHWc1/iEW7j7 v8+pqehENb01dR/Z9CgoM0BK84HdyUowkutiMrGfUnAvuar3Bdoty5x4TOjLFXimdrvm +5I89l3v87dzBQYzkR6QCIJ9Qxpdb+DMmWOxBOKU9i3kVO/j1hDCmhAe6huYeMobhrqU /Ejg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=gQHYqKgcpIZZg8bVcv1hvA0EBYZHQhNUJfSi2n1vXgg=; b=OjUXa3Sj+FsG1u9fqC2Pj5cjb5LUHoc66WeaK477ocvu39OLPnLZVLRsEz3rthxDXL tKXL6VBGoBt87uvfTpTgsJrVI+foCeCLMt/sQuwKxq0OSVOpSOn0vy49PITsB+2oq0lQ GgzScfXntA5eXpggjbRgfZcptUqUYupNHAnqqlVAWlaNsle3oFTKpBfWnQyrEM6PektL l56wlnBCCisLyrXYaRibPuhDU8KmRhX+/wNt6b6Mv8CdRN2mItVQEV5iaa996FFkb+Vz fso6Ty/gpGnEvoNRsLIawKxrrnBfHSNHMb+/0RcQQ/5WvA6uXs8Ga4uqSRp57MoKEhzI 0cBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=qdfjmaBk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n61si242385plb.67.2018.01.17.12.36.58; Wed, 17 Jan 2018 12:37:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=qdfjmaBk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932266AbeAQUfQ (ORCPT + 99 others); Wed, 17 Jan 2018 15:35:16 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:52301 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753888AbeAQUW5 (ORCPT ); Wed, 17 Jan 2018 15:22:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gQHYqKgcpIZZg8bVcv1hvA0EBYZHQhNUJfSi2n1vXgg=; b=qdfjmaBkSWFkCxDJ2K4b0Awo4 hpQYQRVHB53uPShzWtDRyNeWiYfBP9VlP/b4kEQsX8yrjorr0WwM6WLJRHgI1f+9JM1/pytmLBp6K LQ2t2yCc+1QEmy0gdD0cflWamz8zVDNyBGAyf5lUBlcN22bqWkXxwSOMj6M2QELBaEaYajpXXEoWd i1DliRo3+ghfQ5tNogeGhB0gyi+T59kC47AnR29HHHCnmOOonWL7kky8j2nZqxPYhKDHYQK6wfhFi 4fHOGpArfi6I/fdRgK+il9fxTkW8I021QEN0k+9ewQRwFuQM+XLJqTYDkPi1JGJnPl3ACN38EwXtN I2kPBhz6Q==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1ebuEZ-0006AX-St; Wed, 17 Jan 2018 20:22:55 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Cc: Matthew Wilcox , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-usb@vger.kernel.org, Bjorn Andersson , Stefano Stabellini , iommu@lists.linux-foundation.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, intel-gfx@lists.freedesktop.org, cgroups@vger.kernel.org, linux-sh@vger.kernel.org, David Howells Subject: [PATCH v6 72/99] xfs: Convert xfs dquot to XArray Date: Wed, 17 Jan 2018 12:21:36 -0800 Message-Id: <20180117202203.19756-73-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180117202203.19756-1-willy@infradead.org> References: <20180117202203.19756-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox This is a pretty straight-forward conversion. Signed-off-by: Matthew Wilcox --- fs/xfs/xfs_dquot.c | 38 +++++++++++++++++++++----------------- fs/xfs/xfs_qm.c | 36 ++++++++++++++++++------------------ fs/xfs/xfs_qm.h | 18 +++++++++--------- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index e2a466df5dd1..c6832db23ca8 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -44,7 +44,7 @@ * Lock order: * * ip->i_lock - * qi->qi_tree_lock + * qi->qi_xa_lock * dquot->q_qlock (xfs_dqlock() and friends) * dquot->q_flush (xfs_dqflock() and friends) * qi->qi_lru_lock @@ -752,8 +752,8 @@ xfs_qm_dqget( xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */ { struct xfs_quotainfo *qi = mp->m_quotainfo; - struct radix_tree_root *tree = xfs_dquot_tree(qi, type); - struct xfs_dquot *dqp; + struct xarray *xa = xfs_dquot_xa(qi, type); + struct xfs_dquot *dqp, *duplicate; int error; ASSERT(XFS_IS_QUOTA_RUNNING(mp)); @@ -772,23 +772,24 @@ xfs_qm_dqget( } restart: - mutex_lock(&qi->qi_tree_lock); - dqp = radix_tree_lookup(tree, id); + mutex_lock(&qi->qi_xa_lock); + dqp = xa_load(xa, id); +found: if (dqp) { xfs_dqlock(dqp); if (dqp->dq_flags & XFS_DQ_FREEING) { xfs_dqunlock(dqp); - mutex_unlock(&qi->qi_tree_lock); + mutex_unlock(&qi->qi_xa_lock); trace_xfs_dqget_freeing(dqp); delay(1); goto restart; } - /* uninit / unused quota found in radix tree, keep looking */ + /* uninit / unused quota found, keep looking */ if (flags & XFS_QMOPT_DQNEXT) { if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) { xfs_dqunlock(dqp); - mutex_unlock(&qi->qi_tree_lock); + mutex_unlock(&qi->qi_xa_lock); error = xfs_dq_get_next_id(mp, type, &id); if (error) return error; @@ -797,14 +798,14 @@ xfs_qm_dqget( } dqp->q_nrefs++; - mutex_unlock(&qi->qi_tree_lock); + mutex_unlock(&qi->qi_xa_lock); trace_xfs_dqget_hit(dqp); XFS_STATS_INC(mp, xs_qm_dqcachehits); *O_dqpp = dqp; return 0; } - mutex_unlock(&qi->qi_tree_lock); + mutex_unlock(&qi->qi_xa_lock); XFS_STATS_INC(mp, xs_qm_dqcachemisses); /* @@ -854,20 +855,23 @@ xfs_qm_dqget( } } - mutex_lock(&qi->qi_tree_lock); - error = radix_tree_insert(tree, id, dqp); - if (unlikely(error)) { - WARN_ON(error != -EEXIST); + mutex_lock(&qi->qi_xa_lock); + duplicate = xa_cmpxchg(xa, id, NULL, dqp, GFP_NOFS); + if (unlikely(duplicate)) { + if (xa_is_err(duplicate)) { + mutex_unlock(&qi->qi_xa_lock); + return xa_err(duplicate); + } /* * Duplicate found. Just throw away the new dquot and start * over. */ - mutex_unlock(&qi->qi_tree_lock); trace_xfs_dqget_dup(dqp); xfs_qm_dqdestroy(dqp); XFS_STATS_INC(mp, xs_qm_dquot_dups); - goto restart; + dqp = duplicate; + goto found; } /* @@ -877,7 +881,7 @@ xfs_qm_dqget( dqp->q_nrefs = 1; qi->qi_dquots++; - mutex_unlock(&qi->qi_tree_lock); + mutex_unlock(&qi->qi_xa_lock); /* If we are asked to find next active id, keep looking */ if (flags & XFS_QMOPT_DQNEXT) { diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index b897b11afb2c..000b207762d6 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -67,7 +67,7 @@ xfs_qm_dquot_walk( void *data) { struct xfs_quotainfo *qi = mp->m_quotainfo; - struct radix_tree_root *tree = xfs_dquot_tree(qi, type); + struct xarray *xa = xfs_dquot_xa(qi, type); uint32_t next_index; int last_error = 0; int skipped; @@ -83,11 +83,11 @@ xfs_qm_dquot_walk( int error = 0; int i; - mutex_lock(&qi->qi_tree_lock); - nr_found = radix_tree_gang_lookup(tree, (void **)batch, - next_index, XFS_DQ_LOOKUP_BATCH); + mutex_lock(&qi->qi_xa_lock); + nr_found = xa_extract(xa, (void **)batch, next_index, + ULONG_MAX, XFS_DQ_LOOKUP_BATCH, XA_PRESENT); if (!nr_found) { - mutex_unlock(&qi->qi_tree_lock); + mutex_unlock(&qi->qi_xa_lock); break; } @@ -105,7 +105,7 @@ xfs_qm_dquot_walk( last_error = error; } - mutex_unlock(&qi->qi_tree_lock); + mutex_unlock(&qi->qi_xa_lock); /* bail out if the filesystem is corrupted. */ if (last_error == -EFSCORRUPTED) { @@ -178,8 +178,8 @@ xfs_qm_dqpurge( xfs_dqfunlock(dqp); xfs_dqunlock(dqp); - radix_tree_delete(xfs_dquot_tree(qi, dqp->q_core.d_flags), - be32_to_cpu(dqp->q_core.d_id)); + xa_store(xfs_dquot_xa(qi, dqp->q_core.d_flags), + be32_to_cpu(dqp->q_core.d_id), NULL, GFP_NOWAIT); qi->qi_dquots--; /* @@ -623,10 +623,10 @@ xfs_qm_init_quotainfo( if (error) goto out_free_lru; - INIT_RADIX_TREE(&qinf->qi_uquota_tree, GFP_NOFS); - INIT_RADIX_TREE(&qinf->qi_gquota_tree, GFP_NOFS); - INIT_RADIX_TREE(&qinf->qi_pquota_tree, GFP_NOFS); - mutex_init(&qinf->qi_tree_lock); + xa_init(&qinf->qi_uquota_xa); + xa_init(&qinf->qi_gquota_xa); + xa_init(&qinf->qi_pquota_xa); + mutex_init(&qinf->qi_xa_lock); /* mutex used to serialize quotaoffs */ mutex_init(&qinf->qi_quotaofflock); @@ -704,7 +704,7 @@ xfs_qm_init_quotainfo( out_free_inos: mutex_destroy(&qinf->qi_quotaofflock); - mutex_destroy(&qinf->qi_tree_lock); + mutex_destroy(&qinf->qi_xa_lock); xfs_qm_destroy_quotainos(qinf); out_free_lru: list_lru_destroy(&qinf->qi_lru); @@ -731,7 +731,7 @@ xfs_qm_destroy_quotainfo( unregister_shrinker(&qi->qi_shrinker); list_lru_destroy(&qi->qi_lru); xfs_qm_destroy_quotainos(qi); - mutex_destroy(&qi->qi_tree_lock); + mutex_destroy(&qi->qi_xa_lock); mutex_destroy(&qi->qi_quotaofflock); kmem_free(qi); mp->m_quotainfo = NULL; @@ -1620,12 +1620,12 @@ xfs_qm_dqfree_one( struct xfs_mount *mp = dqp->q_mount; struct xfs_quotainfo *qi = mp->m_quotainfo; - mutex_lock(&qi->qi_tree_lock); - radix_tree_delete(xfs_dquot_tree(qi, dqp->q_core.d_flags), - be32_to_cpu(dqp->q_core.d_id)); + mutex_lock(&qi->qi_xa_lock); + xa_store(xfs_dquot_xa(qi, dqp->q_core.d_flags), + be32_to_cpu(dqp->q_core.d_id), NULL, GFP_NOWAIT); qi->qi_dquots--; - mutex_unlock(&qi->qi_tree_lock); + mutex_unlock(&qi->qi_xa_lock); xfs_qm_dqdestroy(dqp); } diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h index 2975a822e9f0..946f929f7bfb 100644 --- a/fs/xfs/xfs_qm.h +++ b/fs/xfs/xfs_qm.h @@ -67,10 +67,10 @@ struct xfs_def_quota { * The mount structure keeps a pointer to this. */ typedef struct xfs_quotainfo { - struct radix_tree_root qi_uquota_tree; - struct radix_tree_root qi_gquota_tree; - struct radix_tree_root qi_pquota_tree; - struct mutex qi_tree_lock; + struct xarray qi_uquota_xa; + struct xarray qi_gquota_xa; + struct xarray qi_pquota_xa; + struct mutex qi_xa_lock; struct xfs_inode *qi_uquotaip; /* user quota inode */ struct xfs_inode *qi_gquotaip; /* group quota inode */ struct xfs_inode *qi_pquotaip; /* project quota inode */ @@ -91,18 +91,18 @@ typedef struct xfs_quotainfo { struct shrinker qi_shrinker; } xfs_quotainfo_t; -static inline struct radix_tree_root * -xfs_dquot_tree( +static inline struct xarray * +xfs_dquot_xa( struct xfs_quotainfo *qi, int type) { switch (type) { case XFS_DQ_USER: - return &qi->qi_uquota_tree; + return &qi->qi_uquota_xa; case XFS_DQ_GROUP: - return &qi->qi_gquota_tree; + return &qi->qi_gquota_xa; case XFS_DQ_PROJ: - return &qi->qi_pquota_tree; + return &qi->qi_pquota_xa; default: ASSERT(0); } -- 2.15.1