Whamcloud - gitweb
LU-6245 libcfs: fix racey module handling 64/18964/5
authorJames Simmons <uja.ornl@yahoo.com>
Wed, 23 Mar 2016 23:22:40 +0000 (19:22 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 6 Apr 2016 01:39:37 +0000 (01:39 +0000)
While working on the upstream client Greg pointed out the
current why we handle libcfs module loading with psdev is
very racy. This patch removes the possible race.

Change-Id: Ic86aa9b0d426cc53a239ae81fc92db2d5a2b5c60
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: http://review.whamcloud.com/18964
Reviewed-by: Frank Zago <fzago@cray.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/libcfs/linux/linux-module.c

index c4f578b..54be33a 100644 (file)
@@ -149,27 +149,6 @@ failed:
        RETURN(err);
 }
 
-static int
-libcfs_psdev_open(struct inode * inode, struct file * file)
-{
-       if (!inode)
-               return -EINVAL;
-
-       try_module_get(THIS_MODULE);
-       return 0;
-}
-
-/* called when closing /dev/device */
-static int
-libcfs_psdev_release(struct inode * inode, struct file * file)
-{
-       if (!inode)
-               return -EINVAL;
-
-       module_put(THIS_MODULE);
-       return 0;
-}
-
 static long
 libcfs_psdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
@@ -188,9 +167,8 @@ libcfs_psdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 }
 
 static struct file_operations libcfs_fops = {
+       .owner          = THIS_MODULE,
        .unlocked_ioctl = libcfs_psdev_ioctl,
-       .open           = libcfs_psdev_open,
-       .release        = libcfs_psdev_release
 };
 
 struct miscdevice libcfs_dev = {