@@ -239,7 +239,7 @@ struct fcloop_nport {
239239 struct fcloop_tport * tport ;
240240 struct fcloop_lport * lport ;
241241 struct list_head nport_list ;
242- struct kref ref ;
242+ refcount_t ref ;
243243 u64 node_name ;
244244 u64 port_name ;
245245 u32 port_role ;
@@ -274,7 +274,7 @@ struct fcloop_fcpreq {
274274 u32 inistate ;
275275 bool active ;
276276 bool aborted ;
277- struct kref ref ;
277+ refcount_t ref ;
278278 struct work_struct fcp_rcv_work ;
279279 struct work_struct abort_rcv_work ;
280280 struct work_struct tio_done_work ;
@@ -534,24 +534,18 @@ fcloop_tgt_discovery_evt(struct nvmet_fc_target_port *tgtport)
534534}
535535
536536static void
537- fcloop_tfcp_req_free (struct kref * ref )
537+ fcloop_tfcp_req_put (struct fcloop_fcpreq * tfcp_req )
538538{
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 ;
541541
542542 kfree (tfcp_req );
543543}
544544
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-
551545static int
552546fcloop_tfcp_req_get (struct fcloop_fcpreq * tfcp_req )
553547{
554- return kref_get_unless_zero (& tfcp_req -> ref );
548+ return refcount_inc_not_zero (& tfcp_req -> ref );
555549}
556550
557551static void
@@ -748,7 +742,7 @@ fcloop_fcp_req(struct nvme_fc_local_port *localport,
748742 INIT_WORK (& tfcp_req -> fcp_rcv_work , fcloop_fcp_recv_work );
749743 INIT_WORK (& tfcp_req -> abort_rcv_work , fcloop_fcp_abort_recv_work );
750744 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 );
752746
753747 queue_work (nvmet_wq , & tfcp_req -> fcp_rcv_work );
754748
@@ -1001,24 +995,18 @@ fcloop_fcp_abort(struct nvme_fc_local_port *localport,
1001995}
1002996
1003997static void
1004- fcloop_nport_free (struct kref * ref )
998+ fcloop_nport_put (struct fcloop_nport * nport )
1005999{
1006- struct fcloop_nport * nport =
1007- container_of ( ref , struct fcloop_nport , ref ) ;
1000+ if (! refcount_dec_and_test ( & nport -> ref ))
1001+ return ;
10081002
10091003 kfree (nport );
10101004}
10111005
1012- static void
1013- fcloop_nport_put (struct fcloop_nport * nport )
1014- {
1015- kref_put (& nport -> ref , fcloop_nport_free );
1016- }
1017-
10181006static int
10191007fcloop_nport_get (struct fcloop_nport * nport )
10201008{
1021- return kref_get_unless_zero (& nport -> ref );
1009+ return refcount_inc_not_zero (& nport -> ref );
10221010}
10231011
10241012static void
@@ -1249,7 +1237,7 @@ fcloop_alloc_nport(const char *buf, size_t count, bool remoteport)
12491237 newnport -> port_role = opts -> roles ;
12501238 if (opts -> mask & NVMF_OPT_FCADDR )
12511239 newnport -> port_id = opts -> fcaddr ;
1252- kref_init (& newnport -> ref );
1240+ refcount_set (& newnport -> ref , 1 );
12531241
12541242 spin_lock_irqsave (& fcloop_lock , flags );
12551243
0 commit comments