@@ -1127,8 +1127,14 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
1127
1127
else if (zc -> done_io )
1128
1128
ret = zc -> done_io ;
1129
1129
1130
- io_notif_flush (zc -> notif );
1131
- req -> flags &= ~REQ_F_NEED_CLEANUP ;
1130
+ /*
1131
+ * If we're in io-wq we can't rely on tw ordering guarantees, defer
1132
+ * flushing notif to io_send_zc_cleanup()
1133
+ */
1134
+ if (!(issue_flags & IO_URING_F_UNLOCKED )) {
1135
+ io_notif_flush (zc -> notif );
1136
+ req -> flags &= ~REQ_F_NEED_CLEANUP ;
1137
+ }
1132
1138
io_req_set_res (req , ret , IORING_CQE_F_MORE );
1133
1139
return IOU_OK ;
1134
1140
}
@@ -1182,17 +1188,25 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)
1182
1188
req_set_fail (req );
1183
1189
}
1184
1190
/* fast path, check for non-NULL to avoid function call */
1185
- if (kmsg -> free_iov )
1191
+ if (kmsg -> free_iov ) {
1186
1192
kfree (kmsg -> free_iov );
1193
+ kmsg -> free_iov = NULL ;
1194
+ }
1187
1195
1188
1196
io_netmsg_recycle (req , issue_flags );
1189
1197
if (ret >= 0 )
1190
1198
ret += sr -> done_io ;
1191
1199
else if (sr -> done_io )
1192
1200
ret = sr -> done_io ;
1193
1201
1194
- io_notif_flush (sr -> notif );
1195
- req -> flags &= ~REQ_F_NEED_CLEANUP ;
1202
+ /*
1203
+ * If we're in io-wq we can't rely on tw ordering guarantees, defer
1204
+ * flushing notif to io_send_zc_cleanup()
1205
+ */
1206
+ if (!(issue_flags & IO_URING_F_UNLOCKED )) {
1207
+ io_notif_flush (sr -> notif );
1208
+ req -> flags &= ~REQ_F_NEED_CLEANUP ;
1209
+ }
1196
1210
io_req_set_res (req , ret , IORING_CQE_F_MORE );
1197
1211
return IOU_OK ;
1198
1212
}
0 commit comments