Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2748413rwb; Sun, 15 Jan 2023 21:53:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXu7Wn/sg2qEBbGHAH82JA/2l7pwXdripFtpy3pLtSyBrizCemRp52nOyMn/XN0/zHfGcHxw X-Received: by 2002:a05:6a00:1da3:b0:589:d831:ad2a with SMTP id z35-20020a056a001da300b00589d831ad2amr23147418pfw.6.1673848417904; Sun, 15 Jan 2023 21:53:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673848417; cv=none; d=google.com; s=arc-20160816; b=Urkq0pYusjLJHe+pM7LLykmlqpsbr12gzh0tawnv6CXBW6UighI5M5Kw36sf6CHi8f MHQkoZ8sLI52tP0LWCY2Y8iOlUTJhu4jIHwRyYu+BAphLL8cMQM6MeTbh9adw0FUQYN5 8jw8ggcEorD9kajB4HvWW7VY/uzXU4NG3vLb0yc6ouwUv4icnKzNF4V/v0ZfMdq1sABB iVhpSE+t1mH55QozTmzuIBLf3IFdStTmGBhjNrm4k6CRLJ8m26OlY7G9GpIigwQgjhHi Zc4I7pk4QY0Bxwn+LSd8ZpzosezpicM39Icp+R+7gmleyMEoSPr05i7n+ZTS1qCC6xZ1 3o8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DyqbCFVVSRH9BdL+CtsL2Q0IUbjE2/UgdwZHHo8qQB0=; b=EEi8oyj5bgnicJQ/EuLOWPLkelyvs7gZD6B89k7EvdENtPYbV4M9XFYBdmasC8319o M3Pypz4wffSP/iCF1f9B+iksxgcQEZ4JcvlZ7Mo9bI/jJMlB4Z1cdFkTmy6Ka5mYb9/M yMsKFTnWGYSPL7sVTXr3TVauodISj111WEUcr7GiuU6pbyIeyCvvEFi8BC6mqG9sGNx8 bHDFNxVjb5N6oWcIkeMnR0NKrBdHeHerD2/hqKsJ1CvMT9RGfVNRj2CCB5Q1ohiOoUSo oPN+Bsmz86zVYdfvYp9lMeNv1z82ECJDAjhqs4t2yFIiVWir1pQJ1RHQHzyxGrDsT+CJ BoJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=VpLfGMnS; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u21-20020a62ed15000000b00586f14297c4si23337600pfh.231.2023.01.15.21.53.19; Sun, 15 Jan 2023 21:53:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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=@infradead.org header.s=casper.20170209 header.b=VpLfGMnS; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231691AbjAPFp7 (ORCPT + 99 others); Mon, 16 Jan 2023 00:45:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231735AbjAPFp5 (ORCPT ); Mon, 16 Jan 2023 00:45:57 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B2D959C8; Sun, 15 Jan 2023 21:45:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=DyqbCFVVSRH9BdL+CtsL2Q0IUbjE2/UgdwZHHo8qQB0=; b=VpLfGMnSfQj8FrosrID5nRtle+ nzIT4ANfYFRckuOCdbv2oJ2HnpBcXVwqkfI/P1K9FPFM70xt8YwOt0UfDlcVci11nIxWv9Wgt1evQ rdOf6sTwJiLeX0Z6uD3pIY9oEcYwVZtaMAmBSZxLqLcKgX2/Me0xLNWLmX2P6h4dKu4t7g8bRZXqy Le5zW6+zPyY5sN2iyBiTMjLuZ3FiUerwjh4u8H1XUfZc4940SNTBY26wmHKnJtdrvVhX+BN1TNLqQ RaEf9hS4DtPfCb3mW/ffI/L1Yax3IOQY5bbo8l723yeF4pU2FduhlWFnNj1DoIm6cOglPov/O6q+0 BoQrNtNA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHIJl-008SpC-8k; Mon, 16 Jan 2023 05:46:01 +0000 Date: Mon, 16 Jan 2023 05:46:01 +0000 From: Matthew Wilcox To: "Darrick J. Wong" Cc: Christoph Hellwig , Andreas Gruenbacher , Dave Chinner , Alexander Viro , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com, Christoph Hellwig Subject: Re: [RFC v6 04/10] iomap: Add iomap_get_folio helper Message-ID: References: <20230108213305.GO1971568@dread.disaster.area> <20230108194034.1444764-1-agruenba@redhat.com> <20230108194034.1444764-5-agruenba@redhat.com> <20230109124642.1663842-1-agruenba@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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-ext4@vger.kernel.org On Sun, Jan 15, 2023 at 09:06:50AM -0800, Darrick J. Wong wrote: > On Sun, Jan 15, 2023 at 09:01:22AM -0800, Darrick J. Wong wrote: > > On Tue, Jan 10, 2023 at 01:34:16PM +0000, Matthew Wilcox wrote: > > > On Tue, Jan 10, 2023 at 12:46:45AM -0800, Christoph Hellwig wrote: > > > > On Mon, Jan 09, 2023 at 01:46:42PM +0100, Andreas Gruenbacher wrote: > > > > > We can handle that by adding a new IOMAP_NOCREATE iterator flag and > > > > > checking for that in iomap_get_folio(). Your patch then turns into > > > > > the below. > > > > > > > > Exactly. And as I already pointed out in reply to Dave's original > > > > patch what we really should be doing is returning an ERR_PTR from > > > > __filemap_get_folio instead of reverse-engineering the expected > > > > error code. > > > > > > Ouch, we have a nasty problem. > > > > > > If somebody passes FGP_ENTRY, we can return a shadow entry. And the > > > encodings for shadow entries overlap with the encodings for ERR_PTR, > > > meaning that some shadow entries will look like errors. The way I > > > solved this in the XArray code is by shifting the error values by > > > two bits and encoding errors as XA_ERROR(-ENOMEM) (for example). > > > > > > I don't _object_ to introducing XA_ERROR() / xa_err() into the VFS, > > > but so far we haven't, and I'd like to make that decision intentionally. > > > > Sorry, I'm not following this at all -- where in buffered-io.c does > > anyone pass FGP_ENTRY? Andreas' code doesn't seem to introduce it > > either...? > > Oh, never mind, I worked out that the conflict is between iomap not > passing FGP_ENTRY and wanting a pointer or a negative errno; and someone > who does FGP_ENTRY, in which case the xarray value can be confused for a > negative errno. > > OFC now I wonder, can we simply say that the return value is "The found > folio or NULL if you set FGP_ENTRY; or the found folio or a negative > errno if you don't" ? Erm ... I would rather not! Part of me remembers that x86-64 has the rather nice calling convention of being able to return a struct containing two values in two registers: : Integer return values up to 64 bits in size are stored in RAX while : values up to 128 bit are stored in RAX and RDX. so maybe we can return: struct OptionFolio { int err; struct folio *folio; };