public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Boaz Harrosh <bharrosh@panasas.com>
Cc: linux-scsi <linux-scsi@vger.kernel.org>, open-osd <osd-dev@open-osd.org>
Subject: Re: [PATCH 4/5] osduld: Use device->release instead of internal kref
Date: Thu, 29 Oct 2009 18:03:06 +0000	[thread overview]
Message-ID: <1256839386.7191.31.camel@mulgrave.site> (raw)
In-Reply-To: <4AE9D5EB.7080202@panasas.com>

On Thu, 2009-10-29 at 19:50 +0200, Boaz Harrosh wrote:
> Some thing like below. 
> 
> There is to much knolage of device in my opinion. To much fidling
> of private device members. What when some new members are added?

What private device members ... the pieces you fill in are the public
ones.  If you want a macro to do that, I'm sure Greg would be
amenable ...

> I hate it.

Because you have to type six more lines of code?  To me it looks cleaner
because there's only a single allocation instead of two and now no need
of chaining destructors because everything goes together thus making the
lifetime rules more obvious and robust.

It also saves memory because it has two fewer pointers.

James


> (compile tested only)
> ---
> git diff --stat -p drivers/scsi/osd/osd_uld.c
>  drivers/scsi/osd/osd_uld.c |   35 ++++++++++++++++++-----------------
>  1 files changed, 18 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
> index 25ef993..5f308be 100644
> --- a/drivers/scsi/osd/osd_uld.c
> +++ b/drivers/scsi/osd/osd_uld.c
> @@ -87,7 +87,7 @@ struct osd_uld_device {
>  	struct osd_dev od;
>  	struct osd_dev_info odi;
>  	struct gendisk *disk;
> -	struct device *class_member;
> +	struct device class_dev;
>  	typeof(((struct device *)NULL)->release) save_release;
>  };
>  
> @@ -316,7 +316,7 @@ void osduld_put_device(struct osd_dev *od)
>  		if (odh->file)
>  			fput(odh->file);
>  		else
> -			put_device(oud->class_member);
> +			put_device(&oud->class_dev);
>  		__uld_put(oud);
>  		kfree(odh);
>  	}
> @@ -378,7 +378,6 @@ static void __remove(struct device *dev)
>  	struct scsi_device *scsi_device = oud->od.scsi_device;
>  
>  	kfree(oud->odi.osdname);
> -	oud->save_release(oud->class_member);
>  
>  	if (oud->cdev.owner)
>  		cdev_del(&oud->cdev);
> @@ -464,16 +463,20 @@ static int osd_probe(struct device *dev)
>  		goto err_put_disk;
>  	}
>  
> -	/* class_member */
> -	oud->class_member = device_create(&osd_uld_class, dev,
> -		MKDEV(SCSI_OSD_MAJOR, oud->minor), oud, disk->disk_name);
> -	if (IS_ERR(oud->class_member)) {
> -		OSD_ERR("class_device_create failed\n");
> -		error = PTR_ERR(oud->class_member);
> +	/* class device member */
> +	oud->class_dev.devt = MKDEV(SCSI_OSD_MAJOR, oud->minor);
> +	oud->class_dev.class = &osd_uld_class;
> +	oud->class_dev.parent = dev;
> +	oud->class_dev.release = __remove;
> +	dev_set_drvdata(&oud->class_dev, oud);
> +
> +	error = kobject_set_name(&oud->class_dev.kobj, disk->disk_name);
> +	if (error)
> +		goto err_put_cdev;
> +
> +	error = device_register(&oud->class_dev);
> +	if (error)
>  		goto err_put_cdev;
> -	}
> -	oud->save_release = oud->class_member->release;
> -	oud->class_member->release = __remove;
>  
>  	__uld_get(oud);
>  
> @@ -504,9 +507,7 @@ static int osd_remove(struct device *dev)
>  			scsi_device);
>  	}
>  
> -	if (oud->class_member)
> -		device_destroy(&osd_uld_class,
> -			       MKDEV(SCSI_OSD_MAJOR, oud->minor));
> +	device_unregister(&oud->class_dev);
>  
>  	__uld_put(oud);
>  	return 0;
> @@ -514,12 +515,12 @@ static int osd_remove(struct device *dev)
>  
>  static void __uld_get(struct osd_uld_device *oud)
>  {
> -	get_device(oud->class_member);
> +	get_device(&oud->class_dev);
>  }
>  
>  static void __uld_put(struct osd_uld_device *oud)
>  {
> -	put_device(oud->class_member);
> +	put_device(&oud->class_dev);
>  }
>  
>  /*
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2009-10-29 18:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-26 16:51 [PATCHSET 0/5] osd: Revised patches for the 2.6.33 merge window Boaz Harrosh
2009-10-26 16:56 ` [PATCH 1/5] libosd: osd_dev_is_ver1 - Minor API cleanup Boaz Harrosh
2009-10-26 16:57 ` [PATCH 2/5] libosd: osd_sense: OSD_CFO_PERMISSIONS Boaz Harrosh
2009-10-26 16:57 ` [PATCH 3/5] osduld: Ref-counting bug fix Boaz Harrosh
2009-10-26 16:58 ` [PATCH 4/5] osduld: Use device->release instead of internal kref Boaz Harrosh
2009-10-29 17:11   ` James Bottomley
2009-10-29 17:24     ` Boaz Harrosh
2009-10-29 17:41       ` James Bottomley
2009-10-29 17:50         ` Boaz Harrosh
2009-10-29 18:03           ` James Bottomley [this message]
2009-10-29 18:10             ` Boaz Harrosh
2009-10-29 18:05           ` Boaz Harrosh
2009-10-29 17:58         ` Boaz Harrosh
2009-10-29 18:06           ` James Bottomley
2009-11-01 16:43   ` [PATCH 4/5 version 2] " Boaz Harrosh
2009-10-26 16:58 ` [PATCH 5/5] libosd: osd_dev_info: Unique Identification of an OSD device Boaz Harrosh
2009-11-01 16:45   ` [PATCH 5/5 version2] " Boaz Harrosh

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=1256839386.7191.31.camel@mulgrave.site \
    --to=james.bottomley@hansenpartnership.com \
    --cc=bharrosh@panasas.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=osd-dev@open-osd.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