39
39
#include <linux/mutex.h>
40
40
#include <linux/random.h>
41
41
#include <linux/igmp.h>
42
- #include <linux/idr .h>
42
+ #include <linux/xarray .h>
43
43
#include <linux/inetdevice.h>
44
44
#include <linux/slab.h>
45
45
#include <linux/module.h>
@@ -191,18 +191,19 @@ static struct workqueue_struct *cma_wq;
191
191
static unsigned int cma_pernet_id ;
192
192
193
193
struct cma_pernet {
194
- struct idr tcp_ps ;
195
- struct idr udp_ps ;
196
- struct idr ipoib_ps ;
197
- struct idr ib_ps ;
194
+ struct xarray tcp_ps ;
195
+ struct xarray udp_ps ;
196
+ struct xarray ipoib_ps ;
197
+ struct xarray ib_ps ;
198
198
};
199
199
200
200
static struct cma_pernet * cma_pernet (struct net * net )
201
201
{
202
202
return net_generic (net , cma_pernet_id );
203
203
}
204
204
205
- static struct idr * cma_pernet_idr (struct net * net , enum rdma_ucm_port_space ps )
205
+ static
206
+ struct xarray * cma_pernet_xa (struct net * net , enum rdma_ucm_port_space ps )
206
207
{
207
208
struct cma_pernet * pernet = cma_pernet (net );
208
209
@@ -247,25 +248,25 @@ struct class_port_info_context {
247
248
static int cma_ps_alloc (struct net * net , enum rdma_ucm_port_space ps ,
248
249
struct rdma_bind_list * bind_list , int snum )
249
250
{
250
- struct idr * idr = cma_pernet_idr (net , ps );
251
+ struct xarray * xa = cma_pernet_xa (net , ps );
251
252
252
- return idr_alloc ( idr , bind_list , snum , snum + 1 , GFP_KERNEL );
253
+ return xa_insert ( xa , snum , bind_list , GFP_KERNEL );
253
254
}
254
255
255
256
static struct rdma_bind_list * cma_ps_find (struct net * net ,
256
257
enum rdma_ucm_port_space ps , int snum )
257
258
{
258
- struct idr * idr = cma_pernet_idr (net , ps );
259
+ struct xarray * xa = cma_pernet_xa (net , ps );
259
260
260
- return idr_find ( idr , snum );
261
+ return xa_load ( xa , snum );
261
262
}
262
263
263
264
static void cma_ps_remove (struct net * net , enum rdma_ucm_port_space ps ,
264
265
int snum )
265
266
{
266
- struct idr * idr = cma_pernet_idr (net , ps );
267
+ struct xarray * xa = cma_pernet_xa (net , ps );
267
268
268
- idr_remove ( idr , snum );
269
+ xa_erase ( xa , snum );
269
270
}
270
271
271
272
enum {
@@ -4655,10 +4656,10 @@ static int cma_init_net(struct net *net)
4655
4656
{
4656
4657
struct cma_pernet * pernet = cma_pernet (net );
4657
4658
4658
- idr_init (& pernet -> tcp_ps );
4659
- idr_init (& pernet -> udp_ps );
4660
- idr_init (& pernet -> ipoib_ps );
4661
- idr_init (& pernet -> ib_ps );
4659
+ xa_init (& pernet -> tcp_ps );
4660
+ xa_init (& pernet -> udp_ps );
4661
+ xa_init (& pernet -> ipoib_ps );
4662
+ xa_init (& pernet -> ib_ps );
4662
4663
4663
4664
return 0 ;
4664
4665
}
@@ -4667,10 +4668,10 @@ static void cma_exit_net(struct net *net)
4667
4668
{
4668
4669
struct cma_pernet * pernet = cma_pernet (net );
4669
4670
4670
- idr_destroy ( & pernet -> tcp_ps );
4671
- idr_destroy ( & pernet -> udp_ps );
4672
- idr_destroy ( & pernet -> ipoib_ps );
4673
- idr_destroy ( & pernet -> ib_ps );
4671
+ WARN_ON (! xa_empty ( & pernet -> tcp_ps ) );
4672
+ WARN_ON (! xa_empty ( & pernet -> udp_ps ) );
4673
+ WARN_ON (! xa_empty ( & pernet -> ipoib_ps ) );
4674
+ WARN_ON (! xa_empty ( & pernet -> ib_ps ) );
4674
4675
}
4675
4676
4676
4677
static struct pernet_operations cma_pernet_operations = {
0 commit comments