Merge tag 'powerpc-6.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[platform/kernel/linux-starfive.git] / drivers / md / dm-mpath.c
index b27d63c..61ab1a8 100644 (file)
@@ -28,6 +28,8 @@
 #include <linux/atomic.h>
 #include <linux/blk-mq.h>
 
+static struct workqueue_struct *dm_mpath_wq;
+
 #define DM_MSG_PREFIX "multipath"
 #define DM_PG_INIT_DELAY_MSECS 2000
 #define DM_PG_INIT_DELAY_DEFAULT ((unsigned int) -1)
@@ -472,13 +474,11 @@ failed:
  * it has been invoked.
  */
 #define dm_report_EIO(m)                                               \
-do {                                                                   \
        DMDEBUG_LIMIT("%s: returning EIO; QIFNP = %d; SQIFNP = %d; DNFS = %d", \
                      dm_table_device_name((m)->ti->table),             \
                      test_bit(MPATHF_QUEUE_IF_NO_PATH, &(m)->flags),   \
                      test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &(m)->flags), \
-                     dm_noflush_suspending((m)->ti));                  \
-} while (0)
+                     dm_noflush_suspending((m)->ti))
 
 /*
  * Check whether bios must be queued in the device-mapper core rather
@@ -1355,7 +1355,7 @@ static int fail_path(struct pgpath *pgpath)
        dm_path_uevent(DM_UEVENT_PATH_FAILED, m->ti,
                       pgpath->path.dev->name, atomic_read(&m->nr_valid_paths));
 
-       schedule_work(&m->trigger_event);
+       queue_work(dm_mpath_wq, &m->trigger_event);
 
        enable_nopath_timeout(m);
 
@@ -2207,12 +2207,11 @@ static struct target_type multipath_target = {
 
 static int __init dm_multipath_init(void)
 {
-       int r;
+       int r = -ENOMEM;
 
        kmultipathd = alloc_workqueue("kmpathd", WQ_MEM_RECLAIM, 0);
        if (!kmultipathd) {
                DMERR("failed to create workqueue kmpathd");
-               r = -ENOMEM;
                goto bad_alloc_kmultipathd;
        }
 
@@ -2226,10 +2225,15 @@ static int __init dm_multipath_init(void)
                                                  WQ_MEM_RECLAIM);
        if (!kmpath_handlerd) {
                DMERR("failed to create workqueue kmpath_handlerd");
-               r = -ENOMEM;
                goto bad_alloc_kmpath_handlerd;
        }
 
+       dm_mpath_wq = alloc_workqueue("dm_mpath_wq", 0, 0);
+       if (!dm_mpath_wq) {
+               DMERR("failed to create workqueue dm_mpath_wq");
+               goto bad_alloc_dm_mpath_wq;
+       }
+
        r = dm_register_target(&multipath_target);
        if (r < 0) {
                DMERR("request-based register failed %d", r);
@@ -2240,6 +2244,8 @@ static int __init dm_multipath_init(void)
        return 0;
 
 bad_register_target:
+       destroy_workqueue(dm_mpath_wq);
+bad_alloc_dm_mpath_wq:
        destroy_workqueue(kmpath_handlerd);
 bad_alloc_kmpath_handlerd:
        destroy_workqueue(kmultipathd);
@@ -2249,6 +2255,7 @@ bad_alloc_kmultipathd:
 
 static void __exit dm_multipath_exit(void)
 {
+       destroy_workqueue(dm_mpath_wq);
        destroy_workqueue(kmpath_handlerd);
        destroy_workqueue(kmultipathd);
 
@@ -2258,8 +2265,7 @@ static void __exit dm_multipath_exit(void)
 module_init(dm_multipath_init);
 module_exit(dm_multipath_exit);
 
-module_param_named(queue_if_no_path_timeout_secs,
-                  queue_if_no_path_timeout_secs, ulong, S_IRUGO | S_IWUSR);
+module_param_named(queue_if_no_path_timeout_secs, queue_if_no_path_timeout_secs, ulong, 0644);
 MODULE_PARM_DESC(queue_if_no_path_timeout_secs, "No available paths queue IO timeout in seconds");
 
 MODULE_DESCRIPTION(DM_NAME " multipath target");