Re: [PATCH] remove useless MOD_{INC,DEC}_USE_COUNT from sunrpc

Christoph Hellwig (hch@lst.de)
Sun, 4 May 2003 23:00:11 +0200


On Sun, May 04, 2003 at 12:06:06PM -0700, David S. Miller wrote:
> Well, what if this hangs? Unless the user specifies
> "--wait" to 2.5.x's rmmod, the user absolutely does not
> expect this behavior.
>
> Rather, so that the "--wait" is respected, something one level
> up ought to be doing try_module_get().

Oh well, what about something like the following?

--- 1.25/net/sunrpc/sched.c Thu May 1 12:52:23 2003
+++ edited/net/sunrpc/sched.c Sun May 4 21:25:21 2003
@@ -952,6 +952,14 @@
wait_queue_head_t *assassin = (wait_queue_head_t*) ptr;
int rounds = 0;

+ /*
+ * We are locked into memory by beeing used by another module,
+ * but the refcount might be 0 neverless so we can't use
+ * __module_get().
+ */
+ if (!try_module_get(THIS_MODULE))
+ return -EBUSY;
+
lock_kernel();
/*
* Let our maker know we're running ...
@@ -994,6 +1002,7 @@

dprintk("RPC: rpciod exiting\n");
unlock_kernel();
+ module_put(THIS_MODULE);
return 0;
}

@@ -1042,6 +1051,11 @@
if (error < 0) {
printk(KERN_WARNING "rpciod_up: create thread failed, error=%d\n", error);
rpciod_users--;
+ goto out;
+ }
+ if (!rpciod_pid) {
+ rpciod_users--;
+ error = -EBUSY;
goto out;
}
down(&rpciod_running);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/