Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp6671008pxu; Thu, 24 Dec 2020 08:48:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYikjA6vTeSDaES3DyaBCkbAzJFULhv669qooJ9q5Ybn1zxUX7VacLL9jIbTuKJyevMigZ X-Received: by 2002:aa7:d64d:: with SMTP id v13mr29706149edr.196.1608828508686; Thu, 24 Dec 2020 08:48:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608828508; cv=none; d=google.com; s=arc-20160816; b=fk2S/Vw5ZOTy+oBQvTbHbIF6l7qK7qz407ujOgCnlFlLrrGRFMAa29rvTO63VpcjBM pNprMNUelYSlXV29y257BMjAB7C4MWSix5mu93IZSXomjeudLrqZoptkabETb7bNfre3 kEu177GDpq0qR+aATXgEczf76mTdhvtTr3/vYXZ9SLNaTFgV5xYuOj+5vINsnlKaWo/F k6Gab7dLxHnRyBnifagqa6uOGOSrtj4PV0JqM7R0l0WgzwXlvfYwv/L503qDnN1+I2oE NSPhE2psLxLOUsy6BduGjsIQM8zcWoKQWomcQm9pktYJtmVGv8rNlpkWlyoXmKzcq7Cs D1/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:reply-to; bh=x0RIKmd2K59mwnyH5MkpGiCsTRJo1VKA06Hcy0y3Vc0=; b=UYdWVk2JLRkQCWIVPMuR8NKU/4ehw/iXB1Wp8ByDzLsgyOHA42JHavtEYenk4vDjXh Hg22XrGfGM/biarCSdj6Djqac1lvDA+lMXu7YqkNZ+6/iQcPwA4HFvHPPzxxanpmcyur KZRnQA0mSL6HvbynAMuJfR/yvn66TdueqmTyM3X3SfaaSCkNfcZ3quNY3hCutaLplW7Q qpvWnkLXiYOobt+Zic4SMIvR4Efc5rRBRmnEU1b1ds/VM8ZoP3MAvFDG4ESgNK2H5IqG 6/A+2fKG3RLXtvyrOAWGxeZOjrsW//Xgh9IGU3z9fhafGEppv0CttBt/6g0apGVzlAQt m/aA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si14350168edk.605.2020.12.24.08.47.55; Thu, 24 Dec 2020 08:48:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728462AbgLXQpy (ORCPT + 99 others); Thu, 24 Dec 2020 11:45:54 -0500 Received: from mail-1.ca.inter.net ([208.85.220.69]:43627 "EHLO mail-1.ca.inter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726839AbgLXQpy (ORCPT ); Thu, 24 Dec 2020 11:45:54 -0500 Received: from localhost (offload-3.ca.inter.net [208.85.220.70]) by mail-1.ca.inter.net (Postfix) with ESMTP id 31C992EA00D; Thu, 24 Dec 2020 11:45:12 -0500 (EST) Received: from mail-1.ca.inter.net ([208.85.220.69]) by localhost (offload-3.ca.inter.net [208.85.220.70]) (amavisd-new, port 10024) with ESMTP id NF1X0jaVqyMg; Thu, 24 Dec 2020 11:33:17 -0500 (EST) Received: from [192.168.48.23] (host-104-157-204-209.dyn.295.ca [104.157.204.209]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: dgilbert@interlog.com) by mail-1.ca.inter.net (Postfix) with ESMTPSA id A198C2EA01C; Thu, 24 Dec 2020 11:45:10 -0500 (EST) Reply-To: dgilbert@interlog.com Subject: Re: [PATCH v1 0/6] no-copy bvec To: Christoph Hellwig , Pavel Begunkov Cc: James Bottomley , Ming Lei , linux-block@vger.kernel.org, Jens Axboe , Matthew Wilcox , Johannes Weiner , Alexander Viro , "Darrick J . Wong" , "Martin K . Petersen" , Jonathan Corbet , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, linux-doc@vger.kernel.org References: <20201215014114.GA1777020@T590> <103235c1-e7d0-0b55-65d0-013d1a09304e@gmail.com> <20201215120357.GA1798021@T590> <20201222141112.GE13079@infradead.org> <933030f0-e428-18fd-4668-68db4f14b976@gmail.com> <20201223155145.GA5902@infradead.org> <8abc56c2-4db8-5ee3-ab2d-8960d0eeeb0d@interlog.com> <20201224064119.GA3048@infradead.org> From: Douglas Gilbert Message-ID: Date: Thu, 24 Dec 2020 11:45:10 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201224064119.GA3048@infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-CA Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-12-24 1:41 a.m., Christoph Hellwig wrote: > On Wed, Dec 23, 2020 at 08:32:45PM +0000, Pavel Begunkov wrote: >> On 23/12/2020 20:23, Douglas Gilbert wrote: >>> On 2020-12-23 11:04 a.m., James Bottomley wrote: >>>> On Wed, 2020-12-23 at 15:51 +0000, Christoph Hellwig wrote: >>>>> On Wed, Dec 23, 2020 at 12:52:59PM +0000, Pavel Begunkov wrote: >>>>>> Can scatterlist have 0-len entries? Those are directly translated >>>>>> into bvecs, e.g. in nvme/target/io-cmd-file.c and >>>>>> target/target_core_file.c. I've audited most of others by this >>>>>> moment, they're fine. >>>>> >>>>> For block layer SGLs we should never see them, and for nvme neither. >>>>> I think the same is true for the SCSI target code, but please double >>>>> check. >>>> >>>> Right, no-one ever wants to see a 0-len scatter list entry.?? The reason >>>> is that every driver uses the sgl to program the device DMA engine in >>>> the way NVME does.?? a 0 length sgl would be a dangerous corner case: >>>> some DMA engines would ignore it and others would go haywire, so if we >>>> ever let a 0 length list down into the driver, they'd have to >>>> understand the corner case behaviour of their DMA engine and filter it >>>> accordingly, which is why we disallow them in the upper levels, since >>>> they're effective nops anyway. >>> >>> When using scatter gather lists at the far end (i.e. on the storage device) >>> the T10 examples (WRITE SCATTERED and POPULATE TOKEN in SBC-4) explicitly >>> allow the "number of logical blocks" in their sgl_s to be zero and state >>> that it is _not_ to be considered an error. >> >> It's fine for my case unless it leaks them out of device driver to the >> net/block layer/etc. Is it? > > None of the SCSI Command mentions above are supported by Linux, > nevermind mapped to struct scatterlist. > The POPULATE TOKEN / WRITE USING TOKEN pair can be viewed as a subset of EXTENDED COPY (SPC-4) which also supports "range descriptors". It is not clear if target_core_xcopy.c supports these range descriptors but if it did, it would be trying to map them to struct scatterlist objects. That said, it would be easy to skip the "number of logical blocks" == 0 case when translating range descriptors to sgl_s. In my ddpt utility (a dd clone) I have generalized skip= and seek= to optionally take sgl_s. If the last element in one of those sgl_s is LBAn,0 then it is interpreted as "until the end of that device" which is further restricted if the other sgl has a "hard" length or count= is given. The point being a length of 0 can have meaning, a benefit lost with NVMe's 0-based counts. Doug Gilbert