From patchwork Sun Jan 8 19:40:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 13092675 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 5AAC4C54EBC for ; Sun, 8 Jan 2023 19:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234019AbjAHTnG (ORCPT ); Sun, 8 Jan 2023 14:43:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233599AbjAHTnD (ORCPT ); Sun, 8 Jan 2023 14:43:03 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E358FBE18 for ; Sun, 8 Jan 2023 11:41:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673206861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jtakh2AgEDKVCPUWaoe26OrkTCvuUUh6tKhp0SuOyNE=; b=RfS700MleufqFrofKcysb/aDFmY8xwpL0Cq2NgZ4S5ooakDjyhlk4rZgKtGY25tiNLWvIm uChtYvi0tqKXjsNhiA1XxLh2t8TY0gh8G8zI+mb93BtkQfkyxVV6p7Zk4wjbLhzCIKoq5Y 0PfoP4CjehUZmbM7jef5fRDdd7TmXHQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647-xSd0PQZENraCFS7Qx9oJQg-1; Sun, 08 Jan 2023 14:40:56 -0500 X-MC-Unique: xSd0PQZENraCFS7Qx9oJQg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94F161875043; Sun, 8 Jan 2023 19:40:55 +0000 (UTC) Received: from pasta.redhat.com (ovpn-192-3.brq.redhat.com [10.40.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53A01492B06; Sun, 8 Jan 2023 19:40:53 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig , "Darrick J . Wong" , Alexander Viro , Matthew Wilcox Cc: Andreas Gruenbacher , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com Subject: [RFC v6 06/10] iomap: Add __iomap_get_folio helper Date: Sun, 8 Jan 2023 20:40:30 +0100 Message-Id: <20230108194034.1444764-7-agruenba@redhat.com> In-Reply-To: <20230108194034.1444764-1-agruenba@redhat.com> References: <20230108194034.1444764-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Add an __iomap_get_folio() helper as the counterpart of the existing __iomap_put_folio() helper. Use the new helper in iomap_write_begin(). Not a functional change. Signed-off-by: Andreas Gruenbacher Reviewed-by: Christoph Hellwig --- fs/iomap/buffered-io.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 418519dea2ce..666107c3a385 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -602,6 +602,17 @@ static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos, return 0; } +static struct folio *__iomap_get_folio(struct iomap_iter *iter, loff_t pos, + size_t len) +{ + const struct iomap_page_ops *page_ops = iter->iomap.page_ops; + + if (page_ops && page_ops->page_prepare) + return page_ops->page_prepare(iter, pos, len); + else + return iomap_get_folio(iter, pos); +} + static void __iomap_put_folio(struct iomap_iter *iter, loff_t pos, size_t ret, struct folio *folio) { @@ -642,10 +653,7 @@ static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, if (!mapping_large_folio_support(iter->inode->i_mapping)) len = min_t(size_t, len, PAGE_SIZE - offset_in_page(pos)); - if (page_ops && page_ops->page_prepare) - folio = page_ops->page_prepare(iter, pos, len); - else - folio = iomap_get_folio(iter, pos); + folio = __iomap_get_folio(iter, pos, len); if (IS_ERR(folio)) return PTR_ERR(folio);