Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2016712ybg; Thu, 30 Jul 2020 08:21:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyCbwVpc5DZOpQH/gKECRbSbWMyxKMATU3Gty/m0gnZLnooKglG10WP8CnyF6l2VIlzwgg X-Received: by 2002:a17:907:42cb:: with SMTP id nz19mr3067917ejb.447.1596122505079; Thu, 30 Jul 2020 08:21:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596122505; cv=none; d=google.com; s=arc-20160816; b=LkhnwTL9B+ebb4AOzY6vhy0EUJbRNCwKQuqQZsqe8L6EPfsO7og1lX7AGNS5pAphLv sRIvR4VCQOAZsphD0iwMW/uIcTjAVR2g7n9tmnazETgDsYEU0j0KLv2ZbFZp4y8j/SvO u6HQoq7lhwvYlXxB2eU3y+QaL2/OBmHQZro5c9RrykH91Xs+wDPgqDL9qdRHphaJ3EA1 Vb9NT/7agCBj+qYNs+2MJTcErpNveUYDKO2DSuBz8HsSTTfF7ofoonGiM1la32xg4cNM 7nn1z7UoQzxP/XjqpzPxyoIPl/n9zN/AZyYYqR6LdMewr4iqQBo/fTuKowbJ232V04xg S7DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=nGQt6vMiqoVRYdnYT9nSFgD74wjAetUKJ/9YT303oFw=; b=eH4Yh5Oj3sd5rIc9VBRWRUMqmyvnHZ3PCAm80/j3EKp1X9OUvkvTIaTr47NBZEU7/C J5Ai7kviXa1IbvGEnBC1oOCvWS3LGnVUrUqcME82LXBwjSSfhvK+DcoLhv2dABjAIrag wcmabsFeFVjb4hczJwXvd7YesaPh8+DPSVVyDT+avVlK1lxn3aG6vl+UvJEItWzOHDP8 Q1d94vB4edbS10R/TLLX5RgSqdP7lGwJASWonVoYSHDsKbYsMC9vxuhEtn2YiuIhfXhI aJ0qpJu+PMiTFUKtN6Z4J1s4k7tTClxojBYDSsBbkKyfSihGHZJ/Sq3v6k1fVOYbzGhc iJGw== 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 e4si3177422ejr.98.2020.07.30.08.21.22; Thu, 30 Jul 2020 08:21:45 -0700 (PDT) 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 S1729092AbgG3PUu (ORCPT + 99 others); Thu, 30 Jul 2020 11:20:50 -0400 Received: from verein.lst.de ([213.95.11.211]:56324 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbgG3PUt (ORCPT ); Thu, 30 Jul 2020 11:20:49 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id A347568BEB; Thu, 30 Jul 2020 17:20:46 +0200 (CEST) Date: Thu, 30 Jul 2020 17:20:46 +0200 From: Christoph Hellwig To: Al Viro Cc: Christoph Hellwig , Linus Torvalds , Stephen Rothwell , Luis Chamberlain , Matthew Wilcox , Kees Cook , Iurii Zaikin , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 22/23] fs: default to generic_file_splice_read for files having ->read_iter Message-ID: <20200730152046.GA21192@lst.de> References: <20200707174801.4162712-1-hch@lst.de> <20200707174801.4162712-23-hch@lst.de> <20200730000544.GC1236929@ZenIV.linux.org.uk> <20200730070329.GB18653@lst.de> <20200730150826.GA1236603@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200730150826.GA1236603@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 30, 2020 at 04:08:26PM +0100, Al Viro wrote: > > I think we need to fix that in the instances, as we really expect > > ->splice_read to just work instead of the caller knowing what could > > work and what might not. > > Er... generic_file_splice_read() is a library helper; the decision to use > is up to the filesystem/driver/protocol in question, and so's making sure > it's not used with ->read_iter() that isn't fit for it. Yes, but.. The problem is that while right now generic_file_splice_read is the only user of ITER_PIPE there is absolutely not guarantee that it remains the only user. Having ->read_iter instances lingering that can't deal with it is at best a mine field waiting for victims. Fortunately I think the fix is pretty easy - remove the special pipe zero copy optimization from copy_page_to_iter, and just have the callers actually want it because they have pagecache or similar refcountable pages use it explicitly for the ITER_PIPE case. That gives us a safe default with an opt-in into the optimized variant. I'm currently auditing all the users of for how it is used and that looks pretty promising. > Note that we *do* have instances where we have different ->splice_read() > (sometimes using generic_file_splice_read(), sometimes not) even though > ->read_iter() is there. > > Your patch ignores those (thankfully), but commit message is rather > misleading - it strongly implies that generic_file_splice_read() is > *always* the right thing when ->read_iter() is there, not just that > in such cases it makes a better fallback than default_file_splice_read(). I don't think it always is right. Not without a major audit and more work at least.