Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp654226rwb; Thu, 12 Jan 2023 10:30:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXtGBv6uKZ4G5ofHL2EKrL5he8Mgb49M6LrPMKazqhXSiyv5cNbyno+RX01RVcszNdaAdfW5 X-Received: by 2002:a05:6a20:3945:b0:b3:5196:9505 with SMTP id r5-20020a056a20394500b000b351969505mr84268226pzg.30.1673548218796; Thu, 12 Jan 2023 10:30:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673548218; cv=none; d=google.com; s=arc-20160816; b=leDt/KvEonly3qV+eEmpC002SByH/OAVlC844F+9itV7PxSzPV8kkgQKLTSDQ2ydWz FehkLuRZsu+jUPWxayESyWYkR0qPVOp32NxYEpqPOqLp1TIJko77IDdl3Ql+2illYSmr 67eDgOzh3KQXKVXAUa6BHTmpcc/x+jzhQumztcbnndMjE4Fl1w8M29sUt54aCoTH9mE2 o/dnHGrnueKdNh20uAE0t3myofjO0rC3s1w/2WAo5+xpH25Gv5Fd4vq0qo01sVdJ3FbF eqNnwLs0bisYXIDp/vLgf2cwiPNtc322uCQecnd92HwkM2IJO7MzWj2pHy3UJQLBCkZY RSLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=MRcNURrCcMAMUGIQZf3CCD7Lvxpvqs5be68sOS6UP0I=; b=qIg2dNsQk1NeSH2HN/BA8gmy4rNSITOCSNymZ/I8u9yLa7+3z03Ardrj5viPYx/nbS i7VvoQzQvr3fahGsR8H4sApfU13PZ/0yw1G5aeW1vWGtJMhxjK229G3zuzcGc/DNZlAI dBJa9ZhNI0Htxyzl0Ibn9BmKxQL9vXy/y9OvU6nnBzrBTpZyKuT7pjB9WryYdmtfEAad 5Em06iOnD5y+PsB759C/d0EKuLzu3kVUhgNJ5LK5Bh4UG+94h1aI5Nfv75kubbr/KtMf pY9RH24BEqjy6qCGUd72vT66IWTa4fKSmtGtFVygsHDZeHylxcdvAxNcCdWrCtALryoX P2aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=nTd60ieJ; 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=zeniv.linux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a655548000000b0047699804989si18173681pgr.64.2023.01.12.10.30.12; Thu, 12 Jan 2023 10:30:18 -0800 (PST) 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=@linux.org.uk header.s=zeniv-20220401 header.b=nTd60ieJ; 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=zeniv.linux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240246AbjALSKA (ORCPT + 50 others); Thu, 12 Jan 2023 13:10:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240215AbjALSJc (ORCPT ); Thu, 12 Jan 2023 13:09:32 -0500 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD62E736E0; Thu, 12 Jan 2023 09:37:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=MRcNURrCcMAMUGIQZf3CCD7Lvxpvqs5be68sOS6UP0I=; b=nTd60ieJVIzIkEvkTjgjJ7SfUT mvK7KmAuVFDifAN4HnMX/RLqSDCsnoBzH/YqsfpejieQECVzMKwkx2+zAdLjUfkvRfdeJrCrCu0EK EL5g/3prvqTr8dqp9RJb3nJ9oOw9Zw7Vfbjc1pwg+invynjid40cLu+Ki15XSoeY7Z+DRUj7z3GLf vx9n2ZlzrNrrvkN/DpDX4rxGoH+ureY8Jbf24lDEr6DGd+DrQxJTUHVZsth5M927rApOKtQYayHix QXOf23LPcM7m41OPHo4xDfk81C2rZEWMl5psV9Zydi2cJta/PSzb4nTFd2ZQ5kA58QqHs5krbPwvE xGdNbK7w==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1pG1W2-001WGB-1g; Thu, 12 Jan 2023 17:37:26 +0000 Date: Thu, 12 Jan 2023 17:37:26 +0000 From: Al Viro To: Christoph Hellwig Cc: David Howells , Matthew Wilcox , Jens Axboe , Jan Kara , Jeff Layton , Logan Gunthorpe , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 3/9] iov_iter: Use IOCB/IOMAP_WRITE if available rather than iterator direction Message-ID: References: <167344725490.2425628.13771289553670112965.stgit@warthog.procyon.org.uk> <167344727810.2425628.4715663653893036683.stgit@warthog.procyon.org.uk> <15330.1673519461@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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 On Thu, Jan 12, 2023 at 06:08:14AM -0800, Christoph Hellwig wrote: > On Thu, Jan 12, 2023 at 10:31:01AM +0000, David Howells wrote: > > > And use the information in the request for this one (see patch below), > > > and then move this patch first in the series, add an explicit direction > > > parameter in the gup_flags to the get/pin helper and drop iov_iter_rw > > > and the whole confusing source/dest information in the iov_iter entirely, > > > which is a really nice big tree wide cleanup that remove redundant > > > information. > > > > Fine by me, but Al might object as I think he wanted the internal checks. Al? > > I'm happy to have another discussion, but the fact the information in > the iov_iter is 98% redundant and various callers got it wrong and > away is a pretty good sign that we should drop this information. It > also nicely simplified the API. I have no problem with getting rid of iov_iter_rw(), but I would really like to keep ->data_source. If nothing else, any place getting direction wrong is a trouble waiting to happen - something that is currently dealing only with iovec and bvec might be given e.g. a pipe. Speaking of which, I would really like to get rid of the kludge /dev/sg is pulling - right now from-device requests there do the following: * copy the entire destination in (and better hope that nothing is mapped write-only, etc.) * form a request + bio, attach the pages with the destination copy to it * submit * copy the damn thing back to destination after the completion. The reason for that is (quoted in commit ecb554a846f8) ==== The semantics of SG_DXFER_TO_FROM_DEV were: - copy user space buffer to kernel (LLD) buffer - do SCSI command which is assumed to be of the DATA_IN (data from device) variety. This would overwrite some or all of the kernel buffer - copy kernel (LLD) buffer back to the user space. The idea was to detect short reads by filling the original user space buffer with some marker bytes ("0xec" it would seem in this report). The "resid" value is a better way of detecting short reads but that was only added this century and requires co-operation from the LLD. ==== IOW, we can't tell how much do we actually want to copy out, unless the SCSI driver in question is recent enough. Note that the above had been written in 2009, so it might not be an issue these days. Do we still have SCSI drivers that would not set the residual on bypass requests completion? Because I would obviously very much prefer to get rid of that copy in-overwrite-copy out thing there - given the accurate information about the transfer length it would be easy to do.