From patchwork Sat Dec 31 15:09:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 13086089 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 E66EDC4708E for ; Sat, 31 Dec 2022 15:10:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235739AbiLaPKT (ORCPT ); Sat, 31 Dec 2022 10:10:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235736AbiLaPKS (ORCPT ); Sat, 31 Dec 2022 10:10:18 -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 65FF065AC for ; Sat, 31 Dec 2022 07:09:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672499370; 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=5Ygc7yO7wRnJEDhfkoYktIJkM0VZCJqLxpPKzS46mK4=; b=eMKTK26ZrdmN8vu/kC/299TIPf/GAaLSLk9E2nGuUclPIMUMDAS8Vuw6dRrj6C3Ck/HGTL qTmLBbMt01zOSlOPptDJytJluDpzSXOVfAaq7c/n6Jl298/gO/GaOljMV1m/NncggMw/JH XC8n1oAriYeomSeryDR95/D4IEiqk3o= 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-295-4TMU-ONqNDiQUilpRPG4uQ-1; Sat, 31 Dec 2022 10:09:26 -0500 X-MC-Unique: 4TMU-ONqNDiQUilpRPG4uQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 96E9A811E9C; Sat, 31 Dec 2022 15:09:25 +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 552D7492B00; Sat, 31 Dec 2022 15:09:23 +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: [PATCH v5 1/9] iomap: Add iomap_put_folio helper Date: Sat, 31 Dec 2022 16:09:11 +0100 Message-Id: <20221231150919.659533-2-agruenba@redhat.com> In-Reply-To: <20221231150919.659533-1-agruenba@redhat.com> References: <20221231150919.659533-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add an iomap_put_folio() helper to encapsulate unlocking the folio, calling ->page_done(), and putting the folio. Use the new helper in iomap_write_begin() and iomap_write_end(). This effectively doesn't change the way the code works, but prepares for successive improvements. Signed-off-by: Andreas Gruenbacher Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/iomap/buffered-io.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 356193e44cf0..c30d150a9303 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -575,6 +575,19 @@ static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos, return 0; } +static void iomap_put_folio(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); +} + static int iomap_write_begin_inline(const struct iomap_iter *iter, struct folio *folio) { @@ -616,7 +629,8 @@ static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, fgp, mapping_gfp_mask(iter->inode->i_mapping)); if (!folio) { status = (iter->flags & IOMAP_NOWAIT) ? -EAGAIN : -ENOMEM; - goto out_no_page; + iomap_put_folio(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_put_folio(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; } @@ -712,7 +722,6 @@ static size_t iomap_write_end_inline(const struct iomap_iter *iter, static size_t iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len, size_t copied, struct folio *folio) { - const struct iomap_page_ops *page_ops = iter->iomap.page_ops; const struct iomap *srcmap = iomap_iter_srcmap(iter); loff_t old_size = iter->inode->i_size; size_t ret; @@ -735,14 +744,10 @@ static size_t iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len, i_size_write(iter->inode, pos + ret); iter->iomap.flags |= IOMAP_F_SIZE_CHANGED; } - folio_unlock(folio); + iomap_put_folio(iter, pos, ret, folio); if (old_size < pos) pagecache_isize_extended(iter->inode, old_size, pos); - if (page_ops && page_ops->page_done) - page_ops->page_done(iter->inode, pos, ret, &folio->page); - folio_put(folio); - if (ret < len) iomap_write_failed(iter->inode, pos + ret, len - ret); return ret; From patchwork Sat Dec 31 15:09:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 13086090 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 E532CC3DA7A for ; Sat, 31 Dec 2022 15:10:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232010AbiLaPKu (ORCPT ); Sat, 31 Dec 2022 10:10:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbiLaPKt (ORCPT ); Sat, 31 Dec 2022 10:10:49 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF576A44A for ; Sat, 31 Dec 2022 07:09:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672499371; 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=fE5cihq5jbVIEnuaqd8gWb8TSdCs9FfG1DNWG6Z5bj4=; b=Ol/sC+ujuQ7ynJT3pg7WIy2pS2ESliWfu5oLi+xs3e9/JEBoVOGwaULn8Shw8VIaORCKzd ehmxGvubxqWWAym+uAJ8FIqFVf6otLGdnluPDhpQ1RNn/P1r2X+oMImTzx7yxdbkN/Fk+k UywE6cBUqXZMyd2iO1Nt8Ipir/4pNkg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-a4Fw95cfPM22mhxNlQQ8RQ-1; Sat, 31 Dec 2022 10:09:28 -0500 X-MC-Unique: a4Fw95cfPM22mhxNlQQ8RQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B0D6F29A9D47; Sat, 31 Dec 2022 15:09:27 +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 03043492B00; Sat, 31 Dec 2022 15:09:25 +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: [PATCH v5 2/9] iomap/gfs2: Unlock and put folio in page_done handler Date: Sat, 31 Dec 2022 16:09:12 +0100 Message-Id: <20221231150919.659533-3-agruenba@redhat.com> In-Reply-To: <20221231150919.659533-1-agruenba@redhat.com> References: <20221231150919.659533-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org When an iomap defines a ->page_done() handler in its page_ops, delegate unlocking the folio and putting the folio reference to that handler. This allows to fix a race between journaled data writes and folio writeback in gfs2: before this change, gfs2_iomap_page_done() was called after unlocking the folio, so writeback could start writing back the folio's buffers before they could be marked for writing to the journal. Also, try_to_free_buffers() could free the buffers before gfs2_iomap_page_done() was done adding the buffers to the current current transaction. With this change, gfs2_iomap_page_done() adds the buffers to the current transaction while the folio is still locked, so the problems described above can no longer occur. The only current user of ->page_done() is gfs2, so other filesystems are not affected. To catch out any out-of-tree users, switch from a page to a folio in ->page_done(). Signed-off-by: Andreas Gruenbacher Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/gfs2/bmap.c | 15 ++++++++++++--- fs/iomap/buffered-io.c | 8 ++++---- include/linux/iomap.h | 7 ++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index e7537fd305dd..46206286ad42 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -968,14 +968,23 @@ static int gfs2_iomap_page_prepare(struct inode *inode, loff_t pos, } static void gfs2_iomap_page_done(struct inode *inode, loff_t pos, - unsigned copied, struct page *page) + unsigned copied, struct folio *folio) { struct gfs2_trans *tr = current->journal_info; struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_sbd *sdp = GFS2_SB(inode); - if (page && !gfs2_is_stuffed(ip)) - gfs2_page_add_databufs(ip, page, offset_in_page(pos), copied); + if (!folio) { + gfs2_trans_end(sdp); + return; + } + + if (!gfs2_is_stuffed(ip)) + gfs2_page_add_databufs(ip, &folio->page, offset_in_page(pos), + copied); + + folio_unlock(folio); + folio_put(folio); if (tr->tr_num_buf_new) __mark_inode_dirty(inode, I_DIRTY_DATASYNC); diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index c30d150a9303..e13d5694e299 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -580,12 +580,12 @@ static void iomap_put_folio(struct iomap_iter *iter, loff_t pos, size_t ret, { const struct iomap_page_ops *page_ops = iter->iomap.page_ops; - if (folio) + if (page_ops && page_ops->page_done) { + page_ops->page_done(iter->inode, pos, ret, folio); + } else 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); + } } static int iomap_write_begin_inline(const struct iomap_iter *iter, diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 0983dfc9a203..743e2a909162 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -131,13 +131,14 @@ static inline bool iomap_inline_data_valid(const struct iomap *iomap) * associated with them. * * When page_prepare succeeds, page_done will always be called to do any - * cleanup work necessary. In that page_done call, @page will be NULL if the - * associated page could not be obtained. + * cleanup work necessary. In that page_done call, @folio will be NULL if the + * associated folio could not be obtained. When folio is not NULL, page_done + * is responsible for unlocking and putting the folio. */ struct iomap_page_ops { int (*page_prepare)(struct inode *inode, loff_t pos, unsigned len); void (*page_done)(struct inode *inode, loff_t pos, unsigned copied, - struct page *page); + struct folio *folio); /* * Check that the cached iomap still maps correctly to the filesystem's From patchwork Sat Dec 31 15:09:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 13086098 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 0EED0C3DA7A for ; Sat, 31 Dec 2022 15:11:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235784AbiLaPLB (ORCPT ); Sat, 31 Dec 2022 10:11:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231926AbiLaPK7 (ORCPT ); Sat, 31 Dec 2022 10:10:59 -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 88B86B1E3 for ; Sat, 31 Dec 2022 07:09:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672499380; 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=l2IfSJX/vtTb5OOkZ9dadpQdlagOz1kQiJKQOgOgBSc=; b=QxjiZ8d4+vAPxkIcONfKO3/dLp50UXdSA4xwmqMLqlL6LQ7AZg4zm64lp5AWqLlLjTv/nC lg8hJz0W6/ADuDRO1nvpGKfZrsAmS2K9ZS51ZEcfXr8quWrEnrC8rZnjACLg0Bo4LBEQ7k +3+ll/LATCrCpNO7eb242HyY824+e0g= 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-553-uVXTcgzJOC6ZZQilKYK-Rg-1; Sat, 31 Dec 2022 10:09:36 -0500 X-MC-Unique: uVXTcgzJOC6ZZQilKYK-Rg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E3309811E6E; Sat, 31 Dec 2022 15:09:35 +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 EEDFA492B00; Sat, 31 Dec 2022 15:09:27 +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: [PATCH v5 3/9] iomap: Rename page_done handler to put_folio Date: Sat, 31 Dec 2022 16:09:13 +0100 Message-Id: <20221231150919.659533-4-agruenba@redhat.com> In-Reply-To: <20221231150919.659533-1-agruenba@redhat.com> References: <20221231150919.659533-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The ->page_done() handler in struct iomap_page_ops is now somewhat misnamed in that it mainly deals with unlocking and putting a folio, so rename it to ->put_folio(). Signed-off-by: Andreas Gruenbacher Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/gfs2/bmap.c | 4 ++-- fs/iomap/buffered-io.c | 4 ++-- include/linux/iomap.h | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 46206286ad42..0c041459677b 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -967,7 +967,7 @@ static int gfs2_iomap_page_prepare(struct inode *inode, loff_t pos, return gfs2_trans_begin(sdp, RES_DINODE + blocks, 0); } -static void gfs2_iomap_page_done(struct inode *inode, loff_t pos, +static void gfs2_iomap_put_folio(struct inode *inode, loff_t pos, unsigned copied, struct folio *folio) { struct gfs2_trans *tr = current->journal_info; @@ -994,7 +994,7 @@ static void gfs2_iomap_page_done(struct inode *inode, loff_t pos, static const struct iomap_page_ops gfs2_iomap_page_ops = { .page_prepare = gfs2_iomap_page_prepare, - .page_done = gfs2_iomap_page_done, + .put_folio = gfs2_iomap_put_folio, }; static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos, diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index e13d5694e299..2a9bab4f3c79 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -580,8 +580,8 @@ static void iomap_put_folio(struct iomap_iter *iter, loff_t pos, size_t ret, { const struct iomap_page_ops *page_ops = iter->iomap.page_ops; - if (page_ops && page_ops->page_done) { - page_ops->page_done(iter->inode, pos, ret, folio); + if (page_ops && page_ops->put_folio) { + page_ops->put_folio(iter->inode, pos, ret, folio); } else if (folio) { folio_unlock(folio); folio_put(folio); diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 743e2a909162..10ec36f373f4 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -126,18 +126,18 @@ static inline bool iomap_inline_data_valid(const struct iomap *iomap) /* * When a filesystem sets page_ops in an iomap mapping it returns, page_prepare - * and page_done will be called for each page written to. This only applies to + * and put_folio will be called for each page written to. This only applies to * buffered writes as unbuffered writes will not typically have pages * associated with them. * - * When page_prepare succeeds, page_done will always be called to do any - * cleanup work necessary. In that page_done call, @folio will be NULL if the - * associated folio could not be obtained. When folio is not NULL, page_done + * When page_prepare succeeds, put_folio will always be called to do any + * cleanup work necessary. In that put_folio call, @folio will be NULL if the + * associated folio could not be obtained. When folio is not NULL, put_folio * is responsible for unlocking and putting the folio. */ struct iomap_page_ops { int (*page_prepare)(struct inode *inode, loff_t pos, unsigned len); - void (*page_done)(struct inode *inode, loff_t pos, unsigned copied, + void (*put_folio)(struct inode *inode, loff_t pos, unsigned copied, struct folio *folio); /* From patchwork Sat Dec 31 15:09:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 13086101 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 93F49C53210 for ; Sat, 31 Dec 2022 15:11:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235678AbiLaPLM (ORCPT ); Sat, 31 Dec 2022 10:11:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231481AbiLaPLE (ORCPT ); Sat, 31 Dec 2022 10:11:04 -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 90961B85D for ; Sat, 31 Dec 2022 07:09:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672499382; 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=UPIwcUbZUfu3w21+Fb54YjfLv2mmYWzObZnyM39KbhE=; b=i5BXq1uDkJDhje5ta7A5MuosyFC+rd7ZwahNhylKNwCyil9OnyMfFqanBaogfGcj3UZUyS TI9yq3owXdt2+qXJwVo2NFsKRmuigUlfaScs+bRcpYaEHVjoSVpBIWPMO//LgVzaGHnSv5 xcAvv6Xi1YBITLmHFk0a+pqyIme5T3c= 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-403-QPYCuytsN6qi_6-tn3Vs8w-1; Sat, 31 Dec 2022 10:09:38 -0500 X-MC-Unique: QPYCuytsN6qi_6-tn3Vs8w-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 504DA101A521; Sat, 31 Dec 2022 15:09:38 +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 3DBFF492B00; Sat, 31 Dec 2022 15:09:36 +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: [PATCH v5 4/9] iomap: Add iomap_get_folio helper Date: Sat, 31 Dec 2022 16:09:14 +0100 Message-Id: <20221231150919.659533-5-agruenba@redhat.com> In-Reply-To: <20221231150919.659533-1-agruenba@redhat.com> References: <20221231150919.659533-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add an iomap_get_folio() helper that gets a folio reference based on an iomap iterator and an offset into the address space. Use it in iomap_write_begin(). Signed-off-by: Andreas Gruenbacher Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/iomap/buffered-io.c | 39 ++++++++++++++++++++++++++++++--------- include/linux/iomap.h | 1 + 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 2a9bab4f3c79..b84838d2b5d8 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -457,6 +457,33 @@ bool iomap_is_partially_uptodate(struct folio *folio, size_t from, size_t count) } EXPORT_SYMBOL_GPL(iomap_is_partially_uptodate); +/** + * iomap_get_folio - get a folio reference for writing + * @iter: iteration structure + * @pos: start offset of write + * + * Returns a locked reference to the folio at @pos, or an error pointer if the + * folio could not be obtained. + */ +struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos) +{ + unsigned fgp = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE | FGP_NOFS; + struct folio *folio; + + if (iter->flags & IOMAP_NOWAIT) + fgp |= FGP_NOWAIT; + + folio = __filemap_get_folio(iter->inode->i_mapping, pos >> PAGE_SHIFT, + fgp, mapping_gfp_mask(iter->inode->i_mapping)); + if (folio) + return folio; + + if (iter->flags & IOMAP_NOWAIT) + return ERR_PTR(-EAGAIN); + return ERR_PTR(-ENOMEM); +} +EXPORT_SYMBOL_GPL(iomap_get_folio); + bool iomap_release_folio(struct folio *folio, gfp_t gfp_flags) { trace_iomap_release_folio(folio->mapping->host, folio_pos(folio), @@ -603,12 +630,8 @@ static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, const struct iomap_page_ops *page_ops = iter->iomap.page_ops; const struct iomap *srcmap = iomap_iter_srcmap(iter); struct folio *folio; - unsigned fgp = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE | FGP_NOFS; int status = 0; - if (iter->flags & IOMAP_NOWAIT) - fgp |= FGP_NOWAIT; - BUG_ON(pos + len > iter->iomap.offset + iter->iomap.length); if (srcmap != &iter->iomap) BUG_ON(pos + len > srcmap->offset + srcmap->length); @@ -625,12 +648,10 @@ static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, return status; } - folio = __filemap_get_folio(iter->inode->i_mapping, pos >> PAGE_SHIFT, - fgp, mapping_gfp_mask(iter->inode->i_mapping)); - if (!folio) { - status = (iter->flags & IOMAP_NOWAIT) ? -EAGAIN : -ENOMEM; + folio = iomap_get_folio(iter, pos); + if (IS_ERR(folio)) { iomap_put_folio(iter, pos, 0, NULL); - return status; + return PTR_ERR(folio); } /* diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 10ec36f373f4..e5732cc5716b 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -261,6 +261,7 @@ int iomap_file_buffered_write_punch_delalloc(struct inode *inode, int iomap_read_folio(struct folio *folio, const struct iomap_ops *ops); void iomap_readahead(struct readahead_control *, const struct iomap_ops *ops); bool iomap_is_partially_uptodate(struct folio *, size_t from, size_t count); +struct folio *iomap_get_folio(struct iomap_iter *iter, loff_t pos); bool iomap_release_folio(struct folio *folio, gfp_t gfp_flags); void iomap_invalidate_folio(struct folio *folio, size_t offset, size_t len); int iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len, From patchwork Sat Dec 31 15:09:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 13086100 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 AD62DC3DA7A for ; Sat, 31 Dec 2022 15:11:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235661AbiLaPLL (ORCPT ); Sat, 31 Dec 2022 10:11:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbiLaPLE (ORCPT ); Sat, 31 Dec 2022 10:11:04 -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 7A39EC746 for ; Sat, 31 Dec 2022 07:09:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672499386; 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=dE6CAlIEWmWcE9bWCr2nokvAv42ISasFHLnBmeQSMa8=; b=Zl6xweVrMGeQX9Iz0BwK2/YS5StmeJJRp4V917mna/AqUBqqkVImXBQp/SazUGFLjBYmui 4wBHYEiabxpFRBZtlJtTkFF6Q2e+vMpMtq+7r76S5tD9d6VxDXSVqwwMWxb03zc1Wx6K1i ZnGaXFXkxDAYmHQO7zh7Tg05aug76O4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-cp8MSuREMbyABvaGjSCQMg-1; Sat, 31 Dec 2022 10:09:41 -0500 X-MC-Unique: cp8MSuREMbyABvaGjSCQMg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BCC823C02585; Sat, 31 Dec 2022 15:09:40 +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 AF2ED492B00; Sat, 31 Dec 2022 15:09:38 +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: [PATCH v5 5/9] iomap/gfs2: Get page in page_prepare handler Date: Sat, 31 Dec 2022 16:09:15 +0100 Message-Id: <20221231150919.659533-6-agruenba@redhat.com> In-Reply-To: <20221231150919.659533-1-agruenba@redhat.com> References: <20221231150919.659533-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Change the iomap ->page_prepare() handler to get and return a locked folio instead of doing that in iomap_write_begin(). This allows to recover from out-of-memory situations in ->page_prepare(), which eliminates the corresponding error handling code in iomap_write_begin(). The ->put_folio() handler now also isn't called with NULL as the folio value anymore. Filesystems are expected to use the iomap_get_folio() helper for getting locked folios in their ->page_prepare() handlers. Signed-off-by: Andreas Gruenbacher Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/gfs2/bmap.c | 21 +++++++++++++-------- fs/iomap/buffered-io.c | 17 ++++++----------- include/linux/iomap.h | 9 +++++---- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 0c041459677b..41349e09558b 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -956,15 +956,25 @@ static int __gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length, goto out; } -static int gfs2_iomap_page_prepare(struct inode *inode, loff_t pos, - unsigned len) +static struct folio * +gfs2_iomap_page_prepare(struct iomap_iter *iter, loff_t pos, unsigned len) { + struct inode *inode = iter->inode; unsigned int blockmask = i_blocksize(inode) - 1; struct gfs2_sbd *sdp = GFS2_SB(inode); unsigned int blocks; + struct folio *folio; + int status; blocks = ((pos & blockmask) + len + blockmask) >> inode->i_blkbits; - return gfs2_trans_begin(sdp, RES_DINODE + blocks, 0); + status = gfs2_trans_begin(sdp, RES_DINODE + blocks, 0); + if (status) + return ERR_PTR(status); + + folio = iomap_get_folio(iter, pos); + if (IS_ERR(folio)) + gfs2_trans_end(sdp); + return folio; } static void gfs2_iomap_put_folio(struct inode *inode, loff_t pos, @@ -974,11 +984,6 @@ static void gfs2_iomap_put_folio(struct inode *inode, loff_t pos, struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_sbd *sdp = GFS2_SB(inode); - if (!folio) { - gfs2_trans_end(sdp); - return; - } - if (!gfs2_is_stuffed(ip)) gfs2_page_add_databufs(ip, &folio->page, offset_in_page(pos), copied); diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index b84838d2b5d8..7decd8cdc755 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -609,7 +609,7 @@ static void iomap_put_folio(struct iomap_iter *iter, loff_t pos, size_t ret, if (page_ops && page_ops->put_folio) { page_ops->put_folio(iter->inode, pos, ret, folio); - } else if (folio) { + } else { folio_unlock(folio); folio_put(folio); } @@ -642,17 +642,12 @@ 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) { - status = page_ops->page_prepare(iter->inode, pos, len); - if (status) - return status; - } - - folio = iomap_get_folio(iter, pos); - if (IS_ERR(folio)) { - iomap_put_folio(iter, pos, 0, NULL); + if (page_ops && page_ops->page_prepare) + folio = page_ops->page_prepare(iter, pos, len); + else + folio = iomap_get_folio(iter, pos); + if (IS_ERR(folio)) return PTR_ERR(folio); - } /* * Now we have a locked folio, before we do anything with it we need to diff --git a/include/linux/iomap.h b/include/linux/iomap.h index e5732cc5716b..87b5d0f8e578 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -13,6 +13,7 @@ struct address_space; struct fiemap_extent_info; struct inode; +struct iomap_iter; struct iomap_dio; struct iomap_writepage_ctx; struct iov_iter; @@ -131,12 +132,12 @@ static inline bool iomap_inline_data_valid(const struct iomap *iomap) * associated with them. * * When page_prepare succeeds, put_folio will always be called to do any - * cleanup work necessary. In that put_folio call, @folio will be NULL if the - * associated folio could not be obtained. When folio is not NULL, put_folio - * is responsible for unlocking and putting the folio. + * cleanup work necessary. put_folio is responsible for unlocking and putting + * @folio. */ struct iomap_page_ops { - int (*page_prepare)(struct inode *inode, loff_t pos, unsigned len); + struct folio *(*page_prepare)(struct iomap_iter *iter, loff_t pos, + unsigned len); void (*put_folio)(struct inode *inode, loff_t pos, unsigned copied, struct folio *folio); From patchwork Sat Dec 31 15:09:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 13086099 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 8DF81C3DA7A for ; Sat, 31 Dec 2022 15:11:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235648AbiLaPLK (ORCPT ); Sat, 31 Dec 2022 10:11:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbiLaPLE (ORCPT ); Sat, 31 Dec 2022 10:11:04 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57708CE06 for ; Sat, 31 Dec 2022 07:09:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672499387; 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=BNcpLuaoMj/aSn3yA96m/tYCTKBmskvk8TA/HV70IVE=; b=Nw6KcwBHzR9EfW4C2G13s7Fedz9CAN7VnrU08nK5Y/+CoJq/Ai76wi5GP3WXulPlUwkWEY dEPmgI0EJXE/7xkAUq83m+ReSVy9mrVpkbLz8b9vmV2/rK6x66srgY1jURAcpHqh2b5qzr YJ/LkiqzfollGqpgH4s/h2yGjm1Hjts= 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-534-oLIIdSz0PGGbZyTDUGAgbQ-1; Sat, 31 Dec 2022 10:09:43 -0500 X-MC-Unique: oLIIdSz0PGGbZyTDUGAgbQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 69FDF811E6E; Sat, 31 Dec 2022 15:09:43 +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 251E7492B00; Sat, 31 Dec 2022 15:09:40 +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: [PATCH v5 6/9] iomap: Rename page_prepare handler to get_folio Date: Sat, 31 Dec 2022 16:09:16 +0100 Message-Id: <20221231150919.659533-7-agruenba@redhat.com> In-Reply-To: <20221231150919.659533-1-agruenba@redhat.com> References: <20221231150919.659533-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The ->page_prepare() handler in struct iomap_page_ops is now somewhat misnamed, so rename it to ->get_folio(). Signed-off-by: Andreas Gruenbacher Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/gfs2/bmap.c | 6 +++--- fs/iomap/buffered-io.c | 4 ++-- include/linux/iomap.h | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 41349e09558b..d3adb715ac8c 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -957,7 +957,7 @@ static int __gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length, } static struct folio * -gfs2_iomap_page_prepare(struct iomap_iter *iter, loff_t pos, unsigned len) +gfs2_iomap_get_folio(struct iomap_iter *iter, loff_t pos, unsigned len) { struct inode *inode = iter->inode; unsigned int blockmask = i_blocksize(inode) - 1; @@ -998,7 +998,7 @@ static void gfs2_iomap_put_folio(struct inode *inode, loff_t pos, } static const struct iomap_page_ops gfs2_iomap_page_ops = { - .page_prepare = gfs2_iomap_page_prepare, + .get_folio = gfs2_iomap_get_folio, .put_folio = gfs2_iomap_put_folio, }; @@ -1291,7 +1291,7 @@ int gfs2_alloc_extent(struct inode *inode, u64 lblock, u64 *dblock, /* * NOTE: Never call gfs2_block_zero_range with an open transaction because it * uses iomap write to perform its actions, which begin their own transactions - * (iomap_begin, page_prepare, etc.) + * (iomap_begin, get_folio, etc.) */ static int gfs2_block_zero_range(struct inode *inode, loff_t from, unsigned int length) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 7decd8cdc755..4f363d42dbaf 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -642,8 +642,8 @@ 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); + if (page_ops && page_ops->get_folio) + folio = page_ops->get_folio(iter, pos, len); else folio = iomap_get_folio(iter, pos); if (IS_ERR(folio)) diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 87b5d0f8e578..dd3575ada5d1 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -126,17 +126,17 @@ static inline bool iomap_inline_data_valid(const struct iomap *iomap) } /* - * When a filesystem sets page_ops in an iomap mapping it returns, page_prepare + * When a filesystem sets page_ops in an iomap mapping it returns, get_folio * and put_folio will be called for each page written to. This only applies to * buffered writes as unbuffered writes will not typically have pages * associated with them. * - * When page_prepare succeeds, put_folio will always be called to do any + * When get_folio succeeds, put_folio will always be called to do any * cleanup work necessary. put_folio is responsible for unlocking and putting * @folio. */ struct iomap_page_ops { - struct folio *(*page_prepare)(struct iomap_iter *iter, loff_t pos, + struct folio *(*get_folio)(struct iomap_iter *iter, loff_t pos, unsigned len); void (*put_folio)(struct inode *inode, loff_t pos, unsigned copied, struct folio *folio); From patchwork Sat Dec 31 15:09:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 13086103 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 A8BB1C3DA7D for ; Sat, 31 Dec 2022 15:11:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235835AbiLaPLp (ORCPT ); Sat, 31 Dec 2022 10:11:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235781AbiLaPLf (ORCPT ); Sat, 31 Dec 2022 10:11:35 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BC11CE2B for ; Sat, 31 Dec 2022 07:09:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672499390; 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=4+kXihu6wtIVaRcBs4N4yPc1MOjQQ5BVEsp96+a6Kzg=; b=FV9Qynaensc+2T4DnD5QSFTUBsMhLflSPFz3yv+N72pVeDZVvojQHbUQQWAgBHLAkO3nwH fRU+PFKGzKes3v1ZhGNeza2x5EN5yGF1Jt0qniY5UJYDvCWmUMN3VsBW+FZh8V3DW1WygG ZttBDK5Xm+7NYmZKMK+OFdH8StthNdw= 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-106-T0pnY96VPEipP16fyHZWQQ-1; Sat, 31 Dec 2022 10:09:46 -0500 X-MC-Unique: T0pnY96VPEipP16fyHZWQQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 01113185A78B; Sat, 31 Dec 2022 15:09:46 +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 CA5D1492B00; Sat, 31 Dec 2022 15:09:43 +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: [PATCH v5 7/9] iomap/xfs: Eliminate the iomap_valid handler Date: Sat, 31 Dec 2022 16:09:17 +0100 Message-Id: <20221231150919.659533-8-agruenba@redhat.com> In-Reply-To: <20221231150919.659533-1-agruenba@redhat.com> References: <20221231150919.659533-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Eliminate the ->iomap_valid() handler by switching to a ->get_folio() handler and validating the mapping there. Signed-off-by: Andreas Gruenbacher --- fs/iomap/buffered-io.c | 25 +++++-------------------- fs/xfs/xfs_iomap.c | 37 ++++++++++++++++++++++++++----------- include/linux/iomap.h | 22 +++++----------------- 3 files changed, 36 insertions(+), 48 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 4f363d42dbaf..df6fca11f18c 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -630,7 +630,7 @@ static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, const struct iomap_page_ops *page_ops = iter->iomap.page_ops; const struct iomap *srcmap = iomap_iter_srcmap(iter); struct folio *folio; - int status = 0; + int status; BUG_ON(pos + len > iter->iomap.offset + iter->iomap.length); if (srcmap != &iter->iomap) @@ -646,27 +646,12 @@ static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, folio = page_ops->get_folio(iter, pos, len); else folio = iomap_get_folio(iter, pos); - if (IS_ERR(folio)) - return PTR_ERR(folio); - - /* - * Now we have a locked folio, before we do anything with it we need to - * check that the iomap we have cached is not stale. The inode extent - * mapping can change due to concurrent IO in flight (e.g. - * IOMAP_UNWRITTEN state can change and memory reclaim could have - * reclaimed a previously partially written page at this index after IO - * completion before this write reaches this file offset) and hence we - * could do the wrong thing here (zero a page range incorrectly or fail - * to zero) and corrupt data. - */ - if (page_ops && page_ops->iomap_valid) { - bool iomap_valid = page_ops->iomap_valid(iter->inode, - &iter->iomap); - if (!iomap_valid) { + if (IS_ERR(folio)) { + if (folio == ERR_PTR(-ESTALE)) { iter->iomap.flags |= IOMAP_F_STALE; - status = 0; - goto out_unlock; + return 0; } + return PTR_ERR(folio); } if (pos + len > folio_pos(folio) + folio_size(folio)) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 669c1bc5c3a7..d0bf99539180 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -62,29 +62,44 @@ xfs_iomap_inode_sequence( return cookie | READ_ONCE(ip->i_df.if_seq); } -/* - * Check that the iomap passed to us is still valid for the given offset and - * length. - */ -static bool -xfs_iomap_valid( - struct inode *inode, - const struct iomap *iomap) +static struct folio * +xfs_get_folio( + struct iomap_iter *iter, + loff_t pos, + unsigned len) { + struct inode *inode = iter->inode; + struct iomap *iomap = &iter->iomap; struct xfs_inode *ip = XFS_I(inode); + struct folio *folio; + folio = iomap_get_folio(iter, pos); + if (IS_ERR(folio)) + return folio; + + /* + * Now that we have a locked folio, we need to check that the iomap we + * have cached is not stale. The inode extent mapping can change due to + * concurrent IO in flight (e.g., IOMAP_UNWRITTEN state can change and + * memory reclaim could have reclaimed a previously partially written + * page at this index after IO completion before this write reaches + * this file offset) and hence we could do the wrong thing here (zero a + * page range incorrectly or fail to zero) and corrupt data. + */ if (iomap->validity_cookie != xfs_iomap_inode_sequence(ip, iomap->flags)) { trace_xfs_iomap_invalid(ip, iomap); - return false; + folio_unlock(folio); + folio_put(folio); + return ERR_PTR(-ESTALE); } XFS_ERRORTAG_DELAY(ip->i_mount, XFS_ERRTAG_WRITE_DELAY_MS); - return true; + return folio; } const struct iomap_page_ops xfs_iomap_page_ops = { - .iomap_valid = xfs_iomap_valid, + .get_folio = xfs_get_folio, }; int diff --git a/include/linux/iomap.h b/include/linux/iomap.h index dd3575ada5d1..6f8e3321e475 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -134,29 +134,17 @@ static inline bool iomap_inline_data_valid(const struct iomap *iomap) * When get_folio succeeds, put_folio will always be called to do any * cleanup work necessary. put_folio is responsible for unlocking and putting * @folio. + * + * When an iomap is created, the filesystem can store internal state (e.g., a + * sequence number) in iomap->validity_cookie. When it then detects in the + * get_folio handler that the iomap is no longer up to date and needs to be + * refreshed, it can return ERR_PTR(-ESTALE) to trigger a retry. */ struct iomap_page_ops { struct folio *(*get_folio)(struct iomap_iter *iter, loff_t pos, unsigned len); void (*put_folio)(struct inode *inode, loff_t pos, unsigned copied, struct folio *folio); - - /* - * Check that the cached iomap still maps correctly to the filesystem's - * internal extent map. FS internal extent maps can change while iomap - * is iterating a cached iomap, so this hook allows iomap to detect that - * the iomap needs to be refreshed during a long running write - * operation. - * - * The filesystem can store internal state (e.g. a sequence number) in - * iomap->validity_cookie when the iomap is first mapped to be able to - * detect changes between mapping time and whenever .iomap_valid() is - * called. - * - * This is called with the folio over the specified file position held - * locked by the iomap code. - */ - bool (*iomap_valid)(struct inode *inode, const struct iomap *iomap); }; /* From patchwork Sat Dec 31 15:09:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 13086102 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 117A5C46467 for ; Sat, 31 Dec 2022 15:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235833AbiLaPLm (ORCPT ); Sat, 31 Dec 2022 10:11:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235769AbiLaPLf (ORCPT ); Sat, 31 Dec 2022 10:11:35 -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 BEBA8D104 for ; Sat, 31 Dec 2022 07:09:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672499391; 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=QpCtDOFIy/Hp2Z9WBG54FGekrDamDSORI9+3PvPYmlA=; b=CKbzhysBwsKVBe1rnErHPWtFmUU8zOsmeZ9drgtPfiLwt/Zt0tRQWXeJ6JDLBPb+dhuf1e mebF3Z8nRcn80ErUK4lF3XyMPfcFW/tU4I5fxWOukZ7AzRnq564UtVmc7cvHUi6TDzpUbc 1ZaZ03ZmHm//fqLuZ12Ey+SRZ8AQOfs= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-kHRwq5viNxGGGz_kkg7rXA-1; Sat, 31 Dec 2022 10:09:49 -0500 X-MC-Unique: kHRwq5viNxGGGz_kkg7rXA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6EE751C04B77; Sat, 31 Dec 2022 15:09:48 +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 5F16B492B00; Sat, 31 Dec 2022 15:09:46 +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: [PATCH v5 8/9] iomap: Rename page_ops to folio_ops Date: Sat, 31 Dec 2022 16:09:18 +0100 Message-Id: <20221231150919.659533-9-agruenba@redhat.com> In-Reply-To: <20221231150919.659533-1-agruenba@redhat.com> References: <20221231150919.659533-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The operations in struct page_ops all operate on folios, so rename struct page_ops to struct folio_ops. Signed-off-by: Andreas Gruenbacher Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/gfs2/bmap.c | 4 ++-- fs/iomap/buffered-io.c | 12 ++++++------ fs/xfs/xfs_iomap.c | 4 ++-- include/linux/iomap.h | 14 +++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index d3adb715ac8c..e191ecfb1fde 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -997,7 +997,7 @@ static void gfs2_iomap_put_folio(struct inode *inode, loff_t pos, gfs2_trans_end(sdp); } -static const struct iomap_page_ops gfs2_iomap_page_ops = { +static const struct iomap_folio_ops gfs2_iomap_folio_ops = { .get_folio = gfs2_iomap_get_folio, .put_folio = gfs2_iomap_put_folio, }; @@ -1075,7 +1075,7 @@ static int gfs2_iomap_begin_write(struct inode *inode, loff_t pos, } if (gfs2_is_stuffed(ip) || gfs2_is_jdata(ip)) - iomap->page_ops = &gfs2_iomap_page_ops; + iomap->folio_ops = &gfs2_iomap_folio_ops; return 0; out_trans_end: diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index df6fca11f18c..c4a7aef2a272 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -605,10 +605,10 @@ static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos, static void iomap_put_folio(struct iomap_iter *iter, loff_t pos, size_t ret, struct folio *folio) { - const struct iomap_page_ops *page_ops = iter->iomap.page_ops; + const struct iomap_folio_ops *folio_ops = iter->iomap.folio_ops; - if (page_ops && page_ops->put_folio) { - page_ops->put_folio(iter->inode, pos, ret, folio); + if (folio_ops && folio_ops->put_folio) { + folio_ops->put_folio(iter->inode, pos, ret, folio); } else { folio_unlock(folio); folio_put(folio); @@ -627,7 +627,7 @@ static int iomap_write_begin_inline(const struct iomap_iter *iter, static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, size_t len, struct folio **foliop) { - const struct iomap_page_ops *page_ops = iter->iomap.page_ops; + const struct iomap_folio_ops *folio_ops = iter->iomap.folio_ops; const struct iomap *srcmap = iomap_iter_srcmap(iter); struct folio *folio; int status; @@ -642,8 +642,8 @@ 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->get_folio) - folio = page_ops->get_folio(iter, pos, len); + if (folio_ops && folio_ops->get_folio) + folio = folio_ops->get_folio(iter, pos, len); else folio = iomap_get_folio(iter, pos); if (IS_ERR(folio)) { diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index d0bf99539180..5bddf31e21eb 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -98,7 +98,7 @@ xfs_get_folio( return folio; } -const struct iomap_page_ops xfs_iomap_page_ops = { +const struct iomap_folio_ops xfs_iomap_folio_ops = { .get_folio = xfs_get_folio, }; @@ -148,7 +148,7 @@ xfs_bmbt_to_iomap( iomap->flags |= IOMAP_F_DIRTY; iomap->validity_cookie = sequence_cookie; - iomap->page_ops = &xfs_iomap_page_ops; + iomap->folio_ops = &xfs_iomap_folio_ops; return 0; } diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 6f8e3321e475..2e2be828af86 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -86,7 +86,7 @@ struct vm_fault; */ #define IOMAP_NULL_ADDR -1ULL /* addr is not valid */ -struct iomap_page_ops; +struct iomap_folio_ops; struct iomap { u64 addr; /* disk offset of mapping, bytes */ @@ -98,7 +98,7 @@ struct iomap { struct dax_device *dax_dev; /* dax_dev for dax operations */ void *inline_data; void *private; /* filesystem private */ - const struct iomap_page_ops *page_ops; + const struct iomap_folio_ops *folio_ops; u64 validity_cookie; /* used with .iomap_valid() */ }; @@ -126,10 +126,10 @@ static inline bool iomap_inline_data_valid(const struct iomap *iomap) } /* - * When a filesystem sets page_ops in an iomap mapping it returns, get_folio - * and put_folio will be called for each page written to. This only applies to - * buffered writes as unbuffered writes will not typically have pages - * associated with them. + * When a filesystem sets folio_ops in an iomap mapping it returns, + * get_folio and put_folio will be called for each page written to. This + * only applies to buffered writes as unbuffered writes will not typically have + * pages associated with them. * * When get_folio succeeds, put_folio will always be called to do any * cleanup work necessary. put_folio is responsible for unlocking and putting @@ -140,7 +140,7 @@ static inline bool iomap_inline_data_valid(const struct iomap *iomap) * get_folio handler that the iomap is no longer up to date and needs to be * refreshed, it can return ERR_PTR(-ESTALE) to trigger a retry. */ -struct iomap_page_ops { +struct iomap_folio_ops { struct folio *(*get_folio)(struct iomap_iter *iter, loff_t pos, unsigned len); void (*put_folio)(struct inode *inode, loff_t pos, unsigned copied, From patchwork Sat Dec 31 15:09:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 13086104 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 A6998C3DA7A for ; Sat, 31 Dec 2022 15:12:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235781AbiLaPMJ (ORCPT ); Sat, 31 Dec 2022 10:12:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235840AbiLaPLq (ORCPT ); Sat, 31 Dec 2022 10:11:46 -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 E7C06D2C1 for ; Sat, 31 Dec 2022 07:10:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672499402; 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=DQKaXBioDSeHnseK3c0h99kI8+k/CfMG7MW+ZVRX6dc=; b=SMkuSeg/XZOOl1Ysn7Q651m67VA6oWW/u1Ddr665qHFz2QFcOKErFpw+FO0Vvbs+HUzAqx qF3HJcF4LagbApqdkNLEu1zHFUG4d/+v4BOm4IX5Ca+HCqLhszeQQVgR6LWxkbBxqF/WKO nMTP+Qp3tDl2QhSAIShoWjF8OQhe41Y= 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-673-u81ISahlMmSRbFuzCDtAOQ-1; Sat, 31 Dec 2022 10:09:51 -0500 X-MC-Unique: u81ISahlMmSRbFuzCDtAOQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0332D80D183; Sat, 31 Dec 2022 15:09:51 +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 CEDFE492B00; Sat, 31 Dec 2022 15:09:48 +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: [PATCH v5 9/9] xfs: Make xfs_iomap_folio_ops static Date: Sat, 31 Dec 2022 16:09:19 +0100 Message-Id: <20221231150919.659533-10-agruenba@redhat.com> In-Reply-To: <20221231150919.659533-1-agruenba@redhat.com> References: <20221231150919.659533-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Variable xfs_iomap_folio_ops isn't used outside xfs_iomap.c, so it should be static. Signed-off-by: Andreas Gruenbacher Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_iomap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 5bddf31e21eb..7d1795a9c742 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -98,7 +98,7 @@ xfs_get_folio( return folio; } -const struct iomap_folio_ops xfs_iomap_folio_ops = { +static const struct iomap_folio_ops xfs_iomap_folio_ops = { .get_folio = xfs_get_folio, };