From patchwork Mon Sep 19 21:27:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 9340575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1BF9F607D0 for ; Mon, 19 Sep 2016 21:29:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C9B529913 for ; Mon, 19 Sep 2016 21:29:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0163829927; Mon, 19 Sep 2016 21:29:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63DEB29913 for ; Mon, 19 Sep 2016 21:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932754AbcISV2s (ORCPT ); Mon, 19 Sep 2016 17:28:48 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:34625 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932654AbcISV2o (ORCPT ); Mon, 19 Sep 2016 17:28:44 -0400 X-IronPort-AV: E=Sophos;i="5.30,363,1470672000"; d="scan'208";a="15969669" Received: from mail-bn3nam01lp0182.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([216.32.180.182]) by ob1.hgst.iphmx.com with ESMTP; 20 Sep 2016 05:28:07 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-hgst-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=bZEj0MitECt905DBwtXBGqnicN1r8dBcqmNz2cRYeW4=; b=BibmTZRARNAv5jjb+6uhtJTeKqLKzDBcdx/iYXeTuDGUiAqa0edn7hs6B/OI1oDlXwsAI9IVMdd3MS7jOJqMJCXdnLIQL7A+LSZI9LQA8lCfB16XF1sN1kst/PFVKyFPDHfPJJ9R91K1u6IgLj5AiAE4ts2eBg5UHHXQyybEyn8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Damien.LeMoal@hgst.com; Received: from localhost.localdomain.localdomain (4.28.11.153) by BY2PR04MB1975.namprd04.prod.outlook.com (10.166.111.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8; Mon, 19 Sep 2016 21:28:03 +0000 From: Damien Le Moal To: , CC: , , , , Damien Le Moal Subject: [PATCH 6/9] block: Add 'BLKPREP_DONE' return value Date: Tue, 20 Sep 2016 06:27:31 +0900 Message-ID: <1474320454-5264-7-git-send-email-damien.lemoal@hgst.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474320454-5264-1-git-send-email-damien.lemoal@hgst.com> References: <1474320454-5264-1-git-send-email-damien.lemoal@hgst.com> MIME-Version: 1.0 X-Originating-IP: [4.28.11.153] X-ClientProxiedBy: BY2PR12CA0038.namprd12.prod.outlook.com (10.160.121.48) To BY2PR04MB1975.namprd04.prod.outlook.com (10.166.111.15) X-MS-Office365-Filtering-Correlation-Id: a6b02aa8-694f-4b7d-9a36-08d3e0d3d80f X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1975; 2:7nUx027rCCR7jJhdyhEFD4sydxyo2L2A3gmxppxUxKJBt8N9hRhVYcWN4IW+r2PLKojC0pxm6YYHl08Ohw5fH94rUt2gRPPDLb3FdyKX8P40pwSFEr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0oFDSy4o/FaQRk6GwByHZ7K7qG70yczDFyfsmLvsqS0DesKLiC+/zdon60CzGT3yTMfI5kBe0twx4QOWwPeDSblN4nJeWmZ4V42fBDXWADf1M+AWgqaV+IA8NnH66X/O7ooT+Ipg/RUT+KsHNbbyvf/KWeKmtabR/mLW1zcupMbyIuKXyjmEiRY6TJjuogbLhEHNcFOZrInHuFDgv3oRvOwEOJ4yp476cdgFJK5d3jFtPEes5XM2lbQeLJm8zfNyO6lWLVW0ppQ8VNFpWJf0C1m9Jg0KfvKbVUFZtvQQKduM2AOx9qnW7fjTKsyN0GA5ijr49Mq491ogFBMlK+KLTLbvZoGNSRf2qpwNhD9NE/Dg52H/iKa/J67naOMk9BKb/QkgFyzqtFnNj2nmZjX9hrVGjOIR3yLI+ol3U3Ji/K X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(79135771888625); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:BY2PR04MB1975; BCL:0; PCL:0; RULEID:; SRVR:BY2PR04MB1975; X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1975; 4:2Ost4cxbHbdTUHZ7oFnxUQ0uMndKIsKzMK/G83ZvS3w9ZK5NypP3RkWc/O6vfnUN+LrB13qg0uFfnnNfvwA9/667M9ypkIRJSA/68+zclWWbN6mi/b2IF3WEhPqxB/Fb4+j+KS4ddOe5S0VBC42IB33vODoRAxHAslki1P6s+NPN/3MCXhSEFX7hbmSp9/k/BCnEG27ZPrJv7LBrfd9apDGYawbGP6juRUKeXC7vZO8qzC9YfSEUBIyjrTT3Pqd/L1HxyxwyZGFqeV1uASFFNt84QGdGmyx0NAP35eVTnEKhV/yDkR/3qqib87LseA6cbb2nTqtt0zQi24eQRi7/KU9opg/ms4iPc9Wu7hc/pOiVWUWO6c1hfT0oZ2eBvskOUgbZOD4Z3NkebqooJMjw4n1OlHULanX6Eed6aXEbo+bAY5sPQMuTKeaASnf3JaZlRC9MjXCP2R2/G+zeunAEsQ== X-Forefront-PRVS: 0070A8666B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(979002)(6009001)(6069001)(7916002)(199003)(54534003)(189002)(4001430100002)(305945005)(5660300001)(2950100001)(5003940100001)(86362001)(47776003)(33646002)(66066001)(97736004)(5001770100001)(50986999)(2906002)(229853001)(6116002)(4326007)(3846002)(76176999)(189998001)(101416001)(106356001)(105586002)(586003)(42186005)(77096005)(36756003)(50466002)(48376002)(19580405001)(81166006)(37156001)(92566002)(7736002)(8676002)(50226002)(68736007)(19580395003)(81156014)(7846002)(107886002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR04MB1975; H:localhost.localdomain.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: hgst.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR04MB1975; 23:CzdCJiAebwxvROW/to60dThMMWF3sOKRNe2HrzM/y?= =?us-ascii?Q?5e7VQlJYKM7tQ82RESZb5Hgvgn8PlD6thx7Q0hAbDNwMDhqSyi6tz++jO1nM?= =?us-ascii?Q?WOfdtuDTgaYicxr6jEI3ZETaWjTcTKx5dAed7mHYBDHjArRkD7l1ZiN2CR17?= =?us-ascii?Q?ZArUbD7IOMPFFNQDzinsCxm6C5kU7VHfjTA0RahyV0o8f3DQMjkRmpB6wMZa?= =?us-ascii?Q?gx5lIoF2VjLY61aifMygM2o6nIKIoYGaSfD/bxHXpDfZKx/0Q7OfsprYOXeD?= =?us-ascii?Q?Ln5SK/3EVGF9sT6zRc+MtoTx+KZdPSLb9fLGpVi7N1OHLjZBYQKwGStH6rsv?= =?us-ascii?Q?JgxQvzQ2VeOFUJIrpx3CMu3eKfE+4mh+dFsgPCT8uIjM2HSINDf4uiS9cRXY?= =?us-ascii?Q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soft-Exchange-Diagnostics: 1; BY2PR04MB1975; 6:WnwhE/TIRl2prMyI+GnyFKKIwO+IyS/34NmnYwZmuaxHK7SOBD8DhP+VXBO2Etn0esiBo1znt/mporbNN05Ce/RvKKA7y9LWhTeHhFGGWKC/om1zdm2f7hEXEA3x4x7QoIu8wfwCBSxSREfPuODw4hy7NKTNwuibVWEzRGEogDG15m5xlQEMg7X0lsNsZIv8el4MpvksmO/jA+YcG2xj/JXKMVHAIVML/UKBDCeQ8QHl3F0Ia8XWdA+PLQjuWml/ftvYlPRy9TDji2ygHCGzAeKAkfMOSJd/wjRG0RyjgW0SFkjt1rR8bKZr2jpek3xc1cC70GVKYyNNIm9jShhQmg==; 5:Hkk/wVVxshUNq30BOhbfE1wRFbzozb9LNW+bhY5dzNNt18qUrUMI7FgjJ3CUQB3RWtT7xtcmTLx8oIcUtrpGtnoOmUmwUIOkNx6QSglyIzG6gXM/egWC1kYJDp8CY/faSaPdzAo1PKB0J5bn8W3iPQ==; 24:YVxygSUUv0lteS1qgxXqX1BUuQjojJD0xM//lIqa9IHuxgQXz4xUsAIRu85rhC3c0GlMSSO8xKypznNsGDwNMOjhZ2H8jqY9OXeargHVhu4=; 7:l6B3CIJAxe0NShgZCfur5yZOHyKCBHrzWFmkQYzuvoD825/xXpyxTMPAn/xOb7bP5vqdS7aNE1e0hplmVhB9w81CtYkW2DW72ttgSc/7RBriYWBTPlvI3KwB37eo+yj3+e9DKSxtqraYAYQpuFk3dZMVVmXy+jAgMsUC8KgzM36UVR3pDo/KrL5+bbN4pwN8+PnPMSwEXLS9YmBh2X6miPYVBtxjBI3aCOGNnLUFF375WvIY6aFnaKtKkcZiY73kFtVLF/OogwN5EW3hC4/qijU7io5jtKjZSsQBoZYLRzaGQPocvHTq8av+4/k58XZz SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1975; 20:/KKKpmZ8iy99dVCRQhOvvki4JFWUyNZGcrma/gMPJmecX5SDSSDYfEMAdNRtBAGfxnmApF2Hjkj9ykAFrulfMPHtNiGBPs3h4B7739XaVmJ7aMcb00PnqmL4llHckPGFAA+d8v3JwRl0STss2nWLterWIW/9BGH/l5Rfh/2yUtx+iCfBLV4csGjjdzI/dgFFsvMCz1UV7mkkeJhIjL+J4O66+s7Y3qNdHT3oTjqc/Kb4qPPMH2YE4bEwXsnJChxO X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2016 21:28:03.7288 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR04MB1975 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hannes Reinecke Add a new blkprep return code BLKPREP_DONE to signal completion without I/O error. Signed-off-by: Hannes Reinecke Changelog (Damien): Rewrite adding blk_prep_end_request as suggested by Christoph Hellwig Suggested-by: Christoph Hellwig Signed-off-by: Damien Le Moal --- block/blk-core.c | 42 ++++++++++++++++++++++++++---------------- drivers/scsi/scsi_lib.c | 1 + include/linux/blkdev.h | 1 + 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 2c5d069d..8dbbb1a 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2341,6 +2341,17 @@ void blk_account_io_start(struct request *rq, bool new_io) part_stat_unlock(); } +static void blk_prep_end_request(struct request *rq, int error) +{ + /* + * Mark this request as started so we don't trigger + * any debug logic in the end I/O path. + */ + rq->cmd_flags |= REQ_QUIET; + blk_start_request(rq); + __blk_end_request_all(rq, error); +} + /** * blk_peek_request - peek at the top of a request queue * @q: request queue to peek at @@ -2408,9 +2419,10 @@ struct request *blk_peek_request(struct request_queue *q) break; ret = q->prep_rq_fn(q, rq); - if (ret == BLKPREP_OK) { - break; - } else if (ret == BLKPREP_DEFER) { + switch(ret) { + case BLKPREP_OK: + goto out; + case BLKPREP_DEFER: /* * the request may have been (partially) prepped. * we need to keep this request in the front to @@ -2425,25 +2437,23 @@ struct request *blk_peek_request(struct request_queue *q) */ --rq->nr_phys_segments; } - rq = NULL; + goto out; + case BLKPREP_KILL: + blk_prep_end_request(rq, -EIO); break; - } else if (ret == BLKPREP_KILL || ret == BLKPREP_INVALID) { - int err = (ret == BLKPREP_INVALID) ? -EREMOTEIO : -EIO; - - rq->cmd_flags |= REQ_QUIET; - /* - * Mark this request as started so we don't trigger - * any debug logic in the end I/O path. - */ - blk_start_request(rq); - __blk_end_request_all(rq, err); - } else { + case BLKPREP_INVALID: + blk_prep_end_request(rq, -EREMOTEIO); + break; + case BLKPREP_DONE: + blk_prep_end_request(rq, 0); + break; + default: printk(KERN_ERR "%s: bad return=%d\n", __func__, ret); break; } } - +out: return rq; } EXPORT_SYMBOL(blk_peek_request); diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index c71344a..f99504d 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1260,6 +1260,7 @@ scsi_prep_return(struct request_queue *q, struct request *req, int ret) case BLKPREP_KILL: case BLKPREP_INVALID: req->errors = DID_NO_CONNECT << 16; + case BLKPREP_DONE: /* release the command and kill it */ if (req->special) { struct scsi_cmnd *cmd = req->special; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1165594..a85f95b 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -819,6 +819,7 @@ enum { BLKPREP_KILL, /* fatal error, kill, return -EIO */ BLKPREP_DEFER, /* leave on queue */ BLKPREP_INVALID, /* invalid command, kill, return -EREMOTEIO */ + BLKPREP_DONE, /* complete w/o error */ }; extern unsigned long blk_max_low_pfn, blk_max_pfn;