Received: by 10.223.164.202 with SMTP id h10csp660879wrb; Wed, 22 Nov 2017 13:14:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMZgeMr9a8ef6hrMycLTiQwV8YuhxfKvEJNhAxBOM3n2HdoY1bh0utcLbzNS0bnPZ3da79Xi X-Received: by 10.99.111.139 with SMTP id k133mr2196594pgc.332.1511385268909; Wed, 22 Nov 2017 13:14:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385268; cv=none; d=google.com; s=arc-20160816; b=kYQHqDMQD1H5RKQ4IIlp10RDSmtwMt9CA0pnXRmMNuO/t8YMjDARyDJsRlLVqCW6nF 4tjyxSxUuLaCDH0GRomfhRHyBFdDaebl0Op9Obt1aoBClcrqRiakxYyoeuvLIbkPGIsS EfdWmFB1F3CFHodDqwLWspQDl/qtPQkxm9chSp2RVJ4g2Sl3GrsKzi1thGmLzSKAj0Kp I92jO8kBuvw5IIcKKiObzEa8aP8YlWZfmSxAVKgGet14wyXaJNxit5mS/UVrVrGa1Abr 2Ue2vmz8VLImDUrEkiRNwaFRZhAPRwOW7lJoxjY49QlNkhREFsr40U3j4OxiYWHPo33q Vkjw== 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=oBkfpySVjMe1DPvQzLS/ky2Vmv3iOuX759ADy7VpeOg=; b=mWoZpte4pjirqbF1PAmjh2U0Ne7bNxf4AQz0TaJN8vonOeRlxUwHvVOQ4iooiRlyz0 OB0AgSZhu3XGcQP9gKWuhqVNxvn55ujXUi6Xn3LDFkQYK8HFaiGh3eIDvSUiTQCBmIx8 lvBs9iU4JKLCjlMzNrxp47Bi1pckeSorRecGDnc2kIRb3RtPeLg9L9jtDpzpiRKfWN+A N8hK6g9Pi5tFa4x0Wv71rvjVABnjfH525NhfOaruT+QJaebFFS7XNiNVOeLE7g6Dvx4e HsnY1yPDbIlBfBMTW83Dw0wqhOqIUFyS252aX0QjjgyimugwLl5SwQ7kIsDG647Senlk pMkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=nGdqitTe; 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 h9si7037022pgp.365.2017.11.22.13.14.17; Wed, 22 Nov 2017 13:14:28 -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=nGdqitTe; 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 S1752151AbdKVVMx (ORCPT + 77 others); Wed, 22 Nov 2017 16:12:53 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:60961 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751842AbdKVVIU (ORCPT ); Wed, 22 Nov 2017 16:08:20 -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=oBkfpySVjMe1DPvQzLS/ky2Vmv3iOuX759ADy7VpeOg=; b=nGdqitTeOo95M1lnXLzMWm4Kl EGVxo7Un2/VgHfv3yggdSGd34aJ15RIGECkCWNB6RuxP7Z1Wdzoo9zpgJhDJNm9ntgfSLVlyB5pVq r2SPPOT1TZQE0W+eymt+r+odfsZc18leNWfiUIEOn9mMim2gYro2jUYjt0PxfQXOpyemMH3mdrZ+f vpSsknVhkqnZ56o2/326IgaqqhB/rmaNgLV76vCSIo67mnqMgUZkXfZHOO8il4y27diEuN3PkzteG Ie+5y7Wibl4iwDLgGBjrEaDDK/Lw/5VEA2/5GJRQ5rRjOiAs5zq8ncYPl78RR327Q5BbI0Am4rZj0 1ggaOWVTQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFn-0007wz-7z; Wed, 22 Nov 2017 21:08:19 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 44/62] xfs: Convert m_perag_tree to XArray Date: Wed, 22 Nov 2017 13:07:21 -0800 Message-Id: <20171122210739.29916-45-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-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 Getting rid of the m_perag_lock lets us also get rid of the call to radix_tree_preload(). This is a relatively naive conversion; we could improve performance over the radix tree implementation by passing around xa_state pointers instead of indices, possibly at the expense of extending rcu_read_lock() periods. Signed-off-by: Matthew Wilcox --- fs/xfs/libxfs/xfs_sb.c | 9 ++++----- fs/xfs/xfs_icache.c | 35 +++++++++-------------------------- fs/xfs/xfs_icache.h | 6 +++--- fs/xfs/xfs_mount.c | 19 ++++--------------- fs/xfs/xfs_mount.h | 3 +-- 5 files changed, 21 insertions(+), 51 deletions(-) diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 9b5aae2bcc0b..811fa57007c9 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -59,7 +59,7 @@ xfs_perag_get( int ref = 0; rcu_read_lock(); - pag = radix_tree_lookup(&mp->m_perag_tree, agno); + pag = xa_load(&mp->m_perag_xa, agno); if (pag) { ASSERT(atomic_read(&pag->pag_ref) >= 0); ref = atomic_inc_return(&pag->pag_ref); @@ -78,14 +78,13 @@ xfs_perag_get_tag( xfs_agnumber_t first, int tag) { + XA_STATE(xas, first); struct xfs_perag *pag; - int found; int ref; rcu_read_lock(); - found = radix_tree_gang_lookup_tag(&mp->m_perag_tree, - (void **)&pag, first, 1, tag); - if (found <= 0) { + pag = xas_find_tag(&mp->m_perag_xa, &xas, ULONG_MAX, tag); + if (!pag) { rcu_read_unlock(); return NULL; } diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index 43005fbe8b1e..f56e500d89e2 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -156,13 +156,10 @@ static void xfs_reclaim_work_queue( struct xfs_mount *mp) { - - rcu_read_lock(); - if (radix_tree_tagged(&mp->m_perag_tree, XFS_ICI_RECLAIM_TAG)) { + if (xa_tagged(&mp->m_perag_xa, XFS_ICI_RECLAIM_TAG)) { queue_delayed_work(mp->m_reclaim_workqueue, &mp->m_reclaim_work, msecs_to_jiffies(xfs_syncd_centisecs / 6 * 10)); } - rcu_read_unlock(); } /* @@ -194,10 +191,7 @@ xfs_perag_set_reclaim_tag( return; /* propagate the reclaim tag up into the perag radix tree */ - spin_lock(&mp->m_perag_lock); - radix_tree_tag_set(&mp->m_perag_tree, pag->pag_agno, - XFS_ICI_RECLAIM_TAG); - spin_unlock(&mp->m_perag_lock); + xa_set_tag(&mp->m_perag_xa, pag->pag_agno, XFS_ICI_RECLAIM_TAG); /* schedule periodic background inode reclaim */ xfs_reclaim_work_queue(mp); @@ -216,10 +210,7 @@ xfs_perag_clear_reclaim_tag( return; /* clear the reclaim tag from the perag radix tree */ - spin_lock(&mp->m_perag_lock); - radix_tree_tag_clear(&mp->m_perag_tree, pag->pag_agno, - XFS_ICI_RECLAIM_TAG); - spin_unlock(&mp->m_perag_lock); + xa_clear_tag(&mp->m_perag_xa, pag->pag_agno, XFS_ICI_RECLAIM_TAG); trace_xfs_perag_clear_reclaim(mp, pag->pag_agno, -1, _RET_IP_); } @@ -847,12 +838,10 @@ void xfs_queue_eofblocks( struct xfs_mount *mp) { - rcu_read_lock(); - if (radix_tree_tagged(&mp->m_perag_tree, XFS_ICI_EOFBLOCKS_TAG)) + if (xa_tagged(&mp->m_perag_xa, XFS_ICI_EOFBLOCKS_TAG)) queue_delayed_work(mp->m_eofblocks_workqueue, &mp->m_eofblocks_work, msecs_to_jiffies(xfs_eofb_secs * 1000)); - rcu_read_unlock(); } void @@ -874,12 +863,10 @@ STATIC void xfs_queue_cowblocks( struct xfs_mount *mp) { - rcu_read_lock(); - if (radix_tree_tagged(&mp->m_perag_tree, XFS_ICI_COWBLOCKS_TAG)) + if (xa_tagged(&mp->m_perag_xa, XFS_ICI_COWBLOCKS_TAG)) queue_delayed_work(mp->m_eofblocks_workqueue, &mp->m_cowblocks_work, msecs_to_jiffies(xfs_cowb_secs * 1000)); - rcu_read_unlock(); } void @@ -1542,7 +1529,7 @@ __xfs_inode_set_eofblocks_tag( void (*execute)(struct xfs_mount *mp), void (*set_tp)(struct xfs_mount *mp, xfs_agnumber_t agno, int error, unsigned long caller_ip), - int tag) + xa_tag_t tag) { struct xfs_mount *mp = ip->i_mount; struct xfs_perag *pag; @@ -1566,11 +1553,9 @@ __xfs_inode_set_eofblocks_tag( XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino), tag); if (!tagged) { /* propagate the eofblocks tag up into the perag radix tree */ - spin_lock(&ip->i_mount->m_perag_lock); - radix_tree_tag_set(&ip->i_mount->m_perag_tree, + xa_set_tag(&ip->i_mount->m_perag_xa, XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino), tag); - spin_unlock(&ip->i_mount->m_perag_lock); /* kick off background trimming */ execute(ip->i_mount); @@ -1597,7 +1582,7 @@ __xfs_inode_clear_eofblocks_tag( xfs_inode_t *ip, void (*clear_tp)(struct xfs_mount *mp, xfs_agnumber_t agno, int error, unsigned long caller_ip), - int tag) + xa_tag_t tag) { struct xfs_mount *mp = ip->i_mount; struct xfs_perag *pag; @@ -1613,11 +1598,9 @@ __xfs_inode_clear_eofblocks_tag( XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino), tag); if (!radix_tree_tagged(&pag->pag_ici_root, tag)) { /* clear the eofblocks tag from the perag radix tree */ - spin_lock(&ip->i_mount->m_perag_lock); - radix_tree_tag_clear(&ip->i_mount->m_perag_tree, + xa_clear_tag(&ip->i_mount->m_perag_xa, XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino), tag); - spin_unlock(&ip->i_mount->m_perag_lock); clear_tp(ip->i_mount, pag->pag_agno, -1, _RET_IP_); } diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h index bff4d85e5498..bd04d5adadfe 100644 --- a/fs/xfs/xfs_icache.h +++ b/fs/xfs/xfs_icache.h @@ -37,9 +37,9 @@ struct xfs_eofblocks { */ #define XFS_ICI_NO_TAG (-1) /* special flag for an untagged lookup in xfs_inode_ag_iterator */ -#define XFS_ICI_RECLAIM_TAG 0 /* inode is to be reclaimed */ -#define XFS_ICI_EOFBLOCKS_TAG 1 /* inode has blocks beyond EOF */ -#define XFS_ICI_COWBLOCKS_TAG 2 /* inode can have cow blocks to gc */ +#define XFS_ICI_RECLAIM_TAG XA_TAG_0 /* inode is to be reclaimed */ +#define XFS_ICI_EOFBLOCKS_TAG XA_TAG_1 /* inode has blocks beyond EOF */ +#define XFS_ICI_COWBLOCKS_TAG XA_TAG_2 /* inode can have cow blocks to gc */ /* * Flags for xfs_iget() diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index c879b517cc94..ae90f6f8fa5c 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -156,9 +156,7 @@ xfs_free_perag( struct xfs_perag *pag; for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { - spin_lock(&mp->m_perag_lock); - pag = radix_tree_delete(&mp->m_perag_tree, agno); - spin_unlock(&mp->m_perag_lock); + pag = xa_store(&mp->m_perag_xa, agno, NULL, GFP_NOWAIT); ASSERT(pag); ASSERT(atomic_read(&pag->pag_ref) == 0); xfs_buf_hash_destroy(pag); @@ -219,19 +217,11 @@ xfs_initialize_perag( goto out_free_pag; init_waitqueue_head(&pag->pagb_wait); - if (radix_tree_preload(GFP_NOFS)) - goto out_hash_destroy; - - spin_lock(&mp->m_perag_lock); - if (radix_tree_insert(&mp->m_perag_tree, index, pag)) { + if (xa_store(&mp->m_perag_xa, index, pag, GFP_NOFS)) { BUG(); - spin_unlock(&mp->m_perag_lock); - radix_tree_preload_end(); error = -EEXIST; goto out_hash_destroy; } - spin_unlock(&mp->m_perag_lock); - radix_tree_preload_end(); /* first new pag is fully initialized */ if (first_initialised == NULLAGNUMBER) first_initialised = index; @@ -252,7 +242,7 @@ xfs_initialize_perag( out_unwind_new_pags: /* unwind any prior newly initialized pags */ for (index = first_initialised; index < agcount; index++) { - pag = radix_tree_delete(&mp->m_perag_tree, index); + pag = xa_store(&mp->m_perag_xa, index, NULL, GFP_NOWAIT); if (!pag) break; xfs_buf_hash_destroy(pag); @@ -816,8 +806,7 @@ xfs_mountfs( /* * Allocate and initialize the per-ag data. */ - spin_lock_init(&mp->m_perag_lock); - INIT_RADIX_TREE(&mp->m_perag_tree, GFP_ATOMIC); + xa_init(&mp->m_perag_xa); error = xfs_initialize_perag(mp, sbp->sb_agcount, &mp->m_maxagi); if (error) { xfs_warn(mp, "Failed per-ag init: %d", error); diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index e0792d036be2..6e5ad7b26f46 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -134,8 +134,7 @@ typedef struct xfs_mount { xfs_extlen_t m_ag_prealloc_blocks; /* reserved ag blocks */ uint m_alloc_set_aside; /* space we can't use */ uint m_ag_max_usable; /* max space per AG */ - struct radix_tree_root m_perag_tree; /* per-ag accounting info */ - spinlock_t m_perag_lock; /* lock for m_perag_tree */ + struct xarray m_perag_xa; /* per-ag accounting info */ struct mutex m_growlock; /* growfs mutex */ int m_fixedfsid[2]; /* unchanged for life of FS */ uint m_dmevmask; /* DMI events for this FS */ -- 2.15.0 From 1584871034421347432@xxx Thu Nov 23 15:26:40 +0000 2017 X-GM-THRID: 1584605754205416111 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread