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 C1E95C77B73 for ; Sun, 4 Jun 2023 03:35:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229563AbjFDDfl (ORCPT ); Sat, 3 Jun 2023 23:35:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjFDDfk (ORCPT ); Sat, 3 Jun 2023 23:35:40 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4784ADA for ; Sat, 3 Jun 2023 20:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CcaX1YqTccJ2pm/jjC3O01CP48RRVQ+VTKTRem2EehI=; b=TwFMSGTU6MLMTpcvIpMUV+kK0N iATUFXml3FjyXJxY9zcofua0V/tim3VfK7QW0rSO8BvbqQsjnVrCegk89TcL+nDYbvjR4gQqfVkd7 /QmYWm7GYnV6YfLc9w5fiZfodDyBuYcBRp5hoTqK4EkqAwVbUK8lMLIteHtKapyrY0KW6EI669r0t ho38/+XleX60H6lpf6vkfZgBccBmSSWMEkDvDuwsV3rePRHfFZEmlnRGqb8ExEx3Jp2mqzrOESqYd 5uQ+1VZ3vQhasEB5fMoJPR0VqqbMpIvqpH6+oaJOsiWB4pC1Zmv6FWS3D9S+JDGh9zLBdrn7MpUif aTLpvKGg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1q5eWk-00Ahrt-Dz; Sun, 04 Jun 2023 03:35:34 +0000 Date: Sun, 4 Jun 2023 04:35:34 +0100 From: Matthew Wilcox To: Andreas Gruenbacher Cc: linux-fsdevel , Andrew Morton , Bob Peterson , cluster-devel , Hannes Reinecke , Luis Chamberlain Subject: Re: [PATCH 3/6] gfs2: Convert gfs2_write_jdata_page() to gfs2_write_jdata_folio() Message-ID: References: <20230517032442.1135379-1-willy@infradead.org> <20230517032442.1135379-4-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Sat, Jun 03, 2023 at 11:34:14AM +0200, Andreas Gruenbacher wrote: > > * This is the same as calling block_write_full_page, but it also > > * writes pages outside of i_size > > */ > > -static int gfs2_write_jdata_page(struct page *page, > > +static int gfs2_write_jdata_folio(struct folio *folio, > > struct writeback_control *wbc) > > { > > - 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; > > > > + if (folio_pos(folio) >= i_size) > > + return 0; > > Function gfs2_write_jdata_page was originally introduced as > gfs2_write_full_page in commit fd4c5748b8d3 ("gfs2: writeout truncated > pages") to allow writing pages even when they are beyond EOF, as the > function description documents. Well, that was stupid of me. > This hack was added because simply skipping journaled pages isn't > enough on gfs2; before a journaled page can be freed, it needs to be > marked as "revoked" in the journal. Journal recovery will then skip > the revoked blocks, which allows them to be reused for regular, > non-journaled data. We can end up here in contexts in which we cannot > "revoke" pages, so instead, we write the original pages even when they > are beyond EOF. This hack could be revisited, but it's pretty nasty > code to pick apart. > > So at least the above if needs to go for now. Understood. So we probably don't want to waste time zeroing the folio if it is entirely beyond i_size, right? Because at the moment we'd zero some essentially random part of the folio if I just take out the check. Should it look like this? if (folio_pos(folio) < i_size && i_size < folio_pos(folio) + folio_size(folio)) folio_zero_segment(folio, offset_in_folio(folio, i_size), folio_size(folio));