linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 2/8] xarray: Provide xas_erase() helper
Date: Tue, 17 Mar 2020 08:28:50 -0700	[thread overview]
Message-ID: <20200317152850.GC22433@bombadil.infradead.org> (raw)
In-Reply-To: <20200204142514.15826-3-jack@suse.cz>

On Tue, Feb 04, 2020 at 03:25:08PM +0100, Jan Kara wrote:
> +void *xas_erase(struct xa_state *xas)
> +{
> +	void *entry;
> +
> +	entry = xas_store(xas, NULL);
> +	xas_init_marks(xas);
> +
> +	return entry;
> +}
> +EXPORT_SYMBOL(xas_erase);

I didn't have a test case to show this, but ...

+static noinline void check_multi_store_4(struct xarray *xa)
+{
+       XA_BUG_ON(xa, xa_marked(xa, XA_MARK_0));
+       XA_BUG_ON(xa, !xa_empty(xa));
+
+       xa_store_index(xa, 0, GFP_KERNEL);
+       xa_store_index(xa, 2, GFP_KERNEL);
+       xa_set_mark(xa, 0, XA_MARK_0);
+       xa_set_mark(xa, 2, XA_MARK_0);
+
+       xa_store_order(xa, 0, 2, NULL, GFP_KERNEL);
+       XA_BUG_ON(xa, xa_marked(xa, XA_MARK_0));
+       xa_destroy(xa);
+}

shows a problem.  Because we delete all the entries in the tree,
xas_delete_node() sets the xas->xa_node to XAS_BOUNDS.  This fixes it:

@@ -492,7 +492,6 @@ static void xas_delete_node(struct xa_state *xas)
 
                if (!parent) {
                        xas->xa->xa_head = NULL;
-                       xas->xa_node = XAS_BOUNDS;
                        return;
                }
 
(it leaves xas->xa_node set to NULL, which makes the above work correctly
because NULL is used to mean the one element at index 0 of the array)

Now I'm wondering if it's going to break anything, though.  The test suite
runs successfully, but it can't be exhaustive.


  parent reply	other threads:[~2020-03-17 15:28 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04 14:25 [PATCH 0/8] mm: Speedup page cache truncation Jan Kara
2020-02-04 14:25 ` [PATCH 1/8] xarray: Fix premature termination of xas_for_each_marked() Jan Kara
2020-03-12 21:45   ` Matthew Wilcox
2020-03-16  9:16     ` Jan Kara
2020-02-04 14:25 ` [PATCH 2/8] xarray: Provide xas_erase() helper Jan Kara
2020-03-14 19:54   ` Matthew Wilcox
2020-03-16  9:21     ` Jan Kara
2020-03-17 15:28   ` Matthew Wilcox [this message]
2020-04-15 16:12     ` Jan Kara
2020-02-04 14:25 ` [PATCH 3/8] xarray: Explicitely set XA_FREE_MARK in __xa_cmpxchg() Jan Kara
2020-02-05 18:45   ` Jason Gunthorpe
2020-02-06  8:03     ` Jan Kara
2020-03-17 15:12   ` Matthew Wilcox
2020-02-04 14:25 ` [PATCH 4/8] mm: Use xas_erase() in page_cache_delete_batch() Jan Kara
2020-02-04 14:25 ` [PATCH 5/8] dax: Use xas_erase() in __dax_invalidate_entry() Jan Kara
2020-02-04 14:25 ` [PATCH 6/8] idr: Use xas_erase() in ida_destroy() Jan Kara
2020-02-04 14:25 ` [PATCH 7/8] mm: Use xas_erase() in collapse_file() Jan Kara
2020-02-04 14:25 ` [PATCH 8/8] xarray: Don't clear marks in xas_store() Jan Kara
2020-02-05 18:43   ` Jason Gunthorpe
2020-02-05 21:59     ` Matthew Wilcox
2020-02-06 13:49       ` Jason Gunthorpe
2020-02-06 14:36         ` Jan Kara
2020-02-06 14:49           ` Jason Gunthorpe
2020-02-05 22:19   ` John Hubbard
2020-02-06  2:21     ` Matthew Wilcox
2020-02-06  3:48       ` John Hubbard
2020-02-06  4:28         ` Matthew Wilcox
2020-02-06  4:37           ` John Hubbard
2020-02-06  8:36           ` Jan Kara
2020-02-06  8:04     ` Jan Kara
2020-02-06 14:40 ` [PATCH 0/8] mm: Speedup page cache truncation David Sterba
2020-02-18  9:25 ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200317152850.GC22433@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).