[lustre-devel] [PATCH] lustre: don't manage module refs in obd_class_open/close.

James Simmons jsimmons at infradead.org
Mon Feb 11 20:17:04 PST 2019


> Core Linux code for managed char-devs ensures that the relevant
> module is held active which a char-dev is open - see cdev_get()
> and cdev_put().
> So there is no need for lustre/obd_class to manage the module
> ref count as well.
> 
> As this is all that obd_class_open and obd_class_close do, those
> functions can be removed.

I was planning to do this but didn't get around to it. Thanks.

Reviewed-by: James Simmons <jsimmons at infradead.org>
 
> Signed-off-by: NeilBrown <neilb at suse.com>
> ---
>  drivers/staging/lustre/lustre/obdclass/class_obd.c | 18 +-----------------
>  1 file changed, 1 insertion(+), 17 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> index 84c077ec0116..b8fc74044fe3 100644
> --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
> +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
> @@ -544,20 +544,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
>  	return err;
>  } /* class_handle_ioctl */
>  
> -/*  opening /dev/obd */
> -static int obd_class_open(struct inode *inode, struct file *file)
> -{
> -	try_module_get(THIS_MODULE);
> -	return 0;
> -}
> -
> -/*  closing /dev/obd */
> -static int obd_class_release(struct inode *inode, struct file *file)
> -{
> -	module_put(THIS_MODULE);
> -	return 0;
> -}
> -
>  /* to control /dev/obd */
>  static long obd_class_ioctl(struct file *filp, unsigned int cmd,
>  			    unsigned long arg)
> @@ -575,9 +561,7 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd,
>  /* declare character device */
>  static const struct file_operations obd_psdev_fops = {
>  	.owner		= THIS_MODULE,
> -	.unlocked_ioctl	= obd_class_ioctl,	/* unlocked_ioctl */
> -	.open		= obd_class_open,	/* open */
> -	.release	= obd_class_release,	/* release */
> +	.unlocked_ioctl	= obd_class_ioctl,
>  };
>  
>  /* modules setup */
> -- 
> 2.14.0.rc0.dirty
> 
> 


More information about the lustre-devel mailing list