Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2318437pxb; Mon, 11 Jan 2021 06:48:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJza4P95JHpU2CjmE3jh02Vz3q3HAAzgBomYylZX0nzLQf1df+K6XDa1O8MnKykKRAY8H42h X-Received: by 2002:a17:907:948d:: with SMTP id dm13mr10703852ejc.545.1610376517772; Mon, 11 Jan 2021 06:48:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610376517; cv=none; d=google.com; s=arc-20160816; b=JG4OJ3u+1TamQQyqs0tczc54ByAkWwoQJFkivs+QuagtVNoqtxFruXYTUXlwjnZqOl Nzp5RME0wM1oBSKlr5wCtvh1guJPcOZtPRo9hpSTk6SG6ZHA01lL4qHm1VXiWPTI/Ndp tVznYqlG8teDrVYnrTKvB2w6P9NbRKOnIihOnI/WpelCX9QbNFAb1lRhrTuuGu8/09PO twijtkSJHLeQA55nfWox+9deRR5PpzX/9HL+8PkanvrjGsOUHt+TlNVXsUnK1gphNOQw ylN6LltmkrcItFczhMhtSUq8pbmiqyTETjQbwxRn1aVUThrvRZpOIcPv2KpNFeKxgdFj miKQ== 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; bh=1v3gaenUOgI2wP24V+gQX4ArzeqJWG7fkzCS/mxdSLI=; b=YitQJosOQEwPLsP0sPUPFFvWAsQH6HK3+M3TOKQnK1XzltgI7GiZc74YguPR0lNg3g 9if4x+DZq5SPBOtGMbx4CATTPJCFObtdbZiOJ9cyFvYgWmMWDH17c1Lpn8Uh02CIcCUM z1x0uwuX1RW/6Ll/GtjpDZJa4uuma3ZT8M2xTSa8tKQPWU4CT3mArffOmWQXMd18+hpz fWKAiP1QAUL2fH/lEcvnqecmE/RPC0S8DiBXqNF3ha6CRg0rRv5UMenCYqhStTe8dECW 4Ip7qF5MKy4tlBhJU3WLTUb5M/l+roEkxRDSyBCpi9pQlqjD5rclMLy74pyxeBvVVJsp npJQ== 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 cz27si5994edb.371.2021.01.11.06.48.14; Mon, 11 Jan 2021 06:48:37 -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 S2387945AbhAKOpH (ORCPT + 99 others); Mon, 11 Jan 2021 09:45:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728850AbhAKOpH (ORCPT ); Mon, 11 Jan 2021 09:45:07 -0500 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADA47C061794; Mon, 11 Jan 2021 06:44:26 -0800 (PST) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kyyQ1-009I2g-Bx; Mon, 11 Jan 2021 14:43:41 +0000 Date: Mon, 11 Jan 2021 14:43:41 +0000 From: Al Viro To: David Laight Cc: 'Mikulas Patocka' , Andrew Morton , Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , Matthew Wilcox , Jan Kara , Steven Whitehouse , Eric Sandeen , Dave Chinner , Theodore Ts'o , Wang Jianchao , "Kani, Toshi" , "Norton, Scott J" , "Tadakamadla, Rajesh" , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-nvdimm@lists.01.org" Subject: Re: [RFC v2] nvfs: a filesystem for persistent memory Message-ID: <20210111144341.GZ3579531@ZenIV.linux.org.uk> References: <20210110162008.GV3579531@ZenIV.linux.org.uk> <57dad96341d34822a7943242c9bcad71@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57dad96341d34822a7943242c9bcad71@AcuMS.aculab.com> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 11, 2021 at 11:57:08AM +0000, David Laight wrote: > > > > size = copy_to_iter(to, ptr, size); > > > > if (unlikely(!size)) { > > > > r = -EFAULT; > > > > goto ret_r; > > > > } > > > > > > > > pos += size; > > > > total += size; > > > > } while (iov_iter_count(to)); > > > > > > That isn't the best formed loop! > > > > > > David > > > > I removed the second "while" statement and fixed the arguments to > > copy_to_iter - other than that, Al's function works. > > The extra while is easy to write and can be difficult to spot. > I've found them looking as the object code before now! That extra while comes from editing cut'n'pasted piece of source while writing a reply. Hint: original had been a do-while. > Oh - the error return for copy_to_iter() is wrong. > It should (probably) return 'total' if it is nonzero. copy_to_iter() call there has an obvious problem (arguments in the wrong order), but return value is handled correctly. It does not do a blind return -EFAULT. RTFS...