From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDE3EC433EB for ; Fri, 26 Mar 2021 15:53:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC41B601FC for ; Fri, 26 Mar 2021 15:53:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231270AbhCZPw4 (ORCPT ); Fri, 26 Mar 2021 11:52:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230372AbhCZPwO (ORCPT ); Fri, 26 Mar 2021 11:52:14 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AAABC0613BB for ; Fri, 26 Mar 2021 08:52:13 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id k8so5828796iop.12 for ; Fri, 26 Mar 2021 08:52:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rN2PgEUoE0VAabXTyRei4LXsCskRh+40CD93NSR8D88=; b=KJ3URsr2+El4FxfCA8c7L51+fhXuXtrsjZWFWyHE7R6k9nTc1M1DlINsINUJirgUPB Z3wZpiceIuWWtTJQGTpkH81BrxXE0dP7vWS8VyTyZ0GxJtAnfpYu/9U/bTunxyCglnV2 k0C4L+vUQfHrmvzRBqPDqXVxXOSFxpfijM8uZzeGrxWbiwbsW2FrASsyTTbCJPmZWi3C /CkCeJW6rxcExu8d4zzYvZbYjyhmdDP1E0Nwl1JVIUXH4QrubWe3Cb5kITSHSxy5SqZr qazYNDOQvkrtCOzIoaIjQGVtShsjA35zEfyjFkgvEBMb6dpMuWpdderVewkojUfWElfD 8ikA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rN2PgEUoE0VAabXTyRei4LXsCskRh+40CD93NSR8D88=; b=lstzWDZ1JiML1WOtS367SPOSLkV0pit6fJUOUJqWP6f4+6w1X9w9oTZh5Ul9aaHPhT TwaN1bXAkVjMPRR41IvMkFb93Axc8BNsFFEVJkHAlxDiD8jAz5pjxfRshjrir/4aKf6x LIjmY2SlDd7QDDWYHCmhF4H6bYpAVZyupJm2t9pgtaKMOH/4L6QtLe/MJHxI4MQ7Xdfx HlE8XG4pUsowqLdLq6uMP2qapcactHKjCaUiIayZokxMERxS9uOO62nmMxagDaBQmKCu +Ab+ZW7w7ygocP6XFFZCERr0TFd4MBKvSbB209tVuTC1YlQ6ilbGIVFCtsqz/OO8yJ/9 fkyA== X-Gm-Message-State: AOAM531OnnCbVSMxwVvIdpug3jamYY1ezabfOwRIzMa1OJYi52B/22Bt 3htKkv7aHG3ZpuqDopnR/eVLRw== X-Google-Smtp-Source: ABdhPJwbc9ed6etEN77W64nWaH3EB8QHDF36SzXvH0lrD5tJF02+SGtboS+GTw/fc3JkC5P7hE7VTg== X-Received: by 2002:a05:6638:ec7:: with SMTP id q7mr12573466jas.54.1616773933022; Fri, 26 Mar 2021 08:52:13 -0700 (PDT) Received: from p1.localdomain ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id a7sm4456337ilj.64.2021.03.26.08.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Mar 2021 08:52:12 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: torvalds@linux-foundation.org, ebiederm@xmission.com, metze@samba.org, oleg@redhat.com, linux-kernel@vger.kernel.org, Pavel Begunkov , Jens Axboe Subject: [PATCH 07/10] io_uring: fix timeout cancel return code Date: Fri, 26 Mar 2021 09:51:25 -0600 Message-Id: <20210326155128.1057078-13-axboe@kernel.dk> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210326155128.1057078-1-axboe@kernel.dk> References: <20210326155128.1057078-1-axboe@kernel.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Begunkov When we cancel a timeout we should emit a sensible return code, like -ECANCELED but not 0, otherwise it may trick users. Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/7b0ad1065e3bd1994722702bd0ba9e7bc9b0683b.1616696997.git.asml.silence@gmail.com Signed-off-by: Jens Axboe --- fs/io_uring.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 350418a88db3..4d0cb2548a67 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1247,7 +1247,7 @@ static void io_queue_async_work(struct io_kiocb *req) io_queue_linked_timeout(link); } -static void io_kill_timeout(struct io_kiocb *req) +static void io_kill_timeout(struct io_kiocb *req, int status) { struct io_timeout_data *io = req->async_data; int ret; @@ -1257,7 +1257,7 @@ static void io_kill_timeout(struct io_kiocb *req) atomic_set(&req->ctx->cq_timeouts, atomic_read(&req->ctx->cq_timeouts) + 1); list_del_init(&req->timeout.list); - io_cqring_fill_event(req, 0); + io_cqring_fill_event(req, status); io_put_req_deferred(req, 1); } } @@ -1274,7 +1274,7 @@ static bool io_kill_timeouts(struct io_ring_ctx *ctx, struct task_struct *tsk, spin_lock_irq(&ctx->completion_lock); list_for_each_entry_safe(req, tmp, &ctx->timeout_list, timeout.list) { if (io_match_task(req, tsk, files)) { - io_kill_timeout(req); + io_kill_timeout(req, -ECANCELED); canceled++; } } @@ -1326,7 +1326,7 @@ static void io_flush_timeouts(struct io_ring_ctx *ctx) break; list_del_init(&req->timeout.list); - io_kill_timeout(req); + io_kill_timeout(req, 0); } while (!list_empty(&ctx->timeout_list)); ctx->cq_last_tm_flush = seq; -- 2.31.0