Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1176186pxx; Tue, 27 Oct 2020 09:58:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF4GJn7G0el2Cf2bptS0RbMAeqnyXPeXf79ASVlN1e0FMYx03+c7B1vd0I3pH6wxwSlxhg X-Received: by 2002:a05:6402:1586:: with SMTP id c6mr3328723edv.84.1603817924543; Tue, 27 Oct 2020 09:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603817924; cv=none; d=google.com; s=arc-20160816; b=OI/AGfwdMZjhLBf4HemTZSjNxPVb8VS5kQFZlusllqw19saa/Mw9Vmov5+Oz6zwWhU Q5Fvdb0k/aKCw2ManIIDRUvB8fcXkb478SYuzd9GqRdbJmq6ZXlNPBA1hkHXzqE7qPLU aeGHRNtwUk9RgwFty3XAAmBiAiUT+xppJgpMkeNbcJrhEMqP9GvOL4izmADKO+xK+5VD AbDgCU7I8P/25Cjlk8IUp+yRE8dQXt5IAlNEbXSmenfC3lIWG5vYydg/i5O9f6151kd7 rU9xxwpU5RUPGPEz/p3cFQLiBY003k8NO3j6gykzM7c14uWLB4fUrABI6Y5mW2FChd8X hwaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=3FiwKhTTNUXKE1vlkDwixEE7F2+Xm0xm6j2vCTDuLYI=; b=MRDkaC+hWSUvCdIld4JExQkDCgs9X0guuwZFeAIdmzyT1XCdjSjZIbnGstPM9/H8Y5 QTBqm/7S5gmC6DqODKTFw4PGZskM1pDbHwgwCe8JqxUzA3vuK6Ydq5qXZpgHLzUkRXuT 8zRKX1CyWmlGZLY0hAQnwZYL59Q+A50tufs0M8277ArBEq5jqNLTKCtur5vV/uK1UJb5 W7rpx0+CZvtSibtiu8c92pW8OzHwlabFC+FWD3QSZZM26jWU2aVIn/4ObJaj7cOViViX eoZgR0COajXXukVz8I6sTTOxUsMjbUi0lv/0YiNPaHf24FqKHMucwdI19T9OU1yyGKEr zGVA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si1450246edx.375.2020.10.27.09.58.05; Tue, 27 Oct 2020 09:58:44 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1807471AbgJ0QK5 (ORCPT + 99 others); Tue, 27 Oct 2020 12:10:57 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:36590 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1807463AbgJ0QKz (ORCPT ); Tue, 27 Oct 2020 12:10:55 -0400 Received: from mail-wm1-f69.google.com ([209.85.128.69]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kXRYi-00062o-Nm for linux-ext4@vger.kernel.org; Tue, 27 Oct 2020 16:10:52 +0000 Received: by mail-wm1-f69.google.com with SMTP id 22so765289wmo.3 for ; Tue, 27 Oct 2020 09:10:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3FiwKhTTNUXKE1vlkDwixEE7F2+Xm0xm6j2vCTDuLYI=; b=oVIsEyViP7auzwoOuLIGoldxs2vYYx5yVBSY5ess+1560ctfM7bYYEq/ElDS/j9iXo dvOal8RFzawMkZ6zEMiHkVN+HcYgyu5/vXH070TXBDzszV1KSo3HXl1354DkDqn8flsO r1xccTvtoK35qfpJL7pfS74RVyi3X/9kPU/NCFH9wuPlML1MO411ZJKcqkxovQcSQTRo jG868bNoTjlxeoaDZheR2wbtxzYvsij1d1UQtsnB2JbEs5ESwFAlZMXkCpu4BoI2nf9o QoXmKyVpIzAc3e63bFBJUgp7fFF/YMJg8LnaecIAm4hcMVMZsjtSyTLZ5Tc+WE8OyB0N b9Gg== X-Gm-Message-State: AOAM533H79zPEXyxTBhyJHBw3o4T1/yYoD4PsIYUEgDl7D3V6NVVzs8u BvjIoMPVE4ap2WD3tQv1uvH+XLw0gT2Qb5+zgtgjKUXpGcdMpX9/vB/Er8lyiFZFuaReARAntZu oUYZ1aY0e5zwdlBOD3FKXpkxBBd/FBzInrJLnK27PKUGwprnfz5uACp4= X-Received: by 2002:a5d:6a4f:: with SMTP id t15mr3686952wrw.126.1603815052354; Tue, 27 Oct 2020 09:10:52 -0700 (PDT) X-Received: by 2002:a5d:6a4f:: with SMTP id t15mr3686931wrw.126.1603815052088; Tue, 27 Oct 2020 09:10:52 -0700 (PDT) MIME-Version: 1.0 References: <20201027132751.29858-1-jack@suse.cz> In-Reply-To: <20201027132751.29858-1-jack@suse.cz> From: Mauricio Faria de Oliveira Date: Tue, 27 Oct 2020 13:10:39 -0300 Message-ID: Subject: Re: [PATCH] ext4: Fix mmap write protection for data=journal mode To: Jan Kara Cc: Ted Tso , linux-ext4@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hey Jan, On Tue, Oct 27, 2020 at 10:27 AM Jan Kara wrote: > > Commit afb585a97f81 "ext4: data=journal: write-protect pages on > j_submit_inode_data_buffers()") added calls ext4_jbd2_inode_add_write() > to track inode ranges whose mappings need to get write-protected during > transaction commits. However the added calls use wrong start of a range > (0 instead of page offset) and so write protection is not necessarily > effective. Use correct range start to fix the problem. > > Fixes: afb585a97f81 ("ext4: data=journal: write-protect pages on j_submit_inode_data_buffers()") > Signed-off-by: Jan Kara > --- > fs/ext4/inode.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > Mauricio, I think this could be the reason for occasional test failures you > were still seeing. Can you try whether this patch fixes those for you? Thanks! > Thanks! Nice catch. Sure, I'll give it a try and follow up. Just as FYI, I've been working on debugging and instrumentation to identify the corner cases where the page has not been write protected; but got a slower pace due to other work items. cheers, Mauricio > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 03c2253005f0..f4a599c6dcde 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -1918,7 +1918,7 @@ static int __ext4_journalled_writepage(struct page *page, > } > if (ret == 0) > ret = err; > - err = ext4_jbd2_inode_add_write(handle, inode, 0, len); > + err = ext4_jbd2_inode_add_write(handle, inode, page_offset(page), len); > if (ret == 0) > ret = err; > EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid; > @@ -6157,7 +6157,8 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf) > if (ext4_walk_page_buffers(handle, page_buffers(page), > 0, len, NULL, write_end_fn)) > goto out_error; > - if (ext4_jbd2_inode_add_write(handle, inode, 0, len)) > + if (ext4_jbd2_inode_add_write(handle, inode, > + page_offset(page), len)) > goto out_error; > ext4_set_inode_state(inode, EXT4_STATE_JDATA); > } else { > -- > 2.16.4 > -- Mauricio Faria de Oliveira