Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1037481pxm; Wed, 23 Feb 2022 16:31:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTKmvjeoPuMAMfpSvlHy2awqdTeXf1BRIfx75lo2P6wBVWkAgPtlP+imyDDob9qpDTGT/u X-Received: by 2002:a17:90a:fb4e:b0:1bc:8227:edd9 with SMTP id iq14-20020a17090afb4e00b001bc8227edd9mr159747pjb.56.1645662714081; Wed, 23 Feb 2022 16:31:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645662714; cv=none; d=google.com; s=arc-20160816; b=NmVJT806u3HzGMoLP5ER9T59cm+sr6zjK3EuYFtpVIED4ERv8Zk34Z8F7mCzrj8hwR kzO9V+ATH98QJLj1qm9GQljYEpiuzqRv4qcDOjY0ZDVfF6PtoDCll0OCgJqHBxwNP5QH 45tse8Crg8BuW48FdZOBUX72+4KVY+VdfjNujBCFwS63aOn/dKnzNf7rcqhpCerWkpnc oRn/njO/KREEBYWn8vmgUfvIFCsPQhrGKpPQ4tnvylPPRI941bfCIwU1xfA9fO6i7z+t 6e8zZNAf2tTASUxhNkEFVitz9SRZAMlht/2U85qCN3SVj9HpLc1YJpnKG0pFkaLXgkOB fzyw== 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:dkim-signature; bh=W9o8E/GqdYtOTLRG+zZAUd0gtjWhs7Bb1g7AEZ+WmaI=; b=Jrk0hfvPzPhfwICHfaCVEVSKqJyhNRClE382jju9TJe/CqUfozSTRhYxodM8YstEMH NwrQPS10qrsJb/XfEyxFHZx3gKaiqY9aDhGLKsc4ZVTv8ZNcAy2o5jfhasVH2aSoa9lb 71rsDzx0mUpp0fWHUJnJtvrRm2P7cgPhNPoE3Se8rptsnSGt8uJhb7/zoYlfNZ/8g9G2 0g/Dyq+nNoxrbFQiRAz1fReDfIKZzRH4DLNUylAGrbGWF6oC0iMzJawCJ2sAUxtJEaEI ZjeB4RqdpcQeHbU+PDLLYdJnSIB3dWjoiQyR8luu4YdJzpr/SGiFRf1lK4ryADskwwX/ b3mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=aXRcJ4yv; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h71si1068276pgc.167.2022.02.23.16.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 16:31:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=aXRcJ4yv; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DBC957563B; Wed, 23 Feb 2022 16:31:34 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237699AbiBWDvk (ORCPT + 99 others); Tue, 22 Feb 2022 22:51:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233958AbiBWDvk (ORCPT ); Tue, 22 Feb 2022 22:51:40 -0500 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 893376579E for ; Tue, 22 Feb 2022 19:51:12 -0800 (PST) Received: by mail-lj1-x22b.google.com with SMTP id p20so14372190ljo.0 for ; Tue, 22 Feb 2022 19:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=W9o8E/GqdYtOTLRG+zZAUd0gtjWhs7Bb1g7AEZ+WmaI=; b=aXRcJ4yvHQJyf6hir6XnrojLMAQB6U8jccX70auhmlB1CquPuAxO5Kj/XnwagE3C3m iycKRFhvQvlKaLOC+DbDUMYJV9DQQzNhIA6i4Bl8PeEn0ftd7oiSO2awlUmRldWHLEL3 GvyRwpIEdEZgZ80W4Pu4tDwf4TQK7kvkcExxFkAk6JyDD8nDJ/102TCiXPHGTnE3vfyO MLXKstC6hZQtMKEf3G5KhHehXE6zvK0jMK40AncVqK7efTJUCmKafH/MxV4+te+5RNTI wtC/Hq3o+rOBi29XVbrlpDeLzJ7zWY2BM1QLQRGR86C3tTwBA83f0QluJ9IHay2GHCuY 2gpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=W9o8E/GqdYtOTLRG+zZAUd0gtjWhs7Bb1g7AEZ+WmaI=; b=sBspcmusBNJa4uhYtOfbpkJNRht7ydNAmtxvFnnWo1xNgN4Uz20xIgLtzLpJuC0wh3 zqkB9gY2op6ozOyKbR9bufvqopYusCiuzNyEjG7apQT6r97gw+cZEuvYprbwQdnu5ZtH llIzd3j5cMHBPuPrNfiLPBV7391My7WgKog+on+Y5NdBQ87n8SAo+Ccd24iwSOLlQm1T 2l6FvQNlt4bNfJ+k4V9mlm5+gMtRk7eFbEB0/XV6o+OfUrgudCZcLZI54K9anceQVG8Q d8vg4ztJSQTSoiFtABVPd20sj38dXUhwCDAQLoP1Qi93Y/loAY7qE4uwWMv2o5AuU9I+ XHug== X-Gm-Message-State: AOAM5314Z5n5DBi+AoEuG7+KJO8MwjvW1QVIXnuD1+u3+7Agx8QOPtXR 5sMLykMXvRr+pGpquG4NvAv05Ehtu/GqZCqCYW1chDiHoaPELg== X-Received: by 2002:a2e:3013:0:b0:246:2ca9:365e with SMTP id w19-20020a2e3013000000b002462ca9365emr13863094ljw.291.1645588270878; Tue, 22 Feb 2022 19:51:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Xin Yin Date: Wed, 23 Feb 2022 11:50:59 +0800 Message-ID: Subject: Re: [External] [RFC 9/9] ext4: fast_commit missing tracking updates to a file To: Ritesh Harjani Cc: linux-ext4@vger.kernel.org, Harshad Shirwadkar , "Theodore Ts'o" , Jan Kara , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Feb 23, 2022 at 4:36 AM Ritesh Harjani wrote: > > > > Testcase > ========== > 1. i=0; while [ $i -lt 1000 ]; do xfs_io -f -c "pwrite -S 0xaa -b 32k 0 32k" -c "fsync" /mnt/$i; i=$(($i+1)); done && sudo ./src/godown -v /mnt && sudo umount /mnt && sudo mount /dev/loop2 /mnt' > 2. ls -alih /mnt/ -> In this you will observe one such file with 0 bytes (which ideally should not happen) > > ^^^ say if you don't see the issue because your underlying storage > device is very fast, then maybe try with commit=1 mount option. > > Analysis > ========== > It seems a file's updates can be a part of two transaction tid. > Below are the sequence of events which could cause this issue. > > jbd2_handle_start -> (t_tid = 38) > __ext4_new_inode > ext4_fc_track_template -> __track_inode -> (i_sync_tid = 38, t_tid = 38) > > jbd2_start_commit -> (t_tid = 38) > > jbd2_handle_start (tid = 39) > ext4_fc_track_template -> __track_inode -> (i_sync_tid = 38, t_tid 39) > -> ext4_fc_reset_inode & ei->i_sync_tid = t_tid > > ext4_fc_commit_start -> (will wait since jbd2 full commit is in progress) > jbd2_end_commit (t_tid = 38) > -> jbd2_fc_cleanup() -> this will cleanup entries in sbi->s_fc_q[FC_Q_MAIN] > -> And the above could result inode size as 0 as after effect. > ext4_fc_commit_stop > > You could find the logs for the above behavior for inode 979 at [1]. > > -> So what is happening here is since the ei->i_fc_list is not empty > (because it is already part of sb's MAIN queue), we don't add this inode > again into neither sb's MAIN or STAGING queue. > And after jbd2_fc_cleanup() is called from jbd2 full commit, we > just remove this inode from the main queue. > > So as a simple fix, what I did below was to check if it is a jbd2 full commit > in ext4_fc_cleanup(), and if the ei->i_sync_tid > tid, that means we > need not remove that from MAIN queue. This is since neither jbd2 nor FC > has committed updates of those inodes for this new txn tid yet. > > But below are some quick queries on this > ========================================= > > 1. why do we call ext4_fc_reset_inode() when inode tid and > running txn tid does not match? This is part of a change in commit:bdc8a53a6f2f, it fixes the issue for fc tracking logic while jbd2 commit is ongoing. If the inode tid is bigger than txn tid, that means this inode may be in the STAGING queue, if we reset it then it will lose the tack range. I think it's a similar issue, the difference is this inode is already in the MAIN queue before the jbd2 commit starts. And yes , I think in this case we can not remove it from the MAIN queue, but still need to clear EXT4_STATE_FC_COMMITTING right? it may block some task still waiting for it. Thanks, Xin Yin > > 2. Also is this an expected behavior from the design perspective of > fast_commit. i.e. > a. the inode can be part of two tids? > b. And that while a full commit is in progress, the inode can still > receive updates but using a new transaction tid. > > Frankly speaking, since I was also working on other things, so I haven't > yet got the chance to completely analyze the situation yet. > Once I have those things sorted, I will spend more time on this, to > understand it more. Meanwhile if you already have some answers to above > queries/observations, please do share those here. > > Links > ========= > [1] https://raw.githubusercontent.com/riteshharjani/LinuxStudy/master/ext4/fast_commit/fc_inode_missing_updates_ino_979.txt > > Signed-off-by: Ritesh Harjani > --- > fs/ext4/fast_commit.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c > index 8803ba087b07..769b584c2552 100644 > --- a/fs/ext4/fast_commit.c > +++ b/fs/ext4/fast_commit.c > @@ -1252,6 +1252,8 @@ static void ext4_fc_cleanup(journal_t *journal, int full, tid_t tid) > spin_lock(&sbi->s_fc_lock); > list_for_each_entry_safe(iter, iter_n, &sbi->s_fc_q[FC_Q_MAIN], > i_fc_list) { > + if (full && iter->i_sync_tid > tid) > + continue; > list_del_init(&iter->i_fc_list); > ext4_clear_inode_state(&iter->vfs_inode, > EXT4_STATE_FC_COMMITTING); > -- > 2.31.1 >