Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2131031lqb; Mon, 27 May 2024 08:48:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6KC3H5TYmbOpuFk9VWt/mXvG3+tsQaqBg0eTJg7jPf6cP13BcF3eB4h11nb1UczxAXU5i3WAB7JYkAiM19Ak8amcsl5Rwf7pqOK1XFQ== X-Google-Smtp-Source: AGHT+IFFcHHBPN7xGsNqNbm3XqenszCJf09HW2ZMb6Kba0Ni3c8vVJnkxVrwA39V8bnaRa7RYOFd X-Received: by 2002:a50:d5d2:0:b0:572:719f:b430 with SMTP id 4fb4d7f45d1cf-578519aa424mr9526896a12.32.1716824917770; Mon, 27 May 2024 08:48:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716824917; cv=pass; d=google.com; s=arc-20160816; b=f3uvI2AeW4huYaVmUoKrJsDCvSuO//lCvkubuMH5IqCXXNbty0/5Rov/jUCd73xjF2 o6pO8NZjQ0YAIdwtCmmiX5eRajJ58RaDMPf6YAkdnwxXzXHWUprNDjrhqomsqguR9Xmy LqRFaLaQQIIknqKLOPaTMyVdE1olzWRC2RWF711MfO3HTaov1SqP6W2ZEzXyKX8RB2Es 8uQxnOgUGn3MO3jGLP7+M/x5FjaMxsRWtjkJCAevyl1RVNgCAOMHziNVPtKRR1Vgq2dd voyp0wu955UEwedzIJJRU9iicl26zxm9pdLEwo+sF1ebyaCcfomzoE8X1kqKNuqHoK07 MIJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=yigDgYzxDm/YXTY6BSYFXprUHJId2yNbt73KT7rVnq0=; fh=cOmIcfQdMATvLtBpJB/HyX3TzUPGIeaSSw+oSAAFcMw=; b=Q11auBelO2OjNFTud7Flj7Jt0lyeIyYpbSI/TqeyyYwl3T6zXOoVfsB1IdRd8m7XO9 Pm3e46YecnZws1r8qOmTGVukgEiZVTpHbCfxk0+c82Blhk6oPbfQ4/lwK2PDvira+g8S ymsK/W6349HCFZANyNHrqFypoD5z/a3uiN0xBOCTmicXkX/cInsv6to6uRgLDh07QsPd Du/JkfdkHEhCxC7+tG07cKyP5/oOBWYu7AMwtK2JKP0VOVQ0k5guETvcmFdDaFYx7gJq TVTQWvORajMhkIORSoFktvB5klb8H10M48o0vPAQPI0Bk3JSfINeRCZ7R0Eyzc/mE0Ag cpSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Yf7gDT7j; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-ext4+bounces-2653-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2653-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-578524b4312si4178277a12.519.2024.05.27.08.48.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 08:48:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2653-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Yf7gDT7j; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-ext4+bounces-2653-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2653-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8257B1F228DA for ; Mon, 27 May 2024 15:48:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2C5461FF9; Mon, 27 May 2024 15:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Yf7gDT7j" X-Original-To: linux-ext4@vger.kernel.org Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1839F61FD8 for ; Mon, 27 May 2024 15:48:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716824911; cv=none; b=BpShT3sAQsrJNT4UuVoRnqXm99yjX1EZGSrOcVHLLX4YEeYy0zXI5lkmFLjt125Tc49Urgz1vEBa9OiotsVGMWy1EojxFLuMh6+csLSbO2+wvBtvt7Q48qFD7O7vQsVIqWiTvxZLbbFu3c6gbE5pj8zZdjL5dtNln0V21hVYfBg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716824911; c=relaxed/simple; bh=j6fD/Ci1a9FwE2Y3sJBitvVUfGGI6XIHk1L7eCzZkBk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=N9fj5UO5RDNZNiT1T90qc5MU2tPSp0ThWqjqOhXeX4dRaNZn2YMLU9JNWjwGaJaI/BZyO7UsC+sfI25Z9H4pnBrMgXld4aPXOW0Sammi7Zy0RXnD1/64BB78bqb8WthvBn1wX3AtyjLPOP27UAJ4JQDKBHFNlNtdGCqk+c1nlrU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Yf7gDT7j; arc=none smtp.client-ip=95.215.58.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: linux-ext4@vger.kernel.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1716824907; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yigDgYzxDm/YXTY6BSYFXprUHJId2yNbt73KT7rVnq0=; b=Yf7gDT7jmS3/ywn6gpmEEvyen4NW9G0f2YQlmmbNZjpllAmD4XfEZT2qsnoMAJLZYOgA6O uOeoKQWMg3hubEw5otwmuiIxoCNzrn2Zul42DoZmgSO4HrLRReeh4kwK5+YTW6yy2/euVk lqAnws11tV5V7Xa7ESPTU6l0QK7qr+g= X-Envelope-To: tytso@mit.edu X-Envelope-To: jack@suse.cz X-Envelope-To: harshadshirwadkar@gmail.com X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: adilger@dilger.ca X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Luis Henriques To: Jan Kara Cc: Theodore Ts'o , Andreas Dilger , Harshad Shirwadkar , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] ext4: fix fast commit inode enqueueing during a full journal commit In-Reply-To: <87h6ej64jv.fsf@brahms.olymp> (Luis Henriques's message of "Mon, 27 May 2024 09:29:40 +0100") References: <20240523111618.17012-1-luis.henriques@linux.dev> <20240524162231.l5r4niz7awjgfju6@quack3> <87h6ej64jv.fsf@brahms.olymp> Date: Mon, 27 May 2024 16:48:24 +0100 Message-ID: <87msob45o7.fsf@brahms.olymp> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT On Mon 27 May 2024 09:29:40 AM +01, Luis Henriques wrote; >>> + /* >>> + * Used to flag an inode as part of the next fast commit; will be >>> + * reset during fast commit clean-up >>> + */ >>> + tid_t i_fc_next; >>> + >> >> Do we really need new tid in the inode? I'd be kind of hoping we could u= se >> EXT4_I(inode)->i_sync_tid for this - I can see we even already set it in >> ext4_fc_track_template() and used for similar comparisons in fast commit >> code. > > Ah, true. It looks like it could be used indeed. We'll still need a flag > here, but a simple bool should be enough for that. After looking again at the code, I'm not 100% sure that this is actually doable. For example, if I replace the above by bool i_fc_next; and set to to 'true' below: >>> diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c >>> index 87c009e0c59a..bfdf249f0783 100644 >>> --- a/fs/ext4/fast_commit.c >>> +++ b/fs/ext4/fast_commit.c >>> @@ -402,6 +402,8 @@ static int ext4_fc_track_template( >>> sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING) ? >>> &sbi->s_fc_q[FC_Q_STAGING] : >>> &sbi->s_fc_q[FC_Q_MAIN]); >>> + else >>> + ei->i_fc_next =3D tid; ei->i_fc_next =3D true; Then, when we get to the ext4_fc_cleanup(), the value of iter->i_sync_tid may have changed in the meantime from, e.g., ext4_do_update_inode() or __ext4_iget(). This would cause the clean-up code to be bogus if it still implements a the logic below, by comparing the tid with i_sync_tid. (Although, to be honest, I couldn't see any visible effect in the quick testing I've done.) Or am I missing something, and this is *exactly* the behaviour you'd expect? Cheers, --=20 Luis >>> spin_unlock(&sbi->s_fc_lock); >>>=20=20 >>> return ret; >>> @@ -1280,6 +1282,15 @@ static void ext4_fc_cleanup(journal_t *journal, = int full, tid_t tid) >>> list_for_each_entry_safe(iter, iter_n, &sbi->s_fc_q[FC_Q_MAIN], >>> i_fc_list) { >>> list_del_init(&iter->i_fc_list); >>> + if (iter->i_fc_next =3D=3D tid) >>> + iter->i_fc_next =3D 0; >>> + else if (iter->i_fc_next > tid) >> ^^^ careful here, TIDs do wrap so you need to use >> tid_geq() for comparison. >> > > Yikes! Thanks, I'll update the code to do that. > >>> + /* >>> + * re-enqueue inode into STAGING, which will later be >>> + * splice back into MAIN >>> + */ >>> + list_add_tail(&EXT4_I(&iter->vfs_inode)->i_fc_list, >>> + &sbi->s_fc_q[FC_Q_STAGING]); >>> ext4_clear_inode_state(&iter->vfs_inode, >>> EXT4_STATE_FC_COMMITTING); >>> if (iter->i_sync_tid <=3D tid) >> ^^^ and I can see this is buggy as >> well and needs tid_geq() (not your fault obviously). > > Yeah, good point. I can that too in v3. > > Again, thanks a lot for your review! > > Cheers, > --=20 > Lu=C3=ADs