Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1967039rwd; Mon, 15 May 2023 05:44:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5EyMS2zvGgDTI025Yi07wlZZjytAgreiD0jVoKt5g10Zbz2XTxZ05+2uyn7P4N+e+vy2hu X-Received: by 2002:a17:902:b68d:b0:1ac:7405:d3ba with SMTP id c13-20020a170902b68d00b001ac7405d3bamr25857457pls.40.1684154639804; Mon, 15 May 2023 05:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684154639; cv=none; d=google.com; s=arc-20160816; b=Gel8mD5usd6mRwGqlf9LD/FF1Qpip37cmoplhNwV6XHufGo1nA9wIkU4RFzRQhP4kE BUbECaQg3o4jx1eJIx4ySC6eGu0bAX5MsTFV/Dyc0tEN7LTBSFyigBZ+C7Vwt8IJMI2p mLcKARK0iHFB+rlUA5FlPIFfHttXZRPA/ruBV3jqZysK/O3mFry0gJvoY1V+n4rX5/fU qEtAcIY2zGKYDLx1mfj2rjDmUR9GGKXBQbaVwXHHsj9m4S9Xzs7dC26WLKCvLat/97Gy D1+8jL4P/MQE0C8ldpfbRwwdrB92s2enTWcV+WZ4wFcLXPXKCdrmpeOZtMaPTOXYbnF9 VMFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GMaiL4YHC7uUUhHJ2ubX8SKdgheUKgR6Z34QRTwNRu8=; b=MYUwx7QN2XHcFvcgdGWKf2yrV/p1RoTn5Jrwym+ZcSJBYfJw2gRo2JG5Lyrkvo/NfC Lgrpf0vqmwfsTMIrem2T4aHyhOB36gZPrpK8W4fTACAJXMSLH9zEVF7fq2RHVLM5xqjC XFQZPR5xlSelZxIA7KlpjDOXFCcBSNK+ewbz1vHEfGbfxgf50844jigFIU4lz8caeROV ghfFkI7b/aWZqIMuTcJCERSsqVGUNpJ14FAGpGGXGcdFjJh5hA6y3q1CIb8wi9/Jqrng R+X7vdFtFX+2OEOzxn6UyTlkiXmX4sQALBlVHPpbgWa0NlMi89KXMW/3jrN7fJf0FF0z 4SOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PHhNYogE; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lx3-20020a17090b4b0300b00246ff7fbff8si6420314pjb.11.2023.05.15.05.43.40; Mon, 15 May 2023 05:43:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PHhNYogE; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242008AbjEOMlb (ORCPT + 99 others); Mon, 15 May 2023 08:41:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241962AbjEOMkR (ORCPT ); Mon, 15 May 2023 08:40:17 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A8EFE7A for ; Mon, 15 May 2023 05:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684154264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GMaiL4YHC7uUUhHJ2ubX8SKdgheUKgR6Z34QRTwNRu8=; b=PHhNYogEyRXH+B44S5EYqHzWWEgkK3hXfdSvgwQOLVlflXhJPOe3/lQnsNOvMlIpH7wCME P9p9zCCBXKKg4kHqbd+Dcti3SHaNVMWMt7LLqweztIwx/13tUVp69Guy0nS6sSsCQrqFq1 l+9zhJxFd5+x31+mYOcLcmJ4JqpH0Go= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-Xx49UU93Od2hEzBHlSISeA-1; Mon, 15 May 2023 08:37:43 -0400 X-MC-Unique: Xx49UU93Od2hEzBHlSISeA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-61abb7cd89cso70282626d6.3 for ; Mon, 15 May 2023 05:37:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684154263; x=1686746263; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GMaiL4YHC7uUUhHJ2ubX8SKdgheUKgR6Z34QRTwNRu8=; b=P2fAZDJxBKxasIQAHutqVPzHPyLi9mdoWVpssyARjbQ7IlJ426nk+JfJdsvkX4Xboa tLe9519A5+1VcmHeT6fXhn4WHXo/T3GvWpdlBq8Qdlb/5Rm1jpD3u1+LCT4a8A+B5q+A +NC0+z77yWO4EZV8pUSiqm6JH6NypXxiWp7cu1owNX0//ANmlqdbbgsWfVPwc0jYWT0i sn6zlUhp6GFkrxriMFNGPmFmaoqp1Wh57nRq4puM+SVLKaKIhY8sMWb82xho7aPLlXo6 vQLybFBUVE6/9YlUw8oj5VCTxIleTECmqEJ87nf7eq7pCXinSsNW1r/ZlldkDs+4hBqQ zpaw== X-Gm-Message-State: AC+VfDw3RzsfbB1TY8VgPC0jxx35g72PpVgnw5sogZgcCjrEAxIqXZsw c8ffPx71ufPgFfMCaBdbqdstN7RdX+Ypj81JS3Bopu3Y9zYfuiTZr/tY4i6AzyNDsLVn4oodP1Q iNtWyeKusCUMIDiHPIVozRQ== X-Received: by 2002:a05:6214:5007:b0:61b:743c:34f6 with SMTP id jo7-20020a056214500700b0061b743c34f6mr60348761qvb.30.1684154262695; Mon, 15 May 2023 05:37:42 -0700 (PDT) X-Received: by 2002:a05:6214:5007:b0:61b:743c:34f6 with SMTP id jo7-20020a056214500700b0061b743c34f6mr60348721qvb.30.1684154262451; Mon, 15 May 2023 05:37:42 -0700 (PDT) Received: from bfoster (c-24-61-119-116.hsd1.ma.comcast.net. [24.61.119.116]) by smtp.gmail.com with ESMTPSA id mm9-20020a0562145e8900b0062138a50d42sm4586271qvb.1.2023.05.15.05.37.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 05:37:41 -0700 (PDT) Date: Mon, 15 May 2023 08:40:10 -0400 From: Brian Foster To: Sarthak Kukreti Cc: dm-devel@redhat.com, linux-block@vger.kernel.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jens Axboe , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , Alasdair Kergon , Mike Snitzer , Christoph Hellwig , Theodore Ts'o , Andreas Dilger , Bart Van Assche , "Darrick J. Wong" Subject: Re: [PATCH v6 5/5] loop: Add support for provision requests Message-ID: References: <20230420004850.297045-1-sarthakkukreti@chromium.org> <20230506062909.74601-1-sarthakkukreti@chromium.org> <20230506062909.74601-6-sarthakkukreti@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230506062909.74601-6-sarthakkukreti@chromium.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, May 05, 2023 at 11:29:09PM -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 | 42 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 42 insertions(+) > > diff --git a/drivers/block/loop.c b/drivers/block/loop.c > index bc31bb7072a2..13c4b4f8b9c1 100644 > --- a/drivers/block/loop.c > +++ b/drivers/block/loop.c > @@ -327,6 +327,24 @@ static int lo_fallocate(struct loop_device *lo, struct request *rq, loff_t pos, > return ret; > } > > +static int lo_req_provision(struct loop_device *lo, struct request *rq, loff_t pos) > +{ > + struct file *file = lo->lo_backing_file; > + struct request_queue *q = lo->lo_queue; > + int ret; > + > + if (!q->limits.max_provision_sectors) { > + ret = -EOPNOTSUPP; > + goto out; > + } > + > + ret = file->f_op->fallocate(file, 0, pos, blk_rq_bytes(rq)); > + if (unlikely(ret && ret != -EINVAL && ret != -EOPNOTSUPP)) > + ret = -EIO; > + out: > + return ret; > +} > + > static int lo_req_flush(struct loop_device *lo, struct request *rq) > { > int ret = vfs_fsync(lo->lo_backing_file, 0); > @@ -488,6 +506,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_req_provision(lo, rq, pos); Hi Sarthak, The only thing that stands out to me is the separate lo_req_provision() helper here. It seems it might be a little cleaner to extend and reuse lo_req_fallocate()..? But that's not something I feel strongly about, so this all looks pretty good to me either way, FWIW. Brian > case REQ_OP_WRITE: > if (cmd->use_aio) > return lo_rw_aio(lo, cmd, pos, ITER_SOURCE); > @@ -754,6 +774,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 +1131,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 +1344,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 +1871,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.521.gf1e218fcd8-goog >