Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp137987pxa; Fri, 21 Aug 2020 03:29:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjl2izv12kVkKv+u/tylqOYT8T6s9GDyW4oWpJ/+glyjmob7fqG3cVTAgWOm1ycbe1kRpl X-Received: by 2002:a17:906:fb07:: with SMTP id lz7mr2140149ejb.49.1598005758116; Fri, 21 Aug 2020 03:29:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598005758; cv=none; d=google.com; s=arc-20160816; b=WWfj/QrprksTbfOlj1d3iBGbWPR6CgSmtfcu8G8S0XADh6wMvLrarWGlU+iFd1Ritv 9L371g1TDpiIy/9+TdDzOhqK39DjtIis6mdBiVI8LfKb0+R/GoHs0ad+Pn4dEKR3nSKn WR5tEEpS3hvV/V0Xs429Q5Hx1Srhi2kL3LgiltRGuEsM7aUVuFBdnOXqk0qykBKlXU7o nJHvsO6fuqjMsKI51GKdYMIWQyzfdY8nnRmhywdBWPPghFKzfvUs2BXCIengivVXJd1d oUiGjMWnDVI2v7rniJWHpLEM3TutYJ8AcUz35twjBYkLXoUTeXpDaoOP8494gPl/ODXW RHMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=awMu722WYacs4DV80Al6cFF4novzhbJK0dSj1bqIv1k=; b=vkSzZUj36Fy83ZiOQzU5EkjB4MvFsWo9NeNX1+ixvF4UG1lk18VtA+Ck5sTwIgTC0i 2EX8PAQTqywHPmAk0/DPJFFkhUwis0qSI1hlsQOuU3q6SZM24oSpfjYpopzahdC4TsQi TiHrFanCgb7l1PxP+lSSooYw0kNgjiaobLRnwll+neA/dj9dpnzd2YizbETcTtdjkURW aJJr8nIlJ+GGxKdJm1QYuGWf+tdGe2OTqkTUpFPzmUI1SyMQMQm6iQnnTwOikq+XCMP2 vM8Ua/o/0JCj2Br3sE7Fsl3pSDYD9WH+nVia+DXMo6mId7ZBHkde3FLFw2PCfX2X5P29 apwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si902655eds.427.2020.08.21.03.28.40; Fri, 21 Aug 2020 03:29:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728372AbgHUK0b (ORCPT + 99 others); Fri, 21 Aug 2020 06:26:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:57798 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728442AbgHUK01 (ORCPT ); Fri, 21 Aug 2020 06:26:27 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 71C2EAE38; Fri, 21 Aug 2020 10:26:53 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 669D31E1312; Fri, 21 Aug 2020 12:26:25 +0200 (CEST) Date: Fri, 21 Aug 2020 12:26:25 +0200 From: Jan Kara To: Mauricio Faria de Oliveira Cc: Jan Kara , linux-ext4@vger.kernel.org, dann frazier , Jan Kara Subject: Re: [RFC PATCH v2 3/5] ext4: data=journal: write-protect pages on submit inode data buffers callback Message-ID: <20200821102625.GB3432@quack2.suse.cz> References: <20200810010210.3305322-1-mfo@canonical.com> <20200810010210.3305322-4-mfo@canonical.com> <20200819084421.GD1902@quack2.suse.cz> <20200819104139.GJ1902@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu 20-08-20 19:55:05, Mauricio Faria de Oliveira wrote: > On Wed, Aug 19, 2020 at 7:41 AM Jan Kara wrote: > > > > On Wed 19-08-20 10:44:21, Jan Kara wrote: > > > I was thinking about this and we may need to do this somewhat differently. > > > I've realized that there's the slight trouble that we now use page dirty > > > bit for two purposes in data=journal mode - to track pages that need write > > > protection during commit and also to track pages which have buffers that > > > need checkpointing. And this mixing is making things complex. So I was > > > thinking that we could simply leave PageDirty bit for checkpointing > > > purposes and always make sure buffers are appropriately attached to a > > > transaction as dirty in ext4_page_mkwrite(). [snip] > > > [snip] Furthermore I > > > don't think that the tricks with PageChecked logic we play in data=journal > > > mode are really needed as well which should bring further simplifications. > > > I'll try to code this cleanup. > > > > I was looking more into this but it isn't as simple as I thought because > > get_user_pages() users can still modify data and call set_page_dirty() when > > the page is no longer writeably mapped. And by the time set_page_dirty() is > > called page buffers are not necessarily part of any transaction so we need > > to do effectively what's in ext4_journalled_writepage(). To handle this > > corner case I didn't find anything considerably simpler than the current > > code. > > > > So let's stay with what we have in > > ext4_journalled_submit_inode_data_buffers(), we just have to also redirty > > the page if we find any dirty buffers. > > > > Could you please clarify/comment whether the dirty buffers "flags" are > different between the suggestions for ext4_page_mkwrite() and > ext4_journalled_submit_inode_data_buffers() ? > > I'm asking because.. > > In ext4_page_mkwrite() the suggestion is to attach buffers as dirty to > a transaction, which I guess can be done with > ext4_walk_page_buffers(..., write_end_fn) after > ext4_walk_page_buffers(..., do_journal_get_write_access) -- just as > done in ext4_journalled_writepage() -- and that sets the buffer as > *jbd* dirty (BH_JBDDirty.) Correct. > In ext4_journalled_submit_inode_data_buffers() the suggestion is to > check for dirty buffers to redirty the page > (for the case of buffers that need checkpointing) and I think this is > the non-jbd/just dirty (BH_Dirty.) Again correct :). > If I actually understood your explanation/suggest, the dirty buffer > flags should be different, > as otherwise we'd be unconditionally setting buffers dirty on > ext4_page_mkwrite() to later > check for (known to be) dirty buffers in > ext4_journalled_submit_inode_data_buffers(). > > ... > > And as you mentioned no cleanup / keeping ext4_journalled_writepage() > and the PageChecked bit, > I would like to revisit two questions from the cover letter that would > have no impact with the cleanup, > so to confirm my understanding for the next steps. > > > 3) When checking to redirty the page in the writepage callback, > > does a buffer without a journal head means we should redirty > > the page? (for the reason it's not part of the committing txn) > > Per your explanation about the page dirty bit for buffers that need > checkpointing, I see we cannot redirty > the page just because a buffer isn't part of the transaction -- the > buffer has to be dirty -- so I think it falls > down to your suggestion of 'also redirty if we find any dirty buffers' > (regardless of a buffer w/out txns.) right? Correct. It should be: if (buffer_dirty(bh) || (jh && ...)) redirty > > 4) Should we clear the PageChecked bit? > ... > > Should we try to prevent that [ext4_journalled_writepage() > running later] by, say, clearing the pagechecked bit > > in case we don't have to redirty the page (in the writepage callback) ? > > And I think the answer is no, per your explanation about page dirty > being set elsewhere outside of our control, > and thus ext4_journalled_page() still needs to run, and thus the page > checked bit still needs to remain set; correct? Correct. Honza -- Jan Kara SUSE Labs, CR