From patchwork Wed Jan 22 10:58:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 11345799 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 E602317EA for ; Wed, 22 Jan 2020 13:58:17 +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 A63C82253D for ; Wed, 22 Jan 2020 13:58:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="enpXcHig" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A63C82253D 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=1579701496; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=+SOsEIQu4sYPn5tdn1zsxxdbS7MxolifkWyaKdYvyOk=; b=enpXcHigTQ0EVL9FyZPu9x3f0MfPbfNi74lZF3Wh1eD5oHKCe0WKRB80Ik6HrGhVGPjyyy M2YpucqtZAZdvo1GXpi9fi4cPtYxP/7A6gpVtw3UPDwaCBhXuoaMPihiqf33i6Tlm0V0EA lUiVudDYZJyJr3+feb2uJ6bglmWActY= 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-237-Nd3njrQrN2KAGoFJlsLWSw-1; Wed, 22 Jan 2020 08:58:14 -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 C19E91088381; Wed, 22 Jan 2020 13:58:09 +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 618C07C42C; Wed, 22 Jan 2020 13:58:09 +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 0252A18089CD; Wed, 22 Jan 2020 13:58:08 +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 00MAwhJg002562 for ; Wed, 22 Jan 2020 05:58:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 654F210ABC8E; Wed, 22 Jan 2020 10:58:43 +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 5FE1E10ABC8B for ; Wed, 22 Jan 2020 10:58:41 +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 1345F802FE6 for ; Wed, 22 Jan 2020 10:58:41 +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-400-y76eKLAYM-6lW2Mppjrhug-1; Wed, 22 Jan 2020 05:58:38 -0500 Received: from dhcp-172-16-24-104.sw.ru ([172.16.24.104] helo=localhost.localdomain) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1iuDiL-0002gz-Dg; Wed, 22 Jan 2020 13:58:25 +0300 From: Kirill Tkhai To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, martin.petersen@oracle.com, bob.liu@oracle.com, axboe@kernel.dk, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, song@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, Chaitanya.Kulkarni@wdc.com, darrick.wong@oracle.com, ming.lei@redhat.com, osandov@fb.com, jthumshirn@suse.de, minwoo.im.dev@gmail.com, damien.lemoal@wdc.com, andrea.parri@amarulasolutions.com, hare@suse.com, tj@kernel.org, ajay.joshi@wdc.com, sagi@grimberg.me, dsterba@suse.com, chaitanya.kulkarni@wdc.com, bvanassche@acm.org, dhowells@redhat.com, asml.silence@gmail.com, ktkhai@virtuozzo.com Date: Wed, 22 Jan 2020 13:58:25 +0300 Message-ID: <157969070494.174869.1733513737078026259.stgit@localhost.localdomain> In-Reply-To: <157968992539.174869.7490844754165043549.stgit@localhost.localdomain> References: <157968992539.174869.7490844754165043549.stgit@localhost.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 X-MC-Unique: y76eKLAYM-6lW2Mppjrhug-1 X-MC-Unique: Nd3njrQrN2KAGoFJlsLWSw-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 00MAwhJg002562 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Wed, 22 Jan 2020 08:58:06 -0500 Subject: [dm-devel] [PATCH v5 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.15 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 --- drivers/block/loop.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 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..bfe76d9adf09 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -581,6 +581,15 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, return 0; } +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); @@ -604,9 +613,7 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq) * 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 +884,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 +894,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); }