Received: by 10.223.185.116 with SMTP id b49csp4145340wrg; Mon, 19 Feb 2018 12:00:40 -0800 (PST) X-Google-Smtp-Source: AH8x227/W2RL0eOH0UoEHwTOVpP/i3nyQWjLcZQZfi6z8egos1RHwyJ0aN4OfZvUpwo2xbVqn+h0 X-Received: by 10.99.110.133 with SMTP id j127mr13296809pgc.79.1519070440531; Mon, 19 Feb 2018 12:00:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519070440; cv=none; d=google.com; s=arc-20160816; b=D4te0WjTKSpWyJGGuttkF1zcGFUvOzJaYr8BQSnsOJLGQAfLb0cKAVTwkWICxEVDll 7ZrDwsOwI2fGsQa9NpcucsdGQ8WtXVJgwlb7R6Tg7NTfpsiyLCmaV8DUaaSxFKTuaYCY eOPOTiI8Af7+6ivz3uf9nDGyeXoXFAPhlkhuImCJFWUJjipJf5vrlkLxYEHV8ljjt68D ntQZRl/TL/wnmsJaEeU8FV4oGXiZdZFzjfhIJU6z+jiqiIOrsrDDV9EuYbw7VIC+NX+d cANQ6enkkQVKFZYJqDgDvQlKeKoI8SgdDSPug6xyvMmswWZADPRAOHfCIz9KQOWcCj8h MKyQ== 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=5DGecaPqz+MyuZZNxvRv/n4mcETcUg6v7sGnAIwI8ng=; b=LGCnV4byR15D6kvTYLqF3v0wkp+WC2zFUKiDJJhFFW1KqR0SLUqC+heq8OGAH8yHwt TDrp0iIR/Y26jAOpqaGG/2jXqn0KeE7LZlt93QZ2mrWgKRQIKGJeIw3dha9WHhOvvtXC /yM8jD7Qyfab1EpKLBx/AsdbaudaV1TGzRkz9rL78IxzT9U54jfMaPTTPSHEl8m4NlDd h6j5pGvRTPV7Dd+vBSbuTJ8DW7SQ7C/R4zWEG71oObh/ZqbpaWRwXENGClpeqkXiBqE7 HSb12192OYHZd2PFQOZOwtpvxaW1v6G77clEQGqtWo6zA5jADsuqVO8P/nzVf7Po3tdV NWSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=lVeeotZn; 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 v4-v6si1560496plz.143.2018.02.19.12.00.25; Mon, 19 Feb 2018 12:00:40 -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=lVeeotZn; 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 S1753748AbeBST7r (ORCPT + 99 others); Mon, 19 Feb 2018 14:59:47 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:44674 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753698AbeBSTqO (ORCPT ); Mon, 19 Feb 2018 14:46:14 -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=5DGecaPqz+MyuZZNxvRv/n4mcETcUg6v7sGnAIwI8ng=; b=lVeeotZnp3N5idkX+y+6UZE5i gqXzjgYHA95K29mK9zbPoIe3df4McUyFtd6ef9FwUAjfxXNjEskRkbdHjswDxma01nqUGpZ3jcawi NZxsYYZMMTtXQMskJpr/ZP8MD91C5MdOpArv6xzf/BIQ2T4KJjR+sJ7nPHwtxhFY+u/ei4PVvKLP7 qw0kMi0yEXjNaC1nKIBQBZy/mdavSZvOPlWDSOupoYmYxCrk/z1TefbnYhdiDvZaPspkdljd2xKO6 tyNPH34BduFg1Z5eV92fnqCzUwIZFktRZNFZK51Ld+2b6RQDLkx/GSo1HKGvvSSpT3sYlCDMVsDJp kOKJPrmqA==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1enrO9-0001nF-3P; Mon, 19 Feb 2018 19:46:13 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v7 23/61] xarray: Add xas_create_range Date: Mon, 19 Feb 2018 11:45:18 -0800 Message-Id: <20180219194556.6575-24-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180219194556.6575-1-willy@infradead.org> References: <20180219194556.6575-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 hopefully temporary function is useful for users who have not yet been converted to multi-index entries. Signed-off-by: Matthew Wilcox --- include/linux/xarray.h | 2 ++ lib/xarray.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/linux/xarray.h b/include/linux/xarray.h index c8a0ddc1b3df..387be18d05ba 100644 --- a/include/linux/xarray.h +++ b/include/linux/xarray.h @@ -744,6 +744,8 @@ void xas_init_tags(const struct xa_state *); bool xas_nomem(struct xa_state *, gfp_t); void xas_pause(struct xa_state *); +void xas_create_range(struct xa_state *, unsigned long max); + /** * xas_reload() - Refetch an entry from the xarray. * @xas: XArray operation state. diff --git a/lib/xarray.c b/lib/xarray.c index 7cf195b6e740..1d94ecc2dca3 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -612,6 +612,28 @@ void *xas_create(struct xa_state *xas) } EXPORT_SYMBOL_GPL(xas_create); +/** + * xas_create_range() - Ensure that stores to this range will succeed + * @xas: XArray operation state. + * @max: The highest index to create a slot for. + * + * Creates all of the slots in the range between the current position of + * @xas and @max. This is for the benefit of users who have not yet been + * converted to multi-index entries. + * + * The implementation is naive. + */ +void xas_create_range(struct xa_state *xas, unsigned long max) +{ + XA_STATE(tmp, xas->xa, xas->xa_index); + + do { + xas_create(&tmp); + xas_set(&tmp, tmp.xa_index + XA_CHUNK_SIZE); + } while (tmp.xa_index < max); +} +EXPORT_SYMBOL_GPL(xas_create_range); + static void store_siblings(struct xa_state *xas, void *entry, void *curr, int *countp, int *valuesp) { -- 2.16.1