async: Introduce async_schedule_dev_nocall()
[linux-2.6-block.git] / kernel / async.c
index cffe6b4cff9f467cf72547f4160d133ea1086555..673bba6bdf3a0b0c0041e4bb7d63e61b8a63d0d7 100644 (file)
@@ -243,6 +243,35 @@ async_cookie_t async_schedule_node(async_func_t func, void *data, int node)
 }
 EXPORT_SYMBOL_GPL(async_schedule_node);
 
+/**
+ * async_schedule_dev_nocall - A simplified variant of async_schedule_dev()
+ * @func: function to execute asynchronously
+ * @dev: device argument to be passed to function
+ *
+ * @dev is used as both the argument for the function and to provide NUMA
+ * context for where to run the function.
+ *
+ * If the asynchronous execution of @func is scheduled successfully, return
+ * true. Otherwise, do nothing and return false, unlike async_schedule_dev()
+ * that will run the function synchronously then.
+ */
+bool async_schedule_dev_nocall(async_func_t func, struct device *dev)
+{
+       struct async_entry *entry;
+
+       entry = kzalloc(sizeof(struct async_entry), GFP_KERNEL);
+
+       /* Give up if there is no memory or too much work. */
+       if (!entry || atomic_read(&entry_count) > MAX_WORK) {
+               kfree(entry);
+               return false;
+       }
+
+       __async_schedule_node_domain(func, dev, dev_to_node(dev),
+                                    &async_dfl_domain, entry);
+       return true;
+}
+
 /**
  * async_synchronize_full - synchronize all asynchronous function calls
  *