Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5690548rwd; Mon, 5 Jun 2023 07:18:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6VfByz5etJZUvocVxY7tA+ZMp/GiAnZj5hXOSy2Yu3N++m75F+S0lJXQmh7zGHWlTcV1lk X-Received: by 2002:a17:90b:1286:b0:255:9453:3780 with SMTP id fw6-20020a17090b128600b0025594533780mr8077735pjb.32.1685974695524; Mon, 05 Jun 2023 07:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685974695; cv=none; d=google.com; s=arc-20160816; b=YEGlbDfqGzF7gX/o2jCKbN4gU/APmpkVMYQrCOZy3id5xmtTV8lNtMF5VpIsO7dCP/ owLci1A/CTmQDDwU+yIfKsjrscoFvLJ/YIWPmtsSNtc3lHPwfCDY/RTWOIe4RBCZsF4A 6rp9pqxzpfMNcnKVFnmdkcSc/Dxb/LHzLpHgvPyKA0utS+NRPNb93FSzkPhZXH4Hetp4 iAs5R7VLsDlHsz74mD/TBs63pYsUBDa6zNua+WDxtgzZb5lktQTFLBtLK0IV7hdOaZo+ x5UQyHsMrtJ/QwlGNTdmj9fu1PxHLVx3EXSRdfSA1dVUEdCSFDni9w1x8M6AXkgpZmO9 sFuw== 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=mCvoAgk8zhYKOoAjq5TY4OQ9rPhl649ZNxRx5rL2Pgk=; b=Z714h/sQld7kjh6SsNfarGiTC+yHNOVaD3GBhsAafRkofyxe7d+zSNFZZIovk8qerD FFhDm7Y6RMGmUbruEOTEsdySK94VxZUH+c5EmFg7vjokdy5C9qXiOM4FL/7osFNB+dfn cd+1dxqprVljFLJudtsg5vWIF3eWyl8zd5uVIKgirh4XcdCxVMeeXwMll0pYU7a41sos czMri570RYacY4uhwFFITjpmTGvGbHNcVAhE2zZKTJD/fSbOhOefWJQ2Kp53tu8OGf4V DKlR3KIXVCvPdGrFy6ExDbNbp6dgj9568JSoEz/dyXxkfLK649DmwR3baED41nkkIRKy ZKtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=e00kjrpp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x18-20020a17090aca1200b00235dc16de3asi7481860pjt.16.2023.06.05.07.18.03; Mon, 05 Jun 2023 07:18:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@infradead.org header.s=bombadil.20210309 header.b=e00kjrpp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233924AbjFENoK (ORCPT + 99 others); Mon, 5 Jun 2023 09:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjFENoJ (ORCPT ); Mon, 5 Jun 2023 09:44:09 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BF2BED; Mon, 5 Jun 2023 06:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=mCvoAgk8zhYKOoAjq5TY4OQ9rPhl649ZNxRx5rL2Pgk=; b=e00kjrppO7/UDAnEpoZmC5VmeB E7eqvoNBSi328I1yZzpw0lKldIjK1ThTD2ydNi6t4PHGUucx35NQa5ecMm28xvQGCrpyDtL7lJqBl 4m7nOY6IDie9bSDo7UKhjMbU64mjO97fyAloPxrKcx236Krf2g3yyuA1fQtCNgI0lIP73npePLbM7 ob5/IqEq55gpp9viuo4Cs37S9snTDPe6VyK3CpAZ0Cp7v+p7Q4K6+cgS0ndKVb0FIwjHunEgbAPdS +VxyJ0VfdPZZ4klREtVPPzMUShagY9Vu6etyAyUchmf8dKFza+DJQ/rkIS5B7LIDcMcUR9zf6rKBJ 9BpC9mOA==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q6AUn-00FeYT-1D; Mon, 05 Jun 2023 13:43:41 +0000 Date: Mon, 5 Jun 2023 06:43:41 -0700 From: Christoph Hellwig To: Nitesh Shetty Cc: Jens Axboe , Jonathan Corbet , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Keith Busch , Christoph Hellwig , Sagi Grimberg , James Smart , Chaitanya Kulkarni , Alexander Viro , Christian Brauner , martin.petersen@oracle.com, linux-scsi@vger.kernel.org, willy@infradead.org, hare@suse.de, djwong@kernel.org, bvanassche@acm.org, ming.lei@redhat.com, dlemoal@kernel.org, nitheshshetty@gmail.com, gost.dev@samsung.com, Kanchan Joshi , Javier =?iso-8859-1?Q?Gonz=E1lez?= , Anuj Gupta , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v12 5/9] nvme: add copy offload support Message-ID: References: <20230605121732.28468-1-nj.shetty@samsung.com> <20230605121732.28468-6-nj.shetty@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230605121732.28468-6-nj.shetty@samsung.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 > break; > case REQ_OP_READ: > - ret = nvme_setup_rw(ns, req, cmd, nvme_cmd_read); > + if (unlikely(req->cmd_flags & REQ_COPY)) > + nvme_setup_copy_read(ns, req); > + else > + ret = nvme_setup_rw(ns, req, cmd, nvme_cmd_read); > break; > case REQ_OP_WRITE: > - ret = nvme_setup_rw(ns, req, cmd, nvme_cmd_write); > + if (unlikely(req->cmd_flags & REQ_COPY)) > + ret = nvme_setup_copy_write(ns, req, cmd); > + else > + ret = nvme_setup_rw(ns, req, cmd, nvme_cmd_write); Yikes. Overloading REQ_OP_READ and REQ_OP_WRITE with something entirely different brings us back the horrors of the block layer 15 years ago. Don't do that. Please add separate REQ_COPY_IN/OUT (or maybe SEND/RECEIVE or whatever) methods. > + /* setting copy limits */ > + if (blk_queue_flag_test_and_set(QUEUE_FLAG_COPY, q)) I don't understand this comment. > +struct nvme_copy_token { > + char *subsys; > + struct nvme_ns *ns; > + sector_t src_sector; > + sector_t sectors; > +}; Why do we need a subsys token? Inter-namespace copy is pretty crazy, and not really anything we should aim for. But this whole token design is pretty odd anyway. The only thing we'd need is a sequence number / idr / etc to find an input and output side match up, as long as we stick to the proper namespace scope. > + if (unlikely((req->cmd_flags & REQ_COPY) && > + (req_op(req) == REQ_OP_READ))) { > + blk_mq_start_request(req); > + return BLK_STS_OK; > + } This really needs to be hiden inside of nvme_setup_cmd. And given that other drivers might need similar handling the best way is probably to have a new magic BLK_STS_* value for request started but we're not actually sending it to hardware.