@@ -909,30 +909,29 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt)
909
909
{
910
910
int ret ;
911
911
struct p9_fid * fid ;
912
- unsigned long flags ;
913
912
914
913
p9_debug (P9_DEBUG_FID , "clnt %p\n" , clnt );
915
914
fid = kmalloc (sizeof (struct p9_fid ), GFP_KERNEL );
916
915
if (!fid )
917
916
return NULL ;
918
917
919
- ret = p9_idpool_get (clnt -> fidpool );
920
- if (ret < 0 )
921
- goto error ;
922
- fid -> fid = ret ;
923
-
924
918
memset (& fid -> qid , 0 , sizeof (struct p9_qid ));
925
919
fid -> mode = -1 ;
926
920
fid -> uid = current_fsuid ();
927
921
fid -> clnt = clnt ;
928
922
fid -> rdir = NULL ;
929
- spin_lock_irqsave (& clnt -> lock , flags );
930
- list_add (& fid -> flist , & clnt -> fidlist );
931
- spin_unlock_irqrestore (& clnt -> lock , flags );
923
+ fid -> fid = 0 ;
932
924
933
- return fid ;
925
+ idr_preload (GFP_KERNEL );
926
+ spin_lock_irq (& clnt -> lock );
927
+ ret = idr_alloc_u32 (& clnt -> fids , fid , & fid -> fid , P9_NOFID - 1 ,
928
+ GFP_NOWAIT );
929
+ spin_unlock_irq (& clnt -> lock );
930
+ idr_preload_end ();
931
+
932
+ if (!ret )
933
+ return fid ;
934
934
935
- error :
936
935
kfree (fid );
937
936
return NULL ;
938
937
}
@@ -944,9 +943,8 @@ static void p9_fid_destroy(struct p9_fid *fid)
944
943
945
944
p9_debug (P9_DEBUG_FID , "fid %d\n" , fid -> fid );
946
945
clnt = fid -> clnt ;
947
- p9_idpool_put (fid -> fid , clnt -> fidpool );
948
946
spin_lock_irqsave (& clnt -> lock , flags );
949
- list_del ( & fid -> flist );
947
+ idr_remove ( & clnt -> fids , fid -> fid );
950
948
spin_unlock_irqrestore (& clnt -> lock , flags );
951
949
kfree (fid -> rdir );
952
950
kfree (fid );
@@ -1029,7 +1027,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
1029
1027
memcpy (clnt -> name , client_id , strlen (client_id ) + 1 );
1030
1028
1031
1029
spin_lock_init (& clnt -> lock );
1032
- INIT_LIST_HEAD (& clnt -> fidlist );
1030
+ idr_init (& clnt -> fids );
1033
1031
1034
1032
err = p9_tag_init (clnt );
1035
1033
if (err < 0 )
@@ -1049,18 +1047,12 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
1049
1047
goto destroy_tagpool ;
1050
1048
}
1051
1049
1052
- clnt -> fidpool = p9_idpool_create ();
1053
- if (IS_ERR (clnt -> fidpool )) {
1054
- err = PTR_ERR (clnt -> fidpool );
1055
- goto put_trans ;
1056
- }
1057
-
1058
1050
p9_debug (P9_DEBUG_MUX , "clnt %p trans %p msize %d protocol %d\n" ,
1059
1051
clnt , clnt -> trans_mod , clnt -> msize , clnt -> proto_version );
1060
1052
1061
1053
err = clnt -> trans_mod -> create (clnt , dev_name , options );
1062
1054
if (err )
1063
- goto destroy_fidpool ;
1055
+ goto put_trans ;
1064
1056
1065
1057
if (clnt -> msize > clnt -> trans_mod -> maxsize )
1066
1058
clnt -> msize = clnt -> trans_mod -> maxsize ;
@@ -1073,8 +1065,6 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
1073
1065
1074
1066
close_trans :
1075
1067
clnt -> trans_mod -> close (clnt );
1076
- destroy_fidpool :
1077
- p9_idpool_destroy (clnt -> fidpool );
1078
1068
put_trans :
1079
1069
v9fs_put_trans (clnt -> trans_mod );
1080
1070
destroy_tagpool :
@@ -1087,7 +1077,8 @@ EXPORT_SYMBOL(p9_client_create);
1087
1077
1088
1078
void p9_client_destroy (struct p9_client * clnt )
1089
1079
{
1090
- struct p9_fid * fid , * fidptr ;
1080
+ struct p9_fid * fid ;
1081
+ int id ;
1091
1082
1092
1083
p9_debug (P9_DEBUG_MUX , "clnt %p\n" , clnt );
1093
1084
@@ -1096,14 +1087,11 @@ void p9_client_destroy(struct p9_client *clnt)
1096
1087
1097
1088
v9fs_put_trans (clnt -> trans_mod );
1098
1089
1099
- list_for_each_entry_safe ( fid , fidptr , & clnt -> fidlist , flist ) {
1090
+ idr_for_each_entry ( & clnt -> fids , fid , id ) {
1100
1091
pr_info ("Found fid %d not clunked\n" , fid -> fid );
1101
1092
p9_fid_destroy (fid );
1102
1093
}
1103
1094
1104
- if (clnt -> fidpool )
1105
- p9_idpool_destroy (clnt -> fidpool );
1106
-
1107
1095
p9_tag_cleanup (clnt );
1108
1096
1109
1097
kfree (clnt );
0 commit comments