@@ -448,24 +448,6 @@ static struct io_kiocb *__io_prep_linked_timeout(struct io_kiocb *req)
448
448
return req -> link ;
449
449
}
450
450
451
- static inline struct io_kiocb * io_prep_linked_timeout (struct io_kiocb * req )
452
- {
453
- if (likely (!(req -> flags & REQ_F_ARM_LTIMEOUT )))
454
- return NULL ;
455
- return __io_prep_linked_timeout (req );
456
- }
457
-
458
- static noinline void __io_arm_ltimeout (struct io_kiocb * req )
459
- {
460
- io_queue_linked_timeout (__io_prep_linked_timeout (req ));
461
- }
462
-
463
- static inline void io_arm_ltimeout (struct io_kiocb * req )
464
- {
465
- if (unlikely (req -> flags & REQ_F_ARM_LTIMEOUT ))
466
- __io_arm_ltimeout (req );
467
- }
468
-
469
451
static void io_prep_async_work (struct io_kiocb * req )
470
452
{
471
453
const struct io_issue_def * def = & io_issue_defs [req -> opcode ];
@@ -518,7 +500,6 @@ static void io_prep_async_link(struct io_kiocb *req)
518
500
519
501
static void io_queue_iowq (struct io_kiocb * req )
520
502
{
521
- struct io_kiocb * link = io_prep_linked_timeout (req );
522
503
struct io_uring_task * tctx = req -> tctx ;
523
504
524
505
BUG_ON (!tctx );
@@ -543,8 +524,6 @@ static void io_queue_iowq(struct io_kiocb *req)
543
524
544
525
trace_io_uring_queue_async_work (req , io_wq_is_hashed (& req -> work ));
545
526
io_wq_enqueue (tctx -> io_wq , & req -> work );
546
- if (link )
547
- io_queue_linked_timeout (link );
548
527
}
549
528
550
529
static void io_req_queue_iowq_tw (struct io_kiocb * req , io_tw_token_t tw )
@@ -1724,15 +1703,22 @@ static bool io_assign_file(struct io_kiocb *req, const struct io_issue_def *def,
1724
1703
return !!req -> file ;
1725
1704
}
1726
1705
1706
+ #define REQ_ISSUE_SLOW_FLAGS (REQ_F_CREDS | REQ_F_ARM_LTIMEOUT)
1707
+
1727
1708
static inline int __io_issue_sqe (struct io_kiocb * req ,
1728
1709
unsigned int issue_flags ,
1729
1710
const struct io_issue_def * def )
1730
1711
{
1731
1712
const struct cred * creds = NULL ;
1713
+ struct io_kiocb * link = NULL ;
1732
1714
int ret ;
1733
1715
1734
- if (unlikely ((req -> flags & REQ_F_CREDS ) && req -> creds != current_cred ()))
1735
- creds = override_creds (req -> creds );
1716
+ if (unlikely (req -> flags & REQ_ISSUE_SLOW_FLAGS )) {
1717
+ if ((req -> flags & REQ_F_CREDS ) && req -> creds != current_cred ())
1718
+ creds = override_creds (req -> creds );
1719
+ if (req -> flags & REQ_F_ARM_LTIMEOUT )
1720
+ link = __io_prep_linked_timeout (req );
1721
+ }
1736
1722
1737
1723
if (!def -> audit_skip )
1738
1724
audit_uring_entry (req -> opcode );
@@ -1742,8 +1728,12 @@ static inline int __io_issue_sqe(struct io_kiocb *req,
1742
1728
if (!def -> audit_skip )
1743
1729
audit_uring_exit (!ret , ret );
1744
1730
1745
- if (creds )
1746
- revert_creds (creds );
1731
+ if (unlikely (creds || link )) {
1732
+ if (creds )
1733
+ revert_creds (creds );
1734
+ if (link )
1735
+ io_queue_linked_timeout (link );
1736
+ }
1747
1737
1748
1738
return ret ;
1749
1739
}
@@ -1769,7 +1759,6 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
1769
1759
1770
1760
if (ret == IOU_ISSUE_SKIP_COMPLETE ) {
1771
1761
ret = 0 ;
1772
- io_arm_ltimeout (req );
1773
1762
1774
1763
/* If the op doesn't have a file, we're not polling for it */
1775
1764
if ((req -> ctx -> flags & IORING_SETUP_IOPOLL ) && def -> iopoll_queue )
@@ -1824,8 +1813,6 @@ void io_wq_submit_work(struct io_wq_work *work)
1824
1813
else
1825
1814
req_ref_get (req );
1826
1815
1827
- io_arm_ltimeout (req );
1828
-
1829
1816
/* either cancelled or io-wq is dying, so don't touch tctx->iowq */
1830
1817
if (atomic_read (& work -> flags ) & IO_WQ_WORK_CANCEL ) {
1831
1818
fail :
@@ -1941,15 +1928,11 @@ struct file *io_file_get_normal(struct io_kiocb *req, int fd)
1941
1928
static void io_queue_async (struct io_kiocb * req , int ret )
1942
1929
__must_hold (& req - > ctx - > uring_lock )
1943
1930
{
1944
- struct io_kiocb * linked_timeout ;
1945
-
1946
1931
if (ret != - EAGAIN || (req -> flags & REQ_F_NOWAIT )) {
1947
1932
io_req_defer_failed (req , ret );
1948
1933
return ;
1949
1934
}
1950
1935
1951
- linked_timeout = io_prep_linked_timeout (req );
1952
-
1953
1936
switch (io_arm_poll_handler (req , 0 )) {
1954
1937
case IO_APOLL_READY :
1955
1938
io_kbuf_recycle (req , 0 );
@@ -1962,9 +1945,6 @@ static void io_queue_async(struct io_kiocb *req, int ret)
1962
1945
case IO_APOLL_OK :
1963
1946
break ;
1964
1947
}
1965
-
1966
- if (linked_timeout )
1967
- io_queue_linked_timeout (linked_timeout );
1968
1948
}
1969
1949
1970
1950
static inline void io_queue_sqe (struct io_kiocb * req )
0 commit comments