From patchwork Thu Apr 14 14:16:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 8837211 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 34CA3C0553 for ; Thu, 14 Apr 2016 14:18:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5BC9E2010E for ; Thu, 14 Apr 2016 14:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6AC9920274 for ; Thu, 14 Apr 2016 14:18:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932294AbcDNORw (ORCPT ); Thu, 14 Apr 2016 10:17:52 -0400 Received: from mga14.intel.com ([192.55.52.115]:31796 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755469AbcDNORu (ORCPT ); Thu, 14 Apr 2016 10:17:50 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 14 Apr 2016 07:17:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,485,1455004800"; d="scan'208";a="85155963" Received: from unknown (HELO thog.int.wil.cx) ([10.254.90.221]) by fmsmga004.fm.intel.com with SMTP; 14 Apr 2016 07:17:06 -0700 Received: by thog.int.wil.cx (Postfix, from userid 1000) id 80E99603EC; Thu, 14 Apr 2016 10:17:01 -0400 (EDT) From: Matthew Wilcox To: linux-kernel@vger.kernel.org, Andrew Morton Cc: Ross Zwisler , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Konstantin Khlebnikov , Kirill Shutemov , Jan Kara , Neil Brown , Matthew Wilcox Subject: [PATCH v2 22/29] radix-tree: Rewrite radix_tree_tag_clear Date: Thu, 14 Apr 2016 10:16:43 -0400 Message-Id: <1460643410-30196-23-git-send-email-willy@linux.intel.com> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1460643410-30196-1-git-send-email-willy@linux.intel.com> References: <1460643410-30196-1-git-send-email-willy@linux.intel.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ross Zwisler Use the new multi-order support functions to rewrite radix_tree_tag_clear() Signed-off-by: Ross Zwisler Signed-off-by: Matthew Wilcox --- lib/radix-tree.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/lib/radix-tree.c b/lib/radix-tree.c index 5234a95..ee56562 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -768,44 +768,40 @@ EXPORT_SYMBOL(radix_tree_tag_set); void *radix_tree_tag_clear(struct radix_tree_root *root, unsigned long index, unsigned int tag) { - struct radix_tree_node *node = NULL; - struct radix_tree_node *slot = NULL; - unsigned int height, shift; + struct radix_tree_node *node, *parent; + unsigned long maxindex; + unsigned int shift; int uninitialized_var(offset); - height = root->height; - if (index > radix_tree_maxindex(height)) - goto out; - - shift = height * RADIX_TREE_MAP_SHIFT; - slot = root->rnode; + shift = radix_tree_load_root(root, &node, &maxindex); + if (index > maxindex) + return NULL; - while (shift) { - if (slot == NULL) - goto out; - if (!radix_tree_is_indirect_ptr(slot)) - break; - slot = indirect_to_ptr(slot); + parent = NULL; + while (radix_tree_is_indirect_ptr(node)) { shift -= RADIX_TREE_MAP_SHIFT; offset = (index >> shift) & RADIX_TREE_MAP_MASK; - node = slot; - slot = slot->slots[offset]; + + parent = indirect_to_ptr(node); + offset = radix_tree_descend(parent, &node, offset); } - if (slot == NULL) + if (node == NULL) goto out; - while (node) { - if (!tag_get(node, tag, offset)) + index >>= shift; + + while (parent) { + if (!tag_get(parent, tag, offset)) goto out; - tag_clear(node, tag, offset); - if (any_tag_set(node, tag)) + tag_clear(parent, tag, offset); + if (any_tag_set(parent, tag)) goto out; index >>= RADIX_TREE_MAP_SHIFT; offset = index & RADIX_TREE_MAP_MASK; - node = node->parent; + parent = parent->parent; } /* clear the root's tag bit */ @@ -813,7 +809,7 @@ void *radix_tree_tag_clear(struct radix_tree_root *root, root_tag_clear(root, tag); out: - return slot; + return node; } EXPORT_SYMBOL(radix_tree_tag_clear);