Re: [PATCH 5/9] XArray: entry in last level is not expected to be a node

From: Wei Yang
Date: Sun Apr 05 2020 - 21:25:10 EST


On Mon, Mar 30, 2020 at 05:48:42AM -0700, Matthew Wilcox wrote:
>On Mon, Mar 30, 2020 at 12:36:39PM +0000, Wei Yang wrote:
>> If an entry is at the last level, whose parent's shift is 0, it is not
>> expected to be a node. We can just leverage the xa_is_node() check to
>> break the loop instead of check shift additionally.
>
>I know you didn't run the test suite after making this change.

Well, I got your point finally. From commit 76b4e5299565 ('XArray: Permit
storing 2-byte-aligned pointers'), xa_is_node() will not be *ACURATE*. Those
2-byte align pointers will be treated as node too.

Well, I found another thing, but not sure whether you have fixed this or not.

If applying following change

@@ -1461,6 +1461,11 @@ static void check_align_1(struct xarray *xa, char *name)
GFP_KERNEL) != 0);
XA_BUG_ON(xa, id != i);
}
+ XA_STATE_ORDER(xas, xa, 0, 0);
+ entry = xas_find_conflict(&xas);
xa_for_each(xa, index, entry)
XA_BUG_ON(xa, xa_is_err(entry));
xa_destroy(xa);

We trigger an error message. The reason is the same. And we can fix this with
the same approach in xas_find_conflict().

If you think this is the proper way, I would add a patch for this.

--
Wei Yang
Help you, Help me