Received: by 10.213.65.68 with SMTP id h4csp359008imn; Tue, 13 Mar 2018 06:43:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELudpvuX97F0O0KVzR8CTjLHlS8Nhf6h4Pj50LVSgObuDhwT9wauwiXOa2v+68yyacH8V/M0 X-Received: by 10.98.50.130 with SMTP id y124mr654847pfy.147.1520948608910; Tue, 13 Mar 2018 06:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520948608; cv=none; d=google.com; s=arc-20160816; b=NwE2QoI+DZKp06vEzjBshshAwNCdrdSNbiRRo6fZ4C3ckCeNDSHa/iLP/VFVkuIDZv Vf9cVAoS0i7SDkoHCT59BSTC9k7In88oO8dScN1+erUoxFIFil15w6sYRpOdRe+ALwNl dFA/sDYC62vqdec/QaQvLW+Dc+69Tp0P4ZAqvSNHekDZ6bEhS6RZWrO1f3Hfs+kUy10y /oImMI6wivLJE5nigD3Zrpv/lkWlsbl5ktX/UNt4zqnb7B3m7uLEit+BNwynHMM4rzPn EVw/rC58u8QFhHrUOn7xIk4+UQNyLJgn+mzzdee33ylfkjFlWYkBaX3TXQ9AU3hPftxP qOsA== 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=eIOjS/FGXFZExx9wX90eoCxeI3BeZDrsj4RJrsRx2zmjZSIY7yFMurJJz0ZZXKnjNr FV3MtF1WOoVThWkUGrBmzrKSbTnjdAx5rf+3OP6v9j45ZQpAEFA/pPdtvnV285r19fMK XIr6BYDlSvhOpuqrCCxt95k6kCGmVI9CMFuR84Quf3HMx9u1bsxzG5ds09vuu4N8GsQY l/CkFcPuZBbETlcgKlYR0gbpd1ArGdyoCMWrvyfBCCod0XdBaO8bAahDMighFqJek3/h QBh3spqwn5giXeq4aj8xja1I7SKV66J0pxnxEzh78efFO2fEuu4FMQvRVwUIL+TKn89C z7hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=rxENiFlz; 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 t67si124333pfi.285.2018.03.13.06.43.13; Tue, 13 Mar 2018 06:43:28 -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=rxENiFlz; 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 S932435AbeCMN06 (ORCPT + 99 others); Tue, 13 Mar 2018 09:26:58 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35160 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752755AbeCMN0v (ORCPT ); Tue, 13 Mar 2018 09:26:51 -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=5DGecaPqz+MyuZZNxvRv/n4mcETcUg6v7sGnAIwI8ng=; b=rxENiFlzqBWlS9LOkSkE/+FBX k1xu8tCIROhPKx/ZWzP6Cxo6POGMcLuX/6aFqAtN6E1yDlz4GkXxX3kIn9KmDex7qAG5yJmSXTYAs crqA9wvWkbnb2F9z/PCOPiSFvsfR1PEHHwIU4GtXm4ZpdLvt6n9BYmPqc5/Y233HNBf22Nii09vjy IQeIbFG/gLcHbMsIUmbrz8mNVnUx44uVaZINvwyhOkPoh7foxSNiCC8GvW0Q5zQ17zrTBYeqAeHZv csaC8e1C8tF2pVC88+Yk6gtWyRXv5vzXsVUTDDfwqZLbPhwK3v5C3A0i1tsanq1vJBn7EGsmmA4PF 63PAVmuow==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1evjx4-0004d6-4f; Tue, 13 Mar 2018 13:26:50 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ryusuke Konishi , linux-nilfs@vger.kernel.org Subject: [PATCH v9 22/61] xarray: Add xas_create_range Date: Tue, 13 Mar 2018 06:26:00 -0700 Message-Id: <20180313132639.17387-23-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313132639.17387-1-willy@infradead.org> References: <20180313132639.17387-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