]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Return error on mas_store_prealloc()
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 1 Sep 2022 20:27:51 +0000 (16:27 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 13 Dec 2022 21:22:36 +0000 (16:22 -0500)
mas_store_prealloc() should never fail, but if it does due to internal
tree issues then return the error message and WARN_ON().

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
include/linux/maple_tree.h
lib/maple_tree.c

index ff6f2e1f1355c8160df2c9b139a1bd061486e21e..3f76b996dda80137c04f0b3b6a9bb6391fd3fdcd 100644 (file)
@@ -454,7 +454,7 @@ void *mas_walk(struct ma_state *mas);
 void *mas_store(struct ma_state *mas, void *entry);
 void *mas_erase(struct ma_state *mas);
 int mas_store_gfp(struct ma_state *mas, void *entry, gfp_t gfp);
-void mas_store_prealloc(struct ma_state *mas, void *entry);
+int mas_store_prealloc(struct ma_state *mas, void *entry);
 void *mas_find(struct ma_state *mas, unsigned long max);
 void *mas_find_rev(struct ma_state *mas, unsigned long min);
 int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp);
index 05feed59570c28df7f021c73678bf900319d65bf..f7273b30cf23a978d2082f30aca36eff1f5fef62 100644 (file)
@@ -5792,16 +5792,24 @@ EXPORT_SYMBOL_GPL(mas_store_gfp);
  * preallocated in the maple state.
  * @mas: The maple state
  * @entry: The entry to store.
+ *
+ * If this does not succeed, something went very wrong.
+ *
+ * Return: 0 on success
  */
-void mas_store_prealloc(struct ma_state *mas, void *entry)
+int mas_store_prealloc(struct ma_state *mas, void *entry)
 {
        MA_WR_STATE(wr_mas, mas, entry);
+       int ret = 0;
 
        mas_wr_store_setup(&wr_mas);
        trace_ma_write(__func__, mas, 0, entry);
        mas_wr_store_entry(&wr_mas);
-       BUG_ON(mas_is_err(mas));
+       if(MT_WARN_ON(mas->tree, mas_is_err(mas)))
+               ret = xa_err(mas->node);
+
        mas_destroy(mas);
+       return ret;
 }
 EXPORT_SYMBOL_GPL(mas_store_prealloc);