From patchwork Mon Jun 28 17:27:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 12348375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06BDAC2B9F4 for ; Mon, 28 Jun 2021 17:27:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE4C861C4D for ; Mon, 28 Jun 2021 17:27:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232901AbhF1RaR (ORCPT ); Mon, 28 Jun 2021 13:30:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20098 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232335AbhF1RaR (ORCPT ); Mon, 28 Jun 2021 13:30:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624901271; 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=Cf6zR78zKAwwuUrcY7BAjfHSnos7uy6FIUf8aGQv4ng=; b=L5f9jMTFa2MMh6pdHmjk7J/D/ZJWmYpyaIzCkEanCxpIohA2mlbLbHE7lZm6xqmKkZauWl bz4uY71GMKSOnpDPSyeKjwORwgWZg4dDMf5yeBeuhOJH7RFQCGyXPEcJwRPjoOGypIXhfq ifxWGDpct1/T3N3n5M5mDi5DYTfxtzI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-590-5Kb0Xk1rO7iDuCwMWmtDPw-1; Mon, 28 Jun 2021 13:27:39 -0400 X-MC-Unique: 5Kb0Xk1rO7iDuCwMWmtDPw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B949410C1ADC; Mon, 28 Jun 2021 17:27:38 +0000 (UTC) Received: from max.com (unknown [10.40.193.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21D755D6AD; Mon, 28 Jun 2021 17:27:33 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig Cc: "Darrick J . Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, cluster-devel@redhat.com, Andreas Gruenbacher Subject: [PATCH 1/2] iomap: Don't create iomap_page objects for inline files Date: Mon, 28 Jun 2021 19:27:26 +0200 Message-Id: <20210628172727.1894503-2-agruenba@redhat.com> In-Reply-To: <20210628172727.1894503-1-agruenba@redhat.com> References: <20210628172727.1894503-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org In iomap_readpage_actor, don't create iop objects for inline inodes. Otherwise, iomap_read_inline_data will set PageUptodate without setting iop->uptodate, and iomap_page_release will eventually complain. To prevent this kind of bug from occurring in the future, make sure the page doesn't have private data attached in iomap_read_inline_data. Signed-off-by: Andreas Gruenbacher Reviewed-by: Matthew Wilcox (Oracle) --- fs/iomap/buffered-io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 9023717c5188..03537ecb2a94 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -215,6 +215,7 @@ iomap_read_inline_data(struct inode *inode, struct page *page, if (PageUptodate(page)) return; + BUG_ON(page_has_private(page)); BUG_ON(page->index); BUG_ON(size > PAGE_SIZE - offset_in_page(iomap->inline_data)); @@ -239,7 +240,7 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, { struct iomap_readpage_ctx *ctx = data; struct page *page = ctx->cur_page; - struct iomap_page *iop = iomap_page_create(inode, page); + struct iomap_page *iop; bool same_page = false, is_contig = false; loff_t orig_pos = pos; unsigned poff, plen; @@ -252,6 +253,7 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, } /* zero post-eof blocks as the page may be mapped */ + iop = iomap_page_create(inode, page); iomap_adjust_read_range(inode, iop, &pos, length, &poff, &plen); if (plen == 0) goto done; From patchwork Mon Jun 28 17:27:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 12348377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5FD5C49EB7 for ; Mon, 28 Jun 2021 17:27:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C284161C4D for ; Mon, 28 Jun 2021 17:27:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233362AbhF1RaU (ORCPT ); Mon, 28 Jun 2021 13:30:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27597 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233558AbhF1RaT (ORCPT ); Mon, 28 Jun 2021 13:30:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624901273; 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=qx+pJPqGuDwHEVclhC42irAu7Sb7G7yMiMuZ9iVPouQ=; b=PmsTDEjMMNGWi+SbEpF4kMiwtCzGCslN4wICMC2n9RBngc59SwPQl+8e/nqdmggdkeOQCB OWw2n0nMElyeaefJfSUJSmwMApHhu0a3APQ2IoIUQYRKtmI+AYN0zKOKKo+xsdcbHaSxxj oX81bR1PJRdp9h3yt9nxPPd9oikHDmo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-164-G6OJ9atuPv29LUSjW8nF4g-1; Mon, 28 Jun 2021 13:27:51 -0400 X-MC-Unique: G6OJ9atuPv29LUSjW8nF4g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 033021922962; Mon, 28 Jun 2021 17:27:50 +0000 (UTC) Received: from max.com (unknown [10.40.193.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 197E45D6AD; Mon, 28 Jun 2021 17:27:38 +0000 (UTC) From: Andreas Gruenbacher To: Christoph Hellwig Cc: "Darrick J . Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, cluster-devel@redhat.com, Bob Peterson , Andreas Gruenbacher Subject: [PATCH 2/2] iomap: Add helper for un-inlining an inline inode Date: Mon, 28 Jun 2021 19:27:27 +0200 Message-Id: <20210628172727.1894503-3-agruenba@redhat.com> In-Reply-To: <20210628172727.1894503-1-agruenba@redhat.com> References: <20210628172727.1894503-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Bob Peterson Add function iomap_uninline_inode for converting an inline inode into a non-inline inode. This takes care of attaching a new iomap_page object to page->private if the block size is smaller than the page size. Signed-off-by: Andreas Gruenbacher --- fs/iomap/buffered-io.c | 24 ++++++++++++++++++++++++ include/linux/iomap.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 03537ecb2a94..44acb59191b2 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -226,6 +226,30 @@ iomap_read_inline_data(struct inode *inode, struct page *page, SetPageUptodate(page); } +int iomap_uninline_inode(struct inode *inode, + int (*uninline)(struct inode *, struct page *)) +{ + struct page *page = NULL; + int ret; + + if (i_size_read(inode)) { + page = find_or_create_page(inode->i_mapping, 0, GFP_NOFS); + if (!page) + return -ENOMEM; + } + ret = uninline(inode, page); + if (page) { + if (PageUptodate(page)) { + iomap_page_create(inode, page); + iomap_set_range_uptodate(page, 0, PAGE_SIZE); + } + unlock_page(page); + put_page(page); + } + return ret; +} +EXPORT_SYMBOL_GPL(iomap_uninline_inode); + static inline bool iomap_block_needs_zeroing(struct inode *inode, struct iomap *iomap, loff_t pos) { diff --git a/include/linux/iomap.h b/include/linux/iomap.h index c87d0cb0de6d..90c924eec09b 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -157,6 +157,8 @@ loff_t iomap_apply(struct inode *inode, loff_t pos, loff_t length, ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from, const struct iomap_ops *ops); +int iomap_uninline_inode(struct inode *inode, + int (*uninline)(struct inode *, struct page *)); int iomap_readpage(struct page *page, const struct iomap_ops *ops); void iomap_readahead(struct readahead_control *, const struct iomap_ops *ops); int iomap_set_page_dirty(struct page *page);