Received: by 10.223.164.202 with SMTP id h10csp667477wrb; Wed, 22 Nov 2017 13:22:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMYJAU0LTrOpynTW2tmPHdJGoLq5fVZUJbEE6nbVp6LUsawNv8dBSwQKWfVhWCLCM/+wpeTv X-Received: by 10.101.80.132 with SMTP id r4mr21667873pgp.428.1511385724740; Wed, 22 Nov 2017 13:22:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385724; cv=none; d=google.com; s=arc-20160816; b=1CBk/rtaOFgRieaRbWavCLysp9zCldDMZNuDUrPLp/c9O+kNoCS0lMs9oqaG4kl7eX mUWztP0w+vK0ppKfABtMFhq3RJWmFLVByK53zcljkCuvejulr1dLH2JLFDhefF3BcpfD glcuT3ke0z+UMpp7mwdezQwUL23p8D7SX6O1a83Lz3maiCcgTQOYpKtuhFgo+TR2va34 zL9pEeyw1wInqukXT9fc+a0JJzg0eXGPDb7emuwPyHD8RYayS/tQfojj/SQVNvYjqDC/ gOiJxALD0vbC5jzjzZ8ltFrXVsQef6mZRkarU6YsR3MwSkYKa9aKYg1OzpKKfqMlwD+a tizA== 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=WKb6cY7oXxOJL1SFLi/2igLC1fFjcRbSupwEBMzuu/g=; b=dC3NrBpQphNKIcln2XTYrli51L8/fw7mAwdWV6Ko1FTIZIamYtkIjwQjykIFcHLjK8 +mmCFJgXMyGrqMZuwYazX3aQid572YoVZiABm8kyNEkTCbu4X25AOVcJXlQEp6j+PEoe FzPK5dlkU2SvJi2M8CSJkTDFDTnqFuSWX1X4+vvYR93WQOmQLKtB0dueDDWZKHw6Ee3W R807tMr2upWYLfkoV1Q6QqXfGyXA9mxgoDGhNnRFHzSwlZFH37/VpczPBgYsBIbW6wcK SPotE88qOek0/+PWLnHXifa1+60e6B+ZfbKOk6aiCfuTTX2O5o1yvacHPKm84GA/NFdq Mbmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=hFYQ1hu3; 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 b5si14578175ple.716.2017.11.22.13.21.53; Wed, 22 Nov 2017 13:22:04 -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=hFYQ1hu3; 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 S1752228AbdKVVUf (ORCPT + 77 others); Wed, 22 Nov 2017 16:20:35 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:35105 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751755AbdKVVIS (ORCPT ); Wed, 22 Nov 2017 16:08:18 -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=WKb6cY7oXxOJL1SFLi/2igLC1fFjcRbSupwEBMzuu/g=; b=hFYQ1hu3mDy+DOEJPixelKn9l aTJkWcdQxHlDzDqQ4xhQuRTHgpd8xRdkuu+gMR9H/6Qiskx+LGorSx4gUS7bOZFFjM/2ISwi9Cdtn p5kAZbTqnNO1xd4G4O9xyzjMeIM/cy7BxKPRafJc3YdYUxs/1XrZkr729fVtj3I2J+IZNWu1x7ctC BIWO00OjCETRkTTK0HxjBoLYYq4cl6HqSMXvxpgd+SwZTEeN7OaAizhUswpgcg1WcjpgGyM/iPW2g JAZt/xumW2ucn8i/d5QxTM6xTqlHcjS1PeLTGwzwvsDSXmbfpUZP/6ovHv6cam7+nimKvfszeCNeH FaGseRfeQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFl-0007uB-LC; Wed, 22 Nov 2017 21:08:17 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 25/62] xarray: Add xa_init Date: Wed, 22 Nov 2017 13:07:02 -0800 Message-Id: <20171122210739.29916-26-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-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 For initialising xarrays in code rather than data. Signed-off-by: Matthew Wilcox --- include/linux/xarray.h | 13 +++++++++++++ lib/xarray.c | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/linux/xarray.h b/include/linux/xarray.h index 08ddad60a43d..19a3974fdc4f 100644 --- a/include/linux/xarray.h +++ b/include/linux/xarray.h @@ -81,6 +81,19 @@ struct xarray { #define DEFINE_XARRAY(name) struct xarray name = XARRAY_INIT(name) +void __xa_init(struct xarray *, gfp_t flags); + +/** + * xa_init() - Initialise an empty XArray. + * @xa: XArray. + * + * An empty XArray is full of NULL entries. + */ +static inline void xa_init(struct xarray *xa) +{ + __xa_init(xa, 0); +} + void *xa_load(struct xarray *, unsigned long index); void *xa_store(struct xarray *, unsigned long index, void *entry, gfp_t); void *xa_cmpxchg(struct xarray *, unsigned long index, diff --git a/lib/xarray.c b/lib/xarray.c index 5409048e8b44..59f45c07988f 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -868,6 +868,21 @@ void *xas_find(struct xarray *xa, struct xa_state *xas, unsigned long max) } EXPORT_SYMBOL_GPL(xas_find); +/** + * __xa_init() - Initialise an empty XArray + * @xa: XArray. + * @flags: XA_FLAG_ values + * + * An empty XArray is full of NULL pointers. + */ +void __xa_init(struct xarray *xa, gfp_t flags) +{ + spin_lock_init(&xa->xa_lock); + xa->xa_flags = flags; + xa->xa_head = NULL; +} +EXPORT_SYMBOL(__xa_init); + /** * xa_load() - Load an entry from an XArray. * @xa: XArray. -- 2.15.0 From 1584803716736328415@xxx Wed Nov 22 21:36:41 +0000 2017 X-GM-THRID: 1584803716736328415 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread