Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp9993001rwl; Wed, 11 Jan 2023 12:54:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXtdwUmD+5Q9pFLe8WY1DPvyqkrX9lADyHuRMDaLuF9uSC6omIOeqPs7/RtC5B91BQ4575gH X-Received: by 2002:a05:6a00:3247:b0:576:65f5:c60a with SMTP id bn7-20020a056a00324700b0057665f5c60amr63483477pfb.27.1673470443497; Wed, 11 Jan 2023 12:54:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673470443; cv=none; d=google.com; s=arc-20160816; b=nixluUulGcWD/+PICL5OJGMfKr7H8TyejZzEnOP+T16limYAaowHYQfkH+k8/2bady DglVMrRwCqvhHBf2rX6qDTJkOsUZOFPKegOQkpbjnSFT4PoXLQT1/AOYH+GJgms+5XRu UgdzfQNDy2z4uZEFAh6Ua53cQ0Hq/1BtxixQQruA5aQ9hghV1FSGRxgkO7btcF5Jz4vv N9NrtZVWu+/Dc/oS37G9lhht4k/UYz7J8G/7Ao+CerVIReVOQ60bEJSzmEC5DWzVpm2q M3H+lPEa36MNGRWn6erENERtmmir2J4qVDAIITFivvME8GhssHmSnkCnss2U+pLHuuSP logQ== 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=EkqhoeCZuwa+2bEMUhxCOdyrJETsu5EtKMG81jKmyM4=; b=BJopA4rPiy3azzIIdA1E87GxXYp/xK3ZvuRLwcK/oAjwIHm9BObDhdCdxWwUHVsSSC ZZVXht4yYWqqK+08Dw0p38BbDkgv+fWitu4a8mDwJse8T7qX2f6SjweQ7RmDFWmmn+Ru fQznP/XUQu+BJdWj6YS7o+9MSQ5g4heCvubMHnqSSdD/SIDCrOF6teP6LOBodM/cQtn4 BCXjngWNy9zZPaxaAksAVJ9Kf2gaR/8C/Kd1IPJfKlmDzQimYJkxa1gidjw4TQaWZcVF nCalh8+3eQB1CYZ07m3d+AAmA4+maPi8sov2C9Bea4+9FGxs/4RR0UfaB05nXQuLWKzH mgKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fromorbit-com.20210112.gappssmtp.com header.s=20210112 header.b=ie0gHeNU; 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 y82-20020a626455000000b00589605fb097si7318190pfb.224.2023.01.11.12.53.44; Wed, 11 Jan 2023 12:54:03 -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=@fromorbit-com.20210112.gappssmtp.com header.s=20210112 header.b=ie0gHeNU; 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 S233380AbjAKUww (ORCPT + 99 others); Wed, 11 Jan 2023 15:52:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230442AbjAKUwr (ORCPT ); Wed, 11 Jan 2023 15:52:47 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53DE93E0C0 for ; Wed, 11 Jan 2023 12:52:46 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id b9-20020a17090a7ac900b00226ef160dcaso16812376pjl.2 for ; Wed, 11 Jan 2023 12:52:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=EkqhoeCZuwa+2bEMUhxCOdyrJETsu5EtKMG81jKmyM4=; b=ie0gHeNUjoqz2jvtZmldqUXtiL0DZ/4lwcY++B/0ysqxzJJczfN176RleYjOTd4hNt viBv7vyljweJKDNXDo8V+QO58QjYsXICTF7GJ3cO1iWDt8GCHwEhu6XCirIIS732o/HZ PJh2O/V+0aPaxqTz6OkWPWLYJDrvRgPSbI5YK0s3cbmeHQTNn0uBrO990NddYB1nYTKH cL2F6FJ/HhUs0DHrdDTQ5IodOt0T2WgBCLkUyco0njpGj0IWoALnmTYM3itpvVkv+k9x PZBXNpWZNsE2kdlfxofFohEo0g6Y9gI2/055tReBc/ragvY+kVbl5P6W4YXvvXyy2qa1 3DRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EkqhoeCZuwa+2bEMUhxCOdyrJETsu5EtKMG81jKmyM4=; b=3S18PqsYlcRjHaxniSw84zmhMnHAi32zXF0bJrFqAeuAJEE+ALzJfoO2fIDcur/Xhu jbeesJnH0mg/QqGvpBY7AUGbSS5K0cyM18HV0y4p1E/rI8Lw9keMrf36otP38x9uHd7I 3zjN2kbVXd+iOeT+VQXXQb9GyhUlwzFpnqxbrrKMSDfly7DK9K1nB0ziXLfwJwvTZAnr 83Ks23ZNOx6UPLnL+oljsJutLrxcJgHJ50VbCH8xEPGqBpNeAwndVpR5NuHew8H1tueZ DRbTm5zrcfds7I+Lbpg11Qc1KHezOyEBvRu1ytLKda2lSoJVmwIIFvH/1xhf5xoJSX+a J2wA== X-Gm-Message-State: AFqh2kp1Fx4u/z0k632YwmaQPW6MrmYzhqyxp/Kd8FU5DMi4bbaQvGfD 954guGt9109BUyo+Do/cqOOVmQ== X-Received: by 2002:a17:902:ce02:b0:18f:a5b6:54f9 with SMTP id k2-20020a170902ce0200b0018fa5b654f9mr80454345plg.11.1673470365866; Wed, 11 Jan 2023 12:52:45 -0800 (PST) Received: from dread.disaster.area (pa49-186-146-207.pa.vic.optusnet.com.au. [49.186.146.207]) by smtp.gmail.com with ESMTPSA id t2-20020a1709027fc200b00192f9991e51sm10459441plb.251.2023.01.11.12.52.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 12:52:45 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1pFi5R-001vGU-0W; Thu, 12 Jan 2023 07:52:41 +1100 Date: Thu, 12 Jan 2023 07:52:41 +1100 From: Dave Chinner To: Matthew Wilcox Cc: Christoph Hellwig , Andreas Gruenbacher , Dave Chinner , "Darrick J . Wong" , 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: <20230111205241.GA360264@dread.disaster.area> 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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 Wed, Jan 11, 2023 at 07:36:26PM +0000, Matthew Wilcox wrote: > On Tue, Jan 10, 2023 at 07:24:27AM -0800, Christoph Hellwig wrote: > > On Tue, Jan 10, 2023 at 01:34:16PM +0000, Matthew Wilcox wrote: > > > > 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. > > > > So what would be an alternative way to tell the callers why no folio > > was found instead of trying to reverse engineer that? Return an errno > > and the folio by reference? The would work, but the calling conventions > > would be awful. > > Agreed. How about an xa_filemap_get_folio()? > > (there are a number of things to fix here; haven't decided if XA_ERROR > should return void *, or whether i should use a separate 'entry' and > 'folio' until I know the entry is actually a folio ...) That's awful. Exposing internal implementation details in the API that is supposed to abstract away the internal implementation details from users doesn't seem like a great idea to me. Exactly what are we trying to fix here? Do we really need to punch a hole through the abstraction layers like this just to remove half a dozen lines of -slow path- context specific error handling from a single caller? If there's half a dozen cases that need this sort of handling, then maybe it's the right thing to do. But for a single calling context that only needs to add a null return check in one specific case? There's absolutely no need to make generic infrastructure violate layering abstractions to handle that... -Dave. -- Dave Chinner david@fromorbit.com