From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2EEEDC77B75 for ; Mon, 22 May 2023 16:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684773460; 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=Sv5qjnMwhospIJVCXfj7wU0LGfGCzmnKMCBxRRSQ3PY=; b=a1av6auKV4RFeJXrESHOmX77QEsO41nDJ9zsdCUglNcTzamcgw21Ln57XcSC4OLlK+kJZV pKYraKjWJwO63+jitP/d5LKv+tn15foaKMqq/d/ArCnd+NvMWTF69BjCtnCpOulWQFczDb trnTvEyrrWSR6yKmtTt4OCqofudWA1Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-hherxMKgPrO5kF-S85ZycQ-1; Mon, 22 May 2023 12:37:39 -0400 X-MC-Unique: hherxMKgPrO5kF-S85ZycQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E7F3811E7C; Mon, 22 May 2023 16:37:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E656C1ED9A; Mon, 22 May 2023 16:37:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9A44119465A0; Mon, 22 May 2023 16:37:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6C3661946595 for ; Mon, 22 May 2023 16:37:20 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 56BF17B7C; Mon, 22 May 2023 16:37:15 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F9607C52 for ; Mon, 22 May 2023 16:37:15 +0000 (UTC) Received: from us-smtp-inbound-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 32A6E1C08785 for ; Mon, 22 May 2023 16:37:15 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-134-SPSu-iIBMS-zbRNlfxHyaw-1; Mon, 22 May 2023 12:37:12 -0400 X-MC-Unique: SPSu-iIBMS-zbRNlfxHyaw-1 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5E40D61F63; Mon, 22 May 2023 16:37:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD5BFC433EF; Mon, 22 May 2023 16:37:10 +0000 (UTC) Date: Mon, 22 May 2023 09:37:10 -0700 From: "Darrick J. Wong" To: Sarthak Kukreti Message-ID: <20230522163710.GA11607@frogsfrogsfrogs> References: <20230518223326.18744-1-sarthakkukreti@chromium.org> <20230518223326.18744-6-sarthakkukreti@chromium.org> MIME-Version: 1.0 In-Reply-To: <20230518223326.18744-6-sarthakkukreti@chromium.org> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Subject: Re: [dm-devel] [PATCH v7 5/5] loop: Add support for provision requests X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jens Axboe , Christoph Hellwig , Theodore Ts'o , "Michael S. Tsirkin" , Jason Wang , Bart Van Assche , Mike Snitzer , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, Andreas Dilger , Stefan Hajnoczi , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Brian Foster , Alasdair Kergon Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Thu, May 18, 2023 at 03:33:26PM -0700, Sarthak Kukreti wrote: > Add support for provision requests to loopback devices. > Loop devices will configure provision support based on > whether the underlying block device/file can support > the provision request and upon receiving a provision bio, > will map it to the backing device/storage. For loop devices > over files, a REQ_OP_PROVISION request will translate to > an fallocate mode 0 call on the backing file. > > Signed-off-by: Sarthak Kukreti > --- > drivers/block/loop.c | 34 +++++++++++++++++++++++++++++++--- > 1 file changed, 31 insertions(+), 3 deletions(-) > > diff --git a/drivers/block/loop.c b/drivers/block/loop.c > index bc31bb7072a2..7fe1a6629754 100644 > --- a/drivers/block/loop.c > +++ b/drivers/block/loop.c > @@ -311,16 +311,20 @@ static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos, > { > /* > * We use fallocate to manipulate the space mappings used by the image > - * a.k.a. discard/zerorange. > + * a.k.a. discard/provision/zerorange. > */ > struct file *file = lo->lo_backing_file; > int ret; > > - mode |= FALLOC_FL_KEEP_SIZE; > + if (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_ZERO_RANGE) && > + !bdev_max_discard_sectors(lo->lo_device)) > + return -EOPNOTSUPP; > > - if (!bdev_max_discard_sectors(lo->lo_device)) > + if (mode == 0 && !bdev_max_provision_sectors(lo->lo_device)) > return -EOPNOTSUPP; > > + mode |= FALLOC_FL_KEEP_SIZE; > + > ret = file->f_op->fallocate(file, mode, pos, blk_rq_bytes(rq)); > if (unlikely(ret && ret != -EINVAL && ret != -EOPNOTSUPP)) > return -EIO; > @@ -488,6 +492,8 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq) > FALLOC_FL_PUNCH_HOLE); > case REQ_OP_DISCARD: > return lo_fallocate(lo, rq, pos, FALLOC_FL_PUNCH_HOLE); > + case REQ_OP_PROVISION: > + return lo_fallocate(lo, rq, pos, 0); If someone calls fallocate(UNSHARE_RANGE) on a loop bdev, shouldn't there be a way to pass that through to the fallocate call to the backing file? --D > case REQ_OP_WRITE: > if (cmd->use_aio) > return lo_rw_aio(lo, cmd, pos, ITER_SOURCE); > @@ -754,6 +760,25 @@ static void loop_sysfs_exit(struct loop_device *lo) > &loop_attribute_group); > } > > +static void loop_config_provision(struct loop_device *lo) > +{ > + struct file *file = lo->lo_backing_file; > + struct inode *inode = file->f_mapping->host; > + > + /* > + * If the backing device is a block device, mirror its provisioning > + * capability. > + */ > + if (S_ISBLK(inode->i_mode)) { > + blk_queue_max_provision_sectors(lo->lo_queue, > + bdev_max_provision_sectors(I_BDEV(inode))); > + } else if (file->f_op->fallocate) { > + blk_queue_max_provision_sectors(lo->lo_queue, UINT_MAX >> 9); > + } else { > + blk_queue_max_provision_sectors(lo->lo_queue, 0); > + } > +} > + > static void loop_config_discard(struct loop_device *lo) > { > struct file *file = lo->lo_backing_file; > @@ -1092,6 +1117,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, > blk_queue_io_min(lo->lo_queue, bsize); > > loop_config_discard(lo); > + loop_config_provision(lo); > loop_update_rotational(lo); > loop_update_dio(lo); > loop_sysfs_init(lo); > @@ -1304,6 +1330,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info) > } > > loop_config_discard(lo); > + loop_config_provision(lo); > > /* update dio if lo_offset or transfer is changed */ > __loop_update_dio(lo, lo->use_dio); > @@ -1830,6 +1857,7 @@ static blk_status_t loop_queue_rq(struct blk_mq_hw_ctx *hctx, > case REQ_OP_FLUSH: > case REQ_OP_DISCARD: > case REQ_OP_WRITE_ZEROES: > + case REQ_OP_PROVISION: > cmd->use_aio = false; > break; > default: > -- > 2.40.1.698.g37aff9b760-goog > > -- > dm-devel mailing list > dm-devel@redhat.com > https://listman.redhat.com/mailman/listinfo/dm-devel > -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel