From patchwork Tue Apr 12 20:39:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 8815091 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1A954C0553 for ; Tue, 12 Apr 2016 20:39:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A4622035D for ; Tue, 12 Apr 2016 20:39:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B23FC201B9 for ; Tue, 12 Apr 2016 20:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965316AbcDLUjN (ORCPT ); Tue, 12 Apr 2016 16:39:13 -0400 Received: from mail-bl2on0071.outbound.protection.outlook.com ([65.55.169.71]:59281 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965195AbcDLUjL (ORCPT ); Tue, 12 Apr 2016 16:39:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandiskcorp.onmicrosoft.com; s=selector1-sandisk-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=JyL+fZKdIZXBfkfWRuyBLhpIevu4wsg3kDK8BclbMYs=; b=b8CFk6sly/zlURhvjz8M7iFj8970tfK8u3mqoOJNyaf3U4PLeUumfymNtgfuAMDGwAk0cKuy2xgPN1chFzcboRb0ggJn7g6yBCr+ivbQ0M1iDlcatvQMkDPS3hgEMNdIbMwzwAye5W/BJztX+ma+OrAD07SE5CINObWXvS01onI= Received: from BY2PR02CA0015.namprd02.prod.outlook.com (10.242.32.15) by CY1PR0201MB1930.namprd02.prod.outlook.com (10.163.56.28) with Microsoft SMTP Server (TLS) id 15.1.453.26; Tue, 12 Apr 2016 20:39:08 +0000 Received: from BY2FFO11OLC011.protection.gbl (2a01:111:f400:7c0c::195) by BY2PR02CA0015.outlook.office365.com (2a01:111:e400:2c2a::15) with Microsoft SMTP Server (TLS) id 15.1.453.26 via Frontend Transport; Tue, 12 Apr 2016 20:39:07 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; openvz.org; dkim=none (message not signed) header.d=none;openvz.org; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.21 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.21; helo=milsmgep15.sandisk.com; Received: from milsmgep15.sandisk.com (63.163.107.21) by BY2FFO11OLC011.mail.protection.outlook.com (10.1.15.22) with Microsoft SMTP Server (TLS) id 15.1.453.6 via Frontend Transport; Tue, 12 Apr 2016 20:39:07 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com (Unknown_Domain [172.22.12.162]) (using TLS with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id BC.B1.03047.DAC5D075; Tue, 12 Apr 2016 13:38:06 -0700 (PDT) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.279.2; Tue, 12 Apr 2016 13:39:07 -0700 X-AuditID: ac160c69-5f3ff70000000be7-1e-570d5cad52bf Received: from exp-402881.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 8B.5F.02566.BEC5D075; Tue, 12 Apr 2016 13:39:07 -0700 (PDT) Subject: [PATCH v3 1/5] block: Introduce blk_round_sect_down() To: Jens Axboe References: <570D5CC1.1030507@sandisk.com> CC: Christoph Hellwig , Jan Kara , Mike Snitzer , "Martin K. Petersen" , Dmitry Monakhov , "Darrick J. Wong" , Sagi Grimberg , "linux-block@vger.kernel.org" From: Bart Van Assche Message-ID: <570D5CEB.3030601@sandisk.com> Date: Tue, 12 Apr 2016 13:39:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <570D5CC1.1030507@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGIsWRmVeSWpSXmKPExsWyRoxnke66GN5wg7MP2C3+7znGZnH3/XZW ixMzPS1Wrj7KZDF7ejOTxd5b2hbLj/9jslj3+j2LRdvGr4wOnB4Tm9+xe5y/t5HFY/fNBjaP SYc/M3l8fHqLxeP9vqtsHmcWHGH3+LxJLoAjissmJTUnsyy1SN8ugSvj8ftLLAVbhCoa1oc0 MD7g62Lk5JAQMJGYtvU0WxcjF4eQwFwmie9rnzNBODsYJVbPP84IU7V470R2iMRSRoneqXuA EhwcwgJ2Esu7DEFqRARkJb7vfs0GYgsJaElsfbeLBaSeWeAsk8SJ5stMIAk2ASOJb+9nsoDY vEBF++bOZgexWQRUJRZdPM8MYosKREgcanwPVSMocXLmExaQXZwC2hLT5smAmMwCmhLrd+mD VDALyEtsfzuHGWSVhMBLVonXj+6xQtygLnFyyXymCYzCs5BMmoXQPgtJ+wJG5lWMYrmZOcW5 6akFhqZ6xYl5KZnF2XrJ+bmbGCGxlbmD8e4T70OMAhyMSjy8D5x5woVYE8uKK3MPMUpwMCuJ 8P6M5g0X4k1JrKxKLcqPLyrNSS0+xCjNwaIkzut270uYkEB6YklqdmpqQWoRTJaJg1OqgXHq Wue2C5OuXPU8uTd6Xbzdo0lvvae9uJOwo7eg9dz2aNn8BD3dQyK/Hm5umLh4q6WkW9WSvxfU 55feiktLmC+pHpSUNXNPBsPL9I0MLJ9dlWbdL/3832hfldacEyJ1Qu/FuO1OeV9Y95TF0LW/ 8fCJ38YBM69wL/rXOk/pYF5lhOGZZrcamUlKLMUZiYZazEXFiQAfgYikqQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplluLIzCtJLcpLzFFi42Lh2siRovs6hjfc4M4tYYv/e46xWdx9v53V 4sRMT4uVq48yWcye3sxksfeWtsXy4/+YLNa9fs9i0bbxK6MDp8fE5nfsHufvbWTx2H2zgc1j 0uHPTB4fn95i8Xi/7yqbx5kFR9g9Pm+SC+CI4rJJSc3JLEst0rdL4Mp4/P4SS8EWoYqG9SEN jA/4uhg5OSQETCQW753I3sXIxSEksJhR4umjJyxdjBwcwgJ2Esu7DEFqRARkJb7vfs0GYgsJ aElsfbeLBaSeWeAik8T72VtYQBJsAkYS397PBLN5gYr2zZ3NDmKzCKhKLLp4nhnEFhWIkDjU +B6qRlDi5EyIXZwC2hLT5smAhJkF1CX+zLvEDGHLS2x/O4d5AiPfLCQds5CUzUJStoCReRWj WG5mTnFuemaBoaFecWJeSmZxtl5yfu4mRnCAc0buYHw60fwQIxMHp1QD44H+lDX9H0wd9i2P 39epsqmBx4unzCb34PujMzSze/3vHPmS3Lb938+unZX/Vod7uLLItllr6BQVpvi2eBxKePlz nuoPp53LJh+6sijpi+jfpcnvryvv4Ndr4Lv9aMLpX6brbbmt07nMBK23qBau2518NCFlS5RY 7Y28YOHns95zzi9QfvikQ4mlOCPRUIu5qDgRAM3R774gAgAA X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:63.163.107.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(2950100001)(64126003)(230700001)(50986999)(77096005)(19580395003)(80316001)(65806001)(5008740100001)(87936001)(53416004)(189998001)(6806005)(4001350100001)(47776003)(110136002)(65956001)(36756003)(586003)(2906002)(1220700001)(11100500001)(1096002)(92566002)(50466002)(65816999)(19580405001)(106466001)(2270400002)(54356999)(33656002)(5003600100002)(81166005)(229853001)(83506001)(87266999)(23676002)(76176999)(4326007)(86362001)(59896002)(50929005); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0201MB1930; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:nov; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC011; 1:Je2YLAbCykadZy9olveGaQwWvG5KcZ8eBPsWw9wPAzogTOSd0Fe1pLjxPpRcMxpRX8rodDje3pYN+/KvigkdVb2IKF8IFIpuL0DwAyaUeeUv/3cQPIW0h8u5fLnJTiVKXx6wpyzoGuJtnXfdT8UDRrokpUOExlWlYYl5pHmZ34R43vMGWD+dvIW1lISHMBSXhfYkiQcKZ0vRr09r+hcD3P26RH4znD0FXGLAeFp/3RiD0fWi7iWXe83JSvnmkzB6dK+wq6+CyaKvgdsoc1Wjtwm246bBlb5mmQJobQyBmpdVTRPuH6WeDGFz8FR/TRqofYnb+OKLAVHEhsffvBxr3kqlGKxXcqA6FeX6BlzWaeESbmlUDsdfpFFtchuqjP5qCTFfYPp8fyW3wxBm8g/ILE8oqnOihYVUhKTc9UKdhRWMuf2c39OWux2G6JxLEFsOzqLYz8Q0NG0r4iFXsphCVWKIc8qp2Juam9DndxDjRc0= X-MS-Office365-Filtering-Correlation-Id: a33eae73-6ded-4853-538b-08d363127edc X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1930; 2:4TWWAPgJzMhlHOeSHbsOztDRW7tQ9gy4Mzio1J+RWnfYKSm2jAU1iFTCYAToBKNXOc0kPEDKmIN6kJQgmuJOrAMgUzKW9KOhMJPiHTe+cjfAwcZn8JPh1oDls8oGT7lhu0mh9Q231pH+L8800NRMycdtLHYNUOv1KNpyogXG/Y0z7WYD38eQLBYkFMjgnxHW; 3:dfxDcOlCGtCgGUel2W86S1Mv8OU6XAXkj10Knhd0uTvcRwn9ChfzLdSlitPhDibLGkUGpDt2L/vhI0eYO3LSGYY3WYFSIVO56Mrk0zQIFwt4ev7e5Bd2CeCjlng+PdHujXWyk7B5oSev5fdX6Omz4oLjkwZpR/rs9THQRbyC4rG1RMo4APAYRI83RwbTXk3/x46Dsitrs7monkAIPmwehXi9TcEY3gfBQhdn7dGYAznZnhFlkI0LkDaN2Z5rIQjhMl+FIwUrXbTA/pDLEUrTtA== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:CY1PR0201MB1930; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1930; 25:TLLJi01HonpY4DCtIJd14N0uH2vzHU9DR5XR/T06yroncidS1jlG9pow7nVRsvCXBgNoJATGZswgo6O35xMsNQA7geWptIK05CcWmxmux7PxXUFPditUznTkVmebLv0L6Ydu3zfiolvHGd5W3+N3mqF59z6d8Uf3MfWqrxpv5IKQ+dfSSNe0dMXNzAraho4dt/LTnVQZ4JsXsKbdPOQPxNpwZUcfN6hjrhqMKRry1Vkxm1figY+zenskewPVClRTH69mJDy+kJzN2YHaP6KrQmV7lGilqd/CXO2AK9cpBjs8YYmTyNpnCrL20vDYeGHoTe8K5FpDEpaDH2afqd2Czu2Nkg5Q69DSH/g3359Bg8Fr2p4EVHTqsp/ioKo/kt7kbvm/TKwfgHzRQDxBzwr7Wyc9DBmI/6NyOJw9Nl94ChdB+a46SamVyDV+HnmYO/ZM1tv8RnCeFBWZVkhOckcwrTdYH17OHu7Hqg6pE6MedzBw8lPWaEOcgGrV5593EeXTa8hEAwig80zAYglz6gDgzZiczuQUof3pjSSdX3EY0sb6dT0sB6zIjy1fRr/P07sj9ddcJbM5rB+sueqHGLq/hFJ1an0ssePg7naKD4BgO+ZBxgejrSi75gtgQN3KWsDUmcTxpyCRBcmbWz6+9XyFgB7NDS8/3PzbyqOplBFdcrPiBuJuQbEvZDDVztZOuurBEooKgkWUl3SPQdje3hN72g== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1930; 20:i4vChn5zEAodDmVFIUqLM44TXgLZO5io5VR4IhHUO3NzWj959ecmThQqhfD6RUghcYQJUbYZsWI+gVPy18sTB/hBFR6X1cybBKt1yiS0ecyKxHqvUBqzDo44fmRTSv8fgiF/3LhbsBUHDkd4qEZpLHQuKmejldTYISn9eKyr1AQHVECwOd7Brybhs6QMhf8c3woQF9UxyWpmuJSIk4Nqs5Jyt6yYFybwrtmj5isd+gnDDciOt0/xDCaMHoKLG/sCJyZgMH728hVu5B53+ScK9ArPBHs93NlMFP1ml7NDtG1R9PkoupjF6QhU2h3aXpIoMbWv129Kovdqsb3QTP0CI3y/p9P9W8CiLlQXs/6qRRFtpLTBgDigU4S7zGJKY6PebhcYu8GsMAnRqoUP0GHL01YWeirNDrxIipK0QCdhdB4CtTsWUwA1ywe4wtBHKMxCLaHTqH8ShHw6uIRTWRbhkxMpWzh751f2HgmEFicRKnqCV2eD8uGBKHB+CA6UYIvO X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(235219596079481); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(13018025)(13016025)(8121501046)(10201501046)(3002001)(2002001); SRVR:CY1PR0201MB1930; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0201MB1930; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1930; 4:+FNr/PjPoh+rntwE+8PJJmmWMnECfyPFdbjnftV+EYdLTwexLrkhT4arGrv+mri7BmOf0mwv8R1y8QKP5OwkfB6JzODTVCHJKgi128BiyVJHWwhKi7yCZg107f23b3A5v41GM67gSm45gIljPwmKkw7j8QTwDL35F8mEATu/Jc/9PPEub3esFs5gZkGMzP73hV7M6VpxCUn7X3cld4BEyqXE2zV8e/Ov32DLKnJgBDmdAK8U/vycSZi4VQ9ovVNZnQuSQboMVQEnNXfBEFpsGzoLLLPMbu+V3YAZccbA4twAsX3uokMKS+67BN6Sr1pzacn5mwOVbuVAOSKIsrE1JxDPsVxG44d2xEzoZMcpv04Q/kD+IexI2l/XvaPWx/EqgwTF8bnOq+F7NGFIgKlkc+S/ykCZ8orcWKlhsQHJ1LiRC1CfmuwnpJYm//Gvz90enC2zk39e+Fu9V+Dkv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7oXTJ/XxyO5JE/jPpqSBGruKPP/mlRzj/mAhGBeflZdnsdstr5G88bVxRD6AzXT6vNL6YRVD4+OYZy3UOntCLyZlZU3cLdgSa4GnzpPClsT1oarZw==; 24:nkD7qDxWS9wZn6rT8WET6dbfVIAp/+86ad2RIVxsYbxEVfLlpysTxf0+xYZm2aDbR2FRqChBD9sbHGKO3vhJEDuR+YDBxOpGzbCLOgsrhmk=; 20:CJYh2sOVUpT5NPNgDQWjrJd5yOHS6nWLrPaWIi0etM1CJxWTfSVux/12qO0mjHZkLXTCdBQM2h1jhMrzpIb6iwn+Y5QXCbDqQeUEuQGiVNiRclZWp9RpmIdMEi5WhrOUVGfwvtgqO8JrAnckt6Pm8gUFzg0qR3NeEtORuSTzTElOpsvJ9Oiir7+4goARzPFTSSEjQhnWpmFcX1/olctLn0WgNPdnNMjf4gIu4aZrtVrtZvHvsc1SL+E5Z7fS9LwQ SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2016 20:39:07.7521 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d; Ip=[63.163.107.21]; Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB1930 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY, URIBL_BLACK autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move the code for rounding down a sector into a new function. This patch does not change any functionality. Signed-off-by: Bart Van Assche Reviewed-by: Christoph Hellwig Cc: Jan Kara Cc: Mike Snitzer Cc: Martin K. Petersen Cc: Dmitry Monakhov Cc: Darrick J. Wong Cc: Sagi Grimberg Reviewed-by: Hannes Reinecke --- block/blk-lib.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/block/blk-lib.c b/block/blk-lib.c index 9ebf653..2f4c6b2 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -26,6 +26,26 @@ static void bio_batch_end_io(struct bio *bio) bio_put(bio); } +/* + * Return the largest number that is less than or equal to @s and for which + * the remainder of the division by @granularity is @alignment. + */ +static sector_t blk_round_sect_down(sector_t s, u32 granularity, u32 alignment) +{ + sector_t tmp = s, res = s; + u32 remainder; + + WARN_ON_ONCE(alignment >= granularity); + + remainder = sector_div(tmp, granularity); + if (remainder == alignment) + return res; + res -= remainder - alignment; + if (remainder < alignment) + res -= granularity; + return min(res, s); +} + /** * blkdev_issue_discard - queue a discard * @bdev: blockdev to issue discard for @@ -73,7 +93,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, blk_start_plug(&plug); while (nr_sects) { unsigned int req_sects; - sector_t end_sect, tmp; + sector_t end_sect; bio = bio_alloc(gfp_mask, 1); if (!bio) { @@ -89,12 +109,10 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector, * misaligned, stop the discard at the previous aligned sector. */ end_sect = sector + req_sects; - tmp = end_sect; - if (req_sects < nr_sects && - sector_div(tmp, granularity) != alignment) { - end_sect = end_sect - alignment; - sector_div(end_sect, granularity); - end_sect = end_sect * granularity + alignment; + if (req_sects < nr_sects) { + end_sect = blk_round_sect_down(end_sect, granularity, + alignment); + WARN_ON_ONCE(end_sect < sector); req_sects = end_sect - sector; }