Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1737384pxu; Thu, 8 Oct 2020 20:58:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsbag26l2REMdF7LFHq8Colch7GRfPEgNhwzqU3E2z0qPPwfTpyUkNWb8y+bZFoAKpv7HW X-Received: by 2002:a05:6402:31b3:: with SMTP id dj19mr12785410edb.210.1602215927719; Thu, 08 Oct 2020 20:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602215927; cv=none; d=google.com; s=arc-20160816; b=dh22Atg5lvbq4knOHdXbtSnSfGA009SBexXCyLo4JKFp4/60wfq7YVNwuelign7Dte NDbCHAvNGYBEWAhtvGsULzaHpyvUjDJxs6IQXATJc7vOEnKCrX4cnwqxN/hdxdG1D/Wo 0e/bgbtGK29D0BciaPUI9gKVsqT9LRhZP261DAnlNcEeiTihRmaAaoFmWvlfYh14SW7G wuTScyK3cW4/1ZtRp+Y6vCubOoMoOwyi6quMJZHxV8KxEAlVir5n0tRboDJGCvl4SfXR LOZbnLrl4j2uAogIH1ZscCkuaWxJapWgy2Za7utoXlVMzTIwxzMUc+aVK7IRf6k/Flkw 03pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=4MANy+mPvXdwZMgK5nUTKJHdsufehBSoYd9Qz9wVQe8=; b=iOiL5WDDh1xr33qQuKkceVZMODBKLDKIib9rBPGqODGQ4PNba1phcyi0AuLnJt7FYu sfZhmRHXG74kHWe0BNTky3PfQ3h5qlIRY3enpQ35wmMB7B+qtRyVfcnWvht1v9XTCIS0 6Lamu829QRgs0cA326SpfWjPah5HfuQcdo5XLZ25+UhZZ0NwNqpH6iO9GqtUzM3g7Qi9 mR9ju8mMQE55XSxQ8kQ9zE6gPePRwJo6N2Eb51yzAcCj8MlzXQCwe3Ut61beIhPCXAz6 Dx4gFma37qf3Qf+3RYn/lwBtuAw8+Qku4B1A+JfpDSLB5fcJOnGzmMokH8hELp/yLcfB I2Dg== 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 l23si5482676eja.289.2020.10.08.20.58.24; Thu, 08 Oct 2020 20:58:47 -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 S1730219AbgJICLB (ORCPT + 99 others); Thu, 8 Oct 2020 22:11:01 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:45493 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729719AbgJICLB (ORCPT ); Thu, 8 Oct 2020 22:11:01 -0400 Received: from callcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 0992Apd1003931 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 8 Oct 2020 22:10:51 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id E3854420107; Thu, 8 Oct 2020 22:10:50 -0400 (EDT) Date: Thu, 8 Oct 2020 22:10:50 -0400 From: "Theodore Y. Ts'o" To: Mauricio Faria de Oliveira Cc: linux-ext4@vger.kernel.org, ocfs2-devel@oss.oracle.com, Jan Kara , Andreas Dilger , dann frazier , Joseph Qi Subject: Re: [PATCH v5 4/4] ext4: data=journal: write-protect pages on j_submit_inode_data_buffers() Message-ID: <20201009021050.GH235506@mit.edu> References: <20201006004841.600488-1-mfo@canonical.com> <20201006004841.600488-5-mfo@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201006004841.600488-5-mfo@canonical.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon, Oct 05, 2020 at 09:48:41PM -0300, Mauricio Faria de Oliveira wrote: > This implements journal callbacks j_submit|finish_inode_data_buffers() > with different behavior for data=journal: to write-protect pages under > commit, preventing changes to buffers writeably mapped to userspace. > > If a buffer's content changes between commit's checksum calculation > and write-out to disk, it can cause journal recovery/mount failures > upon a kernel crash or power loss. > > [ 27.334874] EXT4-fs: Warning: mounting with data=journal disables delayed allocation, dioread_nolock, and O_DIRECT support! > [ 27.339492] JBD2: Invalid checksum recovering data block 8705 in log > [ 27.342716] JBD2: recovery failed > [ 27.343316] EXT4-fs (loop0): error loading journal > mount: /ext4: can't read superblock on /dev/loop0. > > In j_submit_inode_data_buffers() we write-protect the inode's pages > with write_cache_pages() and redirty w/ writepage callback if needed. > > In j_finish_inode_data_buffers() there is nothing do to. > > And in order to use the callbacks, inodes are added to the inode list > in transaction in __ext4_journalled_writepage() and ext4_page_mkwrite(). > > In ext4_page_mkwrite() we must make sure that the buffers are attached > to the transaction as jbddirty with write_end_fn(), as already done in > __ext4_journalled_writepage(). > > Signed-off-by: Mauricio Faria de Oliveira > Reported-by: Dann Frazier > Reported-by: kernel test robot # wbc.nr_to_write > Suggested-by: Jan Kara > Reviewed-by: Jan Kara Thanks, applied. - Ted