Commit 3f2b9c9cdf389e303b2273679af08aab5f153517

Authored by Rusty Russell
1 parent d8524ae9d6

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>

Showing 2 changed files with 8 additions and 41 deletions Side-by-side Diff

include/linux/module.h
... ... @@ -367,9 +367,6 @@
367 367 /* What modules do I depend on? */
368 368 struct list_head target_list;
369 369  
370   - /* Who is waiting for us to be unloaded */
371   - struct task_struct *waiter;
372   -
373 370 /* Destruction function. */
374 371 void (*exit)(void);
375 372  
... ... @@ -644,8 +644,6 @@
644 644  
645 645 /* Hold reference count during initialization. */
646 646 __this_cpu_write(mod->refptr->incs, 1);
647   - /* Backwards compatibility macros put refcount during init. */
648   - mod->waiter = current;
649 647  
650 648 return 0;
651 649 }
652 650  
... ... @@ -771,16 +769,9 @@
771 769  
772 770 static int try_stop_module(struct module *mod, int flags, int *forced)
773 771 {
774   - if (flags & O_NONBLOCK) {
775   - struct stopref sref = { mod, flags, forced };
  772 + struct stopref sref = { mod, flags, forced };
776 773  
777   - 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   - }
  774 + return stop_machine(__try_stop_module, &sref, NULL);
784 775 }
785 776  
786 777 unsigned long module_refcount(struct module *mod)
... ... @@ -813,21 +804,6 @@
813 804 /* This exists whether we can unload or not */
814 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 807 SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
832 808 unsigned int, flags)
833 809 {
... ... @@ -842,6 +818,11 @@
842 818 return -EFAULT;
843 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 826 if (mutex_lock_interruptible(&module_mutex) != 0)
846 827 return -EINTR;
847 828  
... ... @@ -859,8 +840,7 @@
859 840  
860 841 /* Doing init or already dying? */
861 842 if (mod->state != MODULE_STATE_LIVE) {
862   - /* FIXME: if (force), slam module count and wake up
863   - waiter --RR */
  843 + /* FIXME: if (force), slam module count damn the torpedoes */
864 844 pr_debug("%s already dying\n", mod->name);
865 845 ret = -EBUSY;
866 846 goto out;
867 847  
... ... @@ -876,18 +856,11 @@
876 856 }
877 857 }
878 858  
879   - /* Set this up before setting mod->state */
880   - mod->waiter = current;
881   -
882 859 /* Stop the machine so refcounts can't move and disable module. */
883 860 ret = try_stop_module(mod, flags, &forced);
884 861 if (ret != 0)
885 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 864 mutex_unlock(&module_mutex);
892 865 /* Final destruction now no one is using it. */
893 866 if (mod->exit != NULL)
... ... @@ -1005,9 +978,6 @@
1005 978 __this_cpu_inc(module->refptr->decs);
1006 979  
1007 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 981 preempt_enable();
1012 982 }
1013 983 }