Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4234356imm; Mon, 11 Jun 2018 09:02:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI0JoAvTLDWZw2+xchLudJ1nnRyb4/d5SSLUoVKU29dgOMr0FyXVNK60i7UFy/jLb4BtRYa X-Received: by 2002:a63:7b07:: with SMTP id w7-v6mr14776235pgc.199.1528732924476; Mon, 11 Jun 2018 09:02:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528732924; cv=none; d=google.com; s=arc-20160816; b=zCkmxL45EnASz2JdOCJtF4FHjZXK4LqvNC67V1KNmAron/xMceOcDtw/01/GUiA93X sQdinjJfW01fybb3xcePs1PIheOpFQ9WJspIOWlNn1zKUe7RglNyuEza+G9NIw9H9Lxi Vc5fr5KP1vc6OXtXUYuy3kSrxugTciUNLRMPsUk+/5BfSra2DvTYaTDJDnp9flhIlYF/ E1Y3OuNilboK1z1YHDzyyxhJIzO2cjZcW2mFqOc7Nm/rM/nmZQoriV9BsmTkW0iTZ62v H0l1qyc9xHOgJHPqeI0CRI9Ocm9QD8Xf2N+sbVbXEP4akClXcavC5+BAjPt6U9+BE6U4 6y2g== 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=rzcF3hO6XLxL1/X+Qfq4B5Sb1mRT7xWTj3jwSQZnKAY=; b=v669627K6gBVQaQhR0qJceisKTH1GoAT/g58W+xYex5+PD5i2O5HOBd6j+MQGa1PfR urL88DcgU2LtMrAV0LbjbbIq7obe6R9k0QFppgwykQlMLeB/r59qA8hdN4ny+kgyLP7u FC/srOjg+MYTRk+UvxKQM19HZqqaCvhDvDPU00LMbCYWDjW3uFO3GgqXGNQmWYVJWrNX OCggfcvTXA3m3zr2J4jrG76wbUQGh+oU9TAFQMDGDL3Didq+5yM3iiQNGPh1BisCpfeY X4yhlCrE2/I4xaCW10fNxMNRwjLWBKcteUQMhiyUPDykeshVqRZhuuy+Fr9jnv+JFvq5 Nzsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IlC4BzX2; 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 q3-v6si10387897plb.238.2018.06.11.09.01.50; Mon, 11 Jun 2018 09:02:04 -0700 (PDT) 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=IlC4BzX2; 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 S933611AbeFKOHF (ORCPT + 99 others); Mon, 11 Jun 2018 10:07:05 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45026 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933480AbeFKOGr (ORCPT ); Mon, 11 Jun 2018 10:06:47 -0400 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=rzcF3hO6XLxL1/X+Qfq4B5Sb1mRT7xWTj3jwSQZnKAY=; b=IlC4BzX2BUIPttCfGDa0MuHBd sD223X+RrLG5ghncJf7hAIf7tuAt7/O2sOzB8gok99ra8ROxmbf5/fvjMcQ5RwtSZFxso8L00YhOW EcBlBOZinbt4WRWaXOcFGBq+bahGYwHXWEd7jkqGIt8TS8YqTAP7Fg/r7E8keDBeqpWE5GlecKGWd fgfQM4S16OhVwiqe7tK/OgwgwHbWVsGCy9eTufPD/7UdLXYpj2siBjdyJY9bP5WHxIy6ORMFidiPm R2MoR44s+FogOy47TC8m0Twe4mucgilfBnd7rr0SUhWvVWnw1IqvvrPONn9t+sgUZtl9b18YwPisd G7j8SeYvw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSNT4-0004cv-Bs; Mon, 11 Jun 2018 14:06:46 +0000 From: Matthew Wilcox To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Jan Kara , Jeff Layton , Lukas Czerner , Ross Zwisler , Christoph Hellwig , Goldwyn Rodrigues , Nicholas Piggin , Ryusuke Konishi , linux-nilfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v13 17/72] xarray: Add xas_create_range Date: Mon, 11 Jun 2018 07:05:44 -0700 Message-Id: <20180611140639.17215-18-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180611140639.17215-1-willy@infradead.org> References: <20180611140639.17215-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 6a61aab11038..907ecb1d3077 100644 --- a/include/linux/xarray.h +++ b/include/linux/xarray.h @@ -761,6 +761,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 d76db0ff17cf..566c4e233c05 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -638,6 +638,28 @@ static void *xas_create(struct xa_state *xas) return entry; } +/** + * 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 update_node(struct xa_state *xas, struct xa_node *node, int count, int values) { -- 2.17.1