Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp713753rwj; Fri, 23 Dec 2022 07:12:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXusIwi9RvDkmiR/CvZRB1anrmF6gJ7bxwPXQ2g31SSaQf+fMtxyX1qiLRh+JT8AMxl4eFyI X-Received: by 2002:a17:907:8b93:b0:7c1:1dc7:8837 with SMTP id tb19-20020a1709078b9300b007c11dc78837mr8314171ejc.66.1671808363587; Fri, 23 Dec 2022 07:12:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671808363; cv=none; d=google.com; s=arc-20160816; b=T2SasDeRMje0N3ZVGTd2TJvXxK4Zuo6OW7A5ZGQNhiV9+o3Q8cFVYZb5sa00wmaVqT oLPU8ku43Gvj9AohrHhDHMAhApYbHTiI1hz3ndDP6NJHQvsuMsNCqo8dz/8HK43YDsK2 JlliPKDa93r7qshvwpG1wE5toJoWYtJOD40rDv6uaJ0ksrLsYGnaJ2Y8mpzKhhnB9Xgk TRTps9x5gnBZLPsCGZmT4A6dhvsZX7GsIVHbaM9pmACiDYeu4SWFSRVde5IkzG7KsdGl 5n9l2vRjx8TUBqfDX0NcYWDWTho/gJ/qCdDG38lATQQyVvu3AzxICqyjY0f9rHAj7HxA 3DCQ== 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=h+SmOW9vIMluWkiAOCy8s6ZiV2yLlIn3ZNFaeXBMSoA=; b=RooEAmyQGVYJGpkQvNiaxdPFufgOUv6tdMupVNpQ4tM6mbPA6GhbSmvbOfRU2frKcW QQFGgEjMTOecf1DS8KoBvS1FlnhGmx53ZxayxZk7/KBFoIcD3iZ1sgPCyQ6ik6BgKlPB ybPMLLfkWyXsZzoHJAz1mVJozNpzOlrbHVKyWpFFpaK8NWtpHISEcC7ziIBMQgstamaW LAoa2NXCJ8Ud+eDoJpVs7wTVhUell8aLtIChNrMKOjdh1PcrKBGy0fAlGTIU13vdOtbj I04O9H58RmrdUDnL4fSnPkpmq3iTrKtIDvviMYZBRLIH0uyyoYYN1Q2tzrSx/wE+P44v UgRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=UrTkXlzB; 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 sa17-20020a1709076d1100b0082cbe0c28dfsi2714589ejc.980.2022.12.23.07.12.18; Fri, 23 Dec 2022 07:12:43 -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=bombadil.20210309 header.b=UrTkXlzB; 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 S236451AbiLWPCb (ORCPT + 99 others); Fri, 23 Dec 2022 10:02:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236430AbiLWPCa (ORCPT ); Fri, 23 Dec 2022 10:02:30 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78DB424BE0; Fri, 23 Dec 2022 07:02:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; 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=h+SmOW9vIMluWkiAOCy8s6ZiV2yLlIn3ZNFaeXBMSoA=; b=UrTkXlzBBuslEkvIUONV8dJgb5 1jeGUmyfXIsAFWgWw4A0ERmGOjSR59qHBDTfAwqKLpdTKeTihaPx9w1NxfXHwHZShNp4h+YQk4Dua F1O1rdKzj2MHdg0eZj0NqOLj5Iqlxvk8lACDQKKbWUcPX3o7aX8GVQSMZmAhglvwbo91XAC2DuCk+ h0jwk/5l7DAIx9JtoLSiySJeLaXZCbl/V7AFRd/gZnOVOxV+CpNWUkB5e0W5BxMwvENq9XwzgfWwd D7lcPyIIwXzvP+a91FdC5O9bL5YW1rYtYGvNLo0ebpSWyMdQx1gQZM5pWm1s3O3Z8m9Y8JC4Lc0Hh pRszZV4Q==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1p8jZ2-009A0X-UF; Fri, 23 Dec 2022 15:02:24 +0000 Date: Fri, 23 Dec 2022 07:02:24 -0800 From: Christoph Hellwig To: Andreas Gruenbacher Cc: Christoph Hellwig , "Darrick J . Wong" , Alexander Viro , Matthew Wilcox , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com Subject: Re: [RFC v3 2/7] iomap: Add iomap_folio_done helper Message-ID: References: <20221216150626.670312-1-agruenba@redhat.com> <20221216150626.670312-3-agruenba@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221216150626.670312-3-agruenba@redhat.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 Fri, Dec 16, 2022 at 04:06:21PM +0100, Andreas Gruenbacher wrote: > +static void iomap_folio_done(struct iomap_iter *iter, loff_t pos, size_t ret, > + struct folio *folio) > +{ > + const struct iomap_page_ops *page_ops = iter->iomap.page_ops; > + > + if (folio) > + folio_unlock(folio); > + if (page_ops && page_ops->page_done) > + page_ops->page_done(iter->inode, pos, ret, &folio->page); > + if (folio) > + folio_put(folio); > +} How is the folio derefence going to work if folio is NULL? That being said, I really wonder if the current API is the right way to go. Can't we just have a ->get_folio method with the same signature as __filemap_get_folio, and then do the __filemap_get_folio from the file system and avoid the page/folio == NULL clean path entirely? Then on the done side move the unlock and put into the done method as well. > if (!folio) { > status = (iter->flags & IOMAP_NOWAIT) ? -EAGAIN : -ENOMEM; > - goto out_no_page; > + iomap_folio_done(iter, pos, 0, NULL); > + return status; > } > > /* > @@ -656,13 +670,9 @@ static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, > return 0; > > out_unlock: > - folio_unlock(folio); > - folio_put(folio); > + iomap_folio_done(iter, pos, 0, folio); > iomap_write_failed(iter->inode, pos, len); > > -out_no_page: > - if (page_ops && page_ops->page_done) > - page_ops->page_done(iter->inode, pos, 0, NULL); > return status; But for the current version I don't really understand why the error unwinding changes here.