2008-02-11 09:09:19

by Joonwoo Park

[permalink] [raw]
Subject: [PATCH 1/2] [RESENDING] fs/dlm: get rid of unnecessary initialization

default_groups was allocated with kcalloc, so initialize to NULL
is unnecessary.

Signed-off-by: Joonwoo Park <[email protected]>
---
fs/dlm/config.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index c3ad1df..2b96428 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -414,7 +414,6 @@ static struct config_group *make_cluster(struct config_group *g,
cl->group.default_groups = gps;
cl->group.default_groups[0] = &sps->ss_group;
cl->group.default_groups[1] = &cms->cs_group;
- cl->group.default_groups[2] = NULL;

cl->cl_tcp_port = dlm_config.ci_tcp_port;
cl->cl_buffer_size = dlm_config.ci_buffer_size;
@@ -483,7 +482,6 @@ static struct config_group *make_space(struct config_group *g, const char *name)

sp->group.default_groups = gps;
sp->group.default_groups[0] = &nds->ns_group;
- sp->group.default_groups[1] = NULL;

INIT_LIST_HEAD(&sp->members);
mutex_init(&sp->members_lock);
--
1.5.3.rc5


2008-02-11 09:09:43

by Joonwoo Park

[permalink] [raw]
Subject: [PATCH 2/2] [RESENDING] fs/ocfs2: get rid of unnecessary initialization

default_groups was allocated with kcalloc, so initialize to NULL
is unnecessary.

Signed-off-by: Joonwoo Park <[email protected]>
---
fs/ocfs2/cluster/nodemanager.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index 709fba2..08609d7 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -839,7 +839,6 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g
cluster->cl_group.default_groups = defs;
cluster->cl_group.default_groups[0] = &ns->ns_group;
cluster->cl_group.default_groups[1] = o2hb_group;
- cluster->cl_group.default_groups[2] = NULL;
rwlock_init(&cluster->cl_nodes_lock);
cluster->cl_node_ip_tree = RB_ROOT;
cluster->cl_reconnect_delay_ms = O2NET_RECONNECT_DELAY_MS_DEFAULT;
--
1.5.3.rc5

2008-02-11 09:10:08

by Joonwoo Park

[permalink] [raw]
Subject: [PATCH] [RESENDING] netconsole: register cmdline netconsole configs to configfs

This patch intorduces cmdline netconsole configs to register to configfs
with dynamic netconsole. Satyam Sharma who designed shiny dynamic
reconfiguration for netconsole, mentioned about this issue already.
(http://lkml.org/lkml/2007/7/29/360)
But I think, without separately managing of two kind of netconsole target
objects, it's possible by using config_group instead of
config_item in the netconsole_target and default_groups feature of configfs.

Patch was tested with configuration creation/destruction by kernel and
module.
And it makes possible to enable/disable, modify and review netconsole
target configs from cmdline.

Signed-off-by: Joonwoo Park <[email protected]>
---
drivers/net/netconsole.c | 91 ++++++++++++++++++++++++++++++++++++----------
1 files changed, 72 insertions(+), 19 deletions(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 31e047d..63aabbb 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -93,7 +93,7 @@ static DEFINE_SPINLOCK(target_list_lock);
struct netconsole_target {
struct list_head list;
#ifdef CONFIG_NETCONSOLE_DYNAMIC
- struct config_item item;
+ struct config_group group;
#endif
int enabled;
struct netpoll np;
@@ -103,16 +103,49 @@ struct netconsole_target {

static struct configfs_subsystem netconsole_subsys;

-static int __init dynamic_netconsole_init(void)
+static void netconsole_target_put(struct netconsole_target *nt);
+static struct config_item_type netconsole_target_type;
+
+static int __init dynamic_netconsole_init(int defaults)
{
+ int err;
+ unsigned long flags;
config_group_init(&netconsole_subsys.su_group);
+
+ if (defaults > 0) {
+ struct list_head *pos;
+ struct config_group **groups;
+ int i = 0;
+
+ groups = kcalloc(defaults, sizeof(struct config_group *),
+ GFP_KERNEL);
+ if (!groups)
+ return -ENOMEM;
+
+ spin_lock_irqsave(&target_list_lock, flags);
+ list_for_each(pos, &target_list) {
+ struct netconsole_target *nt;
+ nt = list_entry(pos, struct netconsole_target, list);
+ groups[i] = &nt->group;
+ i++;
+ }
+ spin_unlock_irqrestore(&target_list_lock, flags);
+ netconsole_subsys.su_group.default_groups = groups;
+ }
+
mutex_init(&netconsole_subsys.su_mutex);
- return configfs_register_subsystem(&netconsole_subsys);
+
+ err = configfs_register_subsystem(&netconsole_subsys);
+ if (err)
+ kfree(netconsole_subsys.su_group.default_groups);
+
+ return err;
}

static void __exit dynamic_netconsole_exit(void)
{
configfs_unregister_subsystem(&netconsole_subsys);
+ kfree(netconsole_subsys.su_group.default_groups);
}

/*
@@ -122,14 +155,23 @@ static void __exit dynamic_netconsole_exit(void)
*/
static void netconsole_target_get(struct netconsole_target *nt)
{
- if (config_item_name(&nt->item))
- config_item_get(&nt->item);
+ if (config_item_name(&nt->group.cg_item))
+ config_item_get(&nt->group.cg_item);
}

static void netconsole_target_put(struct netconsole_target *nt)
{
- if (config_item_name(&nt->item))
- config_item_put(&nt->item);
+ if (config_item_name(&nt->group.cg_item))
+ config_item_put(&nt->group.cg_item);
+}
+
+static void dynamic_netconsole_init_type_name(struct netconsole_target *nt,
+ int index)
+{
+ char name[16];
+ snprintf(name, sizeof(name), "netcon%d", index);
+ config_item_init_type_name(&nt->group.cg_item, name,
+ &netconsole_target_type);
}

#else /* !CONFIG_NETCONSOLE_DYNAMIC */
@@ -155,6 +197,11 @@ static void netconsole_target_put(struct netconsole_target *nt)
{
}

+static void dynamic_netconsole_init_type_name(struct netconsole_target *nt,
+ int index)
+{
+}
+
#endif /* CONFIG_NETCONSOLE_DYNAMIC */

/* Allocate new target (from boot/module param) and setup netpoll for it */
@@ -236,8 +283,8 @@ struct netconsole_target_attr {
static struct netconsole_target *to_target(struct config_item *item)
{
return item ?
- container_of(item, struct netconsole_target, item) :
- NULL;
+ container_of(to_config_group(item), struct netconsole_target,
+ group) : NULL;
}

/*
@@ -370,7 +417,7 @@ static ssize_t store_dev_name(struct netconsole_target *nt,
if (nt->enabled) {
printk(KERN_ERR "netconsole: target (%s) is enabled, "
"disable to update parameters\n",
- config_item_name(&nt->item));
+ config_item_name(&nt->group.cg_item));
return -EINVAL;
}

@@ -394,7 +441,7 @@ static ssize_t store_local_port(struct netconsole_target *nt,
if (nt->enabled) {
printk(KERN_ERR "netconsole: target (%s) is enabled, "
"disable to update parameters\n",
- config_item_name(&nt->item));
+ config_item_name(&nt->group.cg_item));
return -EINVAL;
}

@@ -417,7 +464,7 @@ static ssize_t store_remote_port(struct netconsole_target *nt,
if (nt->enabled) {
printk(KERN_ERR "netconsole: target (%s) is enabled, "
"disable to update parameters\n",
- config_item_name(&nt->item));
+ config_item_name(&nt->group.cg_item));
return -EINVAL;
}

@@ -437,7 +484,7 @@ static ssize_t store_local_ip(struct netconsole_target *nt,
if (nt->enabled) {
printk(KERN_ERR "netconsole: target (%s) is enabled, "
"disable to update parameters\n",
- config_item_name(&nt->item));
+ config_item_name(&nt->group.cg_item));
return -EINVAL;
}

@@ -453,7 +500,7 @@ static ssize_t store_remote_ip(struct netconsole_target *nt,
if (nt->enabled) {
printk(KERN_ERR "netconsole: target (%s) is enabled, "
"disable to update parameters\n",
- config_item_name(&nt->item));
+ config_item_name(&nt->group.cg_item));
return -EINVAL;
}

@@ -473,7 +520,7 @@ static ssize_t store_remote_mac(struct netconsole_target *nt,
if (nt->enabled) {
printk(KERN_ERR "netconsole: target (%s) is enabled, "
"disable to update parameters\n",
- config_item_name(&nt->item));
+ config_item_name(&nt->group.cg_item));
return -EINVAL;
}

@@ -608,14 +655,15 @@ static struct config_item *make_netconsole_target(struct config_group *group,
memset(nt->np.remote_mac, 0xff, ETH_ALEN);

/* Initialize the config_item member */
- config_item_init_type_name(&nt->item, name, &netconsole_target_type);
+ config_item_init_type_name(&nt->group.cg_item, name,
+ &netconsole_target_type);

/* Adding, but it is disabled */
spin_lock_irqsave(&target_list_lock, flags);
list_add(&nt->list, &target_list);
spin_unlock_irqrestore(&target_list_lock, flags);

- return &nt->item;
+ return &nt->group.cg_item;
}

static void drop_netconsole_target(struct config_group *group,
@@ -635,7 +683,7 @@ static void drop_netconsole_target(struct config_group *group,
if (nt->enabled)
netpoll_cleanup(&nt->np);

- config_item_put(&nt->item);
+ config_item_put(&nt->group.cg_item);
}

static struct configfs_group_operations netconsole_subsys_group_ops = {
@@ -741,6 +789,7 @@ static int __init init_netconsole(void)
unsigned long flags;
char *target_config;
char *input = config;
+ int i = 0;

if (strnlen(input, MAX_PARAM_LENGTH)) {
while ((target_config = strsep(&input, ";"))) {
@@ -749,9 +798,13 @@ static int __init init_netconsole(void)
err = PTR_ERR(nt);
goto fail;
}
+
+ dynamic_netconsole_init_type_name(nt, i);
+
spin_lock_irqsave(&target_list_lock, flags);
list_add(&nt->list, &target_list);
spin_unlock_irqrestore(&target_list_lock, flags);
+ i++;
}
}

@@ -759,7 +812,7 @@ static int __init init_netconsole(void)
if (err)
goto fail;

- err = dynamic_netconsole_init();
+ err = dynamic_netconsole_init(i);
if (err)
goto undonotifier;

--
1.5.3.rc5

2008-02-11 16:31:13

by Matt Mackall

[permalink] [raw]
Subject: Re: [PATCH] [RESENDING] netconsole: register cmdline netconsole configs to configfs


On Mon, 2008-02-11 at 18:08 +0900, Joonwoo Park wrote:
> This patch intorduces cmdline netconsole configs to register to
> configfs
> with dynamic netconsole. Satyam Sharma who designed shiny dynamic
> reconfiguration for netconsole, mentioned about this issue already.
> (http://lkml.org/lkml/2007/7/29/360)
> But I think, without separately managing of two kind of netconsole
> target
> objects, it's possible by using config_group instead of
> config_item in the netconsole_target and default_groups feature of
> configfs.
>
> Patch was tested with configuration creation/destruction by kernel and
> module.
> And it makes possible to enable/disable, modify and review netconsole
> target configs from cmdline.

I'm afraid I'm going to have to leave review of this to someone who is
clueful about configfs. But it seems reasonable.

--
Mathematics is the supreme nostalgia of our time.

2008-02-18 19:31:48

by Mark Fasheh

[permalink] [raw]
Subject: Re: [PATCH 2/2] [RESENDING] fs/ocfs2: get rid of unnecessary initialization

On Mon, Feb 11, 2008 at 06:08:31PM +0900, Joonwoo Park wrote:
> default_groups was allocated with kcalloc, so initialize to NULL
> is unnecessary.

NACK - this isn't a performance critical section of code and that line makes
the array termination obvious, so I'm inclined to leave it as is.

Thanks,
--Mark

--
Mark Fasheh
Principal Software Developer, Oracle
[email protected]

2008-02-18 22:26:06

by David Teigland

[permalink] [raw]
Subject: Re: [PATCH 2/2] [RESENDING] fs/ocfs2: get rid of unnecessary initialization

On Mon, Feb 18, 2008 at 11:30:30AM -0800, Mark Fasheh wrote:
> On Mon, Feb 11, 2008 at 06:08:31PM +0900, Joonwoo Park wrote:
> > default_groups was allocated with kcalloc, so initialize to NULL
> > is unnecessary.
>
> NACK - this isn't a performance critical section of code and that line makes
> the array termination obvious, so I'm inclined to leave it as is.

The same nack for the same patch under fs/dlm.

Dave