From patchwork Wed Jul 13 05:23:33 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: 9226789 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 967C06086B for ; Wed, 13 Jul 2016 05:24:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C92D1FF10 for ; Wed, 13 Jul 2016 05:24:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7117027BF9; Wed, 13 Jul 2016 05:24:41 +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 C487B1FF10 for ; Wed, 13 Jul 2016 05:24:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750783AbcGMFYZ (ORCPT ); Wed, 13 Jul 2016 01:24:25 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:13417 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750767AbcGMFYX (ORCPT ); Wed, 13 Jul 2016 01:24:23 -0400 X-IronPort-AV: E=Sophos;i="5.28,355,1464624000"; d="scan'";a="6978655" Received: from mail-bl2nam02lp0085.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([207.46.163.85]) by ob1.hgst.iphmx.com with ESMTP; 13 Jul 2016 13:23:58 +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=7HrmxJ4hI0FHbJj1q+ZMoUETwjzFgRruQYWHtrs8vl4=; b=DckPXcLyCDMZMGagsgEwtmtatCTsjxtHl5QFnerSRcH5YflfOwcdZKS4mB8aPQXtN1awtXjlIGKklb7MViLOLGP8aZZ2fepHMddffTCu3nFmrK+b7liRrN8g8QS964hByvhkpVsELq8qKtSblwYsQ8u3Dk41MSSdWEzVeXmMMNg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Damien.LeMoal@hgst.com; Received: from washi.fujisawa.hgst.com (199.255.47.8) by BL2PR04MB1969.namprd04.prod.outlook.com (10.167.97.141) with Microsoft SMTP Server (TLS) id 15.1.539.14; Wed, 13 Jul 2016 05:23:55 +0000 From: Damien Le Moal To: , , , CC: Damien Le Moal Subject: [PATCH] block: Fix front merge check Date: Wed, 13 Jul 2016 14:23:33 +0900 Message-ID: <1468387413-2754-1-git-send-email-damien.lemoal@hgst.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [199.255.47.8] X-ClientProxiedBy: BY2PR12CA0040.namprd12.prod.outlook.com (10.160.121.50) To BL2PR04MB1969.namprd04.prod.outlook.com (10.167.97.141) X-MS-Office365-Filtering-Correlation-Id: 879d6959-4b58-4878-b5a5-08d3aadde396 X-Microsoft-Exchange-Diagnostics: 1; BL2PR04MB1969; 2:/sai+55umVBRBer/SO5RNS29KLsswBXMJ6JItF2Bx8l3Ndj8xpI+R2zIz5d39Z62Wzsn3L5FfpmrdPt/X0HwaAyMI9kXQlUuhpqTaPRV4SRnyRMsO6XM6SGDDQ/AWKYIrAUu3b6lipNvqJjXDv+eLD5hgcPMXEubm1z/a9+OeOgtVXCnCft+Jhw7kYWnlcP3; 3:z3nr6sAZmkcv6bCy8ODRmJ0eeaB1e4jH2RBjQIYczzVseUwAlGa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oft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(79135771888625); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:BL2PR04MB1969; BCL:0; PCL:0; RULEID:; SRVR:BL2PR04MB1969; X-Forefront-PRVS: 000227DA0C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(6116002)(48376002)(305945005)(77096005)(33646002)(19580395003)(42186005)(86362001)(229853001)(19580405001)(7736002)(106356001)(3846002)(105586002)(2201001)(586003)(50466002)(5001770100001)(97736004)(66066001)(107886002)(8676002)(47776003)(36756003)(2906002)(92566002)(101416001)(50226002)(81166006)(81156014)(50986999)(5003940100001)(189998001)(4001430100002)(4326007)(68736007)(7846002)(7099028)(2101003); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR04MB1969; H:washi.fujisawa.hgst.com; 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; BL2PR04MB1969; 23:m594cTe275mRYDRouEJiJmjE2RR9Vv7qRo8Kfcxdd?= =?us-ascii?Q?X19dRxtSkVb2jVvcDTCp4ttiOr1e64SqoJbobUmUBi8z/z+6GwhrJhzzI2+L?= =?us-ascii?Q?+k3FiWWomjHtYQcjy8jFO0zMOmicV8Qf48P3GOZ8PS3Ar6z3wVs0489vaIYz?= =?us-ascii?Q?7JdACCE4LYJXKFavL3fFtv0pd1KsjtTTkKep2Vc5f7exCw3VZBImUMtltQq1?= =?us-ascii?Q?/xBqjjvYgxqdAhuHejwJe3OgBJOEqMVoCDu4GswKrp0RkVtVX3EIoHUsLPga?= =?us-ascii?Q?52+vSVlIWSQs9aVZ3O2olHbIyECBInqRsfPv2pHodz5XLc9hm/HQTO2/1Hww?= =?us-ascii?Q?UYv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bzu6XjyF0+ X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2016 05:23:55.9510 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR04MB1969 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 For a front merge, the maximum number of sectors of the request must be checked against the front merge BIO sector, not the current sector of the request. Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke --- block/blk-merge.c | 6 +++--- include/linux/blkdev.h | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 2613531..b736569 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -500,7 +500,7 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req, integrity_req_gap_back_merge(req, bio)) return 0; if (blk_rq_sectors(req) + bio_sectors(bio) > - blk_rq_get_max_sectors(req)) { + blk_rq_get_max_sectors(req, blk_rq_pos(req))) { req->cmd_flags |= REQ_NOMERGE; if (req == q->last_merge) q->last_merge = NULL; @@ -524,7 +524,7 @@ int ll_front_merge_fn(struct request_queue *q, struct request *req, integrity_req_gap_front_merge(req, bio)) return 0; if (blk_rq_sectors(req) + bio_sectors(bio) > - blk_rq_get_max_sectors(req)) { + blk_rq_get_max_sectors(req, bio->bi_iter.bi_sector)) { req->cmd_flags |= REQ_NOMERGE; if (req == q->last_merge) q->last_merge = NULL; @@ -570,7 +570,7 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req, * Will it become too large? */ if ((blk_rq_sectors(req) + blk_rq_sectors(next)) > - blk_rq_get_max_sectors(req)) + blk_rq_get_max_sectors(req, blk_rq_pos(req))) return 0; total_phys_segments = req->nr_phys_segments + next->nr_phys_segments; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 3d9cf32..b99ef36 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -904,7 +904,8 @@ static inline unsigned int blk_max_size_offset(struct request_queue *q, (offset & (q->limits.chunk_sectors - 1)); } -static inline unsigned int blk_rq_get_max_sectors(struct request *rq) +static inline unsigned int blk_rq_get_max_sectors(struct request *rq, + sector_t offset) { struct request_queue *q = rq->q; @@ -914,7 +915,7 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq) if (!q->limits.chunk_sectors || (rq->cmd_flags & REQ_DISCARD)) return blk_queue_get_max_sectors(q, rq->cmd_flags); - return min(blk_max_size_offset(q, blk_rq_pos(rq)), + return min(blk_max_size_offset(q, offset), blk_queue_get_max_sectors(q, rq->cmd_flags)); }