From patchwork Thu Dec 17 11:41:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 7872151 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 39FF3BEEE5 for ; Thu, 17 Dec 2015 11:41:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0740A203F1 for ; Thu, 17 Dec 2015 11:41:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B439A20416 for ; Thu, 17 Dec 2015 11:41:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751672AbbLQLlL (ORCPT ); Thu, 17 Dec 2015 06:41:11 -0500 Received: from mail-by2on0075.outbound.protection.outlook.com ([207.46.100.75]:21728 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750938AbbLQLlJ (ORCPT ); Thu, 17 Dec 2015 06:41:09 -0500 Received: from BLUPR02CA038.namprd02.prod.outlook.com (10.160.23.156) by BY2PR0201MB1574.namprd02.prod.outlook.com (10.163.154.12) with Microsoft SMTP Server (TLS) id 15.1.355.16; Thu, 17 Dec 2015 11:41:07 +0000 Received: from BY2FFO11FD001.protection.gbl (2a01:111:f400:7c0c::108) by BLUPR02CA038.outlook.office365.com (2a01:111:e400:8ad::28) with Microsoft SMTP Server (TLS) id 15.1.361.13 via Frontend Transport; Thu, 17 Dec 2015 11:41:06 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.172) 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.172 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.172; helo=milsmgep11.sandisk.com; Received: from milsmgep11.sandisk.com (63.163.107.172) by BY2FFO11FD001.mail.protection.outlook.com (10.1.14.123) with Microsoft SMTP Server id 15.1.355.15 via Frontend Transport; Thu, 17 Dec 2015 11:41:06 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com ( [172.22.12.162]) by milsmgep11.sandisk.com (Symantec Messaging Gateway) with SMTP id 5B.5F.04667.05F92765; Thu, 17 Dec 2015 03:41:04 -0800 (PST) Received: from milsmgip12.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.248.2; Thu, 17 Dec 2015 03:41:04 -0800 X-AuditID: ac160a68-f790b6d00000123b-4d-56729f501d85 Received: from [10.50.231.72] ( [10.177.8.100]) by milsmgip12.sandisk.com (Symantec Messaging Gateway) with SMTP id AC.E0.17166.E4F92765; Thu, 17 Dec 2015 03:41:04 -0800 (PST) Subject: [PATCH 3/6] block: Optimize __blkdev_issue_zeroout() To: Jens Axboe References: <56729ECF.50906@sandisk.com> CC: Jan Kara , Christoph Hellwig , Mike Snitzer , "Martin K. Petersen" , Dmitry Monakhov , "linux-block@vger.kernel.org" , device-mapper development From: Bart Van Assche Message-ID: <56729F4D.5060105@sandisk.com> Date: Thu, 17 Dec 2015 12:41:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <56729ECF.50906@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJIsWRmVeSWpSXmKPExsWyRoxnkW7A/KIwg3W7zSz+7znGZrH33WxW ixMzPS1Wrj7KZDF7ejOTxd5b2hbLj/9jsmjb+JXRgcNjYvM7do/dNxvYPCYd/szk8fHpLRaP 9/uusnmcWXCE3ePzJr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ycWUBd4s+8S8wQtrzE9rdzmCcw8s9C0jILSdksJGULGJlXMYrl ZuYU56ZnFhga6RUn5qVkFmfrJefnbmIEhzln1A7G6xPNDzEycXBKNTBKMl5cb2o9lW/TFgnv q5vCHv0JTOFcsb9nz4S/XhtjU8xWhiQoTP9zdntRpv3PoLCDOQXBa/z12AI4+KWY/pyrarf6 f5j1htaXYwtf1mSGRe9/ksFyq6ej2J85aP2NQ1xRsQLTSnxEPwSmpHXEf8y/kF3RHN3xW2bn Q/epl74rrT7h/SekVVGJpTgj0VCLuag4EQBdmCkhIwIAAA== X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD001; 1:n4xR50LrUOKFiSpl1R5cx1GmuwNkgMOZvGH16eGhOXV6gcwG4a7PQFohAwnM38GMVBvehHdqiUZgTUeq6UriiuaX7hZXYdIU5TXp6SkqeyHQq8QuPFPyj6r1e0sp1n+j7Btz7i43JHeYYErYUaWk5XD70YXn0WyX5AUJmrvzIi3JU7k4OesmA9VG8ntEwsxHzYPB4V7FtrM+bseiBsjp3Vmal+UymUx5DqPhU8URlEs1cnW1KFEzLF8QLOIsILU5aV4kAKZAVcVkJ6/vq85mgV61uFUTh9L11nAMXqAyfRDHbBs9HFHryPUZBjUiACg69Xn3LHRJgSpIm4FsJm5ezA== X-Forefront-Antispam-Report: CIP:63.163.107.172; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(6009001)(2980300002)(438002)(189002)(199003)(65816999)(2950100001)(99136001)(33656002)(586003)(59896002)(50986999)(229853001)(97736004)(50466002)(76176999)(36756003)(77096005)(4001350100001)(189998001)(81156007)(110136002)(5001960100002)(83506001)(80316001)(87936001)(19580395003)(1220700001)(1096002)(106466001)(87266999)(11100500001)(23676002)(69596002)(64126003)(65806001)(86362001)(47776003)(54356999)(92566002)(65956001)(230700001)(5008740100001)(19580405001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0201MB1574; H:milsmgep11.sandisk.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0201MB1574; 2:+P3GZ7qXXAsOXWb2rduHAmfYEePkmmehk6z/tYerbrWbe3/PEedmdZU1w+ZP0+caVADLAmJMif9vjW03lQ/Gk6S1teDwwNc8j0a9P8do6TIgAiDkbDbhXZ5p1jiSmH/HYcqd0pq1mS3lFfrNb2lpUw==; 3:q7e3nFzoYRml4U6p+c6TQrG6t5Z5qyKp9+gj1iFBC6CrR6o218TPGTDNuvjXMsgcRNTmL8IYIqH7Pasnj2UcA2jH9UAwNNFAnYoTVx7qcDuUi0qJNWCR0EHtiUHOHv5KzQEFxPl7Ysu7I27wykozXuCSeJV670K9IdqLLL6oHk2cPYcMGE8fzwbKV/kPaFaMQj0j4gZOUJaQNlseNsVZ88SAjeZCeuiNxJyJLtEU2Jo7YoWrLl4Bv5FfGdvmzbVFONSBuwa7jQWjx+uGpekMqg==; 25:ij0AVjXd6vdfXjbhXuS1Vm36s0rxBE8ia78hw/gP3zKcgMBjOjjTzK+LIpOBlj3sDDzKz+FlkZUqwRUNt9S+Mh6Ot1ysNvktzoRuFnu+18cC9UpK2FHCWzfezlKPSqRlp843VTIn33ZE7IjlQ0hSOZjqVx1qTza7Mm1EGouJYe81rELUHSigIWTmnhUfZfJ+0HOBv96TS9shvQEDOBFmpD34ewjKT3IDYhzDYERHeAN5StzHjaENoQUZpvMBQ78S8lzO8oKEf2bCHey0sZqBFA== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:BY2PR0201MB1574; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0201MB1574; 20:/aOwQd+Y2FNVU9mYICgB0Yk1Q/aWJXQ6Ln5J0mSnncE/D9u0hD5vAEgPvc5HmUrcPfk2ky9Z8YyY/2MysTkqVmFPqBTf9pnKB2XDm3stgmazEJ2mt1BKOQ/ETrs4r34rr1kuVQpqtQP/VZyJNfPxkZtUhBr6xGEDFERUqg09/p/c1fPVRu4uMg//40btluMA4Xz/nkT4kEe8VySMpu30ANMeGGZQBUmIicKDehWseyTGQ3SMl6X9oRrZ/Tfzd7st8ziZf7CTTEX5cl5MhsUaXd/fEiWajHkKQIi7+gulJfAxigbxlkSqvWl3GKMuq9e9ZTIqv+sAm06c+6OW0vR/5TH11HoMHFU3/SnSl6c/YD1+PyFxiTjlxH7Yc/FlXsKDnBZ0yYiDu0zVE7L2Y9aObKsZEWTqknru6f6ucECYM/Gb7coMmhzXj31Hhrypzmbaw0hIZ9p0siaV49/+OGOaFqkwePAh7y6znsDmWVUvyZdK8SwTxbjQ3h8nYNqqT6CZ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(146099531331640)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001); SRVR:BY2PR0201MB1574; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0201MB1574; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0201MB1574; 4:c2QVcJ3KK9W+zeHKv4kzR3JVkppUH6MEL1FtqhMvJREFGdQBMYkEWQkhri0NUJjZfbqmeb5BTEU1HcWeXvJefWzLD62yyWSeg0iH+rJAH+ZxxP2UvZJhb68o9znSashs/iML6Z6XsEczICB8Cc9Et6aO3V6goH03ij1629VNuOTREaK8BwATAdh7eoaFmWlpaBGzEuPxT8N+cPBycIypqw0yGSiv7V302z82DgsnZ8UWEYrYZs9CpqEMUJsrXb+6efYpFD5qnhjJd18fnZUS3GV7loSEE0YUP+n18jP39DGTvu8PbZwYe8UL0LIm2JYB2+LS6ujTKgf5sieUU0RiPHnXIgNDLLiFq9YkgzyXk6nXP/qP55K4dZKTyqOExYmWEc0qGp2YRqQ7LwBZe10f3srhI/CO4Wdj0yw5qL7vsGewA4qgjesxd2AV3/wbQAI7/2DhVKNUbu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1; BY2PR0201MB1574; 5:grHDbiTDnNM4eXx0dTJ72ch+siw+8orN2z8HqvsACICAo2VLqNAr/ILAf99KJAHK/gENQu4OTjb88vmQeRK1m8BEe7mfA5fM4+yktxAhNn1xiGl8nsXMciYGUa4crxJPtedtEuIlg5H+4wOLhC3jCQ==; 24:QlPaEWAHAhI0eyh94KLrZT4bYjDhtES4YXcAs6fOi8OiN81AxaptG5Jx4q0goUbnC8qghYgz5rXUTyMIoHYoSbwnR8XMxttRrxqX9iijrnQ=; 20:91qQDrpziypGTr4g4FPOOYRWXz9HKRyJnueSDsfp1llHNkiQ1SH9HSqQ/bY0/yLf07ixmaskh37qCgRfQvQo4K5chXiN154DO67fmgPyxt4AY8WmatleOeCBIG4+FS9Qtbq3x3RkcTay8TewEwZM/fpgXwUIJyIXS8L8L1l/F3nj3II0oj7xEnqbKSrI7Zz3AH4qc45qo5pj2aDd/PSo8Ai54tTY3C2sOGCyxIyG/jh3BHCf7PskvD8cIHld6Gg4 SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Dec 2015 11:41:06.2132 (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.172]; Helo=[milsmgep11.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0201MB1574 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY 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 Avoid to confuse SCSI target software by ensuring that the WRITE SAME data buffer length matches the block size. Signed-off-by: Bart Van Assche Cc: Jan Kara Cc: Christoph Hellwig Cc: Mike Snitzer Cc: Martin K. Petersen Cc: Dmitry Monakhov --- block/blk-lib.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/block/blk-lib.c b/block/blk-lib.c index f44ec95..1a60b3f 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -249,7 +249,9 @@ static void bio_add_zero_pages(struct bio *bio, sector_t nr_sects) static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, sector_t nr_sects, gfp_t gfp_mask) { - int ret; + int ret = 0; + struct request_queue *q = bdev_get_queue(bdev); + unsigned req_sects; struct bio *bio; struct bio_batch bb; DECLARE_COMPLETION_ONSTACK(wait); @@ -258,7 +260,6 @@ static int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, bb.error = 0; bb.wait = &wait; - ret = 0; while (nr_sects != 0) { bio = bio_alloc(gfp_mask, min(nr_sects, (sector_t)BIO_MAX_PAGES)); @@ -271,9 +272,11 @@ 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; - bio_add_zero_pages(bio, nr_sects); - nr_sects -= bio->bi_iter.bi_size >> 9; - sector += bio->bi_iter.bi_size >> 9; + bio_add_zero_pages(bio, q->limits.logical_block_size); + req_sects = min_t(sector_t, nr_sects, UINT_MAX >> 9); + bio->bi_iter.bi_size = req_sects << 9; + nr_sects -= req_sects; + sector += req_sects; atomic_inc(&bb.done); submit_bio(WRITE, bio); }