linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] md:Fix name of raid thread when raid takeovered
@ 2012-05-31  7:41 majianpeng
  2012-06-04  3:48 ` NeilBrown
  0 siblings, 1 reply; 4+ messages in thread
From: majianpeng @ 2012-05-31  7:41 UTC (permalink / raw)
  To: Neil Brown; +Cc: linux-raid

When raid takeovered, it used old personality to set task->comm.

Signed-off-by: majianpeng <majianpeng@gmail.com>
---
 drivers/md/md.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 1c2f904..93e20ea 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -32,6 +32,7 @@
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include <linux/sched.h>
 #include <linux/kthread.h>
 #include <linux/blkdev.h>
 #include <linux/sysctl.h>
@@ -3513,6 +3514,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
 	long level;
 	void *priv;
 	struct md_rdev *rdev;
+	char *tmp;
 
 	if (mddev->pers == NULL) {
 		if (len == 0)
@@ -3674,6 +3676,19 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
 		del_timer_sync(&mddev->safemode_timer);
 	}
 	pers->run(mddev);
+	/*
+	 * when raid takeover using old personality,so mddev->thread->tsk
+	 * name is wrong.
+	 * if kzalloc error, only using wrong name.
+	 */
+	len = strlen(mdname(mddev)) + strlen(mddev->pers->name);
+	tmp = kzalloc(len + 2, GFP_KERNEL);
+	if (tmp) {
+		sprintf(tmp, "%s_%s", mdname(mddev), mddev->pers->name);
+		set_task_comm(mddev->thread->tsk, tmp);
+		kfree(tmp);
+	}
+
 	set_bit(MD_CHANGE_DEVS, &mddev->flags);
 	mddev_resume(mddev);
 	sysfs_notify(&mddev->kobj, NULL, "level");
-- 
1.7.5.4

 				
--------------
majianpeng
2012-05-31


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] md:Fix name of raid thread when raid takeovered
  2012-05-31  7:41 [PATCH] md:Fix name of raid thread when raid takeovered majianpeng
@ 2012-06-04  3:48 ` NeilBrown
  2012-06-04  5:36   ` majianpeng
  0 siblings, 1 reply; 4+ messages in thread
From: NeilBrown @ 2012-06-04  3:48 UTC (permalink / raw)
  To: majianpeng; +Cc: linux-raid

[-- Attachment #1: Type: text/plain, Size: 1925 bytes --]

On Thu, 31 May 2012 15:41:22 +0800 "majianpeng" <majianpeng@gmail.com> wrote:

> When raid takeovered, it used old personality to set task->comm.
> 
> Signed-off-by: majianpeng <majianpeng@gmail.com>
> ---
>  drivers/md/md.c |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 1c2f904..93e20ea 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -32,6 +32,7 @@
>     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>  */
>  
> +#include <linux/sched.h>
>  #include <linux/kthread.h>
>  #include <linux/blkdev.h>
>  #include <linux/sysctl.h>
> @@ -3513,6 +3514,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
>  	long level;
>  	void *priv;
>  	struct md_rdev *rdev;
> +	char *tmp;
>  
>  	if (mddev->pers == NULL) {
>  		if (len == 0)
> @@ -3674,6 +3676,19 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
>  		del_timer_sync(&mddev->safemode_timer);
>  	}
>  	pers->run(mddev);
> +	/*
> +	 * when raid takeover using old personality,so mddev->thread->tsk
> +	 * name is wrong.
> +	 * if kzalloc error, only using wrong name.
> +	 */
> +	len = strlen(mdname(mddev)) + strlen(mddev->pers->name);
> +	tmp = kzalloc(len + 2, GFP_KERNEL);
> +	if (tmp) {
> +		sprintf(tmp, "%s_%s", mdname(mddev), mddev->pers->name);
> +		set_task_comm(mddev->thread->tsk, tmp);
> +		kfree(tmp);
> +	}
> +
>  	set_bit(MD_CHANGE_DEVS, &mddev->flags);
>  	mddev_resume(mddev);
>  	sysfs_notify(&mddev->kobj, NULL, "level");

Thanks.  However:

 1/ as a task name is limited to TASK_COMM_LEN, there is little point using
    kzalloc.  Just declare a local variable of that size.
 2/ No all levels have a thread.  You should check that mddev->thread is not
    NULL.

If you resubmit with those fixes I'll apply the patch.

Thanks,
NeilBrown


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: [PATCH] md:Fix name of raid thread when raid takeovered
  2012-06-04  3:48 ` NeilBrown
@ 2012-06-04  5:36   ` majianpeng
  2012-06-04  7:10     ` NeilBrown
  0 siblings, 1 reply; 4+ messages in thread
From: majianpeng @ 2012-06-04  5:36 UTC (permalink / raw)
  To: Neil Brown; +Cc: linux-raid, majianpeng

On Sun, 3 Jun 2012 20:49:05 -0700,neil wrote:
>On Thu, 31 May 2012 15:41:22 +0800 "majianpeng" <majianpeng@gmail.com> wrote:
>
>> When raid takeovered, it used old personality to set task->comm.
>> 
>> Signed-off-by: majianpeng <majianpeng@gmail.com>
>> ---
>>  drivers/md/md.c |   15 +++++++++++++++
>>  1 files changed, 15 insertions(+), 0 deletions(-)
>> 
>> diff --git a/drivers/md/md.c b/drivers/md/md.c
>> index 1c2f904..93e20ea 100644
>> --- a/drivers/md/md.c
>> +++ b/drivers/md/md.c
>> @@ -32,6 +32,7 @@
>>     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>>  */
>>  
>> +#include <linux/sched.h>
>>  #include <linux/kthread.h>
>>  #include <linux/blkdev.h>
>>  #include <linux/sysctl.h>
>> @@ -3513,6 +3514,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
>>  	long level;
>>  	void *priv;
>>  	struct md_rdev *rdev;
>> +	char *tmp;
>>  
>>  	if (mddev->pers == NULL) {
>>  		if (len == 0)
>> @@ -3674,6 +3676,19 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
>>  		del_timer_sync(&mddev->safemode_timer);
>>  	}
>>  	pers->run(mddev);
>> +	/*
>> +	 * when raid takeover using old personality,so mddev->thread->tsk
>> +	 * name is wrong.
>> +	 * if kzalloc error, only using wrong name.
>> +	 */
>> +	len = strlen(mdname(mddev)) + strlen(mddev->pers->name);
>> +	tmp = kzalloc(len + 2, GFP_KERNEL);
>> +	if (tmp) {
>> +		sprintf(tmp, "%s_%s", mdname(mddev), mddev->pers->name);
>> +		set_task_comm(mddev->thread->tsk, tmp);
>> +		kfree(tmp);
>> +	}
>> +
>>  	set_bit(MD_CHANGE_DEVS, &mddev->flags);
>>  	mddev_resume(mddev);
>>  	sysfs_notify(&mddev->kobj, NULL, "level");
>
>Thanks.  However:
>
> 1/ as a task name is limited to TASK_COMM_LEN, there is little point using
>    kzalloc.  Just declare a local variable of that size.
> 2/ No all levels have a thread.  You should check that mddev->thread is not
>    NULL.
>
>If you resubmit with those fixes I'll apply the patch.
>
>Thanks,
>NeilBrown
>
>
Neil, There maybe had anthor issue.
set_task_comm() is not export.So when compile md is module, it will be error.
So I think  it will be rewrite.It should rename in function call md_register_thread().
How about this way?
														Thanks!

--------------
majianpeng

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] md:Fix name of raid thread when raid takeovered
  2012-06-04  5:36   ` majianpeng
@ 2012-06-04  7:10     ` NeilBrown
  0 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2012-06-04  7:10 UTC (permalink / raw)
  To: majianpeng; +Cc: linux-raid

[-- Attachment #1: Type: text/plain, Size: 2694 bytes --]

On Mon, 4 Jun 2012 13:36:11 +0800 majianpeng <majianpeng@gmail.com> wrote:

> On Sun, 3 Jun 2012 20:49:05 -0700,neil wrote:
> >On Thu, 31 May 2012 15:41:22 +0800 "majianpeng" <majianpeng@gmail.com> wrote:
> >
> >> When raid takeovered, it used old personality to set task->comm.
> >> 
> >> Signed-off-by: majianpeng <majianpeng@gmail.com>
> >> ---
> >>  drivers/md/md.c |   15 +++++++++++++++
> >>  1 files changed, 15 insertions(+), 0 deletions(-)
> >> 
> >> diff --git a/drivers/md/md.c b/drivers/md/md.c
> >> index 1c2f904..93e20ea 100644
> >> --- a/drivers/md/md.c
> >> +++ b/drivers/md/md.c
> >> @@ -32,6 +32,7 @@
> >>     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
> >>  */
> >>  
> >> +#include <linux/sched.h>
> >>  #include <linux/kthread.h>
> >>  #include <linux/blkdev.h>
> >>  #include <linux/sysctl.h>
> >> @@ -3513,6 +3514,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
> >>  	long level;
> >>  	void *priv;
> >>  	struct md_rdev *rdev;
> >> +	char *tmp;
> >>  
> >>  	if (mddev->pers == NULL) {
> >>  		if (len == 0)
> >> @@ -3674,6 +3676,19 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
> >>  		del_timer_sync(&mddev->safemode_timer);
> >>  	}
> >>  	pers->run(mddev);
> >> +	/*
> >> +	 * when raid takeover using old personality,so mddev->thread->tsk
> >> +	 * name is wrong.
> >> +	 * if kzalloc error, only using wrong name.
> >> +	 */
> >> +	len = strlen(mdname(mddev)) + strlen(mddev->pers->name);
> >> +	tmp = kzalloc(len + 2, GFP_KERNEL);
> >> +	if (tmp) {
> >> +		sprintf(tmp, "%s_%s", mdname(mddev), mddev->pers->name);
> >> +		set_task_comm(mddev->thread->tsk, tmp);
> >> +		kfree(tmp);
> >> +	}
> >> +
> >>  	set_bit(MD_CHANGE_DEVS, &mddev->flags);
> >>  	mddev_resume(mddev);
> >>  	sysfs_notify(&mddev->kobj, NULL, "level");
> >
> >Thanks.  However:
> >
> > 1/ as a task name is limited to TASK_COMM_LEN, there is little point using
> >    kzalloc.  Just declare a local variable of that size.
> > 2/ No all levels have a thread.  You should check that mddev->thread is not
> >    NULL.
> >
> >If you resubmit with those fixes I'll apply the patch.
> >
> >Thanks,
> >NeilBrown
> >
> >
> Neil, There maybe had anthor issue.
> set_task_comm() is not export.So when compile md is module, it will be error.
> So I think  it will be rewrite.It should rename in function call md_register_thread().
> How about this way?

good point.

If you change all calls to "md_register_thread" that pass NULL as the last
argument to instead pass the name of the personality as the last arg,
then it should get it right.

Thanks,
NeilBrown


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-04  7:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-31  7:41 [PATCH] md:Fix name of raid thread when raid takeovered majianpeng
2012-06-04  3:48 ` NeilBrown
2012-06-04  5:36   ` majianpeng
2012-06-04  7:10     ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).