]> 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>
Fri, 2 Sep 2022 19:41:04 +0000 (15:41 -0400)
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 e668f553a21729ce168a784d52b51886156f584a..49a1f14b7d2a6b57f1eeacc6c8d6e8cb198f4cc2 100644 (file)
@@ -453,7 +453,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 47e0540c9100b7dc40de98a01bde813f89a17cdc..9c4c72512f681e4be6ed12aa54fc954c7503002f 100644 (file)
@@ -5696,16 +5696,24 @@ retry:
  * 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;
 }
 
 /**