From patchwork Wed Oct 19 08:21:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp201778wrs; Wed, 19 Oct 2022 01:38:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7hbo3+X05QoJSbDBgAuouf3E8fJ7Hn40DMXI7JEre/mhL5yCEiSCnQK+wz2cBHNRqFr1qz X-Received: by 2002:a05:6402:1a4d:b0:459:319f:ff80 with SMTP id bf13-20020a0564021a4d00b00459319fff80mr6429349edb.144.1666168739760; Wed, 19 Oct 2022 01:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666168739; cv=none; d=google.com; s=arc-20160816; b=IGmWYb+LTogZjoxhL8V8Raovh71KXZ0OXHnizWZg6mzstXBbdZSvz7lxKzZ9IvVthg 5jmzUsdskLIEK6M6MSXP23pjlQVlsSlVG43j0Mq5ACk8/Un3IRDDlZ5zK4qtZ0gaz8j0 e/J2tyDSeRDyc7GBLd6AMdLH/rP3JhmM42cpwsNtIDg5OGkTaWberROX0vaC88Mh8fgd dNx1eBrARcVuI+vl8SaspECwmiWJ14CfyXywOToE/OaK0yV1AW/MV2dmiNsVAhaO4sam FMBjMsPthx1RkHIUEeMHD9T3JHvo5EmWHYqBThDrmHOYwHKuRwyIT6sD0jkM5QkqI9Us eNIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NihwllnY6AVdg/3Cz/8TgFaBHj1LSocb7Iiup20i7uo=; b=Vd79V6JxznZPzk9GRyoG60G0GdfmEKxYe5kMrOOVqVZ6cbBQFdACx60zgEPDru8yIe yegvfQVAmI1ujWrU3FP+iiv0n0BBcuYti3HOtJMrvcWejU2YohdG4mvK209951wAXhy1 X64GTKjex4T44H1xQMXJTyW1aslb+LdLEZN45W9VbmpUbNmYhstQzxb3EvS9FuMsc/VT 2M5ezMuOinJmjNRoHdLwrdyEBZy3KqfKZIhY+CgR4qD6HLHirt7yoO55U0BaRE/50GFp uZanv3lik1DhmQUJwYbU+EF3IwNxQ7BG6qR6EQgOH98a6nr1oCh3S8m892KzULT3zsKF bxrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iRicA+L0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id tb8-20020a1709078b8800b00781df71dbc1si12514951ejc.174.2022.10.19.01.38.32; Wed, 19 Oct 2022 01:38:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iRicA+L0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229963AbiJSIhr (ORCPT + 99 others); Wed, 19 Oct 2022 04:37:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbiJSIhb (ORCPT ); Wed, 19 Oct 2022 04:37:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14EED5F123; Wed, 19 Oct 2022 01:37:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C8013617D1; Wed, 19 Oct 2022 08:37:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1212C433D6; Wed, 19 Oct 2022 08:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168647; bh=jQ+B1dF/CbazLraF4cxocdEvsIZ59fSeau73fNVHckg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iRicA+L00irScEO/xZO4IdenjyAmtUYc/D8wqRrdGbaUnPoWIz2mglCNJahmdtnCe +Whxb1e7yvNWaXppQ1YjsLO1k2ZAA6zjnkbTMWxOKc3n5MnY849HkWd2PG/ckRwKDg XQNG3TuTT61DKTXuE24s+r/DCN1Zt2i6AIjwtVgM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe Subject: [PATCH 6.0 010/862] io_uring: add custom opcode hooks on fail Date: Wed, 19 Oct 2022 10:21:37 +0200 Message-Id: <20221019083250.464199615@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747104552437536882?= X-GMAIL-MSGID: =?utf-8?q?1747104552437536882?= From: Pavel Begunkov commit a47b255e90395bdb481975ab3d9e96fcf8b3165f upstream. Sometimes we have to do a little bit of a fixup on a request failuer in io_req_complete_failed(). Add a callback in opdef for that. Cc: stable@vger.kernel.org Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/b734cff4e67cb30cca976b9face321023f37549a.1663668091.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/io_uring.c | 4 ++++ io_uring/opdef.h | 1 + 2 files changed, 5 insertions(+) --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -823,8 +823,12 @@ inline void __io_req_complete(struct io_ void io_req_complete_failed(struct io_kiocb *req, s32 res) { + const struct io_op_def *def = &io_op_defs[req->opcode]; + req_set_fail(req); io_req_set_res(req, res, io_put_kbuf(req, IO_URING_F_UNLOCKED)); + if (def->fail) + def->fail(req); io_req_complete_post(req); } --- a/io_uring/opdef.h +++ b/io_uring/opdef.h @@ -36,6 +36,7 @@ struct io_op_def { int (*issue)(struct io_kiocb *, unsigned int); int (*prep_async)(struct io_kiocb *); void (*cleanup)(struct io_kiocb *); + void (*fail)(struct io_kiocb *); }; extern const struct io_op_def io_op_defs[];