From patchwork Mon Jun 11 14:05:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10458067 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 7B7E7601A0 for ; Mon, 11 Jun 2018 14:13:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D9C9284FF for ; Mon, 11 Jun 2018 14:13:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33A55284C8; Mon, 11 Jun 2018 14:13:41 +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=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D99E28726 for ; Mon, 11 Jun 2018 14:12:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83B8E6B02D1; Mon, 11 Jun 2018 10:08:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 76C926B02D3; Mon, 11 Jun 2018 10:08:26 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 636716B02D4; Mon, 11 Jun 2018 10:08:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id 1A6AD6B02D1 for ; Mon, 11 Jun 2018 10:08:26 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id w6-v6so12186115plp.14 for ; Mon, 11 Jun 2018 07:08:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=rzcF3hO6XLxL1/X+Qfq4B5Sb1mRT7xWTj3jwSQZnKAY=; b=iwjmifvK6CoDlaPhcVPC/fRpSpacu0oq7gCNPBkHjqFlEn3D6+zc7HwSw7vMZPK4JP JxALlhTQ1mRKSFGB1o/hgsGJGYQIobjyDmWUJHe9VjJ5ceh0ild6/8BksOeuZxI0UNlA 2BIksP3PxnqxPhinAjHtfmcmMQEs6WTa6HD134GpKw11TXYPhGwAAtWsHaUecXxsv3cY HNvI24AVUNn+SCOsANvOtsoU/JGucEJozvhEoIG6I9fUmWvzXHYkIcJbcQXaHIo5mLn6 W27gYzhQhGmTD/w2NwNnHg+QL/Lxczs87jtRFnTR4APBdcxMyLnJvS/f2mUWMInhYDol dhEg== X-Gm-Message-State: APt69E0X9NrM9xEW8z9tlZ/OefoX6/udIwdtt8lWA4WJxiUyBiF+cWVx m6zXXurucZFDjrQfkyD0sO7fIVig5JTkN8Rxdd9cG3kIgBOptiKzthPx0U+1iMj53g8LfxFMIdz my/RBM2udTTRIgu0zPp/ZdausrZpssTvW4gAmvBfQdkvfEQUZElaXpHLp+aagU4hNLA== X-Received: by 2002:a17:902:b946:: with SMTP id h6-v6mr18350971pls.1.1528726105794; Mon, 11 Jun 2018 07:08:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIl7sEmLW2Vcm4+UlPSSSWmlVsurmSaF9qchh1NLgN56N8UWlidrGw7jKgSXVTYAJr3UJk8 X-Received: by 2002:a17:902:b946:: with SMTP id h6-v6mr18344238pls.1.1528726007159; Mon, 11 Jun 2018 07:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528726007; cv=none; d=google.com; s=arc-20160816; b=vBNnq17gUUOxlNZ3KU4TLf+Jp6ExklUeIyWoZHcE6kVmcHLBEi7qintILwOM62i5En Yxpd4dpHw3GjxZGH4ESmDxMX+FCipIHzb1niBe146s0SpDryf7bcQ+ywQLp8yJwv5EzA MVJ+X8yCFSkfAYBjNbz2rDU8FD7gY6iuFmyLs8z5rcZyba52kWf/weppR1mPGn2FYHN1 xPfSWaL5zheesD805+Rhf/KgoTo9fh+VTf9yzmiWgxmFKv2dFI+ZJ4nfyFbe21f0Oa1M DW2+dkagBXgieEsPgNNy6F8VSpAnDMUYOOIfp9HOxVUW5lYC+2AH7RGpP8oS1WUmdZtX TONA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=rzcF3hO6XLxL1/X+Qfq4B5Sb1mRT7xWTj3jwSQZnKAY=; b=MHbT4dloKTPfTzVwnkXcUwakNb/0E8UxLF/TXxW2rGiiP8DEztXmgWHEe5fadx6Xe/ fA1y/9XstU52ePJDkssU9E52ccU5d2yXxfhBcyE/Fb+xptlHCGsvWQHPP5nUXfteExRf dZx6RXsQr4keVhwFNZYSLzDoBu5u29BFIcvWjvGO3tSmgXWi7nQ2Mz2gl+zvwzss8+pd eKbSnx16fxAXxp/zpnOnEKXhZ6YdTMHsy68RenF3akYobuLNgSch0+LA2SiPvfgVRPtN jOjJE59vaE1zNxrMg8qBtD5ZpR38/o2mIpNvpvQELF1doVhKg/9Awq2PhZ1SDOGQ9ECe 66lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=IlC4BzX2; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id l14-v6si35132647pgu.415.2018.06.11.07.06.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 07:06:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=IlC4BzX2; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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) {