[6/8,SCSI] osduld: use ida_simple_get to handle id.

Submitted by Jonathan Cameron on July 22, 2011, 4:41 p.m.

Details

Message ID 1311352886-4047-7-git-send-email-jic23@cam.ac.uk
State Superseded
Headers show

Commit Message

Jonathan Cameron July 22, 2011, 4:41 p.m.
This does involve additional use of the spin lock in idr.c.
Is this an issue?

Also, some error mangling was needed to keep the interface
the same.  Does this matter or can we return -ENOSPC instead
of -EBUSY?

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
---
 drivers/scsi/osd/osd_uld.c |   22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

Comments

Boaz Harrosh July 22, 2011, 9:47 p.m.
On 07/22/2011 09:41 AM, Jonathan Cameron wrote:
> This does involve additional use of the spin lock in idr.c.
> Is this an issue?
> 

Actually it looks like a bug fix. I had a TODO: to add one.

> Also, some error mangling was needed to keep the interface
> the same.  Does this matter or can we return -ENOSPC instead
> of -EBUSY?
> 

Na. -ENOSPC is just fine. All the osd Application just check for
"any error" not a specific one.

> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>

Ack-by: Boaz Harrosh <bharrosh@panasas.com>

> ---
>  drivers/scsi/osd/osd_uld.c |   22 ++++++++--------------
>  1 files changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
> index b31a8e3..fa849bd 100644
> --- a/drivers/scsi/osd/osd_uld.c
> +++ b/drivers/scsi/osd/osd_uld.c
> @@ -387,7 +387,7 @@ static void __remove(struct device *dev)
>  
>  	if (oud->disk)
>  		put_disk(oud->disk);
> -	ida_remove(&osd_minor_ida, oud->minor);
> +	ida_simple_remove(&osd_minor_ida, oud->minor);
>  
>  	kfree(oud);
>  }
> @@ -403,18 +403,12 @@ static int osd_probe(struct device *dev)
>  	if (scsi_device->type != TYPE_OSD)
>  		return -ENODEV;
>  
> -	do {
> -		if (!ida_pre_get(&osd_minor_ida, GFP_KERNEL))
> -			return -ENODEV;
> -
> -		error = ida_get_new(&osd_minor_ida, &minor);
> -	} while (error == -EAGAIN);
> -
> -	if (error)
> -		return error;
> -	if (minor >= SCSI_OSD_MAX_MINOR) {
> -		error = -EBUSY;
> -		goto err_retract_minor;
> +	minor = ida_simple_get(&osd_minor_ida, 0,
> +			       SCSI_OSD_MAX_MINOR, GFP_KERNEL);
> +	if (minor < 0) {
> +		if (minor == -ENOSPC)
> +			return -EBUSY;

Just drop the translation is fine as well

> +		return minor;
>  	}
>  
>  	error = -ENOMEM;
> @@ -491,7 +485,7 @@ err_free_osd:
>  	dev_set_drvdata(dev, NULL);
>  	kfree(oud);
>  err_retract_minor:
> -	ida_remove(&osd_minor_ida, minor);
> +	ida_simple_remove(&osd_minor_ida, minor);
>  	return error;
>  }
>
Jonathan Cameron July 25, 2011, 11:06 a.m.
On 07/22/11 22:47, Boaz Harrosh wrote:
> On 07/22/2011 09:41 AM, Jonathan Cameron wrote:
>> This does involve additional use of the spin lock in idr.c.
>> Is this an issue?
>>
> 
> Actually it looks like a bug fix. I had a TODO: to add one.
> 
>> Also, some error mangling was needed to keep the interface
>> the same.  Does this matter or can we return -ENOSPC instead
>> of -EBUSY?
>>
> 
> Na. -ENOSPC is just fine. All the osd Application just check for
> "any error" not a specific one.
Cool, I've scrapped the error mangling and added your acked-by
+ removed questions from commit message as you've answered them!

Thanks,

> 
>> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
> 
> Ack-by: Boaz Harrosh <bharrosh@panasas.com>
> 
>> ---
>>  drivers/scsi/osd/osd_uld.c |   22 ++++++++--------------
>>  1 files changed, 8 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
>> index b31a8e3..fa849bd 100644
>> --- a/drivers/scsi/osd/osd_uld.c
>> +++ b/drivers/scsi/osd/osd_uld.c
>> @@ -387,7 +387,7 @@ static void __remove(struct device *dev)
>>  
>>  	if (oud->disk)
>>  		put_disk(oud->disk);
>> -	ida_remove(&osd_minor_ida, oud->minor);
>> +	ida_simple_remove(&osd_minor_ida, oud->minor);
>>  
>>  	kfree(oud);
>>  }
>> @@ -403,18 +403,12 @@ static int osd_probe(struct device *dev)
>>  	if (scsi_device->type != TYPE_OSD)
>>  		return -ENODEV;
>>  
>> -	do {
>> -		if (!ida_pre_get(&osd_minor_ida, GFP_KERNEL))
>> -			return -ENODEV;
>> -
>> -		error = ida_get_new(&osd_minor_ida, &minor);
>> -	} while (error == -EAGAIN);
>> -
>> -	if (error)
>> -		return error;
>> -	if (minor >= SCSI_OSD_MAX_MINOR) {
>> -		error = -EBUSY;
>> -		goto err_retract_minor;
>> +	minor = ida_simple_get(&osd_minor_ida, 0,
>> +			       SCSI_OSD_MAX_MINOR, GFP_KERNEL);
>> +	if (minor < 0) {
>> +		if (minor == -ENOSPC)
>> +			return -EBUSY;
> 
> Just drop the translation is fine as well
> 
>> +		return minor;
>>  	}
>>  
>>  	error = -ENOMEM;
>> @@ -491,7 +485,7 @@ err_free_osd:
>>  	dev_set_drvdata(dev, NULL);
>>  	kfree(oud);
>>  err_retract_minor:
>> -	ida_remove(&osd_minor_ida, minor);
>> +	ida_simple_remove(&osd_minor_ida, minor);
>>  	return error;
>>  }
>>  
> 
>

Patch hide | download patch | download mbox

diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index b31a8e3..fa849bd 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -387,7 +387,7 @@  static void __remove(struct device *dev)
 
 	if (oud->disk)
 		put_disk(oud->disk);
-	ida_remove(&osd_minor_ida, oud->minor);
+	ida_simple_remove(&osd_minor_ida, oud->minor);
 
 	kfree(oud);
 }
@@ -403,18 +403,12 @@  static int osd_probe(struct device *dev)
 	if (scsi_device->type != TYPE_OSD)
 		return -ENODEV;
 
-	do {
-		if (!ida_pre_get(&osd_minor_ida, GFP_KERNEL))
-			return -ENODEV;
-
-		error = ida_get_new(&osd_minor_ida, &minor);
-	} while (error == -EAGAIN);
-
-	if (error)
-		return error;
-	if (minor >= SCSI_OSD_MAX_MINOR) {
-		error = -EBUSY;
-		goto err_retract_minor;
+	minor = ida_simple_get(&osd_minor_ida, 0,
+			       SCSI_OSD_MAX_MINOR, GFP_KERNEL);
+	if (minor < 0) {
+		if (minor == -ENOSPC)
+			return -EBUSY;
+		return minor;
 	}
 
 	error = -ENOMEM;
@@ -491,7 +485,7 @@  err_free_osd:
 	dev_set_drvdata(dev, NULL);
 	kfree(oud);
 err_retract_minor:
-	ida_remove(&osd_minor_ida, minor);
+	ida_simple_remove(&osd_minor_ida, minor);
 	return error;
 }