From patchwork Wed Jan 17 20:21:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10170949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D4F760386 for ; Wed, 17 Jan 2018 20:30:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F2AF207A7 for ; Wed, 17 Jan 2018 20:30:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13E6120856; Wed, 17 Jan 2018 20:30:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F713207A7 for ; Wed, 17 Jan 2018 20:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932067AbeAQU3y (ORCPT ); Wed, 17 Jan 2018 15:29:54 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:40935 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753995AbeAQUXD (ORCPT ); Wed, 17 Jan 2018 15:23:03 -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=UT4reEabBwlrAlD/B4VqBTYh03oxqYSFRm+m3GdzRt0=; b=G7iW+sEWrShg9Ka5i7Zrfmt8A wXz2g7Kq/U3+fK+aQ4514AiTjj2AwJ57v3dcl/HcdwjtFLZsjYvTdvSvYvQjeM5QTywBVWuhp2qu8 pd7EVv2fF3FWaJ27gdLLGLOpcGm4iklUzzOUGfBVZx0XW9Pa2+ssbYuTIFF/2IsBFNzhSEPrX1Qtf +BXIqxQ3hiZvHHZSLqeMBzWKfuLlfrdQ14kkNvGJBfc707UV77zMDWXDs5sFMXR8w7qhlZhAqjKdN aILE67S/MdP2OWPyDUjwpDKpnq5XeEYcl9PkPAE50oOMkUCio/a4zfEKoP6xafZJJzzrE2AtUyPxv if8Xdg/qQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1ebuEg-0006I8-9u; Wed, 17 Jan 2018 20:23:02 +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 87/99] btrfs: Convert reada_extents to XArray Date: Wed, 17 Jan 2018 12:21:51 -0800 Message-Id: <20180117202203.19756-88-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-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox Straightforward conversion. Signed-off-by: Matthew Wilcox --- fs/btrfs/reada.c | 32 +++++++++++++++++--------------- fs/btrfs/volumes.c | 2 +- fs/btrfs/volumes.h | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c index ef8e84ff2012..8100f1565250 100644 --- a/fs/btrfs/reada.c +++ b/fs/btrfs/reada.c @@ -438,13 +438,14 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info, continue; } prev_dev = dev; - ret = radix_tree_insert(&dev->reada_extents, index, re); + ret = xa_insert(&dev->reada_extents, index, re, + GFP_NOFS & ~__GFP_DIRECT_RECLAIM); if (ret) { while (--nzones >= 0) { dev = re->zones[nzones]->device; BUG_ON(dev == NULL); /* ignore whether the entry was inserted */ - radix_tree_delete(&dev->reada_extents, index); + xa_erase(&dev->reada_extents, index); } radix_tree_delete(&fs_info->reada_tree, index); spin_unlock(&fs_info->reada_lock); @@ -504,7 +505,7 @@ static void reada_extent_put(struct btrfs_fs_info *fs_info, for (i = 0; i < re->nzones; ++i) { struct reada_zone *zone = re->zones[i]; - radix_tree_delete(&zone->device->reada_extents, index); + xa_erase(&zone->device->reada_extents, index); } spin_unlock(&fs_info->reada_lock); @@ -644,6 +645,7 @@ static int reada_start_machine_dev(struct btrfs_device *dev) int mirror_num = 0; struct extent_buffer *eb = NULL; u64 logical; + unsigned long index; int ret; int i; @@ -660,19 +662,19 @@ static int reada_start_machine_dev(struct btrfs_device *dev) * a contiguous block of extents, we could also coagulate them or use * plugging to speed things up */ - ret = radix_tree_gang_lookup(&dev->reada_extents, (void **)&re, - dev->reada_next >> PAGE_SHIFT, 1); - if (ret == 0 || re->logical > dev->reada_curr_zone->end) { + index = dev->reada_next >> PAGE_SHIFT; + re = xa_find(&dev->reada_extents, &index, ULONG_MAX, XA_PRESENT); + if (!re || re->logical > dev->reada_curr_zone->end) { ret = reada_pick_zone(dev); if (!ret) { spin_unlock(&fs_info->reada_lock); return 0; } - re = NULL; - ret = radix_tree_gang_lookup(&dev->reada_extents, (void **)&re, - dev->reada_next >> PAGE_SHIFT, 1); + index = dev->reada_next >> PAGE_SHIFT; + re = xa_find(&dev->reada_extents, &index, ULONG_MAX, + XA_PRESENT); } - if (ret == 0) { + if (!re) { spin_unlock(&fs_info->reada_lock); return 0; } @@ -828,11 +830,11 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) cnt = 0; index = 0; while (all) { - struct reada_extent *re = NULL; + struct reada_extent *re; - ret = radix_tree_gang_lookup(&device->reada_extents, - (void **)&re, index, 1); - if (ret == 0) + re = xa_find(&device->reada_extents, &index, ULONG_MAX, + XA_PRESENT); + if (!re) break; pr_debug(" re: logical %llu size %u empty %d scheduled %d", re->logical, fs_info->nodesize, @@ -848,7 +850,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) } } pr_cont("\n"); - index = (re->logical >> PAGE_SHIFT) + 1; + index++; if (++cnt > 15) break; } diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8e683799b436..304c2ef4c557 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -248,7 +248,7 @@ static struct btrfs_device *__alloc_device(void) atomic_set(&dev->dev_stats_ccnt, 0); btrfs_device_data_ordered_init(dev); xa_init(&dev->reada_zones); - INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM); + xa_init(&dev->reada_extents); return dev; } diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index aeabe03d3e44..0e0c04e2613c 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -140,7 +140,7 @@ struct btrfs_device { u64 reada_next; struct reada_zone *reada_curr_zone; struct xarray reada_zones; - struct radix_tree_root reada_extents; + struct xarray reada_extents; /* disk I/O failure stats. For detailed description refer to * enum btrfs_dev_stat_values in ioctl.h */