From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41D27C433EF for ; Mon, 13 Dec 2021 07:38:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231258AbhLMHiM (ORCPT ); Mon, 13 Dec 2021 02:38:12 -0500 Received: from verein.lst.de ([213.95.11.211]:46426 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbhLMHiM (ORCPT ); Mon, 13 Dec 2021 02:38:12 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id CD55C68AA6; Mon, 13 Dec 2021 08:38:08 +0100 (CET) Date: Mon, 13 Dec 2021 08:38:08 +0100 From: Christoph Hellwig To: Matthew Wilcox Cc: Christoph Hellwig , dan.j.williams@intel.com, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, nvdimm@lists.linux.dev, Dan Carpenter Subject: Re: [PATCH] iomap: turn the byte variable in iomap_zero_iter into a ssize_t Message-ID: <20211213073808.GA20684@lst.de> References: <20211208091203.2927754-1-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org On Sat, Dec 11, 2021 at 05:50:51PM +0000, Matthew Wilcox wrote: > On Wed, Dec 08, 2021 at 10:12:03AM +0100, Christoph Hellwig wrote: > > bytes also hold the return value from iomap_write_end, which can contain > > a negative error value. As bytes is always less than the page size even > > the signed type can hold the entire possible range. > > iomap_write_end() can't return an errno. I went through and checked as > part of the folio conversion. It actually has two return values -- 0 > on error and 'len' on success. And it can't have an error because > that only occurs if 'copied' is less than 'length'. > > So I think this should actually be: > > - bytes = iomap_write_end(iter, pos, bytes, bytes, folio); > - if (bytes < 0) > - return bytes; > + status = iomap_write_end(iter, pos, bytes, bytes, folio); > + if (WARN_ON_ONCE(status == 0)) > + return -EIO; > > just like its counterpart loop in iomap_unshare_iter() > > (ok this won't apply to Dan's tree, but YKWIM) Indeed. It might make sense to eventually switch to actually return an errno or a bool as the current calling convention is rather confusing.