From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38BCCC7EE22 for ; Wed, 17 May 2023 03:25:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232076AbjEQDZH (ORCPT ); Tue, 16 May 2023 23:25:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232307AbjEQDY7 (ORCPT ); Tue, 16 May 2023 23:24:59 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C3E3213D for ; Tue, 16 May 2023 20:24:58 -0700 (PDT) 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=AbeZXSrkUqRDuI65kyPYYuObwRGdx2E78FHWlBXfCH4=; b=mBHptnEcNvYNLwI9ydb/p10XxW XDkShpCJ8Gfe687sKd96Yl9ITHLTEuaNrk023aV5jza3fVqEpreonjmt2fMGurIin4aMsjB68Q8Zy LNzQGq89NRTFWZBy3SUsqap0nzBjAY6JF1ikEh6w37SUwLC6G3T4aqgoQ+IIV9CLofqj4akXmznVM b+hI+YaM1fj9il2UXpc9M4W7C5d0na31DZLEU1r5OyUX3ozFSSzzhfIszAvMV5CfLHKgG1j3XgrhH w84bYQXUFUdAqnW3XBr0DUBHP1kwg5+gzjby85OOLdOKMDg5SfjZKccWcFDAmhr8mFyWeu7+6UhQ8 BQ63G4Ig==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pz7mO-004lNE-3m; Wed, 17 May 2023 03:24:44 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Bob Peterson , Andreas Gruenbacher , cluster-devel@redhat.com, Hannes Reinecke , Luis Chamberlain Subject: [PATCH 6/6] buffer: Make block_write_full_page() handle large folios correctly Date: Wed, 17 May 2023 04:24:42 +0100 Message-Id: <20230517032442.1135379-7-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230517032442.1135379-1-willy@infradead.org> References: <20230517032442.1135379-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Keep the interface as struct page, but work entirely on the folio internally. Removes several PAGE_SIZE assumptions and removes some references to page->index and page->mapping. Signed-off-by: Matthew Wilcox (Oracle) --- fs/buffer.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 4d518df50fab..d8c2c000676b 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2678,33 +2678,31 @@ int block_write_full_page(struct page *page, get_block_t *get_block, struct writeback_control *wbc) { struct folio *folio = page_folio(page); - struct inode * const inode = page->mapping->host; + struct inode * const inode = folio->mapping->host; loff_t i_size = i_size_read(inode); - const pgoff_t end_index = i_size >> PAGE_SHIFT; - unsigned offset; - /* Is the page fully inside i_size? */ - if (page->index < end_index) + /* Is the folio fully inside i_size? */ + if (folio_pos(folio) + folio_size(folio) <= i_size) return __block_write_full_folio(inode, folio, get_block, wbc, end_buffer_async_write); - /* Is the page fully outside i_size? (truncate in progress) */ - offset = i_size & (PAGE_SIZE-1); - if (page->index >= end_index+1 || !offset) { + /* Is the folio fully outside i_size? (truncate in progress) */ + if (folio_pos(folio) > i_size) { folio_unlock(folio); return 0; /* don't care */ } /* - * The page straddles i_size. It must be zeroed out on each and every + * The folio straddles i_size. It must be zeroed out on each and every * writepage invocation because it may be mmapped. "A file is mapped * in multiples of the page size. For a file that is not a multiple of - * the page size, the remaining memory is zeroed when mapped, and + * the page size, the remaining memory is zeroed when mapped, and * writes to that region are not written out to the file." */ - zero_user_segment(page, offset, PAGE_SIZE); + folio_zero_segment(folio, offset_in_folio(folio, i_size), + folio_size(folio)); return __block_write_full_folio(inode, folio, get_block, wbc, - end_buffer_async_write); + end_buffer_async_write); } EXPORT_SYMBOL(block_write_full_page); -- 2.39.2