Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp3097997rwe; Sun, 16 Apr 2023 11:38:06 -0700 (PDT) X-Google-Smtp-Source: AKy350YFCRbkOFy2uPmVwDzKEU7DED9oPVEVncfT2IhqJt+WPbe3Tqa4vggsQur8DA1mxTaEfTG1 X-Received: by 2002:a05:6a20:7f99:b0:ec:a494:2115 with SMTP id d25-20020a056a207f9900b000eca4942115mr12665066pzj.12.1681670286741; Sun, 16 Apr 2023 11:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681670286; cv=none; d=google.com; s=arc-20160816; b=xXJbJ0RNgj7nWwuScZlNbVnlhnCVyW7P5J5YDKmBSfOIvSyTEyDhBEpITo2veOyAyt xw2ZXn8QYo28bKzMyZd7b2FL38NQe2CXl8sUW8wGb1Fy+HGEtT8ArnFvkT7vMvuFRPwr 2ZwlJp+x2sDd3kQPDp7b0QQa1qbhfcwA6eN/gueeosy522xkpCWJUe9jXZobnJEKu+82 +oH0vPLENmy6iAIgS7rSOopjjXNoS/mh37U1T8CdCHnNf5CWUMoXD8DRMqYvMeaSPX29 /EoqPSsj5k3sv5cVRKgymGX4H3brEd6OMjvrdsqnlGImVfzvI9OMuoPXHvcpQL/RWm4M m9vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UOtbC0r36Zp4pJlCpOnapY4nEskpGw8qxR2Qca3pKVg=; b=Md/TKcMhwxEzH30vTapsddiwCOMPBsBBb8QgpqE217tQMOzRcIKn+pTnMTGHgqEmr+ X8fyTOsN3v6b8bialcgZU3iFa6KOeFLRa9x6pO6MBeeyrxSUbOCFEBgQvOUEXATTgxGx HUr2r+Ce7Y3ewAA8mQxEiO02S9uaNGNRZh3WTGK2N7CnpI+pfRNBvqgRtjla+V54BBFP WO7g0vKyRlvUen6Yew8RKc+LxSv2g/vH+obUxiv5ro4sBNJOYhJ7mQj+20jh48S5BoOJ fYuGAvLyL/3DwDfJiDKL+ibJUZzGUTXtkgAlrgPhWyBvElZ4+h6ZWwwNwSrgr/PLQ0Ms cUvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=KFynZPXx; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g128-20020a636b86000000b0050bf22172d3si10197569pgc.490.2023.04.16.11.37.45; Sun, 16 Apr 2023 11:38:06 -0700 (PDT) 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=@gmail.com header.s=20221208 header.b=KFynZPXx; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbjDPScR (ORCPT + 99 others); Sun, 16 Apr 2023 14:32:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbjDPScP (ORCPT ); Sun, 16 Apr 2023 14:32:15 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4DAD26AE for ; Sun, 16 Apr 2023 11:32:14 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-51b603b3442so584196a12.3 for ; Sun, 16 Apr 2023 11:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681669934; x=1684261934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UOtbC0r36Zp4pJlCpOnapY4nEskpGw8qxR2Qca3pKVg=; b=KFynZPXxcVZm/nw+bQwa20sU0rvqFMXjuLCsytbvQ4Xv0SMDomU6/HMY0DNRqCHCRc e8VKbsyjylfPnJSLqJnoEvRCzRu4L5mB7X6V4qXPAiOAf7v9UTrgkho0i5AY7z3/QyD8 KYvDTmZDjRsY3G8/QzIIQXxsZ530xrAhhd6Psm6D5+ua/srgWFVrEQoPs6C9TWsTqO9p HQD9skDcgQtPxqDjMN3NyL3hsvNbN5ENEyFBXHwKFc/1LUhIbiDm65/Y+ZaTdsMsGi/F k5AXIwdylTPCgTxnxj2mI4V9jgFJYvkH3bW2vyZiRtB9oKPx6zim+i/kOiCTVTcAhGlz pLhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681669934; x=1684261934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UOtbC0r36Zp4pJlCpOnapY4nEskpGw8qxR2Qca3pKVg=; b=ilDh2Xx/c9Jv1BAAWf7PXuzve9jxbqAZzSvHdIZv/sStm46dFXzExiSNAx93V1TacF WD4wAO/SekXmVV/tE521OVYFiGYpljgZQM67VPpbA1XjmexmQ9VZNkTxV9OA9ZftzcQL XCn9L3YBZ6RLgdk1o2K7O/aUEciuMqFbiWdf8s43gWozep+g/0IoP0qYoa7Tr+jsQRV2 EwpCjlsVch28/1oimwr2ED/1T3bdXY8GCw688YstOPyr70Uq4lICHbCppUDpe/bYcU9X INsffXcrxpn2Z7YBsE5i9cgc5yQdiVmJmKGe7T9dERejFsCZoNZARR11s/NW73nDLBu5 1urA== X-Gm-Message-State: AAQBX9dPc6xeBCb7XbC1G8q8YrB54n3x3dpES3LKkoqvgMagBSVX6Ko+ Dy81S6qrGvxS2w0bhb1cHmT1vwDa7QQ= X-Received: by 2002:a05:6a00:14cc:b0:63b:6933:a30d with SMTP id w12-20020a056a0014cc00b0063b6933a30dmr12465703pfu.25.1681669934284; Sun, 16 Apr 2023 11:32:14 -0700 (PDT) Received: from rh-tp.. ([2406:7400:63:2dd2:8818:e6e1:3a73:368c]) by smtp.gmail.com with ESMTPSA id y10-20020aa7804a000000b00639fc7124c2sm6397480pfm.148.2023.04.16.11.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Apr 2023 11:32:13 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: Matthew Wilcox Cc: linux-ext4@vger.kernel.org, Jan Kara , Ojaswin Mujoo , Disha Goel , "Ritesh Harjani (IBM)" Subject: [RFCv1 3/4] ext4: Make mpage_journal_page_buffers use folio Date: Mon, 17 Apr 2023 00:01:52 +0530 Message-Id: <9d0fe99d45e88fd0446df745c31b561fefab898e.1681669004.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 This patch converts mpage_journal_page_buffers() to use folio and also removes the PAGE_SIZE assumption. Signed-off-by: Ritesh Harjani (IBM) --- fs/ext4/inode.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 5bb141288b1b..3f76b06e9aa4 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2349,11 +2349,11 @@ static bool ext4_folio_nomap_can_writeout(struct folio *folio) return false; } -static int ext4_journal_page_buffers(handle_t *handle, struct page *page, - int len) +static int ext4_journal_page_buffers(handle_t *handle, struct folio *folio, + size_t len) { - struct buffer_head *page_bufs = page_buffers(page); - struct inode *inode = page->mapping->host; + struct buffer_head *page_bufs = folio_buffers(folio); + struct inode *inode = folio->mapping->host; int ret, err; ret = ext4_walk_page_buffers(handle, inode, page_bufs, 0, len, @@ -2362,7 +2362,7 @@ static int ext4_journal_page_buffers(handle_t *handle, struct page *page, NULL, write_end_fn); if (ret == 0) ret = err; - err = ext4_jbd2_inode_add_write(handle, inode, page_offset(page), len); + err = ext4_jbd2_inode_add_write(handle, inode, folio_pos(folio), len); if (ret == 0) ret = err; EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid; @@ -2374,23 +2374,21 @@ static int ext4_journal_page_buffers(handle_t *handle, struct page *page, static int mpage_journal_page_buffers(handle_t *handle, struct mpage_da_data *mpd, - struct page *page) + struct folio *folio) { struct inode *inode = mpd->inode; loff_t size = i_size_read(inode); - int len; + size_t len = folio_size(folio); - ClearPageChecked(page); - clear_page_dirty_for_io(page); + folio_clear_checked(folio); + folio_clear_dirty_for_io(folio); mpd->wbc->nr_to_write--; - if (page->index == size >> PAGE_SHIFT && + if (folio_pos(folio) + len > size && !ext4_verity_in_progress(inode)) - len = size & ~PAGE_MASK; - else - len = PAGE_SIZE; + len = size - folio_pos(folio); - return ext4_journal_page_buffers(handle, page, len); + return ext4_journal_page_buffers(handle, folio, len); } /* @@ -2546,7 +2544,7 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) WARN_ON_ONCE(sb->s_writers.frozen >= SB_FREEZE_FS); err = mpage_journal_page_buffers(handle, - mpd, &folio->page); + mpd, folio); if (err < 0) goto out; } @@ -6184,7 +6182,7 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf) err = __block_write_begin(&folio->page, 0, len, ext4_get_block); if (!err) { ret = VM_FAULT_SIGBUS; - if (ext4_journal_page_buffers(handle, &folio->page, len)) + if (ext4_journal_page_buffers(handle, folio, len)) goto out_error; } else { folio_unlock(folio); -- 2.39.2