From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Wilcox Subject: [PATCH v11 14/63] xarray: Add xas_create_range Date: Sat, 14 Apr 2018 07:12:27 -0700 Message-ID: <20180414141316.7167-15-willy@infradead.org> References: <20180414141316.7167-1-willy@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; 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=WP770Xy2T7I4XLn3dGxGYkgt4g3m6R4NZXkw/Ei4UoM=; b=NXnlVCy/ED9fL6J7OYFXi+LfB4 SXlBHAa88YH/Fj082L7zJRHrdH4d0NyolBBV5+tNn5nAJkymbgIrohNoNXqjM0rnD8EOlbcpOwUOq 05zStcy9tO0SZ0K1wMC7kwV1XwVHN1+Kh037CC3KcM2qSPwspwinNfsO8CVY5S+69ZMI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; 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=WP770Xy2T7I4XLn3dGxGYkgt4g3m6R4NZXkw/Ei4UoM=; b=JOhYf6vtC60MEZBXQL0KGy30xd U6WXdiE2xeZfgXVnyHM28MVnYrfFmW23QbzYDNpCk4qohFIDj8sAFYCkc6P59loyRoDE8x27PDJ8D J2Ol9WZ16It5q2vjUS6NsKR4Kj6MOtEGcQ2J2LUHYQ0+9FepltJLyOvjh6Nn6atTPsk4=; 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=WP770Xy2T7I4XLn3dGxGYkgt4g3m6R4NZXkw/Ei4UoM=; b=D7Ly6nmsmuzv5xvzKq4blYm+/ rozQxsq45GTZ3tXWkfB9r7aos0/087tW5qH/iU8oI7FAGUfWZyK5sibdgMIwAOOYSCgIqEgkXpFeS SfJlhruonDiADQAEceuR0CbzS8c56t1btCc//1cr/bK5Jzn04+ZhZQ2zGXfcL/zptJ/QJyTYp7jWx dzKbVdEb84bXgvf7oMljx++TlxREbeWn9rzAkj+Mc7Hbqk+pU5O1zUAIjUNKbR8uZ92Jq4+Fw3zcg EtfDmuaGaXUEkkGw6yQFl8QYCLTFjG0ckf7OVBQ4szevq8k7eQEswYYVLSfEzEsYBTiJDD9EtvgJj 0Cf5B7umQ==; In-Reply-To: <20180414141316.7167-1-willy@infradead.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: linux-nilfs@vger.kernel.org, Jan Kara , Jeff Layton , Matthew Wilcox , James Simmons , Jaegeuk Kim , Andreas Dilger , Nicholas Piggin , linux-f2fs-devel@lists.sourceforge.net, Oleg Drokin , Ryusuke Konishi , Lukas Czerner , Ross Zwisler , Christoph Hellwig , Goldwyn Rodrigues , Mike Kravetz 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 6f764705382b..b158433b1924 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 7574bafbc6ff..653ab0555673 100644 --- a/lib/xarray.c +++ b/lib/xarray.c @@ -626,6 +626,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.17.0 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot