From patchwork Mon Nov 6 17:38:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447238 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A43F2D022 for ; Mon, 6 Nov 2023 17:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hZtcL/en" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F122410E4; Mon, 6 Nov 2023 09:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=SR/M6J1eCYzIfQnXQGYhFKKiXejmTRdamnCzS3EwsIM=; b=hZtcL/enOfsVgkh/Xwpllkix9F HBCfh6jJtyzI6iodIhegX6pFz/1Vb6UZjkmrKXtmTKf3bKqFDmKFXoG5nw3QwoA/f08bHNpXUNGqF ahxemfdhPA8H/bZCS31RE29/vTG5OVf9+s1rrrk6LFRCwYPtfsppHEufVQg+Csi5CkU9575oKp9n3 nxGOD6OJbbjKBIoBcCWG1cV+gnaTUQjw5C+7ABkuMWxgaYzY0Gjyx/W222nEGC03povpERLvaXnD6 hCdqppExoQqdcOW8TLRY7FXdqudr8n6xR0qwtkyAwx0romWgLimZZqGQFA0jDDrc98etFHPnJPzJp cp8eDV3g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z3-007H7p-R1; Mon, 06 Nov 2023 17:39:05 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 01/35] nilfs2: Add nilfs_end_folio_io() Date: Mon, 6 Nov 2023 17:38:29 +0000 Message-Id: <20231106173903.1734114-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is the folio counterpart of the existing nilfs_end_page_io() which is retained as a wrapper of nilfs_end_folio_io(). Replaces nine hidden calls to compound_head() with one. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/segment.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 55e31cc903d1..1df03d0895be 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -1739,17 +1739,18 @@ static int nilfs_segctor_write(struct nilfs_sc_info *sci, return ret; } -static void nilfs_end_page_io(struct page *page, int err) +static void nilfs_end_folio_io(struct folio *folio, int err) { - if (!page) + if (!folio) return; - if (buffer_nilfs_node(page_buffers(page)) && !PageWriteback(page)) { + if (buffer_nilfs_node(folio_buffers(folio)) && + !folio_test_writeback(folio)) { /* * For b-tree node pages, this function may be called twice * or more because they might be split in a segment. */ - if (PageDirty(page)) { + if (folio_test_dirty(folio)) { /* * For pages holding split b-tree node buffers, dirty * flag on the buffers may be cleared discretely. @@ -1757,24 +1758,31 @@ static void nilfs_end_page_io(struct page *page, int err) * remaining buffers, and it must be cancelled if * all the buffers get cleaned later. */ - lock_page(page); - if (nilfs_page_buffers_clean(page)) - __nilfs_clear_page_dirty(page); - unlock_page(page); + folio_lock(folio); + if (nilfs_page_buffers_clean(&folio->page)) + __nilfs_clear_page_dirty(&folio->page); + folio_unlock(folio); } return; } if (!err) { - if (!nilfs_page_buffers_clean(page)) - __set_page_dirty_nobuffers(page); - ClearPageError(page); + if (!nilfs_page_buffers_clean(&folio->page)) + filemap_dirty_folio(folio->mapping, folio); + folio_clear_error(folio); } else { - __set_page_dirty_nobuffers(page); - SetPageError(page); + filemap_dirty_folio(folio->mapping, folio); + folio_set_error(folio); } - end_page_writeback(page); + folio_end_writeback(folio); +} + +static void nilfs_end_page_io(struct page *page, int err) +{ + if (!page) + return; + nilfs_end_folio_io(page_folio(page), err); } static void nilfs_abort_logs(struct list_head *logs, int err) From patchwork Mon Nov 6 17:38:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447227 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03E9929D0C for ; Mon, 6 Nov 2023 17:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="HABhC2rS" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB7A8D57; Mon, 6 Nov 2023 09:39:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ocUPXujLAlIdfiGe9skNuAQj9DW5J6k/r+nk9Zo0FWQ=; b=HABhC2rSzMOLkkw9pGspvYdoRZ sFaljPC8YAMtd0p9c37q7CbQUayVDDv9Bj7HQlrAxgbXumGh+s6ON+beKGuMjHAr0Lo5Z8lsyrLUm /Kzhd501C0jun9Gmzzil0+vNf9WEzoIa/ZsFhV1Jddsm3/pMNePAsTg5SjJQYB4rIbDqEjIokv9Kk 7+PCqCGOnzYQIN1n3OnLkzmkcOAULqBDKhQzBX6/F1kFbh5cW80PyCquot7/SVeveYRxholKYO+yL RtpDY3ixygNcuZOLqvVCsxkRL03njGqBXO40Ncuu32/Ba0ewK9RYPHI/uYtRHGIp/5HrrF854oEqW 8CScSuEA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z3-007H7v-V7; Mon, 06 Nov 2023 17:39:06 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 02/35] nilfs2: Convert nilfs_abort_logs to use folios Date: Mon, 6 Nov 2023 17:38:30 +0000 Message-Id: <20231106173903.1734114-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new folio APIs, saving five hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/segment.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 1df03d0895be..730062e79bfc 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -1788,7 +1788,7 @@ static void nilfs_end_page_io(struct page *page, int err) static void nilfs_abort_logs(struct list_head *logs, int err) { struct nilfs_segment_buffer *segbuf; - struct page *bd_page = NULL, *fs_page = NULL; + struct folio *bd_folio = NULL, *fs_folio = NULL; struct buffer_head *bh; if (list_empty(logs)) @@ -1798,10 +1798,10 @@ static void nilfs_abort_logs(struct list_head *logs, int err) list_for_each_entry(bh, &segbuf->sb_segsum_buffers, b_assoc_buffers) { clear_buffer_uptodate(bh); - if (bh->b_page != bd_page) { - if (bd_page) - end_page_writeback(bd_page); - bd_page = bh->b_page; + if (bh->b_folio != bd_folio) { + if (bd_folio) + folio_end_writeback(bd_folio); + bd_folio = bh->b_folio; } } @@ -1810,22 +1810,22 @@ static void nilfs_abort_logs(struct list_head *logs, int err) clear_buffer_async_write(bh); if (bh == segbuf->sb_super_root) { clear_buffer_uptodate(bh); - if (bh->b_page != bd_page) { - end_page_writeback(bd_page); - bd_page = bh->b_page; + if (bh->b_folio != bd_folio) { + folio_end_writeback(bd_folio); + bd_folio = bh->b_folio; } break; } - if (bh->b_page != fs_page) { - nilfs_end_page_io(fs_page, err); - fs_page = bh->b_page; + if (bh->b_folio != fs_folio) { + nilfs_end_folio_io(fs_folio, err); + fs_folio = bh->b_folio; } } } - if (bd_page) - end_page_writeback(bd_page); + if (bd_folio) + folio_end_writeback(bd_folio); - nilfs_end_page_io(fs_page, err); + nilfs_end_folio_io(fs_folio, err); } static void nilfs_segctor_abort_construction(struct nilfs_sc_info *sci, From patchwork Mon Nov 6 17:38:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447251 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E06492D059 for ; Mon, 6 Nov 2023 17:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gy3NKUMs" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74B7B171C; Mon, 6 Nov 2023 09:39:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ie7WsUDR1yLQZBGXEbEvfA+topeFIvEQy56tv9SnL9M=; b=gy3NKUMsQa1ZSOKuTyzxefZC1i LxXLQ5ZTVH20hrEbzNInFGAhs6jxB4JkdOdUmgYz4fXoOr1ScLEZUpVVTZdtGPHIVXlnp+4luNbxZ 1LuK3q5aznQHYMNeHCgOPT9pRnLPh99XfYFsOw4pOacpUcgrGNuaX1ELrLdHUuL9DE6dYuLO+QLjE A9SJPebB3ZN7bduRpLp6AeKSC37S9FuSQUvin/jmIfXEPYAE4ibPBQfhpoPE/PcApwZGiGua6ThRu vTPSDsYy0e5zz5ZyW6EhX+eYCjp0RP72MU95M+sG1IWXpo9p2xjrV+Tf22KhayXLv0Ny7IbNOov03 PG+ah0XQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z4-007H7z-3l; Mon, 06 Nov 2023 17:39:06 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 03/35] nilfs2: Convert nilfs_segctor_complete_write to use folios Date: Mon, 6 Nov 2023 17:38:31 +0000 Message-Id: <20231106173903.1734114-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new folio APIs, saving five calls to compound_head(). This includes the last callers of nilfs_end_page_io(), so remove that too. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/segment.c | 49 +++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 730062e79bfc..2a058aad5c2d 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -1778,13 +1778,6 @@ static void nilfs_end_folio_io(struct folio *folio, int err) folio_end_writeback(folio); } -static void nilfs_end_page_io(struct page *page, int err) -{ - if (!page) - return; - nilfs_end_folio_io(page_folio(page), err); -} - static void nilfs_abort_logs(struct list_head *logs, int err) { struct nilfs_segment_buffer *segbuf; @@ -1867,7 +1860,7 @@ static void nilfs_set_next_segment(struct the_nilfs *nilfs, static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci) { struct nilfs_segment_buffer *segbuf; - struct page *bd_page = NULL, *fs_page = NULL; + struct folio *bd_folio = NULL, *fs_folio = NULL; struct the_nilfs *nilfs = sci->sc_super->s_fs_info; int update_sr = false; @@ -1878,21 +1871,21 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci) b_assoc_buffers) { set_buffer_uptodate(bh); clear_buffer_dirty(bh); - if (bh->b_page != bd_page) { - if (bd_page) - end_page_writeback(bd_page); - bd_page = bh->b_page; + if (bh->b_folio != bd_folio) { + if (bd_folio) + folio_end_writeback(bd_folio); + bd_folio = bh->b_folio; } } /* - * We assume that the buffers which belong to the same page + * We assume that the buffers which belong to the same folio * continue over the buffer list. - * Under this assumption, the last BHs of pages is - * identifiable by the discontinuity of bh->b_page - * (page != fs_page). + * Under this assumption, the last BHs of folios is + * identifiable by the discontinuity of bh->b_folio + * (folio != fs_folio). * * For B-tree node blocks, however, this assumption is not - * guaranteed. The cleanup code of B-tree node pages needs + * guaranteed. The cleanup code of B-tree node folios needs * special care. */ list_for_each_entry(bh, &segbuf->sb_payload_buffers, @@ -1905,16 +1898,16 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci) set_mask_bits(&bh->b_state, clear_bits, set_bits); if (bh == segbuf->sb_super_root) { - if (bh->b_page != bd_page) { - end_page_writeback(bd_page); - bd_page = bh->b_page; + if (bh->b_folio != bd_folio) { + folio_end_writeback(bd_folio); + bd_folio = bh->b_folio; } update_sr = true; break; } - if (bh->b_page != fs_page) { - nilfs_end_page_io(fs_page, 0); - fs_page = bh->b_page; + if (bh->b_folio != fs_folio) { + nilfs_end_folio_io(fs_folio, 0); + fs_folio = bh->b_folio; } } @@ -1928,13 +1921,13 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci) } } /* - * Since pages may continue over multiple segment buffers, - * end of the last page must be checked outside of the loop. + * Since folios may continue over multiple segment buffers, + * end of the last folio must be checked outside of the loop. */ - if (bd_page) - end_page_writeback(bd_page); + if (bd_folio) + folio_end_writeback(bd_folio); - nilfs_end_page_io(fs_page, 0); + nilfs_end_folio_io(fs_folio, 0); nilfs_drop_collected_inodes(&sci->sc_dirty_files); From patchwork Mon Nov 6 17:38:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447239 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1C752D02A for ; Mon, 6 Nov 2023 17:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="pkQOg3ya" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49F9C10E7; Mon, 6 Nov 2023 09:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=bPdw8wBJlFg2JRU9mjLBkI9Pe++wsQanm7l3H2XE7tQ=; b=pkQOg3yabK93Jvr0HEijxh0/6j YeA+bM0k4jx8ClvfdK+nEBsl/Ln1hTa2bxH+5LcwfMAnEMokvUt7Vg4XnV10y/mTdCiqTVBOd6YSD j+jcJ4L2pIdOn7flkhYXCUckChh89wUnTIHUzjL5u9VSvqjACKQUk9wCrMsvs+OpgGXDMeE6VYHHZ dT6XM2c4Lzgol48VdV4ukQF635ky53ZxChHtwdCIbMQOgcvPYGgC43Gxx5eSOvobBSTeoCLLlR+3N QJ4aROGIEWlcih828RFrHuxqGn9zIIaNzbbHI6B+/p4pkPCEu/GUuBYka1CqaChsF2BweuUKxyiR8 TFEfbUvA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z4-007H81-6w; Mon, 06 Nov 2023 17:39:06 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 04/35] nilfs2: Convert nilfs_forget_buffer to use a folio Date: Mon, 6 Nov 2023 17:38:32 +0000 Message-Id: <20231106173903.1734114-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Save two hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/page.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 06b04758f289..3882acde1b3e 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -73,7 +73,7 @@ struct buffer_head *nilfs_grab_buffer(struct inode *inode, */ void nilfs_forget_buffer(struct buffer_head *bh) { - struct page *page = bh->b_page; + struct folio *folio = bh->b_folio; const unsigned long clear_bits = (BIT(BH_Uptodate) | BIT(BH_Dirty) | BIT(BH_Mapped) | BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) | @@ -81,12 +81,12 @@ void nilfs_forget_buffer(struct buffer_head *bh) lock_buffer(bh); set_mask_bits(&bh->b_state, clear_bits, 0); - if (nilfs_page_buffers_clean(page)) - __nilfs_clear_page_dirty(page); + if (nilfs_page_buffers_clean(&folio->page)) + __nilfs_clear_page_dirty(&folio->page); bh->b_blocknr = -1; - ClearPageUptodate(page); - ClearPageMappedToDisk(page); + folio_clear_uptodate(folio); + folio_clear_mappedtodisk(folio); unlock_buffer(bh); brelse(bh); } From patchwork Mon Nov 6 17:38:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447226 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D6202C841 for ; Mon, 6 Nov 2023 17:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YIXTxxkN" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 064D5D61; Mon, 6 Nov 2023 09:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=6YmJMS1fBEcalQZgaHkW5Vu6KaT+mCK0+GMTsxlbpis=; b=YIXTxxkNUHJkYhj/M9r7nTzTyn Tn87sP5iU7OFLTjg2UH242y1hy+QdXTivAgGTotPFYXRVf7HJRStBlZfyr+Al9glP9768YQWXUKYR lDt3u0YhVuX6eqbcsL6hIignxfJufP5OVre8tEufe9FcffD8FeCzUQjXmfeQeJMdTpeySHKfBH2zl vKCke/3F/eBRvYiJ/60+zGlPNFy407A5ov6PxbhXJZ1AEy0EQdvhT13pOAbyIqg9KfeRFp4phQo4e g+NtAYQA2KdloIiikG6+JsLEDWdSzNbQhAJ449ML9qBwvQGbZ21yPtoUj81WFPWYpi92L4pWt3MOS B6zS3wTA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z4-007H87-AG; Mon, 06 Nov 2023 17:39:06 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 05/35] nilfs2: Convert to nilfs_folio_buffers_clean() Date: Mon, 6 Nov 2023 17:38:33 +0000 Message-Id: <20231106173903.1734114-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All callers of nilfs_page_buffers_clean() now have a folio, so convert it to take a folio. While I'm at it, make it return a bool. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/page.c | 18 +++++++++--------- fs/nilfs2/page.h | 2 +- fs/nilfs2/segment.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 3882acde1b3e..29799a49c234 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -81,7 +81,7 @@ void nilfs_forget_buffer(struct buffer_head *bh) lock_buffer(bh); set_mask_bits(&bh->b_state, clear_bits, 0); - if (nilfs_page_buffers_clean(&folio->page)) + if (nilfs_folio_buffers_clean(folio)) __nilfs_clear_page_dirty(&folio->page); bh->b_blocknr = -1; @@ -131,23 +131,23 @@ void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh) } /** - * nilfs_page_buffers_clean - check if a page has dirty buffers or not. - * @page: page to be checked + * nilfs_folio_buffers_clean - Check if a folio has dirty buffers or not. + * @folio: Folio to be checked. * - * nilfs_page_buffers_clean() returns zero if the page has dirty buffers. - * Otherwise, it returns non-zero value. + * nilfs_folio_buffers_clean() returns false if the folio has dirty buffers. + * Otherwise, it returns true. */ -int nilfs_page_buffers_clean(struct page *page) +bool nilfs_folio_buffers_clean(struct folio *folio) { struct buffer_head *bh, *head; - bh = head = page_buffers(page); + bh = head = folio_buffers(folio); do { if (buffer_dirty(bh)) - return 0; + return false; bh = bh->b_this_page; } while (bh != head); - return 1; + return true; } void nilfs_page_bug(struct page *page) diff --git a/fs/nilfs2/page.h b/fs/nilfs2/page.h index d249ea1cefff..a8ab800e689c 100644 --- a/fs/nilfs2/page.h +++ b/fs/nilfs2/page.h @@ -36,7 +36,7 @@ struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *, unsigned long, unsigned long); void nilfs_forget_buffer(struct buffer_head *); void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *); -int nilfs_page_buffers_clean(struct page *); +bool nilfs_folio_buffers_clean(struct folio *); void nilfs_page_bug(struct page *); int nilfs_copy_dirty_pages(struct address_space *, struct address_space *); diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 2a058aad5c2d..888b8606a1e8 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -1759,7 +1759,7 @@ static void nilfs_end_folio_io(struct folio *folio, int err) * all the buffers get cleaned later. */ folio_lock(folio); - if (nilfs_page_buffers_clean(&folio->page)) + if (nilfs_folio_buffers_clean(folio)) __nilfs_clear_page_dirty(&folio->page); folio_unlock(folio); } @@ -1767,7 +1767,7 @@ static void nilfs_end_folio_io(struct folio *folio, int err) } if (!err) { - if (!nilfs_page_buffers_clean(&folio->page)) + if (!nilfs_folio_buffers_clean(folio)) filemap_dirty_folio(folio->mapping, folio); folio_clear_error(folio); } else { From patchwork Mon Nov 6 17:38:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447222 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0137029D0B for ; Mon, 6 Nov 2023 17:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="WCRc7XCs" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26CDAD6D; Mon, 6 Nov 2023 09:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=hR2d3wLXiqfslGTGihlfM0yCkgESgafqHrMpePJor1M=; b=WCRc7XCsz0go2ez/i3GAq93DKA sU+DWdB0IPK8U8yeZ7o9lgLw3CVy/9CiRBR5+WLpBt24X6sUCN8SemBSqn71fJiBfY83AtVjpChEE +LxvZwXg7fGNVd6STxkE5/onHbA28nbyxm7XEeOs6gqyYiA0bKkz9Al/as3+ashFqtHwO4W/s7M+O i5D/r0K3qnAqnxZY+XL+N2Lxb8vqJXV3rBNqNs9i3DYUZCL7vL7nII7Bk3CJLtdDqQCQiouRCu2qH 3v8EpMMjByutbuLESPBen7zSANIG/fTyybHOIQ3Mhm78PBzEgAUAUPSE2BAWXi9n7NKqxtIoHvU3k 0gIoZTlQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z4-007H8D-Eq; Mon, 06 Nov 2023 17:39:06 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 06/35] nilfs2: Convert nilfs_writepage() to use a folio Date: Mon, 6 Nov 2023 17:38:34 +0000 Message-Id: <20231106173903.1734114-7-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert the incoming page to a folio. Replaces three calls to compound_head() with one. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/inode.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index f861f3a0bf5c..c7ec56358a79 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -175,7 +175,8 @@ static int nilfs_writepages(struct address_space *mapping, static int nilfs_writepage(struct page *page, struct writeback_control *wbc) { - struct inode *inode = page->mapping->host; + struct folio *folio = page_folio(page); + struct inode *inode = folio->mapping->host; int err; if (sb_rdonly(inode->i_sb)) { @@ -186,12 +187,12 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc) * So, here we simply discard this dirty page. */ nilfs_clear_dirty_page(page, false); - unlock_page(page); + folio_unlock(folio); return -EROFS; } - redirty_page_for_writepage(wbc, page); - unlock_page(page); + folio_redirty_for_writepage(wbc, folio); + folio_unlock(folio); if (wbc->sync_mode == WB_SYNC_ALL) { err = nilfs_construct_segment(inode->i_sb); From patchwork Mon Nov 6 17:38:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447225 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DB5029D10 for ; Mon, 6 Nov 2023 17:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Pr14DMGc" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4280ED71; Mon, 6 Nov 2023 09:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=NwhU+RYRS2KqhDUYWGDRZRyMStg4doHH4Ot5RU5n7LI=; b=Pr14DMGc9xyupLqn7HMLmbMg71 HZwXoeEES9k7lMLdFtH0QaTa5IkOt/MKjRpMZjS3xmY5Y73mIHsJSqH9EYKfbcRybLQsMGRmQlTBG mfueIp08Z1pCFT4zMkx0VHhGvPKIaM6fIXEx9oKqUAs1MxK0MwY+AIxN8aKIxDYLQddD6wQ6seu2k V6dQTZrwJ7jTZX6bHUR2C6n2PluebKj/Ogw/pcz1kEsL3CmHF+J3rk1wf8flewZOu8F1mqTDkM71C 4EMicxfaPpvMWnaFkDq8mgXtHgTIUSfChJEY0GbqTK+2ySStDj5izRFVc8xZ5a1OhnmW3bgUQfCdT tPpDsZrQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z4-007H8K-JP; Mon, 06 Nov 2023 17:39:06 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 07/35] nilfs2: Convert nilfs_mdt_write_page() to use a folio Date: Mon, 6 Nov 2023 17:38:35 +0000 Message-Id: <20231106173903.1734114-8-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert the incoming page to a folio. Replaces three calls to compound_head() with one. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/mdt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c index c97c77a39668..327408512b86 100644 --- a/fs/nilfs2/mdt.c +++ b/fs/nilfs2/mdt.c @@ -399,7 +399,8 @@ int nilfs_mdt_fetch_dirty(struct inode *inode) static int nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc) { - struct inode *inode = page->mapping->host; + struct folio *folio = page_folio(page); + struct inode *inode = folio->mapping->host; struct super_block *sb; int err = 0; @@ -407,16 +408,16 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc) /* * It means that filesystem was remounted in read-only * mode because of error or metadata corruption. But we - * have dirty pages that try to be flushed in background. - * So, here we simply discard this dirty page. + * have dirty folios that try to be flushed in background. + * So, here we simply discard this dirty folio. */ nilfs_clear_dirty_page(page, false); - unlock_page(page); + folio_unlock(folio); return -EROFS; } - redirty_page_for_writepage(wbc, page); - unlock_page(page); + folio_redirty_for_writepage(wbc, folio); + folio_unlock(folio); if (!inode) return 0; From patchwork Mon Nov 6 17:38:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447232 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FEC22C861 for ; Mon, 6 Nov 2023 17:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="g82BkgnI" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0135D78; Mon, 6 Nov 2023 09:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=vqMdaczPBJ0vAOF82i4ZcjgwXI4TjAD+CcB7Mllfddw=; b=g82BkgnIYaQ13JwDngcm+gK09I 8Q7tXJpAoaqdKn1AX8bpteSZ66YmZjKzdm9mo2F8zssm2YVd1zG0Zcxn17sdLJOLlKmVcLI6qezXz KDRpLhr2v9G8oOsWcjObUgudDfCsNwlJVLYdtfHYt8Pd4dUJDq/C75N9/aP/qwHS4Y4lWODm8msBt 8pQBZy57MDn68TxPp7X6RRsgnwLMAkmbq1af9op9TjPnNAiTloIuPli50Hm32fUVYuxGrxewC/J9d uXHixgvOsE3Z92d8+zk5hn2762fzfM6JcKuABrl/YjoE8r+NmSRK/30iDQc0yOTUYDva8HFoSHq+K T4LAbRuw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z4-007H8Q-NW; Mon, 06 Nov 2023 17:39:06 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 08/35] nilfs2: Convert to nilfs_clear_folio_dirty() Date: Mon, 6 Nov 2023 17:38:36 +0000 Message-Id: <20231106173903.1734114-9-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All callers of nilfs_clear_dirty_page() now have a folio, so rename the function and pass in the folio. Saves three hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/inode.c | 2 +- fs/nilfs2/mdt.c | 2 +- fs/nilfs2/page.c | 27 ++++++++++++++------------- fs/nilfs2/page.h | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index c7ec56358a79..8fe784f62720 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -186,7 +186,7 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc) * have dirty pages that try to be flushed in background. * So, here we simply discard this dirty page. */ - nilfs_clear_dirty_page(page, false); + nilfs_clear_folio_dirty(folio, false); folio_unlock(folio); return -EROFS; } diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c index 327408512b86..2e7952ac2f67 100644 --- a/fs/nilfs2/mdt.c +++ b/fs/nilfs2/mdt.c @@ -411,7 +411,7 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc) * have dirty folios that try to be flushed in background. * So, here we simply discard this dirty folio. */ - nilfs_clear_dirty_page(page, false); + nilfs_clear_folio_dirty(folio, false); folio_unlock(folio); return -EROFS; } diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 29799a49c234..48a91ff059f5 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -379,7 +379,7 @@ void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent) * was acquired. Skip processing in that case. */ if (likely(folio->mapping == mapping)) - nilfs_clear_dirty_page(&folio->page, silent); + nilfs_clear_folio_dirty(folio, silent); folio_unlock(folio); } @@ -389,32 +389,33 @@ void nilfs_clear_dirty_pages(struct address_space *mapping, bool silent) } /** - * nilfs_clear_dirty_page - discard dirty page - * @page: dirty page that will be discarded + * nilfs_clear_folio_dirty - discard dirty folio + * @folio: dirty folio that will be discarded * @silent: suppress [true] or print [false] warning messages */ -void nilfs_clear_dirty_page(struct page *page, bool silent) +void nilfs_clear_folio_dirty(struct folio *folio, bool silent) { - struct inode *inode = page->mapping->host; + struct inode *inode = folio->mapping->host; struct super_block *sb = inode->i_sb; + struct buffer_head *bh, *head; - BUG_ON(!PageLocked(page)); + BUG_ON(!folio_test_locked(folio)); if (!silent) nilfs_warn(sb, "discard dirty page: offset=%lld, ino=%lu", - page_offset(page), inode->i_ino); + folio_pos(folio), inode->i_ino); - ClearPageUptodate(page); - ClearPageMappedToDisk(page); + folio_clear_uptodate(folio); + folio_clear_mappedtodisk(folio); - if (page_has_buffers(page)) { - struct buffer_head *bh, *head; + head = folio_buffers(folio); + if (head) { const unsigned long clear_bits = (BIT(BH_Uptodate) | BIT(BH_Dirty) | BIT(BH_Mapped) | BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) | BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected)); - bh = head = page_buffers(page); + bh = head; do { lock_buffer(bh); if (!silent) @@ -427,7 +428,7 @@ void nilfs_clear_dirty_page(struct page *page, bool silent) } while (bh = bh->b_this_page, bh != head); } - __nilfs_clear_page_dirty(page); + __nilfs_clear_page_dirty(&folio->page); } unsigned int nilfs_page_count_clean_buffers(struct page *page, diff --git a/fs/nilfs2/page.h b/fs/nilfs2/page.h index a8ab800e689c..c419bb1f5b7d 100644 --- a/fs/nilfs2/page.h +++ b/fs/nilfs2/page.h @@ -41,7 +41,7 @@ void nilfs_page_bug(struct page *); int nilfs_copy_dirty_pages(struct address_space *, struct address_space *); void nilfs_copy_back_pages(struct address_space *, struct address_space *); -void nilfs_clear_dirty_page(struct page *, bool); +void nilfs_clear_folio_dirty(struct folio *, bool); void nilfs_clear_dirty_pages(struct address_space *, bool); unsigned int nilfs_page_count_clean_buffers(struct page *, unsigned int, unsigned int); From patchwork Mon Nov 6 17:38:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447230 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0E9429D03 for ; Mon, 6 Nov 2023 17:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="cZaCLv8b" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0AEDD7B; Mon, 6 Nov 2023 09:39:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=0AG2dMS81/SkWO59LwqrNQHYrTfMNl58mt0GO8sq17U=; b=cZaCLv8bbcXFDnMvnBmZ0tWWQK 6eqpydnMRkohCxq4Dun8gN1srhkca5sflRbqc7I5cq/PtOt4nFlTZN4nPpj1P69XjfKWp8JzskUb+ J/5/bHBdVArTePiZcM3y/+cdpFk/1yOddrHSvXV+NLa722aNkrbUGLaVGOE5xPA7EFOwFTk6e6rAo OQ5vtaSFqkJ99lx/aZkdhQ2xfTC2HC9fd6eXviRSaozUq7mdXLse/MJGNg7H2+waFFQkDxjX1hf7+ 2YMwLmFmcZeRtgUd3paDdSh6xkNPVOg3hAu7+U+/nMOpHLj6OLG+mgOlB3DJidzw3e5RNFQkKGPQR G2rNhgTQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z4-007H8W-RP; Mon, 06 Nov 2023 17:39:06 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 09/35] nilfs2: Convert to __nilfs_clear_folio_dirty() Date: Mon, 6 Nov 2023 17:38:37 +0000 Message-Id: <20231106173903.1734114-10-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All callers now have a folio, so convert to pass a folio. No caller uses the return value, so make it return void. Removes a couple of hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/page.c | 19 ++++++++++--------- fs/nilfs2/page.h | 2 +- fs/nilfs2/segment.c | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 48a91ff059f5..94e11bcee05b 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -82,7 +82,7 @@ void nilfs_forget_buffer(struct buffer_head *bh) lock_buffer(bh); set_mask_bits(&bh->b_state, clear_bits, 0); if (nilfs_folio_buffers_clean(folio)) - __nilfs_clear_page_dirty(&folio->page); + __nilfs_clear_folio_dirty(folio); bh->b_blocknr = -1; folio_clear_uptodate(folio); @@ -428,7 +428,7 @@ void nilfs_clear_folio_dirty(struct folio *folio, bool silent) } while (bh = bh->b_this_page, bh != head); } - __nilfs_clear_page_dirty(&folio->page); + __nilfs_clear_folio_dirty(folio); } unsigned int nilfs_page_count_clean_buffers(struct page *page, @@ -458,22 +458,23 @@ unsigned int nilfs_page_count_clean_buffers(struct page *page, * 2) Some B-tree operations like insertion or deletion may dispose buffers * in dirty state, and this needs to cancel the dirty state of their pages. */ -int __nilfs_clear_page_dirty(struct page *page) +void __nilfs_clear_folio_dirty(struct folio *folio) { - struct address_space *mapping = page->mapping; + struct address_space *mapping = folio->mapping; if (mapping) { xa_lock_irq(&mapping->i_pages); - if (test_bit(PG_dirty, &page->flags)) { - __xa_clear_mark(&mapping->i_pages, page_index(page), + if (folio_test_dirty(folio)) { + __xa_clear_mark(&mapping->i_pages, folio->index, PAGECACHE_TAG_DIRTY); xa_unlock_irq(&mapping->i_pages); - return clear_page_dirty_for_io(page); + folio_clear_dirty_for_io(folio); + return; } xa_unlock_irq(&mapping->i_pages); - return 0; + return; } - return TestClearPageDirty(page); + folio_clear_dirty(folio); } /** diff --git a/fs/nilfs2/page.h b/fs/nilfs2/page.h index c419bb1f5b7d..968b311d265b 100644 --- a/fs/nilfs2/page.h +++ b/fs/nilfs2/page.h @@ -30,7 +30,7 @@ BUFFER_FNS(NILFS_Checked, nilfs_checked) /* buffer is verified */ BUFFER_FNS(NILFS_Redirected, nilfs_redirected) /* redirected to a copy */ -int __nilfs_clear_page_dirty(struct page *); +void __nilfs_clear_folio_dirty(struct folio *); struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *, unsigned long, unsigned long); diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 888b8606a1e8..8c675c118c66 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -1760,7 +1760,7 @@ static void nilfs_end_folio_io(struct folio *folio, int err) */ folio_lock(folio); if (nilfs_folio_buffers_clean(folio)) - __nilfs_clear_page_dirty(&folio->page); + __nilfs_clear_folio_dirty(folio); folio_unlock(folio); } return; From patchwork Mon Nov 6 17:38:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447229 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A489F2C846 for ; Mon, 6 Nov 2023 17:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Z/309ShV" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 390ABD7E; Mon, 6 Nov 2023 09:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=WMfnqygTYr57TB2SIEdKYkur5BHxcXcMLwxo3SfQNGE=; b=Z/309ShVqrHgJqjX5ad1rsasUc pdnYm23pylROeLhCd0AXo3RzXv+7Tjwh1fFqEpDWJmVN3m1ObHnDQ+NSTBKEkLL9jMlvJt+QnGM6J GpQiyi/FgES/QyWR79e9jWEcKcu7jdfhQImrDExriDXWu9Kj83iNLyczONsUkwxTT6v7YzkwbtZyj N3MTUYh7NDEGbL17r7FTQzT191MRsGZl4btLawcz4i57LVW2D+JCCvJVAoRx4xaqAnnuxzJRiD+Ni pTQl7yYygdi3s7UwOOAIyg7iLjEb0Spu7bQXgZRf5h3YTWqQSRqAEnDF3EavVaCIzRhZ1QASk+Q9m 7J2QdmsQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z4-007H8d-Us; Mon, 06 Nov 2023 17:39:07 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 10/35] nilfs2: Convert nilfs_segctor_prepare_write to use folios Date: Mon, 6 Nov 2023 17:38:38 +0000 Message-Id: <20231106173903.1734114-11-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new folio APIs, saving 17 hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/segment.c | 58 ++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 8c675c118c66..52995838f2de 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -1665,39 +1665,39 @@ static int nilfs_segctor_assign(struct nilfs_sc_info *sci, int mode) return 0; } -static void nilfs_begin_page_io(struct page *page) +static void nilfs_begin_folio_io(struct folio *folio) { - if (!page || PageWriteback(page)) + if (!folio || folio_test_writeback(folio)) /* * For split b-tree node pages, this function may be called * twice. We ignore the 2nd or later calls by this check. */ return; - lock_page(page); - clear_page_dirty_for_io(page); - set_page_writeback(page); - unlock_page(page); + folio_lock(folio); + folio_clear_dirty_for_io(folio); + folio_start_writeback(folio); + folio_unlock(folio); } static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci) { struct nilfs_segment_buffer *segbuf; - struct page *bd_page = NULL, *fs_page = NULL; + struct folio *bd_folio = NULL, *fs_folio = NULL; list_for_each_entry(segbuf, &sci->sc_segbufs, sb_list) { struct buffer_head *bh; list_for_each_entry(bh, &segbuf->sb_segsum_buffers, b_assoc_buffers) { - if (bh->b_page != bd_page) { - if (bd_page) { - lock_page(bd_page); - clear_page_dirty_for_io(bd_page); - set_page_writeback(bd_page); - unlock_page(bd_page); + if (bh->b_folio != bd_folio) { + if (bd_folio) { + folio_lock(bd_folio); + folio_clear_dirty_for_io(bd_folio); + folio_start_writeback(bd_folio); + folio_unlock(bd_folio); } - bd_page = bh->b_page; + bd_folio = bh->b_folio; } } @@ -1705,28 +1705,28 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci) b_assoc_buffers) { set_buffer_async_write(bh); if (bh == segbuf->sb_super_root) { - if (bh->b_page != bd_page) { - lock_page(bd_page); - clear_page_dirty_for_io(bd_page); - set_page_writeback(bd_page); - unlock_page(bd_page); - bd_page = bh->b_page; + if (bh->b_folio != bd_folio) { + folio_lock(bd_folio); + folio_clear_dirty_for_io(bd_folio); + folio_start_writeback(bd_folio); + folio_unlock(bd_folio); + bd_folio = bh->b_folio; } break; } - if (bh->b_page != fs_page) { - nilfs_begin_page_io(fs_page); - fs_page = bh->b_page; + if (bh->b_folio != fs_folio) { + nilfs_begin_folio_io(fs_folio); + fs_folio = bh->b_folio; } } } - if (bd_page) { - lock_page(bd_page); - clear_page_dirty_for_io(bd_page); - set_page_writeback(bd_page); - unlock_page(bd_page); + if (bd_folio) { + folio_lock(bd_folio); + folio_clear_dirty_for_io(bd_folio); + folio_start_writeback(bd_folio); + folio_unlock(bd_folio); } - nilfs_begin_page_io(fs_page); + nilfs_begin_folio_io(fs_folio); } static int nilfs_segctor_write(struct nilfs_sc_info *sci, From patchwork Mon Nov 6 17:38:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447224 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FC6C29D0D for ; Mon, 6 Nov 2023 17:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="VqY+B6Y2" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4264BD7F; Mon, 6 Nov 2023 09:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=F4G+iHL8t8+cwmBR3NRbeBWt2xI2c3RvXRM3QO5MLTw=; b=VqY+B6Y2nO/TvkEt1F/bHt0/gn mimQzV76d7uCC9OHwtbBH8n7UCrVw9bp3wcqTnvVZGQqvmkzAb6roneZBcHJx5ZQfRHJCXAmN0xKW j20AsU93UH8Hsb5PoUT1AS8G3Rf5w8oTj3Iz89Hn1eFtC6qJcVFQ6QoiJ+Q5hVS/+z7XVec3FvyO+ 4rHa3uG3LOjXtqfObpHSllTzEinGqAeukpMCwD/+1yzWT76uYe9jpKFZSTpAgBMoYyHOY/N3tw6wF iBmaRKAvCMfT+U7p7m3D0xtjUxEX86qolpLJChlOi2tgGJx3cntHZlUi1FTYQDsvUsQX9bIDTvHc/ Oltb3jbQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z5-007H8j-2d; Mon, 06 Nov 2023 17:39:07 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 11/35] nilfs2: Convert nilfs_page_mkwrite() to use a folio Date: Mon, 6 Nov 2023 17:38:39 +0000 Message-Id: <20231106173903.1734114-12-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Using the new folio APIs saves seven hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/file.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index 740ce26d1e76..bec33b89a075 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -45,34 +45,36 @@ int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; - struct page *page = vmf->page; + struct folio *folio = page_folio(vmf->page); struct inode *inode = file_inode(vma->vm_file); struct nilfs_transaction_info ti; + struct buffer_head *bh, *head; int ret = 0; if (unlikely(nilfs_near_disk_full(inode->i_sb->s_fs_info))) return VM_FAULT_SIGBUS; /* -ENOSPC */ sb_start_pagefault(inode->i_sb); - lock_page(page); - if (page->mapping != inode->i_mapping || - page_offset(page) >= i_size_read(inode) || !PageUptodate(page)) { - unlock_page(page); + folio_lock(folio); + if (folio->mapping != inode->i_mapping || + folio_pos(folio) >= i_size_read(inode) || + !folio_test_uptodate(folio)) { + folio_unlock(folio); ret = -EFAULT; /* make the VM retry the fault */ goto out; } /* - * check to see if the page is mapped already (no holes) + * check to see if the folio is mapped already (no holes) */ - if (PageMappedToDisk(page)) + if (folio_test_mappedtodisk(folio)) goto mapped; - if (page_has_buffers(page)) { - struct buffer_head *bh, *head; + head = folio_buffers(folio); + if (head) { int fully_mapped = 1; - bh = head = page_buffers(page); + bh = head; do { if (!buffer_mapped(bh)) { fully_mapped = 0; @@ -81,11 +83,11 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) } while (bh = bh->b_this_page, bh != head); if (fully_mapped) { - SetPageMappedToDisk(page); + folio_set_mappedtodisk(folio); goto mapped; } } - unlock_page(page); + folio_unlock(folio); /* * fill hole blocks @@ -105,7 +107,7 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) nilfs_transaction_commit(inode->i_sb); mapped: - wait_for_stable_page(page); + folio_wait_stable(folio); out: sb_end_pagefault(inode->i_sb); return vmf_fs_error(ret); From patchwork Mon Nov 6 17:38:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447221 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0133529D0A for ; Mon, 6 Nov 2023 17:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="FMhC7Kmd" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61DA8B7; Mon, 6 Nov 2023 09:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=8lLT5xkKCqdiPAnTDVlD/IYjZd/DMWn1oTzzcwjirl0=; b=FMhC7KmdIkEelN5hAo6+nA3DZs th8uriNh3lL0MtRwwNwuyKHP58xfRnrDxOh3DI5jSSNCPeSO3Mrya8Nu9v3gSd6vvTqe+MvhQ18fk re4kYrAuwr27XRpYFPxZz3Vu4hnWQ+hYyirM9AiNgolrjlOHgXaKGwZ4QvYuh9uDG3f8LUmFCo9Qm AsS1sYFL1jzzfdWzlGra5j+5zmfjAI9u4NIWJas2C3Ri0gAvNtjlIQ6LRsh+DdPBkYcli3qI8/mS4 gencGaSKW/IWeaD7GRMNjwCFBWNp9p+yS+w8eHX+mqAkOlryL1VyWoRHuDSwTKsAMvHxTXbb1XkA0 SgKSyTaw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z5-007H8q-7a; Mon, 06 Nov 2023 17:39:07 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 12/35] nilfs2: Convert nilfs_mdt_create_block to use a folio Date: Mon, 6 Nov 2023 17:38:40 +0000 Message-Id: <20231106173903.1734114-13-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Saves two calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/mdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c index 2e7952ac2f67..7e4dcff2c94b 100644 --- a/fs/nilfs2/mdt.c +++ b/fs/nilfs2/mdt.c @@ -97,8 +97,8 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block, } failed_bh: - unlock_page(bh->b_page); - put_page(bh->b_page); + folio_unlock(bh->b_folio); + folio_put(bh->b_folio); brelse(bh); failed_unlock: From patchwork Mon Nov 6 17:38:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447231 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE0D62C852 for ; Mon, 6 Nov 2023 17:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="RRy5QkyL" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 752F210C0; Mon, 6 Nov 2023 09:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=lcP/X+IVyIzLgY2RgPKpJTs8qG8I+p0Nsdznb+secT8=; b=RRy5QkyLXnOcDrk8+cFZgrv7km Hla+nCSKaWKGkoe8X0q222AMqTCxNyaDwc9BwrHlqs9Aw5fkAXlMfM5wCeTuJ6DiFPSyabf0GPm7u tO8sKPoPM8uK+3hGe0H4VvLt1SW7KHXIQNgfAYodel60AeEaPVPWN/0SH875im9YP0s48V/aUmB3N 0nxHzdBEuUs5B09sM5UQ5SfDeBm6vt9KNrGj6qd9nj/TPCne+t7WUCWZCBHZ+IuEL+pEkeWQVCTUP 8VjxKtV246QF944+BDXxf4iqLBzsgmAKKw7nVv+N/E4qSOpKZov4YMv+HFu1iXmC0wucIRSdsFSJn zXrvE8ew==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z5-007H8y-Bu; Mon, 06 Nov 2023 17:39:07 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 13/35] nilfs2: Convert nilfs_mdt_submit_block to use a folio Date: Mon, 6 Nov 2023 17:38:41 +0000 Message-Id: <20231106173903.1734114-14-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Saves two calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/mdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c index 7e4dcff2c94b..e45c01a559c0 100644 --- a/fs/nilfs2/mdt.c +++ b/fs/nilfs2/mdt.c @@ -158,8 +158,8 @@ nilfs_mdt_submit_block(struct inode *inode, unsigned long blkoff, blk_opf_t opf, *out_bh = bh; failed_bh: - unlock_page(bh->b_page); - put_page(bh->b_page); + folio_unlock(bh->b_folio); + folio_put(bh->b_folio); brelse(bh); failed: return ret; From patchwork Mon Nov 6 17:38:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447223 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0122D29D09 for ; Mon, 6 Nov 2023 17:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SO28Zj4N" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E33910C1; Mon, 6 Nov 2023 09:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=7t3zYAQvCkvirdJu4c4Q9fMP5+7V3p76B5YGNYy1k74=; b=SO28Zj4NA5VaNVuNsb6c0KEeMO fpEih//rVqdmeIPyFGObhgj8twtgy3oytVduPiNEGv+StD3t4bu7FxMhJ92QVE6z+8PSvuOaXs5Tk 5YYeDxEVUy9EEybmJb98XXOQ/XVQ/HZTLDzqcsu4XjYymhTUipGfj0ZEWIjnpGhswPft3D6pF601v tw0Xh0ayBb6XjXS3FgVJb6mZ/1spO2olubqWjhwirFqpoRb6NCBHwVlU9iUp1eIAp7Dh49v79pWcl +2P9xXtZMAbNbWK016Mow6Rs8uLL5H/4RjYQmhr0z49NzUg61VXldeIbSVYEBrpG9FvapCm8YNWbj 7AmW1Sig==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z5-007H98-H1; Mon, 06 Nov 2023 17:39:07 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 14/35] nilfs2: Convert nilfs_gccache_submit_read_data to use a folio Date: Mon, 6 Nov 2023 17:38:42 +0000 Message-Id: <20231106173903.1734114-15-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Saves two calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/gcinode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/gcinode.c b/fs/nilfs2/gcinode.c index 8beb2730929d..bf9a11d58817 100644 --- a/fs/nilfs2/gcinode.c +++ b/fs/nilfs2/gcinode.c @@ -98,8 +98,8 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff, *out_bh = bh; failed: - unlock_page(bh->b_page); - put_page(bh->b_page); + folio_unlock(bh->b_folio); + folio_put(bh->b_folio); if (unlikely(err)) brelse(bh); return err; From patchwork Mon Nov 6 17:38:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447228 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A8052C85D for ; Mon, 6 Nov 2023 17:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="P5wi36f2" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AF9510C3; Mon, 6 Nov 2023 09:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=RXBHu05/D+Bl9yrdetqm4iOS2E2N7VhXyiJElbk3dHk=; b=P5wi36f21cyyVWtagm3vBAOIYL rwdmTYDgKIVntaaXY3yZZ0G38KT9qTiKosU4eO2vByb/vh+DIBIqIWoSUyVugfr8XD5m+Yka3YvA0 cJscc1GfGV5j8CKnXIh+G5cwkWcIpWLFMpKi8NGccNCfMPC6PkpKguDvLYUCzS2v+qNVUXG1PE6bN VX9c6p7Rq/XyueI2MwXxd8Utyj5ki+Xindfb/Sr42B80L4BryBbGqHZ1i/PYSHSv953cQcr01nGjp XJqbYp+OIBgu7oWVMyUinwg1E8n0/jcs+2BGQ5yZ4X9bRMZSGoJNY1Z5vp5QFpxUjyzbnDQhr+4y7 F2J33VmQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z5-007H9G-Ka; Mon, 06 Nov 2023 17:39:07 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 15/35] nilfs2: Convert nilfs_btnode_create_block to use a folio Date: Mon, 6 Nov 2023 17:38:43 +0000 Message-Id: <20231106173903.1734114-16-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Saves two calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/btnode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index 5710833ac1cc..691a50410ea9 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c @@ -64,8 +64,8 @@ nilfs_btnode_create_block(struct address_space *btnc, __u64 blocknr) set_buffer_mapped(bh); set_buffer_uptodate(bh); - unlock_page(bh->b_page); - put_page(bh->b_page); + folio_unlock(bh->b_folio); + folio_put(bh->b_folio); return bh; } From patchwork Mon Nov 6 17:38:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447233 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53F4F2C863 for ; Mon, 6 Nov 2023 17:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="bGUYcerx" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA91CD4C; Mon, 6 Nov 2023 09:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=7PIZ8KqccUS2TOpXvumG29UeZnAYz8wZ5EmCGu95qn8=; b=bGUYcerxDfRbUaunwTgCJo1I3X 9uyFVYlmU328+l45bB9viY9DsqbfIkZEFsbISO8l9u3Vk+frV/ZKWfjMV1i+emwS+DYzM2Edw0A7x lYhriL3rtzClJZ7uZd1lWrDvme6ok/CYI3Z2CTWKX9YXo7vLjzgm413fuOf7gecKyHeZrqgHWcNDD Oa0qpM2acvGSw8F4gJfgUYEH4L2rbFw6kqqeHoLRlDaib4ThlAcUfoCZmo0wVKBhd2omgzFR08QLj MfMGn1wv0cHvUnQ/Xwv6gQbHE4NRC7dlCHG6doidGbGM1nRlV+ICUz1INNVPonbc6oAlG+7GKlJvN ZGQwiiyw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z5-007H9N-Ny; Mon, 06 Nov 2023 17:39:07 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 16/35] nilfs2: Convert nilfs_btnode_submit_block to use a folio Date: Mon, 6 Nov 2023 17:38:44 +0000 Message-Id: <20231106173903.1734114-17-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Saves two calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/btnode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index 691a50410ea9..5ef9eebd8d2e 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c @@ -75,7 +75,7 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, { struct buffer_head *bh; struct inode *inode = btnc->host; - struct page *page; + struct folio *folio; int err; bh = nilfs_grab_buffer(inode, btnc, blocknr, BIT(BH_NILFS_Node)); @@ -83,7 +83,7 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, return -ENOMEM; err = -EEXIST; /* internal code */ - page = bh->b_page; + folio = bh->b_folio; if (buffer_uptodate(bh) || buffer_dirty(bh)) goto found; @@ -130,8 +130,8 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, *pbh = bh; out_locked: - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); return err; } From patchwork Mon Nov 6 17:38:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447234 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CCA72C867 for ; Mon, 6 Nov 2023 17:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="m3r6FbXa" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01DC010C6; Mon, 6 Nov 2023 09:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=nxKQJgvtD4VqNVRQ69Ua94Y9Py0FFllSC6PheIwXIKg=; b=m3r6FbXa6aIDObJ9Ku4Z5KU2yz YjcX08tzp9PVxn3/UGoghlc98qpFAbiUXaOIE67EmtlxEfJF6Ohmd3P7mPAhWDv2KRNAmEph1vRV9 GjOGP6fFJOrs40Fw6m4vNvM7v+UGiWPFN+QoCTzhmR/sVxLgBkZJ7Xs2qGZBpNqBOONbnacbUMjTn FTOmPsGv8+y/Kz9TD7+DSRPwih7nJLx91e7FD2uZjnsllpCjNtjc2Z08Tmb4P/NGzSrRyQ3pB0/Eh +QfTzgG+opRsXVDbGWYEUthMxqFhRbH7SZMOLNlF5MLsmA4fDGZEBFZftUU43eFcgF4h1c6a8zOpC AAUsfnag==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z5-007H9V-Sk; Mon, 06 Nov 2023 17:39:07 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 17/35] nilfs2: Convert nilfs_btnode_delete to use a folio Date: Mon, 6 Nov 2023 17:38:45 +0000 Message-Id: <20231106173903.1734114-18-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Saves six calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/btnode.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index 5ef9eebd8d2e..e077d4a7a11c 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c @@ -145,19 +145,19 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, void nilfs_btnode_delete(struct buffer_head *bh) { struct address_space *mapping; - struct page *page = bh->b_page; - pgoff_t index = page_index(page); + struct folio *folio = bh->b_folio; + pgoff_t index = folio->index; int still_dirty; - get_page(page); - lock_page(page); - wait_on_page_writeback(page); + folio_get(folio); + folio_lock(folio); + folio_wait_writeback(folio); nilfs_forget_buffer(bh); - still_dirty = PageDirty(page); - mapping = page->mapping; - unlock_page(page); - put_page(page); + still_dirty = folio_test_dirty(folio); + mapping = folio->mapping; + folio_unlock(folio); + folio_put(folio); if (!still_dirty && mapping) invalidate_inode_pages2_range(mapping, index, index); From patchwork Mon Nov 6 17:38:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447237 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0365D2C86E for ; Mon, 6 Nov 2023 17:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="JBU9S/ha" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DC9B10C7; Mon, 6 Nov 2023 09:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=6f31LpAk04SjO1wv4hq8iHBkCZDYWo/mqrg8dAuvBXA=; b=JBU9S/haJTAdpaIbZb2u5PX9hN mr73CG9SWl2lgPNQuXT3sLt1xExgNhnAYx8r1Cr4A5TLqsni9n2wAaWRXMwrgn+LMzARnmEUyNFNF avWtJcXOEIV5v+GRBHPPAoMMHUcLIBvcPVeHSafgaloWO5ff5kQxRaTCyKN3y4unPb2jQ4rSveSjJ UW4TAZ1RUtRp1vrdOZbBQQyziMcoZKVhataeGhckjyxmzQvCxfie+tJ0qSRbgDcMuOMS5tVguDOjG RPp8wNuW0jLXwRa0KmCR98MAuxSX0k7HEtb5n4QIPn6LMhjdox1R+eT4eRd68GbBwJVbFQM86R6z9 toJH8uWA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z6-007H9g-2U; Mon, 06 Nov 2023 17:39:08 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 18/35] nilfs2: Convert nilfs_btnode_prepare_change_key to use a folio Date: Mon, 6 Nov 2023 17:38:46 +0000 Message-Id: <20231106173903.1734114-19-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Saves three calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/btnode.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index e077d4a7a11c..da3e4366625f 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c @@ -185,23 +185,23 @@ int nilfs_btnode_prepare_change_key(struct address_space *btnc, ctxt->newbh = NULL; if (inode->i_blkbits == PAGE_SHIFT) { - struct page *opage = obh->b_page; - lock_page(opage); + struct folio *ofolio = obh->b_folio; + folio_lock(ofolio); retry: /* BUG_ON(oldkey != obh->b_folio->index); */ - if (unlikely(oldkey != opage->index)) - NILFS_PAGE_BUG(opage, + if (unlikely(oldkey != ofolio->index)) + NILFS_PAGE_BUG(&ofolio->page, "invalid oldkey %lld (newkey=%lld)", (unsigned long long)oldkey, (unsigned long long)newkey); xa_lock_irq(&btnc->i_pages); - err = __xa_insert(&btnc->i_pages, newkey, opage, GFP_NOFS); + err = __xa_insert(&btnc->i_pages, newkey, ofolio, GFP_NOFS); xa_unlock_irq(&btnc->i_pages); /* - * Note: page->index will not change to newkey until + * Note: folio->index will not change to newkey until * nilfs_btnode_commit_change_key() will be called. - * To protect the page in intermediate state, the page lock + * To protect the folio in intermediate state, the folio lock * is held. */ if (!err) @@ -213,7 +213,7 @@ int nilfs_btnode_prepare_change_key(struct address_space *btnc, if (!err) goto retry; /* fallback to copy mode */ - unlock_page(opage); + folio_unlock(ofolio); } nbh = nilfs_btnode_create_block(btnc, newkey); @@ -225,7 +225,7 @@ int nilfs_btnode_prepare_change_key(struct address_space *btnc, return 0; failed_unlock: - unlock_page(obh->b_page); + folio_unlock(obh->b_folio); return err; } From patchwork Mon Nov 6 17:38:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447235 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B79CF2C84A for ; Mon, 6 Nov 2023 17:39:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="R+SzJr6K" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37B8D10CE; Mon, 6 Nov 2023 09:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=95Zi5Uka8TKNZtzbGUB5Aonu6jfJqYtRnlAn1ErzqX4=; b=R+SzJr6Kt+JmIg04fFOkEPbpYT HeKXK6LsRy5mon9CQJ0NevMPF3pD/SJytde7lKDrbZpCDh693LBnZVsUQNpXYJy2Abo2gObWs2VJ5 GMAlSTLT90mlifoyVfXwBxcAbe+W9yHB5+IUlgFvdsJUf1nOulTpHLB5JbhOysjJhmSwD/n/bx4e7 dy4dX3cxzwvG/nLsSDFTxrW/sEjW4X9HsT1I8w/iM7Gg5jndYEXUzWsS7QTJTWptSB9GnPpaYzgBJ OVAfM/L5MtPXlWPwvRkSpaiThOytxUcjhrpd+TwxNc1UfOlXr/IbTxNGbjg2zDW9pZZfLgPRfES6x ETkpa2LA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z6-007H9n-8D; Mon, 06 Nov 2023 17:39:08 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 19/35] nilfs2: Convert nilfs_btnode_commit_change_key to use a folio Date: Mon, 6 Nov 2023 17:38:47 +0000 Message-Id: <20231106173903.1734114-20-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Saves one call to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/btnode.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index da3e4366625f..fb1638765d54 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c @@ -238,15 +238,15 @@ void nilfs_btnode_commit_change_key(struct address_space *btnc, { struct buffer_head *obh = ctxt->bh, *nbh = ctxt->newbh; __u64 oldkey = ctxt->oldkey, newkey = ctxt->newkey; - struct page *opage; + struct folio *ofolio; if (oldkey == newkey) return; if (nbh == NULL) { /* blocksize == pagesize */ - opage = obh->b_page; - if (unlikely(oldkey != opage->index)) - NILFS_PAGE_BUG(opage, + ofolio = obh->b_folio; + if (unlikely(oldkey != ofolio->index)) + NILFS_PAGE_BUG(&ofolio->page, "invalid oldkey %lld (newkey=%lld)", (unsigned long long)oldkey, (unsigned long long)newkey); @@ -257,8 +257,8 @@ void nilfs_btnode_commit_change_key(struct address_space *btnc, __xa_set_mark(&btnc->i_pages, newkey, PAGECACHE_TAG_DIRTY); xa_unlock_irq(&btnc->i_pages); - opage->index = obh->b_blocknr = newkey; - unlock_page(opage); + ofolio->index = obh->b_blocknr = newkey; + folio_unlock(ofolio); } else { nilfs_copy_buffer(nbh, obh); mark_buffer_dirty(nbh); From patchwork Mon Nov 6 17:38:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447243 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 501CA2C879 for ; Mon, 6 Nov 2023 17:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="j/u3rT8O" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A180910DB; Mon, 6 Nov 2023 09:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=TgmUIUcJvy4zgyjRhv0niN+gofsFTMFSxbjhNAOTL9Q=; b=j/u3rT8OZvCzrc1Ql619YCcG4g sZhAqEy+ytTKBXt941J6a1j71tkAZtLovN7tOYnOqMIQJmKnw9ncS+y+9hYybqK3ZHufDurfrgIc+ Ce+MmL1vS8TxFQH7sI+frFVKsasHg/tgBC9Qbr+u0soRwW3fw7hsCFTb86evmc0zTg5PFXOZsZDHE F2QtZe/XH3qaVH1pXA5w1jWs1sRniOF3XXbuWf4caGrJOShgORtqcT6E++DVUrEv92ZeLDvi1clyI /E/Bn+mYidURczrP+Gn7joj7N0uwC+1EkbhJ4VOltEJUXswlQUftuGDeVtwZTYlRJS1B2VyEq/EpX jGfbZmuw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z6-007H9w-CV; Mon, 06 Nov 2023 17:39:08 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 20/35] nilfs2: Convert nilfs_btnode_abort_change_key to use a folio Date: Mon, 6 Nov 2023 17:38:48 +0000 Message-Id: <20231106173903.1734114-21-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Saves one call to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/btnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index fb1638765d54..1204dd06ead8 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c @@ -284,7 +284,7 @@ void nilfs_btnode_abort_change_key(struct address_space *btnc, if (nbh == NULL) { /* blocksize == pagesize */ xa_erase_irq(&btnc->i_pages, newkey); - unlock_page(ctxt->bh->b_page); + folio_unlock(ctxt->bh->b_folio); } else { /* * When canceling a buffer that a prepare operation has From patchwork Mon Nov 6 17:38:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447236 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 716412C874 for ; Mon, 6 Nov 2023 17:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Fj204Md2" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 820E210D7; Mon, 6 Nov 2023 09:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=dCruAMK3Rqxl4bYvNBg3suiRYWI7JSCeS94NZiWRCgM=; b=Fj204Md2qC4G55QtoSz3rrAfN7 gkMxrzGy+248YyOHcOkAS5hh/J3sI61L0vVEFJ3kkV3VM/jIM/YcWylZSXTt0u0oTsXNX5dP/Anu7 XjD946dyadclAC8MDnQ4v3srrlKrmNchpUMOnqA1nouDFsxpkyuQAe8j4l3rF/oSEa6jXgVd3QYLl I59CiX9gi3Z/uOjEbJXk55rkFL5FaFNaNG0On7E0/HJAO1Pm+5hj2rDgLxbd8vG/lwgb5iqnYnq+p dGL6MUDj7STQ6q0erDrxJ0fjV9SWyisd3n/yNoqnSgN7SmrH9IYRB0bJoxjyzcmsmp51gJuJGypHT B1+FD0Xw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z6-007HA4-HQ; Mon, 06 Nov 2023 17:39:08 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 21/35] nilfs2: Remove page_address() from nilfs_set_link Date: Mon, 6 Nov 2023 17:38:49 +0000 Message-Id: <20231106173903.1734114-22-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In preparation for removing kmap from directory handling, use offset_in_page() to calculate 'from'. Matches ext2. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index de2073c47651..683101dcbddf 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -417,7 +417,7 @@ ino_t nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr) void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, struct page *page, struct inode *inode) { - unsigned int from = (char *)de - (char *)page_address(page); + unsigned int from = offset_in_page(de); unsigned int to = from + nilfs_rec_len_from_disk(de->rec_len); struct address_space *mapping = page->mapping; int err; From patchwork Mon Nov 6 17:38:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447241 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F70B2D029 for ; Mon, 6 Nov 2023 17:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ahoFAoTZ" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFEB210DC; Mon, 6 Nov 2023 09:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=jrbR4iWef8sIb7H7v7Cy30neHladJbirl+6/uy/A9Ow=; b=ahoFAoTZiwERrrFy9c1GghN93M 7dqmDZYbQ/9AN6DKc86CFLLdjTHIrJpKN5tUFumDpmZKJw42TTPc6nKLU/dhi6zydIH9Dx4f1OEwm 4p1A30kpDEnLYvphynbKhNdO1adrPSx6NM9YJ0772VC3jjcwXqceD5VxnzV76meCYJOIn4Bq/7ho2 nqud352xFQE3UzOY8vxnZju7IGpqTWGT+vN0QuT7Q9Xn5CsGzZVZTyZ3fyE5zleGCCdkyDhGPFppY K7d1r8JrGiLG9mSjirPmchz7QCiVTnxGn8VUSz5nC0nMJlC853m9z8+q9INQXGWDQNldYdcUUtY0N TD3G51Gw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z6-007HAA-Kx; Mon, 06 Nov 2023 17:39:08 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 22/35] nilfs2: Remove page_address() from nilfs_add_link Date: Mon, 6 Nov 2023 17:38:50 +0000 Message-Id: <20231106173903.1734114-23-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In preparation for removing kmap from directory handling, use offset_in_page() to calculate 'from'. Matches ext2. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 683101dcbddf..0cf4fe91aebe 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -501,7 +501,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) return -EINVAL; got_it: - from = (char *)de - (char *)page_address(page); + from = offset_in_page(de); to = from + rec_len; err = nilfs_prepare_chunk(page, from, to); if (err) From patchwork Mon Nov 6 17:38:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447244 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D3692D025 for ; Mon, 6 Nov 2023 17:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="FXXCFxDj" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9AF810DD; Mon, 6 Nov 2023 09:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=h6bp/fpI9MZt0dEiyzYk9ugleWMsOz4HzORTtXlfGKw=; b=FXXCFxDjk7qTLQVqVDLIR/rpAL aLEHHFEtJribXy0gOL56NoNA5Zs9slJpnYjHXetQsOnuidyl2b3H9f5zg7zcbzmgD21+tHRzskFgQ UOYNsgeFLLLNnPJDH+phuhddBzXQZHRgNC7bk9ZsWxFA0PmKHxYfvozhizCeQsORhJZLrKreMWkaM 4S3ykDn/v1gp7HdLIf6g6RtTcLckvx4CAtKg4Y4qmzXmyn0MaXxqc0Fwu4tfuaPQfYzdPxml1AMqC m9Vwunj17gd3+YTWscU6QRed/3Irm4CN1dY8Ppf56+j52QkgG+HdhZh3O+3MA7vrt44dXtFB4ntcV mH4WhetA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z6-007HAH-Oz; Mon, 06 Nov 2023 17:39:08 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 23/35] nilfs2: Remove page_address() from nilfs_delete_entry Date: Mon, 6 Nov 2023 17:38:51 +0000 Message-Id: <20231106173903.1734114-24-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In preparation for removing kmap from directory handling, mask the directory entry pointer to discover the start address of the page. Matches ext2. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 0cf4fe91aebe..07a906d0c786 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -539,7 +539,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page) { struct address_space *mapping = page->mapping; struct inode *inode = mapping->host; - char *kaddr = page_address(page); + char *kaddr = (char *)((unsigned long)dir & PAGE_MASK); unsigned int from, to; struct nilfs_dir_entry *de, *pde = NULL; int err; @@ -559,7 +559,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page) de = nilfs_next_entry(de); } if (pde) - from = (char *)pde - (char *)page_address(page); + from = (char *)pde - kaddr; lock_page(page); err = nilfs_prepare_chunk(page, from, to); BUG_ON(err); From patchwork Mon Nov 6 17:38:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447255 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90F862D023 for ; Mon, 6 Nov 2023 17:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="jw140Xt7" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9DF410DE; Mon, 6 Nov 2023 09:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=fPsLUDBGteELHM8EhPLrcDSkKgdQZrmsCa4cX80SliM=; b=jw140Xt7L3zGoLnMvrzSuTa5W2 ZXURSo3AU8YCX1KzVqUnMZ7KMlnBl3oOwmbLFdo6cHvJUyZJlM+GOz/HXsaMNQvj+Otz6FgYNNwaM AomJ0ny8AowXmz/ZtsYhB9IuAvELEMWnpM+IlAnn/rn68VOlIs4m9D8Roh2NXxzzEtoZhwH5u/zkx AqHHngZVisfgA12cjxyhvUZHm01OwCs8YlirlVwGtQKmKCW4BnshmnSJvz9CBdCI7g8fDHpb53e5R XK4z6O2X49/0j2BkwuHxtGVzMhnEnxFmH80SBWngFZkJ8+v7qVJv7zMUsD/anGRLEtz1QIMsUcljz nZ3tn60w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z6-007HAN-Tb; Mon, 06 Nov 2023 17:39:08 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 24/35] nilfs2: Return the mapped address from nilfs_get_page() Date: Mon, 6 Nov 2023 17:38:52 +0000 Message-Id: <20231106173903.1734114-25-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In prepartion for switching from kmap() to kmap_local(), return the kmap address from nilfs_get_page() instead of having the caller look up page_address(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 58 +++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 07a906d0c786..0308b618fb87 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -186,19 +186,24 @@ static bool nilfs_check_page(struct page *page) return false; } -static struct page *nilfs_get_page(struct inode *dir, unsigned long n) +static void *nilfs_get_page(struct inode *dir, unsigned long n, + struct page **pagep) { struct address_space *mapping = dir->i_mapping; struct page *page = read_mapping_page(mapping, n, NULL); + void *kaddr; - if (!IS_ERR(page)) { - kmap(page); - if (unlikely(!PageChecked(page))) { - if (!nilfs_check_page(page)) - goto fail; - } + if (IS_ERR(page)) + return page; + + kaddr = kmap(page); + if (unlikely(!PageChecked(page))) { + if (!nilfs_check_page(page)) + goto fail; } - return page; + + *pagep = page; + return kaddr; fail: nilfs_put_page(page); @@ -275,14 +280,14 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) for ( ; n < npages; n++, offset = 0) { char *kaddr, *limit; struct nilfs_dir_entry *de; - struct page *page = nilfs_get_page(inode, n); + struct page *page; - if (IS_ERR(page)) { + kaddr = nilfs_get_page(inode, n, &page); + if (IS_ERR(kaddr)) { nilfs_error(sb, "bad page in #%lu", inode->i_ino); ctx->pos += PAGE_SIZE - offset; return -EIO; } - kaddr = page_address(page); de = (struct nilfs_dir_entry *)(kaddr + offset); limit = kaddr + nilfs_last_byte(inode, n) - NILFS_DIR_REC_LEN(1); @@ -345,11 +350,8 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, start = 0; n = start; do { - char *kaddr; - - page = nilfs_get_page(dir, n); - if (!IS_ERR(page)) { - kaddr = page_address(page); + char *kaddr = nilfs_get_page(dir, n, &page); + if (!IS_ERR(kaddr)) { de = (struct nilfs_dir_entry *)kaddr; kaddr += nilfs_last_byte(dir, n) - reclen; while ((char *) de <= kaddr) { @@ -387,15 +389,11 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, struct nilfs_dir_entry *nilfs_dotdot(struct inode *dir, struct page **p) { - struct page *page = nilfs_get_page(dir, 0); - struct nilfs_dir_entry *de = NULL; + struct nilfs_dir_entry *de = nilfs_get_page(dir, 0, p); - if (!IS_ERR(page)) { - de = nilfs_next_entry( - (struct nilfs_dir_entry *)page_address(page)); - *p = page; - } - return de; + if (IS_ERR(de)) + return NULL; + return nilfs_next_entry(de); } ino_t nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr) @@ -459,12 +457,11 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) for (n = 0; n <= npages; n++) { char *dir_end; - page = nilfs_get_page(dir, n); - err = PTR_ERR(page); - if (IS_ERR(page)) + kaddr = nilfs_get_page(dir, n, &page); + err = PTR_ERR(kaddr); + if (IS_ERR(kaddr)) goto out; lock_page(page); - kaddr = page_address(page); dir_end = kaddr + nilfs_last_byte(dir, n); de = (struct nilfs_dir_entry *)kaddr; kaddr += PAGE_SIZE - reclen; @@ -627,11 +624,10 @@ int nilfs_empty_dir(struct inode *inode) char *kaddr; struct nilfs_dir_entry *de; - page = nilfs_get_page(inode, i); - if (IS_ERR(page)) + kaddr = nilfs_get_page(inode, i, &page); + if (IS_ERR(kaddr)) continue; - kaddr = page_address(page); de = (struct nilfs_dir_entry *)kaddr; kaddr += nilfs_last_byte(inode, i) - NILFS_DIR_REC_LEN(1); From patchwork Mon Nov 6 17:38:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447242 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E3252D026 for ; Mon, 6 Nov 2023 17:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gdSwE33D" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3D5310E3; Mon, 6 Nov 2023 09:39:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=TTSeUUY7mg0GJ9TXXjIb/6dT6nWGvJK/p7aiURR/UJI=; b=gdSwE33D56RhB64ADlVVasG82t fuDTAspNPPbaptYloIXh3RRP/z+htUc/O+7pIj02rrK63v2wlO6/6zcpnITRXM5FeavOYiHem7Dwj YVaVgX+JZwaHkv5mLV2kFgOD/ywesGCrSLlXfGUUkmN1wDUfUAw48u3zLCdhkDzNSNqHkpZ3bSHkV w5/npb3d4YWOHrlyeS9e4mUBu2WzE+Jc+onoBr5q3l5LwdD4+hGZ06YJm+VhRWju2HXlS+BdJD/J/ Il0rizxJcNH0rUPGKqYJEJUBE6nMkCkpn5Zmx2BkXvUCYfpa3chr6sLFsLsluabYS3O/LlbqS7f28 fOpfBtKQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z7-007HAU-2E; Mon, 06 Nov 2023 17:39:09 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 25/35] nilfs2: Pass the mapped address to nilfs_check_page() Date: Mon, 6 Nov 2023 17:38:53 +0000 Message-Id: <20231106173903.1734114-26-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove another use of page_address() as part of preparing for the kmap to kmap_local transition. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 0308b618fb87..1ae370521249 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -113,12 +113,11 @@ static void nilfs_commit_chunk(struct page *page, unlock_page(page); } -static bool nilfs_check_page(struct page *page) +static bool nilfs_check_page(struct page *page, char *kaddr) { struct inode *dir = page->mapping->host; struct super_block *sb = dir->i_sb; unsigned int chunk_size = nilfs_chunk_size(dir); - char *kaddr = page_address(page); unsigned int offs, rec_len; unsigned int limit = PAGE_SIZE; struct nilfs_dir_entry *p; @@ -198,7 +197,7 @@ static void *nilfs_get_page(struct inode *dir, unsigned long n, kaddr = kmap(page); if (unlikely(!PageChecked(page))) { - if (!nilfs_check_page(page)) + if (!nilfs_check_page(page, kaddr)) goto fail; } From patchwork Mon Nov 6 17:38:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447245 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24B6B2D035 for ; Mon, 6 Nov 2023 17:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="G7EhUs+y" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 887DE10EC; Mon, 6 Nov 2023 09:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Ct3KgawDRCsn2AuzicsAuc01DGd4DxrTPkN7HUc95r0=; b=G7EhUs+yoMqc8sB2Z5IUlIm1eN 4bItUKbZqFDsppTsbPciaNL6Y+Y8ZQwEm9eku8BjDcQRq4mjc2W1I2pQvR2Au6HbkptBzdDmX0gpU ebjGew6OrGWLDJCikGVZuCtrp1PQ6N39WXkdUGX1fRXj7k5DuoNjhvikoMecy6VNpmdc8a957pEcr 92scMhp90eyqpECTWGtpprhcJ/8g/jpjxF6wM8OATazdgCZMop7pHwQxSby3RFa0pgVGfEOpg361J /xI2hc8zqy+lzoExtwyoeUIOwDKHTVova5Psj7bhRtBicZyFTDkPCs8dk9bXXxn1NnNMi2keEBKCi 4fbLjLMg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z7-007HAb-5V; Mon, 06 Nov 2023 17:39:09 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 26/35] nilfs2: Switch to kmap_local for directory handling Date: Mon, 6 Nov 2023 17:38:54 +0000 Message-Id: <20231106173903.1734114-27-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Match ext2 by using kmap_local() instead of kmap(). This is more efficient. Also use unmap_and_put_page() instead of duplicating it as a nilfs function. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 37 +++++++++++++++---------------------- fs/nilfs2/namei.c | 9 +++------ 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 1ae370521249..01c57573211e 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -64,12 +64,6 @@ static inline unsigned int nilfs_chunk_size(struct inode *inode) return inode->i_sb->s_blocksize; } -static inline void nilfs_put_page(struct page *page) -{ - kunmap(page); - put_page(page); -} - /* * Return the offset into page `page_nr' of the last valid * byte in that page, plus one. @@ -195,7 +189,7 @@ static void *nilfs_get_page(struct inode *dir, unsigned long n, if (IS_ERR(page)) return page; - kaddr = kmap(page); + kaddr = kmap_local_page(page); if (unlikely(!PageChecked(page))) { if (!nilfs_check_page(page, kaddr)) goto fail; @@ -205,7 +199,7 @@ static void *nilfs_get_page(struct inode *dir, unsigned long n, return kaddr; fail: - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); return ERR_PTR(-EIO); } @@ -293,7 +287,7 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) for ( ; (char *)de <= limit; de = nilfs_next_entry(de)) { if (de->rec_len == 0) { nilfs_error(sb, "zero-length directory entry"); - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); return -EIO; } if (de->inode) { @@ -306,13 +300,13 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) if (!dir_emit(ctx, de->name, de->name_len, le64_to_cpu(de->inode), t)) { - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); return 0; } } ctx->pos += nilfs_rec_len_from_disk(de->rec_len); } - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); } return 0; } @@ -357,14 +351,14 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, if (de->rec_len == 0) { nilfs_error(dir->i_sb, "zero-length directory entry"); - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); goto out; } if (nilfs_match(namelen, name, de)) goto found; de = nilfs_next_entry(de); } - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); } if (++n >= npages) n = 0; @@ -404,8 +398,7 @@ ino_t nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr) de = nilfs_find_entry(dir, qstr, &page); if (de) { res = le64_to_cpu(de->inode); - kunmap(page); - put_page(page); + unmap_and_put_page(page, de); } return res; } @@ -425,7 +418,7 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, de->inode = cpu_to_le64(inode->i_ino); nilfs_set_de_type(de, inode); nilfs_commit_chunk(page, mapping, from, to); - nilfs_put_page(page); + unmap_and_put_page(page, de); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); } @@ -491,7 +484,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) de = (struct nilfs_dir_entry *)((char *)de + rec_len); } unlock_page(page); - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); } BUG(); return -EINVAL; @@ -519,7 +512,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) nilfs_mark_inode_dirty(dir); /* OFFSET_CACHE */ out_put: - nilfs_put_page(page); + unmap_and_put_page(page, de); out: return err; out_unlock: @@ -565,7 +558,7 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page) nilfs_commit_chunk(page, mapping, from, to); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); out: - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); return err; } @@ -617,10 +610,10 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent) int nilfs_empty_dir(struct inode *inode) { struct page *page = NULL; + char *kaddr; unsigned long i, npages = dir_pages(inode); for (i = 0; i < npages; i++) { - char *kaddr; struct nilfs_dir_entry *de; kaddr = nilfs_get_page(inode, i, &page); @@ -652,12 +645,12 @@ int nilfs_empty_dir(struct inode *inode) } de = nilfs_next_entry(de); } - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); } return 1; not_empty: - nilfs_put_page(page); + unmap_and_put_page(page, kaddr); return 0; } diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 2a4e7f4a8102..8eebd8a464d8 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -421,13 +421,10 @@ static int nilfs_rename(struct mnt_idmap *idmap, return err; out_dir: - if (dir_de) { - kunmap(dir_page); - put_page(dir_page); - } + if (dir_de) + unmap_and_put_page(dir_page, dir_de); out_old: - kunmap(old_page); - put_page(old_page); + unmap_and_put_page(old_page, old_de); out: nilfs_transaction_abort(old_dir->i_sb); return err; From patchwork Mon Nov 6 17:38:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447248 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DEBF2D03C for ; Mon, 6 Nov 2023 17:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="W92LZg2U" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6B7710F5; Mon, 6 Nov 2023 09:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=C+aIuxXgUDGbbyNke79DCGODEJQx8W97A2KVuBf/oB4=; b=W92LZg2U7xoG1BiSgFqFT14sDq 5xNQngzd/znLWrCtYUHdRdzHymNlBkhRjGw8WZhU7RQTcfg+r2/UPoVdI4ZxPp0haF6NWhw4aGx0c ja9cI9jVCwYNAVsVfDzGLDH1hmB6uiYNaHLq1BwCWsSwpiH7TDAgkzl0KJVAvz8D9LmbI+1G6AsfH 2Ln7V6wy+tk5UI+pNJO8/Mb/1ZV2283emW6W453rGpr1MZL3HwckCkGnMDLgJIT3fMaE98Q3fgdCP 8QeRHDsYgIYiqxkCYLpw/rxeTDVy+zirR3uXY6/g9el8/xqkort1vlWcFa0DDs2PbXSmkxjWPxJ51 9260tH5w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z7-007HAm-An; Mon, 06 Nov 2023 17:39:09 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 27/35] nilfs2: Add nilfs_get_folio() Date: Mon, 6 Nov 2023 17:38:55 +0000 Message-Id: <20231106173903.1734114-28-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert nilfs_get_page() to be a wrapper. Also convert nilfs_check_page() to nilfs_check_folio(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 53 +++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 01c57573211e..9e3339123d89 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -107,18 +107,18 @@ static void nilfs_commit_chunk(struct page *page, unlock_page(page); } -static bool nilfs_check_page(struct page *page, char *kaddr) +static bool nilfs_check_folio(struct folio *folio, char *kaddr) { - struct inode *dir = page->mapping->host; + struct inode *dir = folio->mapping->host; struct super_block *sb = dir->i_sb; unsigned int chunk_size = nilfs_chunk_size(dir); - unsigned int offs, rec_len; - unsigned int limit = PAGE_SIZE; + size_t offs, rec_len; + size_t limit = folio_size(folio); struct nilfs_dir_entry *p; char *error; - if ((dir->i_size >> PAGE_SHIFT) == page->index) { - limit = dir->i_size & ~PAGE_MASK; + if (dir->i_size < folio_pos(folio) + limit) { + limit = dir->i_size - folio_pos(folio); if (limit & (chunk_size - 1)) goto Ebadsize; if (!limit) @@ -140,7 +140,7 @@ static bool nilfs_check_page(struct page *page, char *kaddr) if (offs != limit) goto Eend; out: - SetPageChecked(page); + folio_set_checked(folio); return true; /* Too bad, we had an error */ @@ -163,8 +163,8 @@ static bool nilfs_check_page(struct page *page, char *kaddr) error = "directory entry across blocks"; bad_entry: nilfs_error(sb, - "bad entry in directory #%lu: %s - offset=%lu, inode=%lu, rec_len=%d, name_len=%d", - dir->i_ino, error, (page->index << PAGE_SHIFT) + offs, + "bad entry in directory #%lu: %s - offset=%lu, inode=%lu, rec_len=%zd, name_len=%d", + dir->i_ino, error, (folio->index << PAGE_SHIFT) + offs, (unsigned long)le64_to_cpu(p->inode), rec_len, p->name_len); goto fail; @@ -172,37 +172,48 @@ static bool nilfs_check_page(struct page *page, char *kaddr) p = (struct nilfs_dir_entry *)(kaddr + offs); nilfs_error(sb, "entry in directory #%lu spans the page boundary offset=%lu, inode=%lu", - dir->i_ino, (page->index << PAGE_SHIFT) + offs, + dir->i_ino, (folio->index << PAGE_SHIFT) + offs, (unsigned long)le64_to_cpu(p->inode)); fail: - SetPageError(page); + folio_set_error(folio); return false; } -static void *nilfs_get_page(struct inode *dir, unsigned long n, - struct page **pagep) +static void *nilfs_get_folio(struct inode *dir, unsigned long n, + struct folio **foliop) { struct address_space *mapping = dir->i_mapping; - struct page *page = read_mapping_page(mapping, n, NULL); + struct folio *folio = read_mapping_folio(mapping, n, NULL); void *kaddr; - if (IS_ERR(page)) - return page; + if (IS_ERR(folio)) + return folio; - kaddr = kmap_local_page(page); - if (unlikely(!PageChecked(page))) { - if (!nilfs_check_page(page, kaddr)) + kaddr = kmap_local_folio(folio, 0); + if (unlikely(!folio_test_checked(folio))) { + if (!nilfs_check_folio(folio, kaddr)) goto fail; } - *pagep = page; + *foliop = folio; return kaddr; fail: - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); return ERR_PTR(-EIO); } +static void *nilfs_get_page(struct inode *dir, unsigned long n, + struct page **pagep) +{ + struct folio *folio; + void *kaddr = nilfs_get_folio(dir, n, &folio); + + if (!IS_ERR(kaddr)) + *pagep = &folio->page; + return kaddr; +} + /* * NOTE! unlike strncmp, nilfs_match returns 1 for success, 0 for failure. * From patchwork Mon Nov 6 17:38:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447250 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D85202D032 for ; Mon, 6 Nov 2023 17:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gM8/OHfZ" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8B0610F2; Mon, 6 Nov 2023 09:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=TNJtKlru0Tsq6D54odQRez6pWr4z9Ka0jzU4Cn2l/PY=; b=gM8/OHfZhC7LtdJXfue3UijQ1u WlS7ykIXMMvxM3d8kOL0x0YWjNRNfJCmNN6RUYCXdEz3FnDwyMMJYNvnBqsmLsnBaJvSYtxAxhrTd RR7sucnQ5I3uJbqUYJeEJIOOkIgVLaq8WRtt3ChJ6G1IzeUHeC3MPPRzYA952tbBZLRkTFckod0kR yby+5hR7AJgubYamsEl14Vc3YjraMynmH471iuCcZgrsf/n5NnP5mvAMo1AUe2T2kiofmxaul928Q A7EgQ1GCP3qBec0/sb2G40Wzuclg9Ai2dykXDp/Ldg07VxJNbahY3JhCCZS3GONaHj8I+sf37wBQB emIIxCDA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z7-007HAv-Eo; Mon, 06 Nov 2023 17:39:09 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 28/35] nilfs2: Convert nilfs_readdir to use a folio Date: Mon, 6 Nov 2023 17:38:56 +0000 Message-Id: <20231106173903.1734114-29-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new folio APIs to remove calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 9e3339123d89..8d74f1d9bb62 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -284,9 +284,9 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) for ( ; n < npages; n++, offset = 0) { char *kaddr, *limit; struct nilfs_dir_entry *de; - struct page *page; + struct folio *folio; - kaddr = nilfs_get_page(inode, n, &page); + kaddr = nilfs_get_folio(inode, n, &folio); if (IS_ERR(kaddr)) { nilfs_error(sb, "bad page in #%lu", inode->i_ino); ctx->pos += PAGE_SIZE - offset; @@ -298,7 +298,7 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) for ( ; (char *)de <= limit; de = nilfs_next_entry(de)) { if (de->rec_len == 0) { nilfs_error(sb, "zero-length directory entry"); - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); return -EIO; } if (de->inode) { @@ -311,13 +311,13 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) if (!dir_emit(ctx, de->name, de->name_len, le64_to_cpu(de->inode), t)) { - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); return 0; } } ctx->pos += nilfs_rec_len_from_disk(de->rec_len); } - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); } return 0; } From patchwork Mon Nov 6 17:38:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447252 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21CE12D034 for ; Mon, 6 Nov 2023 17:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="o+je91/J" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7C1310F4; Mon, 6 Nov 2023 09:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=/EIk8IFp+MoTx354i8IVq/Foy766pngJB0dETx6s62o=; b=o+je91/JpCT5gq72gWD1t1+JkT IYNv5STaT4nYmnulnYTk0orViCGn8dRMWPujaggmQJeegdHyGYUj0Bt2oVENL59jjUuAZe2XPED1H 4KDv5Bgz7ZYrCeA8WZwAB6RXhu0lR+LWIJPDFwIMmBYirmwzoQlBfo0ZuCDrhWuSzxspMffIytAc5 baKrtP6OviNQDqMlK05slkkr86k9pEAiNLuZoDcPRBvNX4CR56UYWpavwihTbAQMGvCjwz2sGAOaC yfy8EOwMh0k1NmTSI4l5+UyzUvO1G7MChqWw5gKygRQdCQy+wxGfjH9Q6chQiShhNqsGdQv70HlHj C0HOD8Rg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z7-007HB2-IK; Mon, 06 Nov 2023 17:39:09 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 29/35] nilfs2: Convert nilfs_find_entry to use a folio Date: Mon, 6 Nov 2023 17:38:57 +0000 Message-Id: <20231106173903.1734114-30-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the new folio APIs to remove calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 8d74f1d9bb62..9f2a02b71ddc 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -339,7 +339,7 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, unsigned int reclen = NILFS_DIR_REC_LEN(namelen); unsigned long start, n; unsigned long npages = dir_pages(dir); - struct page *page = NULL; + struct folio *folio = NULL; struct nilfs_inode_info *ei = NILFS_I(dir); struct nilfs_dir_entry *de; @@ -354,7 +354,7 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, start = 0; n = start; do { - char *kaddr = nilfs_get_page(dir, n, &page); + char *kaddr = nilfs_get_folio(dir, n, &folio); if (!IS_ERR(kaddr)) { de = (struct nilfs_dir_entry *)kaddr; kaddr += nilfs_last_byte(dir, n) - reclen; @@ -362,18 +362,18 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, if (de->rec_len == 0) { nilfs_error(dir->i_sb, "zero-length directory entry"); - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); goto out; } if (nilfs_match(namelen, name, de)) goto found; de = nilfs_next_entry(de); } - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); } if (++n >= npages) n = 0; - /* next page is past the blocks we've got */ + /* next folio is past the blocks we've got */ if (unlikely(n > (dir->i_blocks >> (PAGE_SHIFT - 9)))) { nilfs_error(dir->i_sb, "dir %lu size %lld exceeds block count %llu", @@ -386,7 +386,7 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, return NULL; found: - *res_page = page; + *res_page = &folio->page; ei->i_dir_start_lookup = n; return de; } From patchwork Mon Nov 6 17:38:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447253 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6709C2C84E for ; Mon, 6 Nov 2023 17:39:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ZxVcI+0P" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1206110FD; Mon, 6 Nov 2023 09:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=1cG286y5GAw2GB25GESmvS8q26knZkjNHGUK8msdP0Y=; b=ZxVcI+0PnEjAtuAatbGZ13Fhaj o+qJ6K6evkwbSXkUrxlbfU++s3HsQwM3ezdlF9O1SmyF3SL6lOTGxSZUO71xclcKie5YsCRp4bycD +3Adt5cyYi2/osQdNHoPxaZ2rr6E44iNT9E1emgqWMmPjTX91k6sx+ycsclynzjRQnz1HSSpt/TbB tlz7aQMbZehpZ05sdcz5bSDDcPRDgfg2Ae7MCsEs6mIZefdWAVVE7wFXEdepyaeqzOhtHi4bGzPwi dcAEbacWuYz1UPWOqMDnonDShC5vzK4Z4E1PkaSQLDYGNkrV4vI3op+fGh7Jsl74DYF0vIXVjydLS e/Slt9tQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z7-007HB9-MH; Mon, 06 Nov 2023 17:39:09 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 30/35] nilfs2: Convert nilfs_rename() to use folios Date: Mon, 6 Nov 2023 17:38:58 +0000 Message-Id: <20231106173903.1734114-31-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This involves converting nilfs_find_entry(), nilfs_dotdot(), nilfs_set_link(), nilfs_delete_entry() and nilfs_do_unlink() to use folios as well. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 74 ++++++++++++++++++++++------------------------- fs/nilfs2/namei.c | 28 +++++++++--------- fs/nilfs2/nilfs.h | 20 ++++++------- 3 files changed, 59 insertions(+), 63 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 9f2a02b71ddc..25a468dda0f3 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -323,38 +323,35 @@ static int nilfs_readdir(struct file *file, struct dir_context *ctx) } /* - * nilfs_find_entry() + * nilfs_find_entry() * - * finds an entry in the specified directory with the wanted name. It - * returns the page in which the entry was found, and the entry itself - * (as a parameter - res_dir). Page is returned mapped and unlocked. - * Entry is guaranteed to be valid. + * Finds an entry in the specified directory with the wanted name. It + * returns the folio in which the entry was found, and the entry itself. + * The folio is mapped and unlocked. When the caller is finished with + * the entry, it should call folio_release_kmap(). + * + * On failure, returns NULL and the caller should ignore foliop. */ -struct nilfs_dir_entry * -nilfs_find_entry(struct inode *dir, const struct qstr *qstr, - struct page **res_page) +struct nilfs_dir_entry *nilfs_find_entry(struct inode *dir, + const struct qstr *qstr, struct folio **foliop) { const unsigned char *name = qstr->name; int namelen = qstr->len; unsigned int reclen = NILFS_DIR_REC_LEN(namelen); unsigned long start, n; unsigned long npages = dir_pages(dir); - struct folio *folio = NULL; struct nilfs_inode_info *ei = NILFS_I(dir); struct nilfs_dir_entry *de; if (npages == 0) goto out; - /* OFFSET_CACHE */ - *res_page = NULL; - start = ei->i_dir_start_lookup; if (start >= npages) start = 0; n = start; do { - char *kaddr = nilfs_get_folio(dir, n, &folio); + char *kaddr = nilfs_get_folio(dir, n, foliop); if (!IS_ERR(kaddr)) { de = (struct nilfs_dir_entry *)kaddr; kaddr += nilfs_last_byte(dir, n) - reclen; @@ -362,14 +359,14 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, if (de->rec_len == 0) { nilfs_error(dir->i_sb, "zero-length directory entry"); - folio_release_kmap(folio, kaddr); + folio_release_kmap(*foliop, kaddr); goto out; } if (nilfs_match(namelen, name, de)) goto found; de = nilfs_next_entry(de); } - folio_release_kmap(folio, kaddr); + folio_release_kmap(*foliop, kaddr); } if (++n >= npages) n = 0; @@ -386,14 +383,13 @@ nilfs_find_entry(struct inode *dir, const struct qstr *qstr, return NULL; found: - *res_page = &folio->page; ei->i_dir_start_lookup = n; return de; } -struct nilfs_dir_entry *nilfs_dotdot(struct inode *dir, struct page **p) +struct nilfs_dir_entry *nilfs_dotdot(struct inode *dir, struct folio **foliop) { - struct nilfs_dir_entry *de = nilfs_get_page(dir, 0, p); + struct nilfs_dir_entry *de = nilfs_get_folio(dir, 0, foliop); if (IS_ERR(de)) return NULL; @@ -404,32 +400,32 @@ ino_t nilfs_inode_by_name(struct inode *dir, const struct qstr *qstr) { ino_t res = 0; struct nilfs_dir_entry *de; - struct page *page; + struct folio *folio; - de = nilfs_find_entry(dir, qstr, &page); + de = nilfs_find_entry(dir, qstr, &folio); if (de) { res = le64_to_cpu(de->inode); - unmap_and_put_page(page, de); + folio_release_kmap(folio, de); } return res; } -/* Releases the page */ +/* Releases the folio */ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, - struct page *page, struct inode *inode) + struct folio *folio, struct inode *inode) { - unsigned int from = offset_in_page(de); - unsigned int to = from + nilfs_rec_len_from_disk(de->rec_len); - struct address_space *mapping = page->mapping; + size_t from = offset_in_folio(folio, de); + size_t to = from + nilfs_rec_len_from_disk(de->rec_len); + struct address_space *mapping = folio->mapping; int err; - lock_page(page); - err = nilfs_prepare_chunk(page, from, to); + folio_lock(folio); + err = nilfs_prepare_chunk(&folio->page, from, to); BUG_ON(err); de->inode = cpu_to_le64(inode->i_ino); nilfs_set_de_type(de, inode); - nilfs_commit_chunk(page, mapping, from, to); - unmap_and_put_page(page, de); + nilfs_commit_chunk(&folio->page, mapping, from, to); + folio_release_kmap(folio, de); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); } @@ -533,14 +529,14 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) /* * nilfs_delete_entry deletes a directory entry by merging it with the - * previous entry. Page is up-to-date. Releases the page. + * previous entry. Folio is up-to-date. Releases the folio. */ -int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page) +int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct folio *folio) { - struct address_space *mapping = page->mapping; + struct address_space *mapping = folio->mapping; struct inode *inode = mapping->host; - char *kaddr = (char *)((unsigned long)dir & PAGE_MASK); - unsigned int from, to; + char *kaddr = (char *)((unsigned long)dir & ~(folio_size(folio) - 1)); + size_t from, to; struct nilfs_dir_entry *de, *pde = NULL; int err; @@ -560,16 +556,16 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct page *page) } if (pde) from = (char *)pde - kaddr; - lock_page(page); - err = nilfs_prepare_chunk(page, from, to); + folio_lock(folio); + err = nilfs_prepare_chunk(&folio->page, from, to); BUG_ON(err); if (pde) pde->rec_len = nilfs_rec_len_to_disk(to - from); dir->inode = 0; - nilfs_commit_chunk(page, mapping, from, to); + nilfs_commit_chunk(&folio->page, mapping, from, to); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); out: - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); return err; } diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index 8eebd8a464d8..d9d23f3cc4d7 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -260,11 +260,11 @@ static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry) { struct inode *inode; struct nilfs_dir_entry *de; - struct page *page; + struct folio *folio; int err; err = -ENOENT; - de = nilfs_find_entry(dir, &dentry->d_name, &page); + de = nilfs_find_entry(dir, &dentry->d_name, &folio); if (!de) goto out; @@ -279,7 +279,7 @@ static int nilfs_do_unlink(struct inode *dir, struct dentry *dentry) inode->i_ino, inode->i_nlink); set_nlink(inode, 1); } - err = nilfs_delete_entry(de, page); + err = nilfs_delete_entry(de, folio); if (err) goto out; @@ -347,9 +347,9 @@ static int nilfs_rename(struct mnt_idmap *idmap, { struct inode *old_inode = d_inode(old_dentry); struct inode *new_inode = d_inode(new_dentry); - struct page *dir_page = NULL; + struct folio *dir_folio = NULL; struct nilfs_dir_entry *dir_de = NULL; - struct page *old_page; + struct folio *old_folio; struct nilfs_dir_entry *old_de; struct nilfs_transaction_info ti; int err; @@ -362,19 +362,19 @@ static int nilfs_rename(struct mnt_idmap *idmap, return err; err = -ENOENT; - old_de = nilfs_find_entry(old_dir, &old_dentry->d_name, &old_page); + old_de = nilfs_find_entry(old_dir, &old_dentry->d_name, &old_folio); if (!old_de) goto out; if (S_ISDIR(old_inode->i_mode)) { err = -EIO; - dir_de = nilfs_dotdot(old_inode, &dir_page); + dir_de = nilfs_dotdot(old_inode, &dir_folio); if (!dir_de) goto out_old; } if (new_inode) { - struct page *new_page; + struct folio *new_folio; struct nilfs_dir_entry *new_de; err = -ENOTEMPTY; @@ -382,10 +382,10 @@ static int nilfs_rename(struct mnt_idmap *idmap, goto out_dir; err = -ENOENT; - new_de = nilfs_find_entry(new_dir, &new_dentry->d_name, &new_page); + new_de = nilfs_find_entry(new_dir, &new_dentry->d_name, &new_folio); if (!new_de) goto out_dir; - nilfs_set_link(new_dir, new_de, new_page, old_inode); + nilfs_set_link(new_dir, new_de, new_folio, old_inode); nilfs_mark_inode_dirty(new_dir); inode_set_ctime_current(new_inode); if (dir_de) @@ -408,10 +408,10 @@ static int nilfs_rename(struct mnt_idmap *idmap, */ inode_set_ctime_current(old_inode); - nilfs_delete_entry(old_de, old_page); + nilfs_delete_entry(old_de, old_folio); if (dir_de) { - nilfs_set_link(old_inode, dir_de, dir_page, new_dir); + nilfs_set_link(old_inode, dir_de, dir_folio, new_dir); drop_nlink(old_dir); } nilfs_mark_inode_dirty(old_dir); @@ -422,9 +422,9 @@ static int nilfs_rename(struct mnt_idmap *idmap, out_dir: if (dir_de) - unmap_and_put_page(dir_page, dir_de); + folio_release_kmap(dir_folio, dir_de); out_old: - unmap_and_put_page(old_page, old_de); + folio_release_kmap(old_folio, old_de); out: nilfs_transaction_abort(old_dir->i_sb); return err; diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index 8046490cd7fe..98cffaf0ac12 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h @@ -226,16 +226,16 @@ static inline __u32 nilfs_mask_flags(umode_t mode, __u32 flags) } /* dir.c */ -extern int nilfs_add_link(struct dentry *, struct inode *); -extern ino_t nilfs_inode_by_name(struct inode *, const struct qstr *); -extern int nilfs_make_empty(struct inode *, struct inode *); -extern struct nilfs_dir_entry * -nilfs_find_entry(struct inode *, const struct qstr *, struct page **); -extern int nilfs_delete_entry(struct nilfs_dir_entry *, struct page *); -extern int nilfs_empty_dir(struct inode *); -extern struct nilfs_dir_entry *nilfs_dotdot(struct inode *, struct page **); -extern void nilfs_set_link(struct inode *, struct nilfs_dir_entry *, - struct page *, struct inode *); +int nilfs_add_link(struct dentry *, struct inode *); +ino_t nilfs_inode_by_name(struct inode *, const struct qstr *); +int nilfs_make_empty(struct inode *, struct inode *); +struct nilfs_dir_entry *nilfs_find_entry(struct inode *, const struct qstr *, + struct folio **); +int nilfs_delete_entry(struct nilfs_dir_entry *, struct folio *); +int nilfs_empty_dir(struct inode *); +struct nilfs_dir_entry *nilfs_dotdot(struct inode *, struct folio **); +void nilfs_set_link(struct inode *, struct nilfs_dir_entry *, + struct folio *, struct inode *); /* file.c */ extern int nilfs_sync_file(struct file *, loff_t, loff_t, int); From patchwork Mon Nov 6 17:38:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447254 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82E1E29D03 for ; Mon, 6 Nov 2023 17:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="OC2PMPFj" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06F4910F8; Mon, 6 Nov 2023 09:39:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=vaMf6+ceFAF1BP5HFmDPS10ulzb64i/FkHesSTm9xno=; b=OC2PMPFjVpVlg2EfhoYkqMwOzP OJGvz8ttxlR23/WD8Wq/wVVEILmEv9i/P9cOgBXBMXg0XatwJUpoY3Yl0YnHZeyHqluQezk9PVz8x FdZsLzmHquhwKbmSOOeJ/XtcCu37k6mT9ekWbNXJovs94HhnkV1d9ThQVF2261AN1TwG+ndu2mUhC 8p0KaAOsdFPaGsCO6k3YqOCCscQfuy2fp385HVt+gG32GwAeYVdKiyPuycNfYpBpnyi0I0aoun0NS Rqlabd6NsZ/FhHPLksN9KLXW0PGQ9g3pD1o7Z1ddiODzI245vO/mcEwLmsLKeeCPcfyz5U7V7jwS2 V+RppHYw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z7-007HBG-Qw; Mon, 06 Nov 2023 17:39:09 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 31/35] nilfs2: Convert nilfs_add_link() to use a folio Date: Mon, 6 Nov 2023 17:38:59 +0000 Message-Id: <20231106173903.1734114-32-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove six calls to compound_head() by using the folio API. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 25a468dda0f3..fd4f99a7f402 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -440,30 +440,28 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) unsigned int chunk_size = nilfs_chunk_size(dir); unsigned int reclen = NILFS_DIR_REC_LEN(namelen); unsigned short rec_len, name_len; - struct page *page = NULL; + struct folio *folio = NULL; struct nilfs_dir_entry *de; unsigned long npages = dir_pages(dir); unsigned long n; - char *kaddr; - unsigned int from, to; + size_t from, to; int err; /* * We take care of directory expansion in the same loop. - * This code plays outside i_size, so it locks the page + * This code plays outside i_size, so it locks the folio * to protect that region. */ for (n = 0; n <= npages; n++) { + char *kaddr = nilfs_get_folio(dir, n, &folio); char *dir_end; - kaddr = nilfs_get_page(dir, n, &page); - err = PTR_ERR(kaddr); if (IS_ERR(kaddr)) - goto out; - lock_page(page); + return PTR_ERR(kaddr); + folio_lock(folio); dir_end = kaddr + nilfs_last_byte(dir, n); de = (struct nilfs_dir_entry *)kaddr; - kaddr += PAGE_SIZE - reclen; + kaddr += folio_size(folio) - reclen; while ((char *)de <= kaddr) { if ((char *)de == dir_end) { /* We hit i_size */ @@ -490,16 +488,16 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) goto got_it; de = (struct nilfs_dir_entry *)((char *)de + rec_len); } - unlock_page(page); - unmap_and_put_page(page, kaddr); + folio_unlock(folio); + folio_release_kmap(folio, kaddr); } BUG(); return -EINVAL; got_it: - from = offset_in_page(de); + from = offset_in_folio(folio, de); to = from + rec_len; - err = nilfs_prepare_chunk(page, from, to); + err = nilfs_prepare_chunk(&folio->page, from, to); if (err) goto out_unlock; if (de->inode) { @@ -514,16 +512,15 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) memcpy(de->name, name, namelen); de->inode = cpu_to_le64(inode->i_ino); nilfs_set_de_type(de, inode); - nilfs_commit_chunk(page, page->mapping, from, to); + nilfs_commit_chunk(&folio->page, folio->mapping, from, to); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); nilfs_mark_inode_dirty(dir); /* OFFSET_CACHE */ out_put: - unmap_and_put_page(page, de); -out: + folio_release_kmap(folio, de); return err; out_unlock: - unlock_page(page); + folio_unlock(folio); goto out_put; } From patchwork Mon Nov 6 17:39:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447246 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BA772D04A for ; Mon, 6 Nov 2023 17:39:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="d4ti3kBf" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11CDB10FB; Mon, 6 Nov 2023 09:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=4uhZUS0AdWumlXemxYuWKBzovY188acPLOiZKj6oePo=; b=d4ti3kBfS7MwI5eFQEiHq5/2ok Z/YhG8QJ2Vo3ym7Gw7cAyS9s6Mv2xFuOsmP1K6rS3PYm8lVoNCTMUOZSk2ggqXn5l+G4uR+QiQ1Yx bRZnEhWXedopHqc47YjwNGlYS+DalD17IaIINVKeTOum4BSz1N9kEBICLb0tWD8RMWuiKX7mj5prj 9KBn0E5xmEwtrX2IiXfXt+7PPVDYcxZbS7qIR2Jzy0utzk9k8tHKLmLXps0bCCCJS05k1hregmoMr CGS03P9eXP+3cNr5JHEljl94Pg5F1aPJ1q0mov0Wmtqlys5IaUXH7QWjyijeKtNokdzFv12V/0xd7 T/uyWzoA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z8-007HBP-0W; Mon, 06 Nov 2023 17:39:10 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 32/35] nilfs2: Convert nilfs_empty_dir() to use a folio Date: Mon, 6 Nov 2023 17:39:00 +0000 Message-Id: <20231106173903.1734114-33-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove three calls to compound_head() by using the folio API. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index fd4f99a7f402..e598431516fc 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -203,17 +203,6 @@ static void *nilfs_get_folio(struct inode *dir, unsigned long n, return ERR_PTR(-EIO); } -static void *nilfs_get_page(struct inode *dir, unsigned long n, - struct page **pagep) -{ - struct folio *folio; - void *kaddr = nilfs_get_folio(dir, n, &folio); - - if (!IS_ERR(kaddr)) - *pagep = &folio->page; - return kaddr; -} - /* * NOTE! unlike strncmp, nilfs_match returns 1 for success, 0 for failure. * @@ -613,14 +602,14 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent) */ int nilfs_empty_dir(struct inode *inode) { - struct page *page = NULL; + struct folio *folio = NULL; char *kaddr; unsigned long i, npages = dir_pages(inode); for (i = 0; i < npages; i++) { struct nilfs_dir_entry *de; - kaddr = nilfs_get_page(inode, i, &page); + kaddr = nilfs_get_folio(inode, i, &folio); if (IS_ERR(kaddr)) continue; @@ -649,12 +638,12 @@ int nilfs_empty_dir(struct inode *inode) } de = nilfs_next_entry(de); } - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); } return 1; not_empty: - unmap_and_put_page(page, kaddr); + folio_release_kmap(folio, kaddr); return 0; } From patchwork Mon Nov 6 17:39:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447247 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95FBF2D04B for ; Mon, 6 Nov 2023 17:39:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="CHON0uSQ" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11EEB10FC; Mon, 6 Nov 2023 09:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=FlLbEVf0PN4kX7ByTNMKLyW2/z0i6E9D6N10cj5kGFU=; b=CHON0uSQvxnKZ31wwV5oToeTyz lnyVoG2tfrzTZTHqNEp4kWmm6LkYGiLI9SCJTzl5Df/Fd7SlrLvekWmnMSu9JOmh3h0Q9KVs1GVyb AeALwf/2hqKXEa7eP+IeujASdkVZmDD7ZfdhfIS5QKszUVyVPp7G6jXTnSEPFlJh0LkPPJMvyh5XZ vHO/p5WrfYwuJA7JDD3REGM6VKcPW6GOHW9JIPlfwgNHmWkdA4o1gsKV5IcDVexARgHGKutDDBwax 8E/m53kB6wGSHwYMiYxSOhkot8080U/WRm0K5LkIPe83fyLDDjAjiq5s8XorF64OG2N2YU+tE11eO tWa36Rlw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z8-007HBZ-5A; Mon, 06 Nov 2023 17:39:10 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 33/35] nilfs2: Convert nilfs_make_empty() to use a folio Date: Mon, 6 Nov 2023 17:39:01 +0000 Message-Id: <20231106173903.1734114-34-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove two calls to compound_head() and switch from kmap_atomic to kmap_local. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index e598431516fc..1085e9a5b84e 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -561,21 +561,21 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct folio *folio) int nilfs_make_empty(struct inode *inode, struct inode *parent) { struct address_space *mapping = inode->i_mapping; - struct page *page = grab_cache_page(mapping, 0); + struct folio *folio = filemap_grab_folio(mapping, 0); unsigned int chunk_size = nilfs_chunk_size(inode); struct nilfs_dir_entry *de; int err; void *kaddr; - if (!page) - return -ENOMEM; + if (IS_ERR(folio)) + return PTR_ERR(folio); - err = nilfs_prepare_chunk(page, 0, chunk_size); + err = nilfs_prepare_chunk(&folio->page, 0, chunk_size); if (unlikely(err)) { - unlock_page(page); + folio_unlock(folio); goto fail; } - kaddr = kmap_atomic(page); + kaddr = kmap_local_folio(folio, 0); memset(kaddr, 0, chunk_size); de = (struct nilfs_dir_entry *)kaddr; de->name_len = 1; @@ -590,10 +590,10 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent) de->inode = cpu_to_le64(parent->i_ino); memcpy(de->name, "..\0", 4); nilfs_set_de_type(de, inode); - kunmap_atomic(kaddr); - nilfs_commit_chunk(page, mapping, 0, chunk_size); + kunmap_local(kaddr); + nilfs_commit_chunk(&folio->page, mapping, 0, chunk_size); fail: - put_page(page); + folio_put(folio); return err; } From patchwork Mon Nov 6 17:39:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447240 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B57332D041 for ; Mon, 6 Nov 2023 17:39:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="WPjoA4r6" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45F1910FE; Mon, 6 Nov 2023 09:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ht1nE6SouNNqW2kjQ+aS4bAvHBgYKtkA+uUBcsC3lgw=; b=WPjoA4r6xy94/HOVUz9sXCuuOc xKiM2twJemtPbuMis8G/VqHLeuGluz7116x0FE1DAhQCKo4wGY/YKS6mBpyye88ZqNNuAmjeSU9iK ErzY2sT+/BPZTugNAeLueLzCcC4YQs5C+/KG3hQhK4yd3Q3ZmsEaVM91+U9BhjykjJGBmt0zbZIWH FepRR7iRB9EnFbFDGKFCpBMYa/30UN4NthpL457EVzD3uPq2OKgEO3fkYfFq4RsakFWoKqt3gs7Zz hfCHFDa9KNKbLFeAU1/Glal7LJNQr1nAL8ECkuMAqcN4Wb37cJhhQcVSC063ovP+mdN/0KzR5Fvuv a+yyZ0eQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z8-007HBh-8U; Mon, 06 Nov 2023 17:39:10 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 34/35] nilfs2: Convert nilfs_prepare_chunk() and nilfs_commit_chunk() to folios Date: Mon, 6 Nov 2023 17:39:02 +0000 Message-Id: <20231106173903.1734114-35-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All callers now have a folio, so convert these two functions. Saves one call to compound_head() in unlock_page(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/dir.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c index 1085e9a5b84e..85db5772795b 100644 --- a/fs/nilfs2/dir.c +++ b/fs/nilfs2/dir.c @@ -78,33 +78,32 @@ static unsigned int nilfs_last_byte(struct inode *inode, unsigned long page_nr) return last_byte; } -static int nilfs_prepare_chunk(struct page *page, unsigned int from, +static int nilfs_prepare_chunk(struct folio *folio, unsigned int from, unsigned int to) { - loff_t pos = page_offset(page) + from; + loff_t pos = folio_pos(folio) + from; - return __block_write_begin(page, pos, to - from, nilfs_get_block); + return __block_write_begin(&folio->page, pos, to - from, nilfs_get_block); } -static void nilfs_commit_chunk(struct page *page, - struct address_space *mapping, - unsigned int from, unsigned int to) +static void nilfs_commit_chunk(struct folio *folio, + struct address_space *mapping, size_t from, size_t to) { struct inode *dir = mapping->host; - loff_t pos = page_offset(page) + from; - unsigned int len = to - from; - unsigned int nr_dirty, copied; + loff_t pos = folio_pos(folio) + from; + size_t copied, len = to - from; + unsigned int nr_dirty; int err; - nr_dirty = nilfs_page_count_clean_buffers(page, from, to); - copied = block_write_end(NULL, mapping, pos, len, len, page, NULL); + nr_dirty = nilfs_page_count_clean_buffers(&folio->page, from, to); + copied = block_write_end(NULL, mapping, pos, len, len, &folio->page, NULL); if (pos + copied > dir->i_size) i_size_write(dir, pos + copied); if (IS_DIRSYNC(dir)) nilfs_set_transaction_flag(NILFS_TI_SYNC); err = nilfs_set_file_dirty(dir, nr_dirty); WARN_ON(err); /* do not happen */ - unlock_page(page); + folio_unlock(folio); } static bool nilfs_check_folio(struct folio *folio, char *kaddr) @@ -409,11 +408,11 @@ void nilfs_set_link(struct inode *dir, struct nilfs_dir_entry *de, int err; folio_lock(folio); - err = nilfs_prepare_chunk(&folio->page, from, to); + err = nilfs_prepare_chunk(folio, from, to); BUG_ON(err); de->inode = cpu_to_le64(inode->i_ino); nilfs_set_de_type(de, inode); - nilfs_commit_chunk(&folio->page, mapping, from, to); + nilfs_commit_chunk(folio, mapping, from, to); folio_release_kmap(folio, de); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); } @@ -486,7 +485,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) got_it: from = offset_in_folio(folio, de); to = from + rec_len; - err = nilfs_prepare_chunk(&folio->page, from, to); + err = nilfs_prepare_chunk(folio, from, to); if (err) goto out_unlock; if (de->inode) { @@ -501,7 +500,7 @@ int nilfs_add_link(struct dentry *dentry, struct inode *inode) memcpy(de->name, name, namelen); de->inode = cpu_to_le64(inode->i_ino); nilfs_set_de_type(de, inode); - nilfs_commit_chunk(&folio->page, folio->mapping, from, to); + nilfs_commit_chunk(folio, folio->mapping, from, to); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); nilfs_mark_inode_dirty(dir); /* OFFSET_CACHE */ @@ -543,12 +542,12 @@ int nilfs_delete_entry(struct nilfs_dir_entry *dir, struct folio *folio) if (pde) from = (char *)pde - kaddr; folio_lock(folio); - err = nilfs_prepare_chunk(&folio->page, from, to); + err = nilfs_prepare_chunk(folio, from, to); BUG_ON(err); if (pde) pde->rec_len = nilfs_rec_len_to_disk(to - from); dir->inode = 0; - nilfs_commit_chunk(&folio->page, mapping, from, to); + nilfs_commit_chunk(folio, mapping, from, to); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); out: folio_release_kmap(folio, kaddr); @@ -570,7 +569,7 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent) if (IS_ERR(folio)) return PTR_ERR(folio); - err = nilfs_prepare_chunk(&folio->page, 0, chunk_size); + err = nilfs_prepare_chunk(folio, 0, chunk_size); if (unlikely(err)) { folio_unlock(folio); goto fail; @@ -591,7 +590,7 @@ int nilfs_make_empty(struct inode *inode, struct inode *parent) memcpy(de->name, "..\0", 4); nilfs_set_de_type(de, inode); kunmap_local(kaddr); - nilfs_commit_chunk(&folio->page, mapping, 0, chunk_size); + nilfs_commit_chunk(folio, mapping, 0, chunk_size); fail: folio_put(folio); return err; From patchwork Mon Nov 6 17:39:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13447249 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 418262D048 for ; Mon, 6 Nov 2023 17:39:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="lyFuy+ho" Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 465F210FF; Mon, 6 Nov 2023 09:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=cufnaJg2QOsF32aUmx1UzAxRfZEwQNwO4xqmARoWL4c=; b=lyFuy+hoVsJbum6wnUyMQpqxTD pHS3cU3eS0SUmBBDZoh84G7wdCGQ06zOB335xd7+csdxan/Lx2WA84sGR59ev3Iec+olEF5IKG9KH Xm+JUZ97xVb6v67z/OolbRuGpPF1BZQXGHxAcwIJh+9tfT9bxjhuMinZ+u12f006TVhuKIjjXFpTI +jMjt+vWw1NVQap2+T7UZ2QZOQL44ngwRHiAmk8Z2aciCKF5oST0cqiJ5B6VZKcp79trgNrMTvLoI ex5/BUTSK2uOXagmbEHEIudDcIUgPwdICsdNUKjW4FNu5fqQrkA56nNi4MFRH1+xr5B/w3ZMb2ZMP 9foRsb+w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r03Z8-007HBn-CY; Mon, 06 Nov 2023 17:39:10 +0000 From: "Matthew Wilcox (Oracle)" To: Ryusuke Konishi Cc: "Matthew Wilcox (Oracle)" , linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 35/35] nilfs2: Convert nilfs_page_bug() to nilfs_folio_bug() Date: Mon, 6 Nov 2023 17:39:03 +0000 Message-Id: <20231106173903.1734114-36-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231106173903.1734114-1-willy@infradead.org> References: <20231106173903.1734114-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All callers have a folio now, so convert it. Signed-off-by: Matthew Wilcox (Oracle) --- fs/nilfs2/btnode.c | 4 ++-- fs/nilfs2/page.c | 25 +++++++++++++------------ fs/nilfs2/page.h | 6 +++--- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index 1204dd06ead8..0131d83b912d 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c @@ -190,7 +190,7 @@ int nilfs_btnode_prepare_change_key(struct address_space *btnc, retry: /* BUG_ON(oldkey != obh->b_folio->index); */ if (unlikely(oldkey != ofolio->index)) - NILFS_PAGE_BUG(&ofolio->page, + NILFS_FOLIO_BUG(ofolio, "invalid oldkey %lld (newkey=%lld)", (unsigned long long)oldkey, (unsigned long long)newkey); @@ -246,7 +246,7 @@ void nilfs_btnode_commit_change_key(struct address_space *btnc, if (nbh == NULL) { /* blocksize == pagesize */ ofolio = obh->b_folio; if (unlikely(oldkey != ofolio->index)) - NILFS_PAGE_BUG(&ofolio->page, + NILFS_FOLIO_BUG(ofolio, "invalid oldkey %lld (newkey=%lld)", (unsigned long long)oldkey, (unsigned long long)newkey); diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c index 94e11bcee05b..5c2eba1987bd 100644 --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -150,29 +150,30 @@ bool nilfs_folio_buffers_clean(struct folio *folio) return true; } -void nilfs_page_bug(struct page *page) +void nilfs_folio_bug(struct folio *folio) { + struct buffer_head *bh, *head; struct address_space *m; unsigned long ino; - if (unlikely(!page)) { - printk(KERN_CRIT "NILFS_PAGE_BUG(NULL)\n"); + if (unlikely(!folio)) { + printk(KERN_CRIT "NILFS_FOLIO_BUG(NULL)\n"); return; } - m = page->mapping; + m = folio->mapping; ino = m ? m->host->i_ino : 0; - printk(KERN_CRIT "NILFS_PAGE_BUG(%p): cnt=%d index#=%llu flags=0x%lx " + printk(KERN_CRIT "NILFS_FOLIO_BUG(%p): cnt=%d index#=%llu flags=0x%lx " "mapping=%p ino=%lu\n", - page, page_ref_count(page), - (unsigned long long)page->index, page->flags, m, ino); + folio, folio_ref_count(folio), + (unsigned long long)folio->index, folio->flags, m, ino); - if (page_has_buffers(page)) { - struct buffer_head *bh, *head; + head = folio_buffers(folio); + if (head) { int i = 0; - bh = head = page_buffers(page); + bh = head; do { printk(KERN_CRIT " BH[%d] %p: cnt=%d block#=%llu state=0x%lx\n", @@ -258,7 +259,7 @@ int nilfs_copy_dirty_pages(struct address_space *dmap, folio_lock(folio); if (unlikely(!folio_test_dirty(folio))) - NILFS_PAGE_BUG(&folio->page, "inconsistent dirty state"); + NILFS_FOLIO_BUG(folio, "inconsistent dirty state"); dfolio = filemap_grab_folio(dmap, folio->index); if (unlikely(IS_ERR(dfolio))) { @@ -268,7 +269,7 @@ int nilfs_copy_dirty_pages(struct address_space *dmap, break; } if (unlikely(!folio_buffers(folio))) - NILFS_PAGE_BUG(&folio->page, + NILFS_FOLIO_BUG(folio, "found empty page in dat page cache"); nilfs_copy_folio(dfolio, folio, true); diff --git a/fs/nilfs2/page.h b/fs/nilfs2/page.h index 968b311d265b..7e1a2c455a10 100644 --- a/fs/nilfs2/page.h +++ b/fs/nilfs2/page.h @@ -37,7 +37,7 @@ struct buffer_head *nilfs_grab_buffer(struct inode *, struct address_space *, void nilfs_forget_buffer(struct buffer_head *); void nilfs_copy_buffer(struct buffer_head *, struct buffer_head *); bool nilfs_folio_buffers_clean(struct folio *); -void nilfs_page_bug(struct page *); +void nilfs_folio_bug(struct folio *); int nilfs_copy_dirty_pages(struct address_space *, struct address_space *); void nilfs_copy_back_pages(struct address_space *, struct address_space *); @@ -49,7 +49,7 @@ unsigned long nilfs_find_uncommitted_extent(struct inode *inode, sector_t start_blk, sector_t *blkoff); -#define NILFS_PAGE_BUG(page, m, a...) \ - do { nilfs_page_bug(page); BUG(); } while (0) +#define NILFS_FOLIO_BUG(folio, m, a...) \ + do { nilfs_folio_bug(folio); BUG(); } while (0) #endif /* _NILFS_PAGE_H */