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

James Simmons jsimmons at infradead.org
Sun Feb 10 20:22:35 PST 2019


> 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.
 
> 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 */
> 
> 
> 


More information about the lustre-devel mailing list