linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-raid@vger.kernel.org
Subject: [PATCH md 002 of 8] Fix ref-counting problems with kobjects in md
Date: Fri, 14 Oct 2005 12:26:01 +1000	[thread overview]
Message-ID: <1051014022601.11773@suse.de> (raw)
In-Reply-To: 20051014122335.11602.patches@notabene


Thanks Greg.

Cc:  Greg KH <greg@kroah.com>

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./drivers/md/md.c    |    8 ++++++--
 ./drivers/md/raid5.c |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff ./drivers/md/md.c~current~ ./drivers/md/md.c
--- ./drivers/md/md.c~current~	2005-10-14 12:15:05.000000000 +1000
+++ ./drivers/md/md.c	2005-10-14 12:15:42.000000000 +1000
@@ -805,7 +805,11 @@ static void super_90_sync(mddev_t *mddev
 			if (fixdesc & (1<<rdev2->desc_nr)) {
 				snprintf(rdev2->kobj.name, KOBJ_NAME_LEN, "dev%d",
 					 rdev2->desc_nr);
+				/* kobject_add gets a ref on the parent, so
+				 * we have to drop the one we already have
+				 */
 				kobject_add(&rdev2->kobj);
+				kobject_put(rdev->kobj.parent);
 				sysfs_create_link(&rdev2->kobj,
 						  &rdev2->bdev->bd_disk->kobj,
 						  "block");
@@ -1178,7 +1182,7 @@ static int bind_rdev_to_array(mdk_rdev_t
 
 	rdev->kobj.k_name = NULL;
 	snprintf(rdev->kobj.name, KOBJ_NAME_LEN, "dev%d", rdev->desc_nr);
-	rdev->kobj.parent = kobject_get(&mddev->kobj);
+	rdev->kobj.parent = &mddev->kobj;
 	kobject_add(&rdev->kobj);
 
 	sysfs_create_link(&rdev->kobj, &rdev->bdev->bd_disk->kobj, "block");
@@ -1864,7 +1868,7 @@ static struct kobject *md_probe(dev_t de
 	add_disk(disk);
 	mddev->gendisk = disk;
 	up(&disks_sem);
-	mddev->kobj.parent = kobject_get(&disk->kobj);
+	mddev->kobj.parent = &disk->kobj;
 	mddev->kobj.k_name = NULL;
 	snprintf(mddev->kobj.name, KOBJ_NAME_LEN, "%s", "md");
 	mddev->kobj.ktype = &md_ktype;

diff ./drivers/md/raid5.c~current~ ./drivers/md/raid5.c
--- ./drivers/md/raid5.c~current~	2005-10-14 12:15:25.000000000 +1000
+++ ./drivers/md/raid5.c	2005-10-14 12:15:42.000000000 +1000
@@ -1979,7 +1979,7 @@ memory = conf->max_nr_stripes * (sizeof(
 	}
 
 	/* Ok, everything is just fine now */
-	conf->kobj.parent = kobject_get(&mddev->kobj);
+	conf->kobj.parent = &mddev->kobj;
 	strcpy(conf->kobj.name, "raid5");
 	conf->kobj.ktype = &raid5_ktype;
 	kobject_register(&conf->kobj);

  parent reply	other threads:[~2005-10-14  2:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-14  2:25 [PATCH md 000 of 8] Introduction NeilBrown
2005-10-14  2:25 ` [PATCH md 001 of 8] Provide proper rcu_dereference / rcu_assign_pointer annotations in md NeilBrown
2005-10-14  2:26 ` NeilBrown [this message]
2005-10-14  2:26 ` [PATCH md 003 of 8] Minor MD fixes NeilBrown
2005-10-14  2:26 ` [PATCH md 004 of 8] Change raid5 sysfs attribute to not create a new directory NeilBrown
2005-10-14  2:26 ` [PATCH md 005 of 8] Improvements to raid5 handling of read errors NeilBrown
2005-10-14  2:26 ` [PATCH md 006 of 8] Convert 'faulty' and 'in_sync' fields to bits in 'flags' field NeilBrown
2005-10-14  2:26 ` [PATCH md 007 of 8] Make md on-disk bitmaps not host-endian NeilBrown
2005-10-14  2:26 ` [PATCH md 008 of 8] Support BIO_RW_BARRIER for md/raid1 NeilBrown
2005-10-16 15:57 ` [PATCH md 000 of 8] Introduction Mr. James W. Laferriere
2005-10-17  2:38   ` Neil Brown
2005-10-18  1:02     ` Mr. James W. Laferriere

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1051014022601.11773@suse.de \
    --to=neilb@suse.de \
    --cc=akpm@osdl.org \
    --cc=linux-raid@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).