4242#include <linux/poll.h>
4343#include <linux/sched.h>
4444#include <linux/file.h>
45- #include <linux/mount.h>
45+ #include <linux/cdev.h>
46+ #include <linux/anon_inodes.h>
4647
4748#include <asm/uaccess.h>
4849
@@ -52,8 +53,6 @@ MODULE_AUTHOR("Roland Dreier");
5253MODULE_DESCRIPTION ("InfiniBand userspace verbs access" );
5354MODULE_LICENSE ("Dual BSD/GPL" );
5455
55- #define INFINIBANDEVENTFS_MAGIC 0x49426576 /* "IBev" */
56-
5756enum {
5857 IB_UVERBS_MAJOR = 231 ,
5958 IB_UVERBS_BASE_MINOR = 192 ,
@@ -109,8 +108,6 @@ static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
109108 [IB_USER_VERBS_CMD_DESTROY_SRQ ] = ib_uverbs_destroy_srq ,
110109};
111110
112- static struct vfsmount * uverbs_event_mnt ;
113-
114111static void ib_uverbs_add_one (struct ib_device * device );
115112static void ib_uverbs_remove_one (struct ib_device * device );
116113
@@ -490,7 +487,6 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
490487 int is_async , int * fd )
491488{
492489 struct ib_uverbs_event_file * ev_file ;
493- struct path path ;
494490 struct file * filp ;
495491 int ret ;
496492
@@ -513,27 +509,16 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
513509 goto err ;
514510 }
515511
516- /*
517- * fops_get() can't fail here, because we're coming from a
518- * system call on a uverbs file, which will already have a
519- * module reference.
520- */
521- path .mnt = uverbs_event_mnt ;
522- path .dentry = uverbs_event_mnt -> mnt_root ;
523- path_get (& path );
524- filp = alloc_file (& path , FMODE_READ , fops_get (& uverbs_event_fops ));
512+ filp = anon_inode_getfile ("[uverbs-event]" , & uverbs_event_fops ,
513+ ev_file , O_RDONLY );
525514 if (!filp ) {
526515 ret = - ENFILE ;
527516 goto err_fd ;
528517 }
529518
530- filp -> private_data = ev_file ;
531-
532519 return filp ;
533520
534521err_fd :
535- fops_put (& uverbs_event_fops );
536- path_put (& path );
537522 put_unused_fd (* fd );
538523
539524err :
@@ -854,21 +839,6 @@ static void ib_uverbs_remove_one(struct ib_device *device)
854839 kfree (uverbs_dev );
855840}
856841
857- static int uverbs_event_get_sb (struct file_system_type * fs_type , int flags ,
858- const char * dev_name , void * data ,
859- struct vfsmount * mnt )
860- {
861- return get_sb_pseudo (fs_type , "infinibandevent:" , NULL ,
862- INFINIBANDEVENTFS_MAGIC , mnt );
863- }
864-
865- static struct file_system_type uverbs_event_fs = {
866- /* No owner field so module can be unloaded */
867- .name = "infinibandeventfs" ,
868- .get_sb = uverbs_event_get_sb ,
869- .kill_sb = kill_litter_super
870- };
871-
872842static int __init ib_uverbs_init (void )
873843{
874844 int ret ;
@@ -893,33 +863,14 @@ static int __init ib_uverbs_init(void)
893863 goto out_class ;
894864 }
895865
896- ret = register_filesystem (& uverbs_event_fs );
897- if (ret ) {
898- printk (KERN_ERR "user_verbs: couldn't register infinibandeventfs\n" );
899- goto out_class ;
900- }
901-
902- uverbs_event_mnt = kern_mount (& uverbs_event_fs );
903- if (IS_ERR (uverbs_event_mnt )) {
904- ret = PTR_ERR (uverbs_event_mnt );
905- printk (KERN_ERR "user_verbs: couldn't mount infinibandeventfs\n" );
906- goto out_fs ;
907- }
908-
909866 ret = ib_register_client (& uverbs_client );
910867 if (ret ) {
911868 printk (KERN_ERR "user_verbs: couldn't register client\n" );
912- goto out_mnt ;
869+ goto out_class ;
913870 }
914871
915872 return 0 ;
916873
917- out_mnt :
918- mntput (uverbs_event_mnt );
919-
920- out_fs :
921- unregister_filesystem (& uverbs_event_fs );
922-
923874out_class :
924875 class_destroy (uverbs_class );
925876
@@ -933,8 +884,6 @@ static int __init ib_uverbs_init(void)
933884static void __exit ib_uverbs_cleanup (void )
934885{
935886 ib_unregister_client (& uverbs_client );
936- mntput (uverbs_event_mnt );
937- unregister_filesystem (& uverbs_event_fs );
938887 class_destroy (uverbs_class );
939888 unregister_chrdev_region (IB_UVERBS_BASE_DEV , IB_UVERBS_MAX_DEVICES );
940889 if (overflow_maj )
0 commit comments