[lustre-devel] [PATCH 17/21] lustre: obdclass: result of try_module_get() should not be ignored.

NeilBrown neilb at suse.com
Sun Feb 10 21:01:42 PST 2019


On Mon, Feb 11 2019, James Simmons wrote:

>> If try_module_get() fails, the open must fail.
>> 
>> In practice this should be impossible, but it is
>> best to make the code look right.
>
> I remembar having discussion with Greg about this approach in libcfs.
> He though it was racey to do this in general. The discussion was a
> while ago so I need to dig up the thread. In the end we remove the
> whole module handling in the xxx_open() and such.

Yes, you are right. This should just be removed.
This is a chardev, and the .owner of a chardev will always have a
reference held while the device is open - cdev_get/cdev_put ensure that.

We can just get rid of the obd_class_open and obd_class_release.

I'll drop this patch and replace it.

Thanks,
NeilBrown


>  
>> Signed-off-by: NeilBrown <neilb at suse.com>
>> ---
>>  drivers/staging/lustre/lustre/obdclass/class_obd.c |    3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
>> index 48d1dabafa65..982d47b6f50e 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
>> @@ -548,8 +548,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
>>  /*  opening /dev/obd */
>>  static int obd_class_open(struct inode *inode, struct file *file)
>>  {
>> -	try_module_get(THIS_MODULE);
>> -	return 0;
>> +	return try_module_get(THIS_MODULE) ? 0 : -ENODEV;
>>  }
>>  
>>  /*  closing /dev/obd */
>> 
>> 
>> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190211/319ccd7c/attachment.sig>


More information about the lustre-devel mailing list