]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
XArray: Fix xas_reload for multi-index entries
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Sun, 2 Aug 2020 18:17:21 +0000 (14:17 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 13 Oct 2020 12:41:26 +0000 (08:41 -0400)
xas_reload() was only checking that the head entry was still at the
head index.  If the entry has been split, that's not enough as there
may be a different entry at the specified index now.

Solve this by checking the slot for the requested index instead of the
head index.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/xarray.h

index 29db4e16eb89ed819098f314f38aa40c01d566a3..4be9c57132fe4125a946b8f0e516c00cbb091722 100644 (file)
@@ -1524,10 +1524,21 @@ void xas_create_range(struct xa_state *);
 static inline void *xas_reload(struct xa_state *xas)
 {
        struct xa_node *node = xas->xa_node;
-
-       if (node)
-               return xa_entry(xas->xa, node, xas->xa_offset);
-       return xa_head(xas->xa);
+       void *entry;
+       char offset;
+
+       if (!node)
+               return xa_head(xas->xa);
+       if (IS_ENABLED(CONFIG_XARRAY_MULTI)) {
+               offset = (xas->xa_index >> node->shift) & XA_CHUNK_MASK;
+               entry = xa_entry(xas->xa, node, offset);
+               if (!xa_is_sibling(entry))
+                       return entry;
+               offset = xa_to_sibling(entry);
+       } else {
+               offset = xas->xa_offset;
+       }
+       return xa_entry(xas->xa, node, offset);
 }
 
 /**