sys_sysfs: Add CONFIG_SYSFS_SYSCALL
[cascardo/linux.git] / kernel / torture.c
index 4394518..acc9afc 100644 (file)
@@ -454,7 +454,10 @@ static int torture_shutdown(void *arg)
 
        VERBOSE_TOROUT_STRING("torture_shutdown task shutting down system");
        shutdown_task = NULL;   /* Avoid self-kill deadlock. */
-       torture_shutdown_hook();/* Shut down the enclosing torture test. */
+       if (torture_shutdown_hook)
+               torture_shutdown_hook();
+       else
+               VERBOSE_TOROUT_STRING("No torture_shutdown_hook(), skipping.");
        kernel_power_off();     /* Shut down the system. */
        return 0;
 }
@@ -477,20 +480,6 @@ int torture_shutdown_init(int ssecs, void (*cleanup)(void))
 }
 EXPORT_SYMBOL_GPL(torture_shutdown_init);
 
-/*
- * Shut down the shutdown task.  Say what???  Heh!  This can happen if
- * the torture module gets an rmmod before the shutdown time arrives.  ;-)
- */
-void torture_shutdown_cleanup(void)
-{
-       if (shutdown_task != NULL) {
-               VERBOSE_TOROUT_STRING("Stopping torture_shutdown task");
-               kthread_stop(shutdown_task);
-       }
-       shutdown_task = NULL;
-}
-EXPORT_SYMBOL_GPL(torture_shutdown_cleanup);
-
 /*
  * Detect and respond to a system shutdown.
  */
@@ -512,6 +501,20 @@ static struct notifier_block torture_shutdown_nb = {
        .notifier_call = torture_shutdown_notify,
 };
 
+/*
+ * Shut down the shutdown task.  Say what???  Heh!  This can happen if
+ * the torture module gets an rmmod before the shutdown time arrives.  ;-)
+ */
+static void torture_shutdown_cleanup(void)
+{
+       unregister_reboot_notifier(&torture_shutdown_nb);
+       if (shutdown_task != NULL) {
+               VERBOSE_TOROUT_STRING("Stopping torture_shutdown task");
+               kthread_stop(shutdown_task);
+       }
+       shutdown_task = NULL;
+}
+
 /*
  * Variables for stuttering, which means to periodically pause and
  * restart testing in order to catch bugs that appear when load is
@@ -575,7 +578,7 @@ EXPORT_SYMBOL_GPL(torture_stutter_init);
 /*
  * Cleanup after the torture_stutter kthread.
  */
-void torture_stutter_cleanup(void)
+static void torture_stutter_cleanup(void)
 {
        if (!stutter_task)
                return;
@@ -583,7 +586,6 @@ void torture_stutter_cleanup(void)
        kthread_stop(stutter_task);
        stutter_task = NULL;
 }
-EXPORT_SYMBOL_GPL(torture_stutter_cleanup);
 
 /*
  * Initialize torture module.  Please note that this is -not- invoked via
@@ -619,7 +621,8 @@ EXPORT_SYMBOL_GPL(torture_init_end);
  * Clean up torture module.  Please note that this is -not- invoked via
  * the usual module_exit() mechanism, but rather by an explicit call from
  * the client torture module.  Returns true if a race with system shutdown
- * is detected.
+ * is detected, otherwise, all kthreads started by functions in this file
+ * will be shut down.
  *
  * This must be called before the caller starts shutting down its own
  * kthreads.
@@ -635,8 +638,9 @@ bool torture_cleanup(void)
        }
        ACCESS_ONCE(fullstop) = FULLSTOP_RMMOD;
        mutex_unlock(&fullstop_mutex);
-       unregister_reboot_notifier(&torture_shutdown_nb);
+       torture_shutdown_cleanup();
        torture_shuffle_cleanup();
+       torture_stutter_cleanup();
        torture_onoff_cleanup();
        return false;
 }
@@ -700,3 +704,16 @@ int _torture_create_kthread(int (*fn)(void *arg), void *arg, char *s, char *m,
        return ret;
 }
 EXPORT_SYMBOL_GPL(_torture_create_kthread);
+
+/*
+ * Stop a generic kthread, emitting a message.
+ */
+void _torture_stop_kthread(char *m, struct task_struct **tp)
+{
+       if (*tp == NULL)
+               return;
+       VERBOSE_TOROUT_STRING(m);
+       kthread_stop(*tp);
+       *tp = NULL;
+}
+EXPORT_SYMBOL_GPL(_torture_stop_kthread);