From patchwork Tue Jan 21 10:42:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Tkhai X-Patchwork-Id: 11345219 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 C3954159A for ; Wed, 22 Jan 2020 08:21:42 +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 85F4C24655 for ; Wed, 22 Jan 2020 08:21:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ap+CGwnV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85F4C24655 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=1579681301; 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=ap+CGwnVng+vWJITxHw43bs1zTL4i0G3+tzCKEL9jrC83RVel8Z8zYcntFitmYOfQ0ZpMR BlHHZi8ViUepz4ZeMzUOcW6CCiYuDzHjiNCndzjLSzzQF28SRZF29m2twXi6Gbi063H0JN SXqxscUYuSUo7i1P/Ktd+UMrz+zmOqg= 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-87-BtJsgf9hPuGt3IRmCsJLzQ-1; Wed, 22 Jan 2020 03:21:36 -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 0CB54800D50; Wed, 22 Jan 2020 08:21:31 +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 DCB948CCCC; Wed, 22 Jan 2020 08:21:30 +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 9F2C0870AF; Wed, 22 Jan 2020 08:21:30 +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 00LAhG2g005955 for ; Tue, 21 Jan 2020 05:43:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6B8BFD95F3; Tue, 21 Jan 2020 10:43:16 +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 681E8D95ED for ; Tue, 21 Jan 2020 10:43:16 +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 4B2EA80329C for ; Tue, 21 Jan 2020 10:43:16 +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-200-d8gwT54sPW-otbbiYQX__Q-1; Tue, 21 Jan 2020 05:43:12 -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 1itqzq-0006R9-Dg; Tue, 21 Jan 2020 13:42:58 +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: Tue, 21 Jan 2020 13:42:58 +0300 Message-ID: <157960337828.108120.15650028156076032048.stgit@localhost.localdomain> In-Reply-To: <157960325642.108120.13626623438131044304.stgit@localhost.localdomain> References: <157960325642.108120.13626623438131044304.stgit@localhost.localdomain> User-Agent: StGit/0.19 MIME-Version: 1.0 X-MC-Unique: d8gwT54sPW-otbbiYQX__Q-1 X-MC-Unique: BtJsgf9hPuGt3IRmCsJLzQ-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 00LAhG2g005955 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Wed, 22 Jan 2020 03:20:59 -0500 Subject: [dm-devel] [PATCH v4 7/7] 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.13 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); }