Commit 1b0cb4ce authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[PATCH] get rid of __MOD_INC_USE_COUNT/__MOD_DEC_USE_COUNT

As the netfilter folks don't seem to have any interest in 2.5 currently
I decided to fix their last uses of those old module interfaces myself.
The implementation (get a reference first and release it again when
not actually needed) might be slightly suboptimial but the netfilter
team should just fix it if/when they get any interest in Linux 2.5/2.6.

Also fix the MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT to give more accurate
deprecation warnings.
parent 48bcb216
......@@ -69,8 +69,6 @@ extern const struct gtype##_id __mod_##gtype##_table \
__attribute__ ((unused, alias(__stringify(name))))
#define THIS_MODULE (&__this_module)
#define MOD_INC_USE_COUNT _MOD_INC_USE_COUNT(THIS_MODULE)
#define MOD_DEC_USE_COUNT __MOD_DEC_USE_COUNT(THIS_MODULE)
/*
* The following license idents are currently accepted as indicating free
......@@ -107,8 +105,6 @@ extern const struct gtype##_id __mod_##gtype##_table \
#define MODULE_ALIAS(alias)
#define MODULE_GENERIC_TABLE(gtype,name)
#define THIS_MODULE ((struct module *)0)
#define MOD_INC_USE_COUNT do { } while (0)
#define MOD_DEC_USE_COUNT do { } while (0)
#define MODULE_LICENSE(license)
#endif
......@@ -418,20 +414,6 @@ __attribute__((section(".gnu.linkonce.this_module"))) = {
#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
static inline void __deprecated __MOD_INC_USE_COUNT(struct module *module)
{
__unsafe(module);
/*
* Yes, we ignore the retval here, that's why it's deprecated.
*/
try_module_get(module);
}
static inline void __deprecated __MOD_DEC_USE_COUNT(struct module *module)
{
module_put(module);
}
#define SET_MODULE_OWNER(dev) ((dev)->owner = THIS_MODULE)
struct obsolete_modparm {
......@@ -445,14 +427,7 @@ struct obsolete_modparm {
struct obsolete_modparm __parm_##var __attribute__((section("__obsparm"))) = \
{ __stringify(var), type };
#else
#define MODULE_PARM(var,type)
#endif
/* People do this inside their init routines, when the module isn't
"live" yet. They should no longer be doing that, but
meanwhile... */
static inline void __deprecated _MOD_INC_USE_COUNT(struct module *module)
static inline void __deprecated MOD_INC_USE_COUNT(struct module *module)
{
__unsafe(module);
......@@ -460,9 +435,23 @@ static inline void __deprecated _MOD_INC_USE_COUNT(struct module *module)
local_inc(&module->ref[get_cpu()].count);
put_cpu();
#else
try_module_get(module);
(void)try_module_get(module);
#endif
}
static inline void __deprecated MOD_DEC_USE_COUNT(struct module *module)
{
module_put(module);
}
#define MOD_INC_USE_COUNT MOD_INC_USE_COUNT(THIS_MODULE)
#define MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT(THIS_MODULE)
#else
#define MODULE_PARM(var,type)
#define MOD_INC_USE_COUNT do { } while (0)
#define MOD_DEC_USE_COUNT do { } while (0)
#endif
#define __MODULE_STRING(x) __stringify(x)
/*
......
......@@ -912,19 +912,25 @@ static int do_replace(void *user, unsigned int len)
goto free_newinfo_counters_untrans_unlock;
}
/* Get a reference in advance, we're not allowed fail later */
if (!try_module_get(t->me)) {
ret = -EBUSY;
goto free_newinfo_counters_untrans_unlock;
}
oldinfo = replace_table(t, tmp.num_counters, newinfo, &ret);
if (!oldinfo)
goto free_newinfo_counters_untrans_unlock;
goto put_module;
/* Update module usage count based on number of rules */
duprintf("do_replace: oldnum=%u, initnum=%u, newnum=%u\n",
oldinfo->number, oldinfo->initial_entries, newinfo->number);
if (t->me && (oldinfo->number <= oldinfo->initial_entries) &&
(newinfo->number > oldinfo->initial_entries))
__MOD_INC_USE_COUNT(t->me);
else if (t->me && (oldinfo->number > oldinfo->initial_entries) &&
(newinfo->number <= oldinfo->initial_entries))
__MOD_DEC_USE_COUNT(t->me);
if ((oldinfo->number > oldinfo->initial_entries) ||
(newinfo->number <= oldinfo->initial_entries))
module_put(t->me);
if ((oldinfo->number > oldinfo->initial_entries) &&
(newinfo->number <= oldinfo->initial_entries))
module_put(t->me);
/* Get the old counters. */
get_counters(oldinfo, counters);
......@@ -938,6 +944,8 @@ static int do_replace(void *user, unsigned int len)
up(&arpt_mutex);
return 0;
put_module:
module_put(t->me);
free_newinfo_counters_untrans_unlock:
up(&arpt_mutex);
free_newinfo_counters_untrans:
......
......@@ -1106,19 +1106,26 @@ do_replace(void *user, unsigned int len)
goto free_newinfo_counters_untrans_unlock;
}
/* Get a reference in advance, we're not allowed fail later */
if (!try_module_get(t->me)) {
ret = -EBUSY;
goto free_newinfo_counters_untrans_unlock;
}
oldinfo = replace_table(t, tmp.num_counters, newinfo, &ret);
if (!oldinfo)
goto free_newinfo_counters_untrans_unlock;
goto put_module;
/* Update module usage count based on number of rules */
duprintf("do_replace: oldnum=%u, initnum=%u, newnum=%u\n",
oldinfo->number, oldinfo->initial_entries, newinfo->number);
if (t->me && (oldinfo->number <= oldinfo->initial_entries) &&
(newinfo->number > oldinfo->initial_entries))
__MOD_INC_USE_COUNT(t->me);
else if (t->me && (oldinfo->number > oldinfo->initial_entries) &&
(newinfo->number <= oldinfo->initial_entries))
__MOD_DEC_USE_COUNT(t->me);
if ((oldinfo->number > oldinfo->initial_entries) ||
(newinfo->number <= oldinfo->initial_entries))
module_put(t->me);
if ((oldinfo->number > oldinfo->initial_entries) &&
(newinfo->number <= oldinfo->initial_entries))
module_put(t->me);
/* Get the old counters. */
get_counters(oldinfo, counters);
......@@ -1132,6 +1139,8 @@ do_replace(void *user, unsigned int len)
up(&ipt_mutex);
return 0;
put_module:
module_put(t->me);
free_newinfo_counters_untrans_unlock:
up(&ipt_mutex);
free_newinfo_counters_untrans:
......
......@@ -1178,19 +1178,25 @@ do_replace(void *user, unsigned int len)
goto free_newinfo_counters_untrans_unlock;
}
/* Get a reference in advance, we're not allowed fail later */
if (!try_module_get(t->me)) {
ret = -EBUSY;
goto free_newinfo_counters_untrans_unlock;
}
oldinfo = replace_table(t, tmp.num_counters, newinfo, &ret);
if (!oldinfo)
goto free_newinfo_counters_untrans_unlock;
goto put_module;
/* Update module usage count based on number of rules */
duprintf("do_replace: oldnum=%u, initnum=%u, newnum=%u\n",
oldinfo->number, oldinfo->initial_entries, newinfo->number);
if (t->me && (oldinfo->number <= oldinfo->initial_entries) &&
(newinfo->number > oldinfo->initial_entries))
__MOD_INC_USE_COUNT(t->me);
else if (t->me && (oldinfo->number > oldinfo->initial_entries) &&
(newinfo->number <= oldinfo->initial_entries))
__MOD_DEC_USE_COUNT(t->me);
if ((oldinfo->number > oldinfo->initial_entries) ||
(newinfo->number <= oldinfo->initial_entries))
module_put(t->me);
if ((oldinfo->number > oldinfo->initial_entries) &&
(newinfo->number <= oldinfo->initial_entries))
module_put(t->me);
/* Get the old counters. */
get_counters(oldinfo, counters);
......@@ -1204,6 +1210,8 @@ do_replace(void *user, unsigned int len)
up(&ip6t_mutex);
return 0;
put_module:
module_put(t->me);
free_newinfo_counters_untrans_unlock:
up(&ip6t_mutex);
free_newinfo_counters_untrans:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment