From patchwork Thu Feb 13 07:39:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 11393609 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 139C1930 for ; Thu, 20 Feb 2020 09:06:37 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9C1624654 for ; Thu, 20 Feb 2020 09:06:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TSnyojfy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9C1624654 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582189595; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mgr0thsxemqa6uICpSKPgahwYasLJYqXzN5kQpC8XvQ=; b=TSnyojfyCg8pCwDfIEAYYtldMoPJtV6tUJdJQ2j2TMB5/ewRLygs5tl+CmK1mgldcUCWvk GOl9nVMcR9fbvd0CXAcc+pDBcOO0iGewQy95wYMDywwhmnBsvtvIKEAqpfh5FaW+eCeUzS sDWyv/GUJqNXN606uuo0kTDzTZAtAZQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-1-KH878zMdOfjTee4QLlUg-1; Thu, 20 Feb 2020 04:06:33 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 109E718AB2CB; Thu, 20 Feb 2020 09:06:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E18299077C; Thu, 20 Feb 2020 09:06:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A770B1803C40; Thu, 20 Feb 2020 09:06:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01D7dpiV017077 for ; Thu, 13 Feb 2020 02:39:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 949881005E3A; Thu, 13 Feb 2020 07:39:51 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 906DB1005E36 for ; Thu, 13 Feb 2020 07:39:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AF5AF8EFB24 for ; Thu, 13 Feb 2020 07:39:49 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-151-GHZpC-Q5P_OQS3fiFrOLtA-1; Thu, 13 Feb 2020 02:39:47 -0500 Received: from [192.168.15.156] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j295X-0001TT-VD; Thu, 13 Feb 2020 10:39:08 +0300 From: Kirill Tkhai To: martin.petersen@oracle.com, bob.liu@oracle.com, axboe@kernel.dk, darrick.wong@oracle.com Date: Thu, 13 Feb 2020 10:39:07 +0300 Message-ID: <158157954759.111879.10496231687886192984.stgit@localhost.localdomain> In-Reply-To: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> References: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 X-MC-Unique: GHZpC-Q5P_OQS3fiFrOLtA-1 X-MC-Unique: 1-KH878zMdOfjTee4QLlUg-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01D7dpiV017077 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 20 Feb 2020 04:05:51 -0500 Cc: andrea.parri@amarulasolutions.com, snitzer@redhat.com, dhowells@redhat.com, song@kernel.org, dm-devel@redhat.com, adilger.kernel@dilger.ca, osandov@fb.com, agk@redhat.com, hare@suse.com, bvanassche@acm.org, minwoo.im.dev@gmail.com, jthumshirn@suse.de, ajay.joshi@wdc.com, chaitanya.kulkarni@wdc.com, ming.lei@redhat.com, linux-block@vger.kernel.org, ktkhai@virtuozzo.com, dsterba@suse.com, sagi@grimberg.me, damien.lemoal@wdc.com, tytso@mit.edu, linux-kernel@vger.kernel.org, tj@kernel.org, asml.silence@gmail.com Subject: [dm-devel] [PATCH v7 1/6] block: Add @flags argument to bdev_write_zeroes_sectors() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This is a preparation for next patch, which introduces a new flag BLKDEV_ZERO_ALLOCATE for calls, which need only allocation of blocks and don't need actual blocks zeroing. Signed-off-by: Kirill Tkhai Reviewed-by: Bob Liu Reviewed-by: Martin K. Petersen --- block/blk-lib.c | 6 +++--- drivers/md/dm-kcopyd.c | 2 +- drivers/target/target_core_iblock.c | 4 ++-- include/linux/blkdev.h | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/block/blk-lib.c b/block/blk-lib.c index 5f2c429d4378..3e38c93cfc53 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -224,7 +224,7 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev, return -EPERM; /* Ensure that max_write_zeroes_sectors doesn't overflow bi_size */ - max_write_zeroes_sectors = bdev_write_zeroes_sectors(bdev); + max_write_zeroes_sectors = bdev_write_zeroes_sectors(bdev, 0); if (max_write_zeroes_sectors == 0) return -EOPNOTSUPP; @@ -362,7 +362,7 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, sector_t bs_mask; struct bio *bio; struct blk_plug plug; - bool try_write_zeroes = !!bdev_write_zeroes_sectors(bdev); + bool try_write_zeroes = !!bdev_write_zeroes_sectors(bdev, 0); bs_mask = (bdev_logical_block_size(bdev) >> 9) - 1; if ((sector | nr_sects) & bs_mask) @@ -391,7 +391,7 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, try_write_zeroes = false; goto retry; } - if (!bdev_write_zeroes_sectors(bdev)) { + if (!bdev_write_zeroes_sectors(bdev, 0)) { /* * Zeroing offload support was indicated, but the * device reported ILLEGAL REQUEST (for some devices diff --git a/drivers/md/dm-kcopyd.c b/drivers/md/dm-kcopyd.c index 1bbe4a34ef4c..f1b8e7926dd4 100644 --- a/drivers/md/dm-kcopyd.c +++ b/drivers/md/dm-kcopyd.c @@ -831,7 +831,7 @@ void dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from, */ job->rw = REQ_OP_WRITE_ZEROES; for (i = 0; i < job->num_dests; i++) - if (!bdev_write_zeroes_sectors(job->dests[i].bdev)) { + if (!bdev_write_zeroes_sectors(job->dests[i].bdev, 0)) { job->rw = WRITE; break; } diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 51ffd5c002de..73a63e197bf5 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -117,7 +117,7 @@ static int iblock_configure_device(struct se_device *dev) * Enable write same emulation for IBLOCK and use 0xFFFF as * the smaller WRITE_SAME(10) only has a two-byte block count. */ - max_write_zeroes_sectors = bdev_write_zeroes_sectors(bd); + max_write_zeroes_sectors = bdev_write_zeroes_sectors(bd, 0); if (max_write_zeroes_sectors) dev->dev_attrib.max_write_same_len = max_write_zeroes_sectors; else @@ -468,7 +468,7 @@ iblock_execute_write_same(struct se_cmd *cmd) return TCM_INVALID_CDB_FIELD; } - if (bdev_write_zeroes_sectors(bdev)) { + if (bdev_write_zeroes_sectors(bdev, 0)) { if (!iblock_execute_zero_out(bdev, cmd)) return 0; } diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 053ea4b51988..1e3c08854b09 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1417,7 +1417,8 @@ static inline unsigned int bdev_write_same(struct block_device *bdev) return 0; } -static inline unsigned int bdev_write_zeroes_sectors(struct block_device *bdev) +static inline unsigned int bdev_write_zeroes_sectors(struct block_device *bdev, + unsigned int flags) { struct request_queue *q = bdev_get_queue(bdev); From patchwork Thu Feb 13 07:39:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 11393607 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 930661892 for ; Thu, 20 Feb 2020 09:06:35 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5069E2465D for ; Thu, 20 Feb 2020 09:06:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DYUqhJyi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5069E2465D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582189594; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=P4HlSIEKVz4VOH5+3mGmWv7UvaGX5tc/fOVbT0GJFXs=; b=DYUqhJyiUs5263qqvvGEghkreNr6FJz4O0Pxj/dOO0TxrereAPyDfu2y5OLFJ1krzPzaN+ XZejajmgctjCei27va754QXWX2NMAK/srXPuHzl74ro78N0GYMug+DnqKVj8VGXMSQymWI TGl9jMSOpeRzOfZb0Ub0/duvm/9HlOQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-YHK6lgMVPHeeylE6G9Nwyw-1; Thu, 20 Feb 2020 04:06:31 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 369351007270; Thu, 20 Feb 2020 09:06:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D9791001920; Thu, 20 Feb 2020 09:06:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BB4FD8B2CC; Thu, 20 Feb 2020 09:06:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01D7dsXw017103 for ; Thu, 13 Feb 2020 02:39:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 890F111232F; Thu, 13 Feb 2020 07:39:54 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84698112327 for ; Thu, 13 Feb 2020 07:39:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E0608EFB21 for ; Thu, 13 Feb 2020 07:39:49 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-282-1acXQO9LPgqOxzb4FNZT4g-1; Thu, 13 Feb 2020 02:39:46 -0500 Received: from [192.168.15.156] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j295d-0001TW-OE; Thu, 13 Feb 2020 10:39:13 +0300 From: Kirill Tkhai To: martin.petersen@oracle.com, bob.liu@oracle.com, axboe@kernel.dk, darrick.wong@oracle.com Date: Thu, 13 Feb 2020 10:39:13 +0300 Message-ID: <158157955322.111879.16371696985080169961.stgit@localhost.localdomain> In-Reply-To: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> References: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 X-MC-Unique: 1acXQO9LPgqOxzb4FNZT4g-1 X-MC-Unique: YHK6lgMVPHeeylE6G9Nwyw-1 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01D7dsXw017103 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 20 Feb 2020 04:05:51 -0500 Cc: andrea.parri@amarulasolutions.com, snitzer@redhat.com, dhowells@redhat.com, song@kernel.org, dm-devel@redhat.com, adilger.kernel@dilger.ca, osandov@fb.com, agk@redhat.com, hare@suse.com, bvanassche@acm.org, minwoo.im.dev@gmail.com, jthumshirn@suse.de, ajay.joshi@wdc.com, chaitanya.kulkarni@wdc.com, ming.lei@redhat.com, linux-block@vger.kernel.org, ktkhai@virtuozzo.com, dsterba@suse.com, sagi@grimberg.me, damien.lemoal@wdc.com, tytso@mit.edu, linux-kernel@vger.kernel.org, tj@kernel.org, asml.silence@gmail.com Subject: [dm-devel] [PATCH v7 2/6] block: Pass op_flags into blk_queue_get_max_sectors() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This preparation patch changes argument type, and now the function takes full op_flags instead of just op code. Signed-off-by: Kirill Tkhai Reviewed-by: Bob Liu --- block/blk-core.c | 4 ++-- include/linux/blkdev.h | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/block/blk-core.c b/block/blk-core.c index 089e890ab208..28a6d46eb982 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1221,10 +1221,10 @@ EXPORT_SYMBOL(submit_bio); static int blk_cloned_rq_check_limits(struct request_queue *q, struct request *rq) { - if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, req_op(rq))) { + if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, rq->cmd_flags)) { printk(KERN_ERR "%s: over max size limit. (%u > %u)\n", __func__, blk_rq_sectors(rq), - blk_queue_get_max_sectors(q, req_op(rq))); + blk_queue_get_max_sectors(q, rq->cmd_flags)); return -EIO; } diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1e3c08854b09..f4ec7ae214ab 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -988,8 +988,10 @@ static inline struct bio_vec req_bvec(struct request *rq) } static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, - int op) + unsigned int op_flags) { + int op = op_flags & REQ_OP_MASK; + if (unlikely(op == REQ_OP_DISCARD || op == REQ_OP_SECURE_ERASE)) return min(q->limits.max_discard_sectors, UINT_MAX >> SECTOR_SHIFT); @@ -1028,10 +1030,10 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq, if (!q->limits.chunk_sectors || req_op(rq) == REQ_OP_DISCARD || req_op(rq) == REQ_OP_SECURE_ERASE) - return blk_queue_get_max_sectors(q, req_op(rq)); + return blk_queue_get_max_sectors(q, rq->cmd_flags); return min(blk_max_size_offset(q, offset), - blk_queue_get_max_sectors(q, req_op(rq))); + blk_queue_get_max_sectors(q, rq->cmd_flags)); } static inline unsigned int blk_rq_count_bios(struct request *rq) From patchwork Thu Feb 13 07:39:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 11393599 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6214013A4 for ; Thu, 20 Feb 2020 09:06:23 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2332324656 for ; Thu, 20 Feb 2020 09:06:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JWMaSsPz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2332324656 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582189582; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/WMN4Cwca3etXm18kgXDSmjcdVZpwYjY2qXHHXGgC10=; b=JWMaSsPzOqztoKOfYNG07jOAH7ht2ZR/FGjaVZaZBIxTUc5zQb8/ZpnLi1186Bpoyk3m0n 7YfnsIr1zqSLNjIsie//Hr5nBbAbGatJLiFgjVmTZ+uiaB2l07mySPqMV0/RX/ld/easaA DCXzFORTJ49bZR5kzieomPZv2d42EyQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-u7uo3N8TO7ifnTAqYayWfQ-1; Thu, 20 Feb 2020 04:06:20 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86B2613F9; Thu, 20 Feb 2020 09:06:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B04C19C58; Thu, 20 Feb 2020 09:06:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0143F1803C40; Thu, 20 Feb 2020 09:06:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01D7eBjg017147 for ; Thu, 13 Feb 2020 02:40:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id B71F5112328; Thu, 13 Feb 2020 07:40:11 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B339117596 for ; Thu, 13 Feb 2020 07:40:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 29FA1185B0D5 for ; Thu, 13 Feb 2020 07:40:09 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-419-TMPduqOcN5eWQl283xFZeQ-1; Thu, 13 Feb 2020 02:40:07 -0500 Received: from [192.168.15.156] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j295j-0001TZ-7I; Thu, 13 Feb 2020 10:39:19 +0300 From: Kirill Tkhai To: martin.petersen@oracle.com, bob.liu@oracle.com, axboe@kernel.dk, darrick.wong@oracle.com Date: Thu, 13 Feb 2020 10:39:18 +0300 Message-ID: <158157955888.111879.4517095626498945551.stgit@localhost.localdomain> In-Reply-To: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> References: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 X-MC-Unique: TMPduqOcN5eWQl283xFZeQ-1 X-MC-Unique: u7uo3N8TO7ifnTAqYayWfQ-1 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01D7eBjg017147 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 20 Feb 2020 04:05:51 -0500 Cc: andrea.parri@amarulasolutions.com, snitzer@redhat.com, dhowells@redhat.com, song@kernel.org, dm-devel@redhat.com, adilger.kernel@dilger.ca, osandov@fb.com, agk@redhat.com, hare@suse.com, bvanassche@acm.org, minwoo.im.dev@gmail.com, jthumshirn@suse.de, ajay.joshi@wdc.com, chaitanya.kulkarni@wdc.com, ming.lei@redhat.com, linux-block@vger.kernel.org, ktkhai@virtuozzo.com, dsterba@suse.com, sagi@grimberg.me, damien.lemoal@wdc.com, tytso@mit.edu, linux-kernel@vger.kernel.org, tj@kernel.org, asml.silence@gmail.com Subject: [dm-devel] [PATCH v7 3/6] block: Introduce blk_queue_get_max_write_zeroes_sectors() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This introduces a new primitive, which returns max sectors for REQ_OP_WRITE_ZEROES operation. @op_flags is unused now, and it will be enabled in next patch. Signed-off-by: Kirill Tkhai Reviewed-by: Bob Liu --- block/blk-core.c | 2 +- block/blk-merge.c | 9 ++++++--- include/linux/blkdev.h | 8 +++++++- 3 files changed, 14 insertions(+), 5 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/block/blk-core.c b/block/blk-core.c index 28a6d46eb982..c7387b0d69e5 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -949,7 +949,7 @@ generic_make_request_checks(struct bio *bio) goto not_supported; break; case REQ_OP_WRITE_ZEROES: - if (!q->limits.max_write_zeroes_sectors) + if (!blk_queue_get_max_write_zeroes_sectors(q, bio->bi_opf)) goto not_supported; break; default: diff --git a/block/blk-merge.c b/block/blk-merge.c index 1534ed736363..467b292bc6e8 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -105,15 +105,18 @@ static struct bio *blk_bio_discard_split(struct request_queue *q, static struct bio *blk_bio_write_zeroes_split(struct request_queue *q, struct bio *bio, struct bio_set *bs, unsigned *nsegs) { + unsigned int max_sectors; + + max_sectors = blk_queue_get_max_write_zeroes_sectors(q, bio->bi_opf); *nsegs = 0; - if (!q->limits.max_write_zeroes_sectors) + if (!max_sectors) return NULL; - if (bio_sectors(bio) <= q->limits.max_write_zeroes_sectors) + if (bio_sectors(bio) <= max_sectors) return NULL; - return bio_split(bio, q->limits.max_write_zeroes_sectors, GFP_NOIO, bs); + return bio_split(bio, max_sectors, GFP_NOIO, bs); } static struct bio *blk_bio_write_same_split(struct request_queue *q, diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index f4ec7ae214ab..55a714161684 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -987,6 +987,12 @@ static inline struct bio_vec req_bvec(struct request *rq) return mp_bvec_iter_bvec(rq->bio->bi_io_vec, rq->bio->bi_iter); } +static inline unsigned int blk_queue_get_max_write_zeroes_sectors( + struct request_queue *q, unsigned int op_flags) +{ + return q->limits.max_write_zeroes_sectors; +} + static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, unsigned int op_flags) { @@ -1000,7 +1006,7 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, return q->limits.max_write_same_sectors; if (unlikely(op == REQ_OP_WRITE_ZEROES)) - return q->limits.max_write_zeroes_sectors; + return blk_queue_get_max_write_zeroes_sectors(q, op_flags); return q->limits.max_sectors; } From patchwork Thu Feb 13 07:39:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 11393605 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38F06930 for ; Thu, 20 Feb 2020 09:06:35 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EAE5C24654 for ; Thu, 20 Feb 2020 09:06:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gMx0zrte" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EAE5C24654 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582189594; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=S1+8B/D6MiUAU4le6tAQF5eEARbKdq44MTLi75t3trg=; b=gMx0zrteH8ZGPM9dYDbSQTVn51/llxMxKE3AYAR20bP42rE7fVI7e2DfT7J7Irhmy7ukNZ GRAx9PCNr90ptNC4KbpOalrVPmoSSTUyaMINXiycFwW0aSD1j+Vh/ImwCE1MjYC8CpHUDU 15DZdwWSllN+6eXwHHaz259SYCM5mNs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-278-1835xhBEOfKMHY8sb1MSyg-1; Thu, 20 Feb 2020 04:06:31 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2002F101FC6E; Thu, 20 Feb 2020 09:06:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED47A8B54A; Thu, 20 Feb 2020 09:06:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AC79835AF3; Thu, 20 Feb 2020 09:06:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01D7dpBv017076 for ; Thu, 13 Feb 2020 02:39:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 94C891005E3B; Thu, 13 Feb 2020 07:39:51 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 908641005E37 for ; Thu, 13 Feb 2020 07:39:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E2B1185B0D5 for ; Thu, 13 Feb 2020 07:39:50 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-388--ZEsBYCdOpe-Iff9aM3Hig-1; Thu, 13 Feb 2020 02:39:47 -0500 Received: from [192.168.15.156] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j295p-0001Te-0k; Thu, 13 Feb 2020 10:39:25 +0300 From: Kirill Tkhai To: martin.petersen@oracle.com, bob.liu@oracle.com, axboe@kernel.dk, darrick.wong@oracle.com Date: Thu, 13 Feb 2020 10:39:24 +0300 Message-ID: <158157956448.111879.4846533854153943119.stgit@localhost.localdomain> In-Reply-To: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> References: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 X-MC-Unique: -ZEsBYCdOpe-Iff9aM3Hig-1 X-MC-Unique: 1835xhBEOfKMHY8sb1MSyg-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01D7dpBv017076 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 20 Feb 2020 04:05:51 -0500 Cc: andrea.parri@amarulasolutions.com, snitzer@redhat.com, dhowells@redhat.com, song@kernel.org, dm-devel@redhat.com, adilger.kernel@dilger.ca, osandov@fb.com, agk@redhat.com, hare@suse.com, bvanassche@acm.org, minwoo.im.dev@gmail.com, jthumshirn@suse.de, ajay.joshi@wdc.com, chaitanya.kulkarni@wdc.com, ming.lei@redhat.com, linux-block@vger.kernel.org, ktkhai@virtuozzo.com, dsterba@suse.com, sagi@grimberg.me, damien.lemoal@wdc.com, tytso@mit.edu, linux-kernel@vger.kernel.org, tj@kernel.org, asml.silence@gmail.com Subject: [dm-devel] [PATCH v7 4/6] block: Add support for REQ_ALLOCATE flag X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This adds support for REQ_ALLOCATE extension of REQ_OP_WRITE_ZEROES operation, which encourages a block device driver to just allocate blocks (or mark them allocated) instead of actual blocks zeroing. REQ_ALLOCATE is aimed to be used for network filesystems providing a block device interface. Also, block devices, which map a file on other filesystem (like loop), may use this for less fragmentation and batching fallocate() requests. Hypervisors like QEMU may introduce optimizations of clusters allocations based on this. BLKDEV_ZERO_ALLOCATE is a new corresponding flag for blkdev_issue_zeroout(). Stacking devices start from zero max_allocate_sectors limit for now, and the support is going to be implemented separate for each device in the future. Signed-off-by: Kirill Tkhai Reviewed-by: Bob Liu --- block/blk-lib.c | 17 ++++++++++------- block/blk-settings.c | 4 ++++ fs/block_dev.c | 4 ++++ include/linux/blk_types.h | 6 ++++++ include/linux/blkdev.h | 13 ++++++++++--- 5 files changed, 34 insertions(+), 10 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/block/blk-lib.c b/block/blk-lib.c index 3e38c93cfc53..9cd6f86523ba 100644 --- a/block/blk-lib.c +++ b/block/blk-lib.c @@ -214,7 +214,7 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev, struct bio **biop, unsigned flags) { struct bio *bio = *biop; - unsigned int max_write_zeroes_sectors; + unsigned int max_write_zeroes_sectors, req_flags = 0; struct request_queue *q = bdev_get_queue(bdev); if (!q) @@ -224,18 +224,21 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev, return -EPERM; /* Ensure that max_write_zeroes_sectors doesn't overflow bi_size */ - max_write_zeroes_sectors = bdev_write_zeroes_sectors(bdev, 0); + max_write_zeroes_sectors = bdev_write_zeroes_sectors(bdev, flags); if (max_write_zeroes_sectors == 0) return -EOPNOTSUPP; + if (flags & BLKDEV_ZERO_NOUNMAP) + req_flags |= REQ_NOUNMAP; + if (flags & BLKDEV_ZERO_ALLOCATE) + req_flags |= REQ_ALLOCATE|REQ_NOUNMAP; + while (nr_sects) { bio = blk_next_bio(bio, 0, gfp_mask); bio->bi_iter.bi_sector = sector; bio_set_dev(bio, bdev); - bio->bi_opf = REQ_OP_WRITE_ZEROES; - if (flags & BLKDEV_ZERO_NOUNMAP) - bio->bi_opf |= REQ_NOUNMAP; + bio->bi_opf = REQ_OP_WRITE_ZEROES | req_flags; if (nr_sects > max_write_zeroes_sectors) { bio->bi_iter.bi_size = max_write_zeroes_sectors << 9; @@ -362,7 +365,7 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, sector_t bs_mask; struct bio *bio; struct blk_plug plug; - bool try_write_zeroes = !!bdev_write_zeroes_sectors(bdev, 0); + bool try_write_zeroes = !!bdev_write_zeroes_sectors(bdev, flags); bs_mask = (bdev_logical_block_size(bdev) >> 9) - 1; if ((sector | nr_sects) & bs_mask) @@ -391,7 +394,7 @@ int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, try_write_zeroes = false; goto retry; } - if (!bdev_write_zeroes_sectors(bdev, 0)) { + if (!bdev_write_zeroes_sectors(bdev, flags)) { /* * Zeroing offload support was indicated, but the * device reported ILLEGAL REQUEST (for some devices diff --git a/block/blk-settings.c b/block/blk-settings.c index c8eda2e7b91e..8d5df9d37239 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -48,6 +48,7 @@ void blk_set_default_limits(struct queue_limits *lim) lim->chunk_sectors = 0; lim->max_write_same_sectors = 0; lim->max_write_zeroes_sectors = 0; + lim->max_allocate_sectors = 0; lim->max_discard_sectors = 0; lim->max_hw_discard_sectors = 0; lim->discard_granularity = 0; @@ -83,6 +84,7 @@ void blk_set_stacking_limits(struct queue_limits *lim) lim->max_dev_sectors = UINT_MAX; lim->max_write_same_sectors = UINT_MAX; lim->max_write_zeroes_sectors = UINT_MAX; + lim->max_allocate_sectors = 0; } EXPORT_SYMBOL(blk_set_stacking_limits); @@ -506,6 +508,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, b->max_write_same_sectors); t->max_write_zeroes_sectors = min(t->max_write_zeroes_sectors, b->max_write_zeroes_sectors); + t->max_allocate_sectors = min(t->max_allocate_sectors, + b->max_allocate_sectors); t->bounce_pfn = min_not_zero(t->bounce_pfn, b->bounce_pfn); t->seg_boundary_mask = min_not_zero(t->seg_boundary_mask, diff --git a/fs/block_dev.c b/fs/block_dev.c index 69bf2fb6f7cd..1ffef894b3bd 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -2122,6 +2122,10 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start, error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9, GFP_KERNEL, BLKDEV_ZERO_NOFALLBACK); break; + case FALLOC_FL_KEEP_SIZE: + error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9, + GFP_KERNEL, BLKDEV_ZERO_ALLOCATE | BLKDEV_ZERO_NOFALLBACK); + break; case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE: error = blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL, 0); diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 70254ae11769..6f34f5d6edf1 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -335,6 +335,11 @@ enum req_flag_bits { /* command specific flags for REQ_OP_WRITE_ZEROES: */ __REQ_NOUNMAP, /* do not free blocks when zeroing */ + /* + * Ensure the LBA range is backed by physical storage + * without writing zeroes to the blocks. + */ + __REQ_ALLOCATE, __REQ_HIPRI, @@ -362,6 +367,7 @@ enum req_flag_bits { #define REQ_CGROUP_PUNT (1ULL << __REQ_CGROUP_PUNT) #define REQ_NOUNMAP (1ULL << __REQ_NOUNMAP) +#define REQ_ALLOCATE (1ULL << __REQ_ALLOCATE) #define REQ_HIPRI (1ULL << __REQ_HIPRI) #define REQ_DRV (1ULL << __REQ_DRV) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 55a714161684..40707f980a2e 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -336,6 +336,7 @@ struct queue_limits { unsigned int max_hw_discard_sectors; unsigned int max_write_same_sectors; unsigned int max_write_zeroes_sectors; + unsigned int max_allocate_sectors; unsigned int discard_granularity; unsigned int discard_alignment; @@ -990,6 +991,8 @@ static inline struct bio_vec req_bvec(struct request *rq) static inline unsigned int blk_queue_get_max_write_zeroes_sectors( struct request_queue *q, unsigned int op_flags) { + if (op_flags & REQ_ALLOCATE) + return q->limits.max_allocate_sectors; return q->limits.max_write_zeroes_sectors; } @@ -1226,6 +1229,7 @@ extern int __blkdev_issue_discard(struct block_device *bdev, sector_t sector, #define BLKDEV_ZERO_NOUNMAP (1 << 0) /* do not free blocks */ #define BLKDEV_ZERO_NOFALLBACK (1 << 1) /* don't write explicit zeroes */ +#define BLKDEV_ZERO_ALLOCATE (1 << 2) /* allocate range of blocks */ extern int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector, sector_t nr_sects, gfp_t gfp_mask, struct bio **biop, @@ -1430,10 +1434,13 @@ static inline unsigned int bdev_write_zeroes_sectors(struct block_device *bdev, { struct request_queue *q = bdev_get_queue(bdev); - if (q) - return q->limits.max_write_zeroes_sectors; + if (!q) + return 0; - return 0; + if (flags & BLKDEV_ZERO_ALLOCATE) + return q->limits.max_allocate_sectors; + else + return q->limits.max_write_zeroes_sectors; } static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev) From patchwork Thu Feb 13 07:39:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 11393603 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E16A4930 for ; Thu, 20 Feb 2020 09:06:31 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A380624654 for ; Thu, 20 Feb 2020 09:06:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zjf2QIUX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A380624654 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582189590; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JoUv8gywQOqmZsTnHmpWH9jbzHoo7j75nZc51y8q7Do=; b=Zjf2QIUXdZ12jAPNbw9e4Q3cgL1Ijf8J+Mj+rfP8upSIE9Gfs1TtDu4ViO8Xa/szbXtfIN 4pPpMpC51y+C/TdfCuWgqeAeF1uIAZf0/6fGeKRONZMk210puFGBpJk2LjIIwv5GwYwLoY Sn+zvZddn2XVHaG1bGrs1QWux/7p65s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-227-R5e9EUw8NGq8cuQGyRdzbQ-1; Thu, 20 Feb 2020 04:06:28 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7B75218AB2D3; Thu, 20 Feb 2020 09:06:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 570EB90F7B; Thu, 20 Feb 2020 09:06:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 158378B2CD; Thu, 20 Feb 2020 09:06:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01D7dpRb017079 for ; Thu, 13 Feb 2020 02:39:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id B5CB52166B2E; Thu, 13 Feb 2020 07:39:51 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B16282166B2B for ; Thu, 13 Feb 2020 07:39:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AA4548032BD for ; Thu, 13 Feb 2020 07:39:49 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-260-kv46uviiPgmOmRHDyDLItw-1; Thu, 13 Feb 2020 02:39:47 -0500 Received: from [192.168.15.156] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j295u-0001Tm-IL; Thu, 13 Feb 2020 10:39:30 +0300 From: Kirill Tkhai To: martin.petersen@oracle.com, bob.liu@oracle.com, axboe@kernel.dk, darrick.wong@oracle.com Date: Thu, 13 Feb 2020 10:39:30 +0300 Message-ID: <158157957022.111879.2458344432302909777.stgit@localhost.localdomain> In-Reply-To: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> References: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 X-MC-Unique: kv46uviiPgmOmRHDyDLItw-1 X-MC-Unique: R5e9EUw8NGq8cuQGyRdzbQ-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01D7dpRb017079 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 20 Feb 2020 04:05:51 -0500 Cc: andrea.parri@amarulasolutions.com, snitzer@redhat.com, dhowells@redhat.com, song@kernel.org, dm-devel@redhat.com, adilger.kernel@dilger.ca, osandov@fb.com, agk@redhat.com, hare@suse.com, bvanassche@acm.org, minwoo.im.dev@gmail.com, jthumshirn@suse.de, ajay.joshi@wdc.com, chaitanya.kulkarni@wdc.com, ming.lei@redhat.com, linux-block@vger.kernel.org, ktkhai@virtuozzo.com, dsterba@suse.com, sagi@grimberg.me, damien.lemoal@wdc.com, tytso@mit.edu, linux-kernel@vger.kernel.org, tj@kernel.org, asml.silence@gmail.com Subject: [dm-devel] [PATCH v7 5/6] block: Add blk_queue_max_allocate_sectors() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This is a new helper to assign max_allocate_sectors limit of block device queue. Signed-off-by: Kirill Tkhai Reviewed-by: Bob Liu --- block/blk-settings.c | 13 +++++++++++++ include/linux/blkdev.h | 2 ++ 2 files changed, 15 insertions(+) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/block/blk-settings.c b/block/blk-settings.c index 8d5df9d37239..24cf8fbbd125 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -259,6 +259,19 @@ void blk_queue_max_write_zeroes_sectors(struct request_queue *q, } EXPORT_SYMBOL(blk_queue_max_write_zeroes_sectors); +/** + * blk_queue_max_allocate_sectors - set max sectors for a single + * allocate request + * @q: the request queue for the device + * @max_allocate_sectors: maximum number of sectors to write per command + **/ +void blk_queue_max_allocate_sectors(struct request_queue *q, + unsigned int max_allocate_sectors) +{ + q->limits.max_allocate_sectors = max_allocate_sectors; +} +EXPORT_SYMBOL(blk_queue_max_allocate_sectors); + /** * blk_queue_max_segments - set max hw segments for a request for this queue * @q: the request queue for the device diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 40707f980a2e..f5edbfea7b84 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1088,6 +1088,8 @@ extern void blk_queue_max_write_same_sectors(struct request_queue *q, unsigned int max_write_same_sectors); extern void blk_queue_max_write_zeroes_sectors(struct request_queue *q, unsigned int max_write_same_sectors); +extern void blk_queue_max_allocate_sectors(struct request_queue *q, + unsigned int max_allocate_sectors); extern void blk_queue_logical_block_size(struct request_queue *, unsigned int); extern void blk_queue_physical_block_size(struct request_queue *, unsigned int); extern void blk_queue_alignment_offset(struct request_queue *q, From patchwork Thu Feb 13 07:39:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 11393595 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E39413A4 for ; Thu, 20 Feb 2020 09:06:19 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BB8224656 for ; Thu, 20 Feb 2020 09:06:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PEYv0PU/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BB8224656 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582189578; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mPFGar9/NEzfBWvpN8ETY0/P9Vv+Xzk7zPbQG1C+PM8=; b=PEYv0PU/F9hDa1T4ISydDBwEw/BzrGxLEcj9/0Aa49STtAIF8jdJDxSYydXY08a+W/i3H9 9pf+Dtb3gJaNMKpXxaOTTjfmj0ru2CTmOdXFqRzvBGcS11sm4+z62aSl+DtirRRtwDHo9M mAOHe4aBxTyeYQRW0XwrEcbTy7hCrwU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-202-k9mKlXlTMtStlN4r02VIhQ-1; Thu, 20 Feb 2020 04:06:16 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24407800D55; Thu, 20 Feb 2020 09:06:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F285085735; Thu, 20 Feb 2020 09:06:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7D8811803C32; Thu, 20 Feb 2020 09:06:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01D7dpoH017078 for ; Thu, 13 Feb 2020 02:39:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id B797B2166B2A; Thu, 13 Feb 2020 07:39:51 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B3A912166B2C for ; Thu, 13 Feb 2020 07:39:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6787A1017E73 for ; Thu, 13 Feb 2020 07:39:51 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-siBOAQPwOrKwbPCbs9rT4Q-1; Thu, 13 Feb 2020 02:39:47 -0500 Received: from [192.168.15.156] (helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j2961-0001Tq-5i; Thu, 13 Feb 2020 10:39:37 +0300 From: Kirill Tkhai To: martin.petersen@oracle.com, bob.liu@oracle.com, axboe@kernel.dk, darrick.wong@oracle.com Date: Thu, 13 Feb 2020 10:39:35 +0300 Message-ID: <158157957565.111879.5952051034259419400.stgit@localhost.localdomain> In-Reply-To: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> References: <158157930219.111879.12072477040351921368.stgit@localhost.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 X-MC-Unique: siBOAQPwOrKwbPCbs9rT4Q-1 X-MC-Unique: k9mKlXlTMtStlN4r02VIhQ-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01D7dpoH017078 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 20 Feb 2020 04:05:51 -0500 Cc: andrea.parri@amarulasolutions.com, snitzer@redhat.com, dhowells@redhat.com, song@kernel.org, dm-devel@redhat.com, adilger.kernel@dilger.ca, osandov@fb.com, agk@redhat.com, hare@suse.com, bvanassche@acm.org, minwoo.im.dev@gmail.com, jthumshirn@suse.de, ajay.joshi@wdc.com, chaitanya.kulkarni@wdc.com, ming.lei@redhat.com, linux-block@vger.kernel.org, ktkhai@virtuozzo.com, dsterba@suse.com, sagi@grimberg.me, damien.lemoal@wdc.com, tytso@mit.edu, linux-kernel@vger.kernel.org, tj@kernel.org, asml.silence@gmail.com Subject: [dm-devel] [PATCH v7 6/6] loop: Add support for REQ_ALLOCATE X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Support for new modifier of REQ_OP_WRITE_ZEROES command. This results in allocation extents in backing file instead of actual blocks zeroing. Signed-off-by: Kirill Tkhai Reviewed-by: Bob Liu Reviewed-by: Darrick J. Wong --- drivers/block/loop.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 739b372a5112..0704167a5aaa 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -581,6 +581,16 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, return 0; } +/* Convert REQ_OP_WRITE_ZEROES modifiers into fallocate mode */ +static unsigned int write_zeroes_to_fallocate_mode(unsigned int flags) +{ + if (flags & REQ_ALLOCATE) + return 0; + if (flags & REQ_NOUNMAP) + return FALLOC_FL_ZERO_RANGE; + return FALLOC_FL_PUNCH_HOLE; +} + static int do_req_filebacked(struct loop_device *lo, struct request *rq) { struct loop_cmd *cmd = blk_mq_rq_to_pdu(rq); @@ -599,14 +609,8 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq) case REQ_OP_FLUSH: return lo_req_flush(lo, rq); case REQ_OP_WRITE_ZEROES: - /* - * If the caller doesn't want deallocation, call zeroout to - * write zeroes the range. Otherwise, punch them out. - */ return lo_fallocate(lo, rq, pos, - (rq->cmd_flags & REQ_NOUNMAP) ? - FALLOC_FL_ZERO_RANGE : - FALLOC_FL_PUNCH_HOLE); + write_zeroes_to_fallocate_mode(rq->cmd_flags)); case REQ_OP_DISCARD: return lo_fallocate(lo, rq, pos, FALLOC_FL_PUNCH_HOLE); case REQ_OP_WRITE: @@ -877,6 +881,7 @@ static void loop_config_discard(struct loop_device *lo) q->limits.discard_alignment = 0; blk_queue_max_discard_sectors(q, 0); blk_queue_max_write_zeroes_sectors(q, 0); + blk_queue_max_allocate_sectors(q, 0); blk_queue_flag_clear(QUEUE_FLAG_DISCARD, q); return; } @@ -886,6 +891,7 @@ static void loop_config_discard(struct loop_device *lo) blk_queue_max_discard_sectors(q, UINT_MAX >> 9); blk_queue_max_write_zeroes_sectors(q, UINT_MAX >> 9); + blk_queue_max_allocate_sectors(q, UINT_MAX >> 9); blk_queue_flag_set(QUEUE_FLAG_DISCARD, q); }