@@ -239,7 +239,7 @@ struct fcloop_nport {
239
239
struct fcloop_tport * tport ;
240
240
struct fcloop_lport * lport ;
241
241
struct list_head nport_list ;
242
- struct kref ref ;
242
+ refcount_t ref ;
243
243
u64 node_name ;
244
244
u64 port_name ;
245
245
u32 port_role ;
@@ -274,7 +274,7 @@ struct fcloop_fcpreq {
274
274
u32 inistate ;
275
275
bool active ;
276
276
bool aborted ;
277
- struct kref ref ;
277
+ refcount_t ref ;
278
278
struct work_struct fcp_rcv_work ;
279
279
struct work_struct abort_rcv_work ;
280
280
struct work_struct tio_done_work ;
@@ -534,24 +534,18 @@ fcloop_tgt_discovery_evt(struct nvmet_fc_target_port *tgtport)
534
534
}
535
535
536
536
static void
537
- fcloop_tfcp_req_free (struct kref * ref )
537
+ fcloop_tfcp_req_put (struct fcloop_fcpreq * tfcp_req )
538
538
{
539
- struct fcloop_fcpreq * tfcp_req =
540
- container_of ( ref , struct fcloop_fcpreq , ref ) ;
539
+ if (! refcount_dec_and_test ( & tfcp_req -> ref ))
540
+ return ;
541
541
542
542
kfree (tfcp_req );
543
543
}
544
544
545
- static void
546
- fcloop_tfcp_req_put (struct fcloop_fcpreq * tfcp_req )
547
- {
548
- kref_put (& tfcp_req -> ref , fcloop_tfcp_req_free );
549
- }
550
-
551
545
static int
552
546
fcloop_tfcp_req_get (struct fcloop_fcpreq * tfcp_req )
553
547
{
554
- return kref_get_unless_zero (& tfcp_req -> ref );
548
+ return refcount_inc_not_zero (& tfcp_req -> ref );
555
549
}
556
550
557
551
static void
@@ -748,7 +742,7 @@ fcloop_fcp_req(struct nvme_fc_local_port *localport,
748
742
INIT_WORK (& tfcp_req -> fcp_rcv_work , fcloop_fcp_recv_work );
749
743
INIT_WORK (& tfcp_req -> abort_rcv_work , fcloop_fcp_abort_recv_work );
750
744
INIT_WORK (& tfcp_req -> tio_done_work , fcloop_tgt_fcprqst_done_work );
751
- kref_init (& tfcp_req -> ref );
745
+ refcount_set (& tfcp_req -> ref , 1 );
752
746
753
747
queue_work (nvmet_wq , & tfcp_req -> fcp_rcv_work );
754
748
@@ -1001,24 +995,18 @@ fcloop_fcp_abort(struct nvme_fc_local_port *localport,
1001
995
}
1002
996
1003
997
static void
1004
- fcloop_nport_free (struct kref * ref )
998
+ fcloop_nport_put (struct fcloop_nport * nport )
1005
999
{
1006
- struct fcloop_nport * nport =
1007
- container_of ( ref , struct fcloop_nport , ref ) ;
1000
+ if (! refcount_dec_and_test ( & nport -> ref ))
1001
+ return ;
1008
1002
1009
1003
kfree (nport );
1010
1004
}
1011
1005
1012
- static void
1013
- fcloop_nport_put (struct fcloop_nport * nport )
1014
- {
1015
- kref_put (& nport -> ref , fcloop_nport_free );
1016
- }
1017
-
1018
1006
static int
1019
1007
fcloop_nport_get (struct fcloop_nport * nport )
1020
1008
{
1021
- return kref_get_unless_zero (& nport -> ref );
1009
+ return refcount_inc_not_zero (& nport -> ref );
1022
1010
}
1023
1011
1024
1012
static void
@@ -1249,7 +1237,7 @@ fcloop_alloc_nport(const char *buf, size_t count, bool remoteport)
1249
1237
newnport -> port_role = opts -> roles ;
1250
1238
if (opts -> mask & NVMF_OPT_FCADDR )
1251
1239
newnport -> port_id = opts -> fcaddr ;
1252
- kref_init (& newnport -> ref );
1240
+ refcount_set (& newnport -> ref , 1 );
1253
1241
1254
1242
spin_lock_irqsave (& fcloop_lock , flags );
1255
1243
0 commit comments