Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7193451rwd; Tue, 6 Jun 2023 07:32:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4hpP/Xu29fSutL3AxzaFu17YXN7UuKLj/rzEkI00RdL1Oox6s6Xe414LI9vX9cMVHuu2+n X-Received: by 2002:a05:620a:20c6:b0:75b:23a1:d8c5 with SMTP id f6-20020a05620a20c600b0075b23a1d8c5mr2518375qka.9.1686061954324; Tue, 06 Jun 2023 07:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686061954; cv=none; d=google.com; s=arc-20160816; b=yYuF9sXrq9NVMjqjWzxwk+sK6ASh4l7ecD36M2VUkiRTvglcMUdHJSEJy19n2XaMdp pUtT2x2Os76MNgWHQkSY1cNl4fJk0c/K9L8nrlM6/3gsRq2EytyezaI5VrPyIr5dnqXF USNkwtirWewxWZEmEHpM3+gcE0HxmIenTQAPziJM0lSt5Db7mqjing8H7a/LMRDYzUc8 EEEy5QA2BZYHYP3sgrJBJ4ywHyGSYLRUflmqHZheHut6L2MvABxkXtrl210kFByL6q8C SIQVx3V2KIZPNpueQ+KGMt0UvqQOf9gRACwsLlNYdYhygbVHGucsvRw3gQ+6Tm35s8Ue tnAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:user-agent :in-reply-to:mime-version:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=UOxM1GwH4N78/5VcZmRi0SOFUE4InTqlB4yboWdBops=; b=POZCXOe9I5w3cwRwZCYYDgV+WmgKO+zGcON73ZZ1iHgAzvq/6VzIgVl00rCuCeLVM+ 0f5cG9TZ1cPtdfPF14mquoRX6JgkNRqbj+CQV5S2XAO8vD4uBcAKD8jFL0wZq4yoQujK +AXlyfG52xXaevX9YAc92lZSubnGxz2UsqoEHmuVvIT5uF1nqh1buTKG/iKAj1h77p4t 6V+WbujcTHrTQmivnU2ypEnxaYjOY2ffCqJE4/2DC9GzQ6tQyOeUSpKhGXLgCIAae/2L B7UGPwIJcSgsudspcGWadYcp9bMbHEI68UpKQyB8DvZgUmyLfwlg0iWDSGEEg88Cia45 JZnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=PZw1PRsP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n9-20020a05620a152900b0075ec7f9e8e2si1452163qkk.263.2023.06.06.07.32.19; Tue, 06 Jun 2023 07:32:34 -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=@samsung.com header.s=mail20170921 header.b=PZw1PRsP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237823AbjFFOTX (ORCPT + 99 others); Tue, 6 Jun 2023 10:19:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbjFFOTU (ORCPT ); Tue, 6 Jun 2023 10:19:20 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93AA110E9 for ; Tue, 6 Jun 2023 07:19:15 -0700 (PDT) Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230606141912epoutp010f93c32bb1b8a6c448981a9c9185f16f~mF69xR9WH0704207042epoutp01c for ; Tue, 6 Jun 2023 14:19:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230606141912epoutp010f93c32bb1b8a6c448981a9c9185f16f~mF69xR9WH0704207042epoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1686061152; bh=UOxM1GwH4N78/5VcZmRi0SOFUE4InTqlB4yboWdBops=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=PZw1PRsP3Vrqe4rBgl2Q+llmA+X/Y64Mgt62j0rqVIiINQHQz37xv9cTHbe78woTb 5BxEesBBycF+gggWT9A5ORabSDHqm0HgkJVRO6OoIW9+f+7OZdJFEDgW6HO58kUDBK ZFYVIHdSenb57diO3bEYFPfETDlbB5mJcxWAs+jM= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20230606141911epcas5p3feaf4868278ede2a218037055402778a~mF68ppvKo0226602266epcas5p3G; Tue, 6 Jun 2023 14:19:11 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.181]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4QbCJt3gbnz4x9Pp; Tue, 6 Jun 2023 14:19:10 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id ED.0D.04567.E504F746; Tue, 6 Jun 2023 23:19:10 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20230606113849epcas5p20436fd9c3a47354fc4f5264540cd9887~mDu7kpk5C1243112431epcas5p2V; Tue, 6 Jun 2023 11:38:49 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230606113849epsmtrp1037164b0d5a6cfbe44a01819ba98ed2b~mDu7i-Kls0420604206epsmtrp1I; Tue, 6 Jun 2023 11:38:49 +0000 (GMT) X-AuditID: b6c32a49-943ff700000011d7-f9-647f405ec85f Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id B7.47.28392.9CA1F746; Tue, 6 Jun 2023 20:38:49 +0900 (KST) Received: from green245 (unknown [107.99.41.245]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230606113842epsmtip230b93d2fae8d0d35d5b4cfcfbf869ead~mDu1DVgJ-2435324353epsmtip29; Tue, 6 Jun 2023 11:38:42 +0000 (GMT) Date: Tue, 6 Jun 2023 17:05:35 +0530 From: Nitesh Shetty To: Christoph Hellwig 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 =?utf-8?B?R29uesOhbGV6?= , 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: <20230606113535.rjbhe6eqlyqk4pqq@green245> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20171215 X-Brightmail-Tracker: H4sIAAAAAAAAA02Te1STZRzHz/O+493QZq9c6nGUcN44JtiAGeADSKChvQEVzTpd/gB2tvcw AradjYlmHW4KAnJRWycWxEUuAiUIZBNEcURDkYAQCPJCBmgQ90MoKLS50fG/z/P9/b7P7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GKU5WJTEeS90nYwXEkhPLEnN Tk0tSC2CyTJxcEo1MLU+OaWufuTyRoVPCv08vlE7nq07MuF4bcMm/o60vvMlbcm7Pl/1mLd9 ztH9l+72c6ee+DXFKzvLa+ZxCT/JZIblbzofX2vVkWUO0L/6SClK5h6Xs/ilnIlPQ9XXn3vq az1NPSqi7N2O30XznC8Hlk7YfTvg9nRR5xtOV+4Giql2/vgsmRWz+OOxyODJgvZWjS8c5py8 fTj96Y+iY/HVKw/4199n3rhRdOf3isRqnWVybZllKaqa1/bfevKp3m99aAznpTviSy66L308 TyX0j4DyhcYmmVbBc4zz9NRN+5Z379TodNuh9HDxt9N7zy5+5bJ37v2m09OYj1kk+FwXNmN1 bHg75X/8fTv5DyZ9PSFKLMUZiYZazEXFiQAmhJ86lQMAAA== X-CMS-MailID: 20230606113849epcas5p20436fd9c3a47354fc4f5264540cd9887 X-Msg-Generator: CA Content-Type: multipart/mixed; boundary="----JBF_njb0NWiSS48ThI00c_Y9Zxz.JAos93qymBy6wSZnW6dc=_4db83_" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230605122310epcas5p4aaebfc26fe5377613a36fe50423cf494 References: <20230605121732.28468-1-nj.shetty@samsung.com> <20230605121732.28468-6-nj.shetty@samsung.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-kernel@vger.kernel.org ------JBF_njb0NWiSS48ThI00c_Y9Zxz.JAos93qymBy6wSZnW6dc=_4db83_ Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Disposition: inline On 23/06/05 06:43AM, Christoph Hellwig wrote: >> 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. > Downside will be duplicating checks which are present for read, write in block layer, device-mapper and zoned devices. But we can do this, shouldn't be an issue. >> + /* setting copy limits */ >> + if (blk_queue_flag_test_and_set(QUEUE_FLAG_COPY, q)) > >I don't understand this comment. > It was a mistake. Comment is misplaced and it should have been "setting copy flag" instead of "setting copy limits". Anyway now we feel this comment is redundant, will remove it. Also, we should have used blk_queue_flag_set to enable copy offload. >> +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. > The idea behind subsys is to prevent copy across different subsystem. For example, copy across nvme subsystem and the scsi subsystem. [1] At present, we don't support inter-namespace(copy across NVMe namespace), but after community feedback for previous series we left scope for it. About idr per namespace, it will be similar to namespace check that we are doing to prevent copy across namespace. We went with current structure for token, as it was solving above issues as well as provides a placeholder for storing source LBA and number of sectors. Do have any suggestions on how we can store source info, if we go with idr based approach ? [1] https://lore.kernel.org/all/alpine.LRH.2.02.2202011327350.22481@file01.intranet.prod.int.rdu2.redhat.com/T/#m407f24fb4454d35c3283a5e51fdb04f1600463af >> + 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. Sure we will add new BLK_STS_* for completion and move the snippet. Thank you, Nitesh Shetty ------JBF_njb0NWiSS48ThI00c_Y9Zxz.JAos93qymBy6wSZnW6dc=_4db83_ Content-Type: text/plain; charset="utf-8" ------JBF_njb0NWiSS48ThI00c_Y9Zxz.JAos93qymBy6wSZnW6dc=_4db83_--