Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp247420iob; Mon, 2 May 2022 18:27:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlWor1j2XFjFvAIr08/PVn1MJ8dIwS744tF8hvwrZU9uNzfY9KwYf8D8LnLYGEJ03HNAbP X-Received: by 2002:a17:90b:4acb:b0:1dc:32dd:d51e with SMTP id mh11-20020a17090b4acb00b001dc32ddd51emr2094191pjb.5.1651541229830; Mon, 02 May 2022 18:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651541229; cv=none; d=google.com; s=arc-20160816; b=HPF2I2FZFA/f9ERqjbG9YPAFVGkany7DP/SDEuH6aWcsjo5wQMVDYtG9o9klFgeuJi RxhdVT0Rm+bGIPVn0/E8c7YLFCYkSxtLsvhqr538ODtFwxcLDkxU46DpDplb3DuH11ia jzRmx+Rg+02Oo+NVZIl65tXDGKBVvnifkTbD12J6Twyi7E191l1htbFA1VQa3IYyCFMZ HJvN4eAlGRLAosYHbjeUc+40JNT8wIK9/k8hs+Pc3fFXCuzCLolcOzv1dVTWB+JzU1Le MMeBXXK8Z6jvh4bLeJmSmRFht84jo3m8+1R8FdwKJz+2v6gZ6TtFGjOUFEdCvQoTWY4X H64A== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=JUsxm589EFYDVvGQ4JlZplJQXGwSA2cfyzFS4oxRBkM=; b=zVRcVjdGrSTlrjCHMC/6CncnsA5CIeAR8/CNmCgS1I/ObW44Qx9+FUV8H+tX9DqzWc OnvPXWUUKQqea8WmrS3xl6kwkENXG3FE4ahdBM2wQ7dBxdiPWXyxdFTZdP+FRVn4HtDo 3uaXuceIR+w2Ny2N7QA+2Coe5srmJJqYLIYtpwWOurX+gHJrkwvYMoujtuEIrMLir1pM yYNZNs6Tekv5uBtGdW8RUtoXCR+ZNMoJFZDgKT+UZCI7IBrymci285RH43N9bKhTvuSl ex+im2OY9Ey5wehyx3EhXStM2Pvy0hbHYxn3ilodbuqcHpkcJJyxpWZwik0QFXJAjDEv k74g== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e18-20020a170902e0d200b0015ea480f268si3790745pla.294.2022.05.02.18.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 18:27:09 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 798A745074; Mon, 2 May 2022 18:05:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231586AbiEBX0R (ORCPT + 99 others); Mon, 2 May 2022 19:26:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232273AbiEBXYM (ORCPT ); Mon, 2 May 2022 19:24:12 -0400 Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 41BEE63CB; Mon, 2 May 2022 16:20:40 -0700 (PDT) Received: from dread.disaster.area (pa49-181-2-147.pa.nsw.optusnet.com.au [49.181.2.147]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id 71A01534701; Tue, 3 May 2022 09:20:38 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1nlfLH-007IoG-TM; Tue, 03 May 2022 09:20:35 +1000 Date: Tue, 3 May 2022 09:20:35 +1000 From: Dave Chinner To: Damien Le Moal Cc: Nitesh Shetty , linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, dm-devel@redhat.com, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, nitheshshetty@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 00/10] Add Copy offload support Message-ID: <20220502232035.GE1360180@dread.disaster.area> References: <20220426101241.30100-1-nj.shetty@samsung.com> <6a85e8c8-d9d1-f192-f10d-09052703c99a@opensource.wdc.com> <20220427124951.GA9558@test-zns> <20220502040951.GC1360180@dread.disaster.area> <46e95412-9a79-51f8-3d52-caed4875d41f@opensource.wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <46e95412-9a79-51f8-3d52-caed4875d41f@opensource.wdc.com> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.4 cv=e9dl9Yl/ c=1 sm=1 tr=0 ts=62706747 a=ivVLWpVy4j68lT4lJFbQgw==:117 a=ivVLWpVy4j68lT4lJFbQgw==:17 a=IkcTkHD0fZMA:10 a=oZkIemNP1mAA:10 a=7-415B0cAAAA:8 a=kuBEN3JhnRn9nEiEWMwA:9 a=QEXdDO2ut3YA:10 a=biEYGPWJfzWAr4FL6Ov7:22 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-kernel@vger.kernel.org On Mon, May 02, 2022 at 09:54:55PM +0900, Damien Le Moal wrote: > On 2022/05/02 13:09, Dave Chinner wrote: > > On Wed, Apr 27, 2022 at 06:19:51PM +0530, Nitesh Shetty wrote: > >> O Wed, Apr 27, 2022 at 11:19:48AM +0900, Damien Le Moal wrote: > >>> On 4/26/22 19:12, Nitesh Shetty wrote: > >>>> The patch series covers the points discussed in November 2021 virtual call > >>>> [LSF/MM/BFP TOPIC] Storage: Copy Offload[0]. > >>>> We have covered the Initial agreed requirements in this patchset. > >>>> Patchset borrows Mikulas's token based approach for 2 bdev > >>>> implementation. > >>>> > >>>> Overall series supports – > >>>> > >>>> 1. Driver > >>>> - NVMe Copy command (single NS), including support in nvme-target (for > >>>> block and file backend) > >>> > >>> It would also be nice to have copy offload emulation in null_blk for testing. > >>> > >> > >> We can plan this in next phase of copy support, once this series settles down. > > > > Why not just hook the loopback driver up to copy_file_range() so > > that the backend filesystem can just reflink copy the ranges being > > passed? That would enable testing on btrfs, XFS and NFSv4.2 hosted > > image files without needing any special block device setup at all... > > That is a very good idea ! But that will cover only the non-zoned case. For copy > offload on zoned devices, adding support in null_blk is probably the simplest > thing to do. Sure, but that's a zone device implementation issue, not a "how do applications use this offload" issue. i.e. zonefs support is not necessary to test the bio/block layer interfaces at all. All we need is a block device that can decode the bio-encoded offload packet and execute it to do full block layer testing. We can build dm devices on top of loop devices, etc, so we can test that the oflload support is plumbed, sliced, diced, and regurgitated correctly that way. We don't need actual low level device drivers to test this. And, unlike the nullblk device, using the loopback device w/ copy_file_range() will also allow data integrity testing if a generic copy_file_range() offload implementation is added. That is, we test a non-reflink capable filesystem on the loop device with the image file hosted on a reflink-capable filesystem. The upper filesystem copy then gets offloaded to reflinks in the lower filesystem. We already have copy_file_range() support in fsx, so all the data integrity fsx tests in fstests will exercise this offload path and find all the data corruptions the initial block layer bugs expose... Further, fsstress also has copy_file_range() support, and so all the fstests that generate stress tests or use fstress as load for failure testing will also exercise it. Indeed, this then gives us fine-grained error injection capability within fstests via devices like dm-flakey. What happens when dm-flakey kills the device IO mid-offload? Does everything recover correctly? Do we end up with data corruption? Are partial offload completions when errors occur signalled correctly? Is there -any- test coverage (or even capability for testing) of user driven copy offload failure situations like this in any of the other test suites? I mean, once the loop device has cfr offload, we can use dm-flakey to kill IO in the image file or even do a force shutdown of the image host filesystem. Hence we can actually trash the copy offload operation in mid-flight, not just error it out on full completion. This is trivial to do with the fstests infrastructure - it just relies on having generic copy_file_range() block offload support and a loopback device offload of hardware copy bios back to copy_file_range().... This is what I mean about copy offload being designed the wrong way. We have the high level hooks needed to implement it right though the filesystems and block layer without any specific hardware support, and we can test the whole stack without needing specific hardware support. We already have filesystem level copy offload acceleration, so the last thing we want to see is a block layer offload implementation that is incompatible with the semantics we've already exposed to userspace for copy offloads. As I said: > > i.e. I think you're doing this compeltely backwards by trying to > > target non-existent hardware first.... Rather than tie the block layer offload function/implementation to the specific quirks of a specific target hardware, we should be adding generic support in the block layer for the copy offload semantics we've already exposed to userspace. We already have test coverage and infrastructure for this interface and is already in use by applications. Transparent hardware acceleration of data copies when the hardware supports it is exactly where copy offloads are useful - implementing support based around hardware made of unobtainium and then adding high level user facing API support as an afterthought is putting the cart before the horse. We need to make sure the high level functionality is robust and handles errors correctly before we even worry about what quirks the hardware might bring to the table. Build a reference model first with the loop device and copy-file-range, test it, validate it, make sure it all works. Then hook up the hardware, and fix all the hardware bugs that are exposed before the hardware is released to the general public.... Why haven't we learnt this lesson yet from all the problems we've had with, say, broken discard/trim, zeroing, erase, etc in hardware implementations, incompatible hardware protocol implementations of equivalent functionality, etc? i.e. We haven't defined the OS required behaviour that hardware must support and instead just tried to make whatever has come from the hardware vendor's "standarisation" process work ok? In this case, we already have a functioning model, syscalls and user applications making use of copy offloads at the OS level. Now we need to implement those exact semantics at the block layer to build a validated reference model for the block layer offload behaviour that hardware must comply with. Then hardware offloads in actual hardware can be compared and validated against the reference model behaviour, and any hardware that doesn't match can be quirked/blacklisted until the manufacturer fixes their firmware... Cheers, Dave. -- Dave Chinner david@fromorbit.com