From patchwork Tue Apr 12 20:39:30 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: 8815431 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 C2792C0553 for ; Tue, 12 Apr 2016 20:54:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB3FC2035D for ; Tue, 12 Apr 2016 20:54:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C4E820374 for ; Tue, 12 Apr 2016 20:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933463AbcDLUyy (ORCPT ); Tue, 12 Apr 2016 16:54:54 -0400 Received: from mail-bl2on0095.outbound.protection.outlook.com ([65.55.169.95]:23075 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932351AbcDLUyv (ORCPT ); Tue, 12 Apr 2016 16:54:51 -0400 X-Greylist: delayed 979 seconds by postgrey-1.27 at vger.kernel.org; Tue, 12 Apr 2016 16:54:51 EDT 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=zXP/N1MbwDcJkYZskZ9WESfvpwDqo8CHuNlvh4k6vUI=; b=CICL9YrQOiCkcNA/6sxQ5Vx0v7C7SQ4r9+YW29iYBbj/CdxTJyTMzPmddX32v9J+WBZL02/pr9GVbFk6Jh5gRQ+DN7kMtJhvlp73JUrNlBsKDSaiTG2Y/dtzXheb9KuNmR4+MGdL4icdBwa85zFGzQ6EXNcukBNtKCUDSt0Aeb0= Received: from BN1PR02CA0045.namprd02.prod.outlook.com (10.141.56.45) by BLUPR0201MB1922.namprd02.prod.outlook.com (10.162.239.156) with Microsoft SMTP Server (TLS) id 15.1.453.26; Tue, 12 Apr 2016 20:39:32 +0000 Received: from BY2FFO11FD002.protection.gbl (2a01:111:f400:7c0c::132) by BN1PR02CA0045.outlook.office365.com (2a01:111:e400:2a::45) with Microsoft SMTP Server (TLS) id 15.1.453.26 via Frontend Transport; Tue, 12 Apr 2016 20:39:32 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; fb.com; dkim=none (message not signed) header.d=none;fb.com; 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 BY2FFO11FD002.mail.protection.outlook.com (10.1.14.124) with Microsoft SMTP Server (TLS) id 15.1.453.6 via Frontend Transport; Tue, 12 Apr 2016 20:39:31 +0000 Received: from MILHUBIP03.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 2F.B1.03047.5CC5D075; Tue, 12 Apr 2016 13:38:29 -0700 (PDT) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.279.2; Tue, 12 Apr 2016 13:39:30 -0700 X-AuditID: ac160c69-5dfff70000000be7-26-570d5cc567b4 Received: from exp-402881.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 4E.45.03935.20D5D075; Tue, 12 Apr 2016 13:39:30 -0700 (PDT) Subject: [PATCH v3 2/5] block: Introduce bio_add_zero_pages() 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: <570D5D02.3030807@sandisk.com> Date: Tue, 12 Apr 2016 13:39:30 -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+NgFprOIsWRmVeSWpSXmKPExsWyRoxnke7RGN5wg4ntphb/9xxjs7j7fjur xYmZnhYrVx9lspg9vZnJYu8tbYvlx/8xWax7/Z7Fom3jV0YHTo+Jze/YPc7f28jisftmA5vH pMOfmTw+Pr3F4vF+31U2jzMLjrB7fN4kF8ARxWWTkpqTWZZapG+XwJVx/e8tloJTghVT1mxn amCcwNfFyMkhIWAi8eXCVaYuRi4OIYG5TBKX56xjhXB2MEosvreWHabq9YuNLCC2kMBSRokX reYgtrCArcTy86sZQWwRAVmJ77tfs0HUaElsfbeLBWQQs8BZJokTzZeZQBJsAkYS397PBBvE C1S0+/prsAUsAqoSv6bNBhskKhAhcajxPVSNoMTJmU+AbA4OTgFtiWnzZEBMZgFNifW79EEq mAXkJba/ncMMskpC4C2rxM8j75kgblCXOLlkPtMERuFZSCbNQmifhaR9ASPzKkax3Myc4tz0 1AJDU73ixLyUzOJsveT83E2MkOjK3MF494n3IUYBDkYlHt4HzjzhQqyJZcWVuYcYJTiYlUR4 f0bzhgvxpiRWVqUW5ccXleakFh9ilOZgURLndbv3JUxIID2xJDU7NbUgtQgmy8TBKdXAKCp0 fV4pQ6z85S3mGQWdzlezH12fxpe5+fmSxdWT6mar2tc33XmtOtMl8LtbLLPonek8Z5/PvDLV 22a5TejE+frOlzI8nzye9eCfdkPErosZzhe9HsXO9/mn/PfEynWhoWJd3SWMWcU33b8l6npO W7OhJftpctWM78cS1lTEO+7Zrl/mub3xiRJLcUaioRZzUXEiAIP1Vl6qAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnluLIzCtJLcpLzFFi42Lh2siRossUyxtusLHPxuL/nmNsFnffb2e1 ODHT02Ll6qNMFrOnNzNZ7L2lbbH8+D8mi3Wv37NYtG38yujA6TGx+R27x/l7G1k8dt9sYPOY dPgzk8fHp7dYPN7vu8rmcWbBEXaPz5vkAjiiuGxSUnMyy1KL9O0SuDKu/73FUnBKsGLKmu1M DYwT+LoYOTkkBEwkXr/YyNLFyMUhJLCYUWL5yUvMIAlhAVuJ5edXM4LYIgKyEt93v2YDsYUE tCS2vtsF1sAscJFJ4v3sLSwgCTYBI4lv72eC2bxARbuvv2YHsVkEVCV+TZsNNkhUIELiUON7 qBpBiZMznwDZHBycAtoS0+bJgISZBdQl/syDuIFZQF5i+9s5zBMY+WYh6ZiFpGwWkrIFjMyr GMVyM3OKc9MzCwyN9IoT81Iyi7P1kvNzNzGCg5wzagfj9YnmhxiZODilGhhFvHMqAu23fH5a NUeYp3vG0f8P7SNKjs4Pkv+/JvML97aGam2X8xx5Tx1KKkRY1ytOYWjw2bOWN8pqdvvZxdVf n9v2//riqPLiZVdNzO7/avVR50VlHB5vDJ6vkfXLtrP+VIRcA7vGhuxvzL5tkmHpD+rjJ/L9 /zl5k3LbGxfRhszZsrsniiuxFGckGmoxFxUnAgA+xkYrIgIAAA== 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)(189002)(199003)(64126003)(1220700001)(36756003)(4326007)(189998001)(50466002)(230700001)(586003)(53416004)(87266999)(76176999)(5008740100001)(19580405001)(80316001)(6806005)(1096002)(54356999)(50986999)(86362001)(19580395003)(2906002)(33656002)(23676002)(110136002)(5003600100002)(87936001)(83506001)(2950100001)(81166005)(2270400002)(106466001)(11100500001)(59896002)(92566002)(4001350100001)(229853001)(65806001)(65956001)(47776003)(65816999)(77096005)(50929005); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0201MB1922; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:nov; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD002; 1:YVTyCPUUtrDR8xS/sBEBGKS9JCEwKzFNPV5eXYg9WBFVMCWd0RbgVpg6/0QbvzSqVzFk+gC+sUrCS/fzAopgQ2GH/1qo7hfBSvXto6DrbkDXQgMZwU1LKex2KfLVpRHlJOo9NKfU1quDu/yv2uNtRJyDBw8szhunQhRgkTuPTk8AzthAuqsc17gcKENgDcg7ZnUVXfwxAiOoduNftHPLV0Ieo+V1tnJLwBB1WVEuy78w8chYQ9QUrUVPl0Dw/YeUEiXq/KGhpYTDminXeYl0cG7Pe1BlXNNzzeJPh21gKbnOQkcOyabTcBfgwa3+sEcuWWXXQMRg7lmBCm4sgpYZZVPNaqm+NOhJ4ReHRtPFPYygSJis3YVKRKNCLElwC2jupEo+J61BJyMHoUfrpy07MhJcWtHjlKPDkcQA55+4/nF2o6IECKrBIoUHqPfH/Q1p X-MS-Office365-Filtering-Correlation-Id: 602eb417-8ea3-4072-f8d7-08d363128d30 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0201MB1922; 2:P9Lk5Kd8mOLN+Shauwwv8vc9gvTIIe6TtiEodvFo9kKZ/0eYuB1EvsQLu8eY+yg933MnD3323CMZxBm61VLfjtDiU9DNXVvigfAGgu0pmfWghmRoj8q/LDxzKAnbxULxw+ZN8Jf84ZyUwWuwUf/aktQfZ/YNq7SeiQoOS9BjwV1HoQ55lK3RkjpNpEQMVtR6; 3:uelbkN8BgzT2nGsL9kraOCsn0mdORwyvKR6fBIkn4t+a1UZxgjU6Bu6K88w94Ixkm5fw+qeotiNLRy1tvLzRwgwrGfVGv7SRTz3wL74Mvt4qSbaesYw+F4aceF1X58QugEIelisf+WV8eVr4eCGT1jmM1ko2Lv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8VWPB 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:BLUPR0201MB1922; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0201MB1922; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0201MB1922; 4:xusxHLYOdGlthhBGds5S8PtcGnX+EH59f5RwxZzfvLmB+XUpuUKC2kg0x7QI2VUMyuGJJ7/qYNQ2DwIaJ1qz7oWJ3JBn0n4B5PgKwOSq7Lz4eaG+fkx6ljqZo3qQk1VnHlc7McJSDMsWc5lM3eezshY684dvJPHWxrNEBJbWaZljdQYP2iC9W921MGvozbSDs28CgAVHIh8kYoP/K+KDdbskD+ueiyXSlKzUL7lkBPMODIkDTfVAIzReUEzFMjoIUqQU5WD9az5YgMAWG0UloD1YQxastTIok12q63WeGxv76c6VIYApzHNjdp7M4aKDN/DgQ85sXDE+KyS6+nW2yctilE+Wlt+v9aTleIu142HdUnzLDn82YD3zYuQ5bt/dy78puS1+19KeBOLjcU0HRVLBzAfB8ETV0bpHH/JkU+kXmQyHRJkQR5FIU9rKDGIFGaPVZefhmKWVQAnY9AoklYbBmG2stDiugjToFpJWjQw= X-Forefront-PRVS: 0910AAF391 X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTFVQUjAyMDFNQjE5MjI7MjM6bXplNVVZbTRRL3kzdmxsZ0hIaU5DNTht?= =?utf-8?B?K2RwUUxnTnZFRGJNY2NsRDU3N1VtUEplLzhyV090SDNCVnpPSUZDdHU1RXU0?= =?utf-8?B?Sk1xdVN4VFo0dGFYejhmempjSmpuMFk1K1VMOEpBNm1acmpibDM3cXFQSmww?= =?utf-8?B?cjF5TVkvTzJnakJXdFpZb0duSHNVUFJCQXd6M1FJZzdrdStmVnJGeS9HZStL?= =?utf-8?B?RnFxeUMwaVJoZ1dG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PYnLNyzltm7YeX7NdKjtEwQhh5TS4Tq2KHpMUMwGnXALmwm6sov8LVRENrjuY/vDVtvMqegcX/sWXqc/biBb8WR3KNP/Hz1DNYiIulY5nMVP7 SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2016 20:39:31.7793 (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: BLUPR0201MB1922 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 adding one or more zero pages 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 | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/block/blk-lib.c b/block/blk-lib.c index 2f4c6b2..9a93ca4 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -219,6 +219,22 @@ int blkdev_issue_write_same(struct block_device *bdev, sector_t sector, } EXPORT_SYMBOL(blkdev_issue_write_same); +static void bio_add_zero_pages(struct bio *bio, sector_t nr_sects) +{ + unsigned int sz; + int ret; + + /* Avoid that bi_size overflows */ + nr_sects = min_t(sector_t, nr_sects, UINT_MAX >> 9); + + for (; nr_sects != 0; nr_sects -= ret >> 9) { + sz = min_t(unsigned int, PAGE_SIZE >> 9, nr_sects) << 9; + ret = bio_add_page(bio, ZERO_PAGE(0), sz, 0); + if (ret < sz) + break; + } +} + /** * blkdev_issue_zeroout - generate number of zero filed write bios * @bdev: blockdev to issue @@ -236,7 +252,6 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, int ret; struct bio *bio; struct bio_batch bb; - unsigned int sz; DECLARE_COMPLETION_ONSTACK(wait); atomic_set(&bb.done, 1); @@ -256,16 +271,9 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, bio->bi_bdev = bdev; bio->bi_end_io = bio_batch_end_io; bio->bi_private = &bb; - - while (nr_sects != 0) { - sz = min((sector_t) PAGE_SIZE >> 9 , nr_sects); - ret = bio_add_page(bio, ZERO_PAGE(0), sz << 9, 0); - nr_sects -= ret >> 9; - sector += ret >> 9; - if (ret < (sz << 9)) - break; - } - ret = 0; + bio_add_zero_pages(bio, nr_sects); + nr_sects -= bio->bi_iter.bi_size >> 9; + sector += bio->bi_iter.bi_size >> 9; atomic_inc(&bb.done); submit_bio(WRITE, bio); }