@@ -562,11 +562,12 @@ __cold bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk,
562562
563563static struct io_kiocb * io_poll_find (struct io_ring_ctx * ctx , bool poll_only ,
564564 struct io_cancel_data * cd ,
565+ struct io_hash_bucket hash_table [],
565566 struct io_hash_bucket * * out_bucket )
566567{
567568 struct io_kiocb * req ;
568569 u32 index = hash_long (cd -> data , ctx -> cancel_hash_bits );
569- struct io_hash_bucket * hb = & ctx -> cancel_hash [index ];
570+ struct io_hash_bucket * hb = & hash_table [index ];
570571
571572 * out_bucket = NULL ;
572573
@@ -590,6 +591,7 @@ static struct io_kiocb *io_poll_find(struct io_ring_ctx *ctx, bool poll_only,
590591
591592static struct io_kiocb * io_poll_file_find (struct io_ring_ctx * ctx ,
592593 struct io_cancel_data * cd ,
594+ struct io_hash_bucket hash_table [],
593595 struct io_hash_bucket * * out_bucket )
594596{
595597 struct io_kiocb * req ;
@@ -598,7 +600,7 @@ static struct io_kiocb *io_poll_file_find(struct io_ring_ctx *ctx,
598600 * out_bucket = NULL ;
599601
600602 for (i = 0 ; i < (1U << ctx -> cancel_hash_bits ); i ++ ) {
601- struct io_hash_bucket * hb = & ctx -> cancel_hash [i ];
603+ struct io_hash_bucket * hb = & hash_table [i ];
602604
603605 spin_lock (& hb -> lock );
604606 hlist_for_each_entry (req , & hb -> list , hash_node ) {
@@ -625,15 +627,16 @@ static bool io_poll_disarm(struct io_kiocb *req)
625627 return true;
626628}
627629
628- int io_poll_cancel (struct io_ring_ctx * ctx , struct io_cancel_data * cd )
630+ static int __io_poll_cancel (struct io_ring_ctx * ctx , struct io_cancel_data * cd ,
631+ struct io_hash_bucket hash_table [])
629632{
630633 struct io_hash_bucket * bucket ;
631634 struct io_kiocb * req ;
632635
633636 if (cd -> flags & (IORING_ASYNC_CANCEL_FD |IORING_ASYNC_CANCEL_ANY ))
634- req = io_poll_file_find (ctx , cd , & bucket );
637+ req = io_poll_file_find (ctx , cd , ctx -> cancel_hash , & bucket );
635638 else
636- req = io_poll_find (ctx , false, cd , & bucket );
639+ req = io_poll_find (ctx , false, cd , ctx -> cancel_hash , & bucket );
637640
638641 if (req )
639642 io_poll_cancel_req (req );
@@ -642,6 +645,11 @@ int io_poll_cancel(struct io_ring_ctx *ctx, struct io_cancel_data *cd)
642645 return req ? 0 : - ENOENT ;
643646}
644647
648+ int io_poll_cancel (struct io_ring_ctx * ctx , struct io_cancel_data * cd )
649+ {
650+ return __io_poll_cancel (ctx , cd , ctx -> cancel_hash );
651+ }
652+
645653static __poll_t io_poll_parse_events (const struct io_uring_sqe * sqe ,
646654 unsigned int flags )
647655{
@@ -737,7 +745,7 @@ int io_poll_remove(struct io_kiocb *req, unsigned int issue_flags)
737745 int ret2 , ret = 0 ;
738746 bool locked ;
739747
740- preq = io_poll_find (ctx , true, & cd , & bucket );
748+ preq = io_poll_find (ctx , true, & cd , ctx -> cancel_hash , & bucket );
741749 if (preq )
742750 ret2 = io_poll_disarm (preq );
743751 if (bucket )
0 commit comments