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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14960C433FE for ; Wed, 2 Feb 2022 16:21:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242530AbiBBQVz (ORCPT ); Wed, 2 Feb 2022 11:21:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237479AbiBBQVz (ORCPT ); Wed, 2 Feb 2022 11:21:55 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C73AC061714; Wed, 2 Feb 2022 08:21:55 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id E301EB831A5; Wed, 2 Feb 2022 16:21:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA674C340EB; Wed, 2 Feb 2022 16:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643818912; bh=aprhBNqV/yFavedqX4mLmND+1zJ0/xnjL0T01FTR7FQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HT12BqX8WuaY6JoH1taO7b/LCdLfxiSE+hPWLRvgT/CX2DLVBW/uckAJw1dLj6jRf U3wsftOUOQU8wUoWQuUURO7I+tUF+Wl9eQgipUfNZD3e9/O8UlAN8waqMJWbZvCKDi XUqaD852mzgPMfvB9JL0NoBjz9OL2l+7+6nYrmsjMZemEiqFfQuFLJ7etadp38euIP ZFURUM805EuRpRYW/9L24emVSXNycbI7wgV6NMzNJ/8E1nk0dNQpX1fArUV9ym5LiY ajri4+R/B6gU7JPFg9AaC0z6e0Gg2Vgv17QrxiKRJXJJ19pEWvj+WumReSroCP9kr/ HMIXOam+C3+sg== Date: Wed, 2 Feb 2022 08:21:47 -0800 From: Keith Busch To: Mikulas Patocka Cc: Javier =?iso-8859-1?Q?Gonz=E1lez?= , Chaitanya Kulkarni , "linux-block@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "dm-devel@redhat.com" , "linux-nvme@lists.infradead.org" , linux-fsdevel , Jens Axboe , "msnitzer@redhat.com >> msnitzer@redhat.com" , Bart Van Assche , "martin.petersen@oracle.com >> Martin K. Petersen" , "roland@purestorage.com" , Hannes Reinecke , Christoph Hellwig , "Frederick.Knight@netapp.com" , "zach.brown@ni.com" , "osandov@fb.com" , "lsf-pc@lists.linux-foundation.org" , "djwong@kernel.org" , "josef@toxicpanda.com" , "clm@fb.com" , "dsterba@suse.com" , "tytso@mit.edu" , "jack@suse.com" , Kanchan Joshi Subject: Re: [RFC PATCH 1/3] block: add copy offload support Message-ID: <20220202162147.GC3077632@dhcp-10-100-145-180.wdc.com> References: <20220201102122.4okwj2gipjbvuyux@mpHalley-2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Tue, Feb 01, 2022 at 01:32:29PM -0500, Mikulas Patocka wrote: > +int blkdev_issue_copy(struct block_device *bdev1, sector_t sector1, > + struct block_device *bdev2, sector_t sector2, > + sector_t nr_sects, sector_t *copied, gfp_t gfp_mask) > +{ > + struct page *token; > + sector_t m; > + int r = 0; > + struct completion comp; > + > + *copied = 0; > + > + m = min(bdev_max_copy_sectors(bdev1), bdev_max_copy_sectors(bdev2)); > + if (!m) > + return -EOPNOTSUPP; > + m = min(m, (sector_t)round_down(UINT_MAX, PAGE_SIZE) >> 9); > + > + if (unlikely(bdev_read_only(bdev2))) > + return -EPERM; > + > + token = alloc_page(gfp_mask); > + if (unlikely(!token)) > + return -ENOMEM; > + > + while (nr_sects) { > + struct bio *read_bio, *write_bio; > + sector_t this_step = min(nr_sects, m); > + > + read_bio = bio_alloc(gfp_mask, 1); > + if (unlikely(!read_bio)) { > + r = -ENOMEM; > + break; > + } > + bio_set_op_attrs(read_bio, REQ_OP_COPY_READ_TOKEN, REQ_NOMERGE); > + bio_set_dev(read_bio, bdev1); > + __bio_add_page(read_bio, token, PAGE_SIZE, 0); You have this "token" payload as driver specific data, but there's no check that bdev1 and bdev2 subscribe to the same driver specific format. I thought we discussed defining something like a "copy domain" that establishes which block devices can offload copy operations to/from each other, and that should be checked before proceeding with the copy operation. 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 598D5C433F5 for ; Thu, 3 Feb 2022 07:03:57 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-571-P9W46DuzM7e32-NvoE5uFw-1; Thu, 03 Feb 2022 02:03:53 -0500 X-MC-Unique: P9W46DuzM7e32-NvoE5uFw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A85881B18BC3; Thu, 3 Feb 2022 07:03:48 +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 4485878C3D; Thu, 3 Feb 2022 07:03:48 +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 1C5DB4CA9B; Thu, 3 Feb 2022 07:03:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 212GVSTn022420 for ; Wed, 2 Feb 2022 11:31:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4064B400DFAD; Wed, 2 Feb 2022 16:31:28 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C9A0401013A for ; Wed, 2 Feb 2022 16:31:28 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 232DE8027FC for ; Wed, 2 Feb 2022 16:31:28 +0000 (UTC) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-30-yRKXbB1MNO-HCMl9yteV_A-1; Wed, 02 Feb 2022 11:31:24 -0500 X-MC-Unique: yRKXbB1MNO-HCMl9yteV_A-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 ams.source.kernel.org (Postfix) with ESMTPS id AD39EB83061; Wed, 2 Feb 2022 16:21:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA674C340EB; Wed, 2 Feb 2022 16:21:49 +0000 (UTC) Date: Wed, 2 Feb 2022 08:21:47 -0800 From: Keith Busch To: Mikulas Patocka Message-ID: <20220202162147.GC3077632@dhcp-10-100-145-180.wdc.com> References: <20220201102122.4okwj2gipjbvuyux@mpHalley-2> MIME-Version: 1.0 In-Reply-To: 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 2.84 on 10.11.54.1 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 03 Feb 2022 02:03:19 -0500 Cc: "djwong@kernel.org" , "linux-nvme@lists.infradead.org" , "clm@fb.com" , "dm-devel@redhat.com" , "osandov@fb.com" , Javier =?iso-8859-1?Q?Gonz=E1lez?= , Bart Van Assche , "linux-scsi@vger.kernel.org" , Christoph Hellwig , "roland@purestorage.com" , "zach.brown@ni.com" , Chaitanya Kulkarni , "msnitzer@redhat.com >> msnitzer@redhat.com" , "josef@toxicpanda.com" , "linux-block@vger.kernel.org" , "dsterba@suse.com" , "Frederick.Knight@netapp.com" , Jens Axboe , "tytso@mit.edu" , Kanchan Joshi , "martin.petersen@oracle.com >> Martin K. Petersen" , "jack@suse.com" , linux-fsdevel , "lsf-pc@lists.linux-foundation.org" Subject: Re: [dm-devel] [RFC PATCH 1/3] block: add copy offload support 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.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Tue, Feb 01, 2022 at 01:32:29PM -0500, Mikulas Patocka wrote: > +int blkdev_issue_copy(struct block_device *bdev1, sector_t sector1, > + struct block_device *bdev2, sector_t sector2, > + sector_t nr_sects, sector_t *copied, gfp_t gfp_mask) > +{ > + struct page *token; > + sector_t m; > + int r = 0; > + struct completion comp; > + > + *copied = 0; > + > + m = min(bdev_max_copy_sectors(bdev1), bdev_max_copy_sectors(bdev2)); > + if (!m) > + return -EOPNOTSUPP; > + m = min(m, (sector_t)round_down(UINT_MAX, PAGE_SIZE) >> 9); > + > + if (unlikely(bdev_read_only(bdev2))) > + return -EPERM; > + > + token = alloc_page(gfp_mask); > + if (unlikely(!token)) > + return -ENOMEM; > + > + while (nr_sects) { > + struct bio *read_bio, *write_bio; > + sector_t this_step = min(nr_sects, m); > + > + read_bio = bio_alloc(gfp_mask, 1); > + if (unlikely(!read_bio)) { > + r = -ENOMEM; > + break; > + } > + bio_set_op_attrs(read_bio, REQ_OP_COPY_READ_TOKEN, REQ_NOMERGE); > + bio_set_dev(read_bio, bdev1); > + __bio_add_page(read_bio, token, PAGE_SIZE, 0); You have this "token" payload as driver specific data, but there's no check that bdev1 and bdev2 subscribe to the same driver specific format. I thought we discussed defining something like a "copy domain" that establishes which block devices can offload copy operations to/from each other, and that should be checked before proceeding with the copy operation. -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel