diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2013-09-16 16:18:51 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-09-23 02:14:58 -0400 |
commit | 3f2b9c9cdf389e303b2273679af08aab5f153517 (patch) | |
tree | 915b06441005e02d02c6e9f9549bd6449b70d501 /kernel/module.c | |
parent | d8524ae9d6f492a9c6db9f4d89c5f9b8782fa2d5 (diff) |
module: remove rmmod --wait option.
The option to wait for a module reference count to reach zero was in
the initial module implementation, but it was never supported in
modprobe (you had to use rmmod --wait). After discussion with Lucas,
It has been deprecated (with a 10 second sleep) in kmod for the last
year.
This finally removes it: the flag will evoke a printk warning and a
normal (non-blocking) remove attempt.
Cc: Lucas De Marchi <lucas.de.marchi@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 46 |
1 files changed, 8 insertions, 38 deletions
diff --git a/kernel/module.c b/kernel/module.c index dc582749fa13..947105fd4cab 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -644,8 +644,6 @@ static int module_unload_init(struct module *mod) | |||
644 | 644 | ||
645 | /* Hold reference count during initialization. */ | 645 | /* Hold reference count during initialization. */ |
646 | __this_cpu_write(mod->refptr->incs, 1); | 646 | __this_cpu_write(mod->refptr->incs, 1); |
647 | /* Backwards compatibility macros put refcount during init. */ | ||
648 | mod->waiter = current; | ||
649 | 647 | ||
650 | return 0; | 648 | return 0; |
651 | } | 649 | } |
@@ -771,16 +769,9 @@ static int __try_stop_module(void *_sref) | |||
771 | 769 | ||
772 | static int try_stop_module(struct module *mod, int flags, int *forced) | 770 | static int try_stop_module(struct module *mod, int flags, int *forced) |
773 | { | 771 | { |
774 | if (flags & O_NONBLOCK) { | 772 | struct stopref sref = { mod, flags, forced }; |
775 | struct stopref sref = { mod, flags, forced }; | ||
776 | 773 | ||
777 | return stop_machine(__try_stop_module, &sref, NULL); | 774 | return stop_machine(__try_stop_module, &sref, NULL); |
778 | } else { | ||
779 | /* We don't need to stop the machine for this. */ | ||
780 | mod->state = MODULE_STATE_GOING; | ||
781 | synchronize_sched(); | ||
782 | return 0; | ||
783 | } | ||
784 | } | 775 | } |
785 | 776 | ||
786 | unsigned long module_refcount(struct module *mod) | 777 | unsigned long module_refcount(struct module *mod) |
@@ -813,21 +804,6 @@ EXPORT_SYMBOL(module_refcount); | |||
813 | /* This exists whether we can unload or not */ | 804 | /* This exists whether we can unload or not */ |
814 | static void free_module(struct module *mod); | 805 | static void free_module(struct module *mod); |
815 | 806 | ||
816 | static void wait_for_zero_refcount(struct module *mod) | ||
817 | { | ||
818 | /* Since we might sleep for some time, release the mutex first */ | ||
819 | mutex_unlock(&module_mutex); | ||
820 | for (;;) { | ||
821 | pr_debug("Looking at refcount...\n"); | ||
822 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
823 | if (module_refcount(mod) == 0) | ||
824 | break; | ||
825 | schedule(); | ||
826 | } | ||
827 | current->state = TASK_RUNNING; | ||
828 | mutex_lock(&module_mutex); | ||
829 | } | ||
830 | |||
831 | SYSCALL_DEFINE2(delete_module, const char __user *, name_user, | 807 | SYSCALL_DEFINE2(delete_module, const char __user *, name_user, |
832 | unsigned int, flags) | 808 | unsigned int, flags) |
833 | { | 809 | { |
@@ -842,6 +818,11 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user, | |||
842 | return -EFAULT; | 818 | return -EFAULT; |
843 | name[MODULE_NAME_LEN-1] = '\0'; | 819 | name[MODULE_NAME_LEN-1] = '\0'; |
844 | 820 | ||
821 | if (!(flags & O_NONBLOCK)) { | ||
822 | printk(KERN_WARNING | ||
823 | "waiting module removal not supported: please upgrade"); | ||
824 | } | ||
825 | |||
845 | if (mutex_lock_interruptible(&module_mutex) != 0) | 826 | if (mutex_lock_interruptible(&module_mutex) != 0) |
846 | return -EINTR; | 827 | return -EINTR; |
847 | 828 | ||
@@ -859,8 +840,7 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user, | |||
859 | 840 | ||
860 | /* Doing init or already dying? */ | 841 | /* Doing init or already dying? */ |
861 | if (mod->state != MODULE_STATE_LIVE) { | 842 | if (mod->state != MODULE_STATE_LIVE) { |
862 | /* FIXME: if (force), slam module count and wake up | 843 | /* FIXME: if (force), slam module count damn the torpedoes */ |
863 | waiter --RR */ | ||
864 | pr_debug("%s already dying\n", mod->name); | 844 | pr_debug("%s already dying\n", mod->name); |
865 | ret = -EBUSY; | 845 | ret = -EBUSY; |
866 | goto out; | 846 | goto out; |
@@ -876,18 +856,11 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user, | |||
876 | } | 856 | } |
877 | } | 857 | } |
878 | 858 | ||
879 | /* Set this up before setting mod->state */ | ||
880 | mod->waiter = current; | ||
881 | |||
882 | /* Stop the machine so refcounts can't move and disable module. */ | 859 | /* Stop the machine so refcounts can't move and disable module. */ |
883 | ret = try_stop_module(mod, flags, &forced); | 860 | ret = try_stop_module(mod, flags, &forced); |
884 | if (ret != 0) | 861 | if (ret != 0) |
885 | goto out; | 862 | goto out; |
886 | 863 | ||
887 | /* Never wait if forced. */ | ||
888 | if (!forced && module_refcount(mod) != 0) | ||
889 | wait_for_zero_refcount(mod); | ||
890 | |||
891 | mutex_unlock(&module_mutex); | 864 | mutex_unlock(&module_mutex); |
892 | /* Final destruction now no one is using it. */ | 865 | /* Final destruction now no one is using it. */ |
893 | if (mod->exit != NULL) | 866 | if (mod->exit != NULL) |
@@ -1005,9 +978,6 @@ void module_put(struct module *module) | |||
1005 | __this_cpu_inc(module->refptr->decs); | 978 | __this_cpu_inc(module->refptr->decs); |
1006 | 979 | ||
1007 | trace_module_put(module, _RET_IP_); | 980 | trace_module_put(module, _RET_IP_); |
1008 | /* Maybe they're waiting for us to drop reference? */ | ||
1009 | if (unlikely(!module_is_live(module))) | ||
1010 | wake_up_process(module->waiter); | ||
1011 | preempt_enable(); | 981 | preempt_enable(); |
1012 | } | 982 | } |
1013 | } | 983 | } |