aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xarray.c
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2019-02-21 17:54:44 -0500
committerMatthew Wilcox <willy@infradead.org>2019-02-21 17:54:44 -0500
commit4a5c8d898948d1ac876522cdd62f07a78104bfe9 (patch)
treef7b60e242dc970b9f4c6524f6882a4eb9261c388 /lib/xarray.c
parent2fbe967b3eb7466f679307b38564b8271c093241 (diff)
XArray: Fix xa_reserve for 2-byte aligned entries
If we reserve index 0, the next entry to be stored there might be 2-byte aligned. That means we have to create the root xa_node at the time of reserving the initial entry. Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'lib/xarray.c')
-rw-r--r--lib/xarray.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/xarray.c b/lib/xarray.c
index 2cc3798672f7..6be3acbb861f 100644
--- a/lib/xarray.c
+++ b/lib/xarray.c
@@ -767,10 +767,12 @@ void *xas_store(struct xa_state *xas, void *entry)
767 void *first, *next; 767 void *first, *next;
768 bool value = xa_is_value(entry); 768 bool value = xa_is_value(entry);
769 769
770 if (entry) 770 if (entry) {
771 first = xas_create(xas, !xa_is_node(entry)); 771 bool allow_root = !xa_is_node(entry) && !xa_is_zero(entry);
772 else 772 first = xas_create(xas, allow_root);
773 } else {
773 first = xas_load(xas); 774 first = xas_load(xas);
775 }
774 776
775 if (xas_invalid(xas)) 777 if (xas_invalid(xas))
776 return first; 778 return first;