Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1811249lql; Wed, 13 Mar 2024 08:47:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVT/jHcy0WMwDdtZ+Sv7eZd5FeL8Sz9k/y1VRNGfCmGPa/+C02+Ba8XOjAz+aRXfn5QJ3cTYj+f2yjeMYKJc5jQu6gU4noyDowTsQ6maw== X-Google-Smtp-Source: AGHT+IF2Y9wo1l8JpmYfxO/pK21oQMavoCNT9Ff5z9kXePU5VOJh9PKU3te+YkTLpnCzOprE0int X-Received: by 2002:a05:6808:15a8:b0:3c2:1191:763d with SMTP id t40-20020a05680815a800b003c21191763dmr223236oiw.27.1710344820538; Wed, 13 Mar 2024 08:47:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710344820; cv=pass; d=google.com; s=arc-20160816; b=BGwpY1wRfuVCQkv3RKrWWLdauJFrATKed48YmeBr/SFaubYqYJgF35avdmqARMeIXX zK8wjf5S58ZBN7RF0GDa6KtguuZ1Wt4n61L16a7cedQ/5HF+Wz9nHPP0om2g8EjwgEye rlee6VZCFYp9nJamiAaV/FFAkO2cdjPXPJu67T2Uon9vsex49vBLRliQS+opC2SxzmyT uHV+X6IyPrSFNJgi/EZes0rNLlXKRZvgFM9tPIjNOkjI2we6vbij/35978eMBNSNEJC1 Q0MEpTsgxYliORjHqBAEzCNhv4yg08OAwNWoAjrlbV/7Uwmry+jkfDb6w5KXdH7+1H2L okXg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=+WwWvBD5JICifAC4LRXMA04LWk4FKdSKpZw2yIN4sdE=; fh=mQOhTs4YfwW2MshvHRYdBUG6ywUTQyDphdep1ruycLs=; b=dmT5RigzdR6IrBL3/Z83aMJ4uL2vZbXvJZrC5JgC5+in+zYLyQSZUolZJvD0FOHRsM xUaYDMyn1zLBh2JQWULyuTp9z5vTLk90jiyTo+FAK9Ss/RSAkpe/nRjYbzhoPoPjCEQ7 CviKSLFqKGdDNg0ZTpeJ8ipLlnSMnw66RNxuyELY3Rs8+77KUF/diqtMW893aLkWKiVt 7GNUzOjtQXhlavdH6Q37KswnqtFC634zTZQE2Ck+6HX56iQlbQ2g8V3udBVcfaKvNIxT FS5O/YvZAsse/3z9rDFNHjvkxpYWFB5I0f5o4hPY3jAK0RElNBywPMrxM9XI/vMSHAzz m87A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HmGuABx4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-101695-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101695-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v39-20020a05622a18a700b0042eeb7a6911si10066681qtc.287.2024.03.13.08.47.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 08:47:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101695-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HmGuABx4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-101695-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101695-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1342D1C23102 for ; Wed, 13 Mar 2024 15:46:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B84C47A5D; Wed, 13 Mar 2024 15:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HmGuABx4" Received: from mail-vs1-f51.google.com (mail-vs1-f51.google.com [209.85.217.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6339481BE; Wed, 13 Mar 2024 15:46:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710344786; cv=none; b=CZaj1CmzMKdEYUMAM8Si5M+WtIRR2+iM/uyvbrrq/A0jHndozuUpv4hiBLJVOL8cHHDe6sTHQYjup1x7RXr/HGgPC4n9Setqk3txvPRLaAwii2Z2JHaKWCZ7d9r8xEZ0Ik/dDFA7aUtJ+3BWgoMzotsyi3HMvtK9Y9FQwI2SCHQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710344786; c=relaxed/simple; bh=kbZTvKIUyKrKVMm68AL0IRPNR5dRypdr5syArylXTQ4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=MjDPg4j9JfgcWA/0JsHLFLVTnquFoR5EDt4yp/WzhlSUXibLAVpbyJRxWrYZ5QT05LgLewYuhsQnvhfx7OJtXGLKTFV5FK+JVAXTSpK1AtPK4nCx9V4l9wX6un+u6DrjL8aaqvkogMWzCUYA/OeRYQwTPy7gQFiqoJYBKAR6zeI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HmGuABx4; arc=none smtp.client-ip=209.85.217.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vs1-f51.google.com with SMTP id ada2fe7eead31-474cb4bcd3dso480047137.2; Wed, 13 Mar 2024 08:46:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710344784; x=1710949584; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+WwWvBD5JICifAC4LRXMA04LWk4FKdSKpZw2yIN4sdE=; b=HmGuABx4O/wZG+k/PL/LrQeb2mH3ckkZfUO8aST2cJOP99FOyxTlTm/WufZi7T3W2K L9ZL4HDC6tC58In+wHc+KuuHvMghPiWX8dajECeatG3XYtFZtyCtm/kKlMfXtC3IYEsf p29ju9YNZdhE8w7Jx8k02gRC5ozzXHl0Gr9ePkRMSvGJN7V+qHHZ7FyWBWu8wtWfPDhh B8nxZXnlw1/QKgV+fkauw8tSgNMKU/6T9gf6wAKdCBViZcO16hPWN1Y2/7bVSQtcjvej D8nDTDAXYGY498fmgx3T7hKI8zAHhfolTz2qsHsq/dEdTSu+WNbfbblb9dm+vMfmtiG1 VXrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710344784; x=1710949584; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+WwWvBD5JICifAC4LRXMA04LWk4FKdSKpZw2yIN4sdE=; b=L7D7YfqhNYhSe/vcd0pc0brkvwb91zAS0gMaHqHc8BkVZX/s/EdHcRMhHPF7KtvchM CeiOHAbWB6MrZsxfqyz6SCuZO7JiPPZXpP849C4K+qkqyvcAXRA9xZtoKVSle06h1crX Jn3hbw+Crfsn1I3nI2GMTBPXI9LjGD+BMpbtsaeQNkX/LWSnJ/JbuDLucWup/Un0wagf zsE7AVW4c3gWzpJ+M5QgJdHPIjWLrK7UYoyQqPxT6+hJp/cM/BwQXlkoJTAAKHP69Ffp zWIfCGINs3hxUnMOkugy9jtDk5iWJU9nzxIttPxLV2ddGABEFvm35n8p4Z3QOX/ukAP+ dKYQ== X-Forwarded-Encrypted: i=1; AJvYcCWMN0zNz/sMd41nj9gu1Zcjnr4t5qO7ocP7jw6dLeQBa9QK7ByGEzobv1f1E3kenXgbjworXjgxP4gTzGoMouW1hGIXglab1ffz883yEl54BtQM/xku+CFQE24rij7S545KzhvI X-Gm-Message-State: AOJu0YykD1HD6uKLekvaujWMXFFmnfxvQ7tRicWGVfJQYjEo8AMxqDW9 7Wba19IbyfIQ0+Wevxm6e+uMQebKJIi+AE8SM6Sz3MTeQRDdKjpTZ4lh+OM1C5eK3azZB9lu2/d xTnFpxAARbmNXIQq5HPEG2mJYc6G6TWiI1SbUM0D+ X-Received: by 2002:a05:6102:227a:b0:472:e8a6:ad0 with SMTP id v26-20020a056102227a00b00472e8a60ad0mr251000vsd.18.1710344783671; Wed, 13 Mar 2024 08:46:23 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240313112620.1061463-1-s_min.jeong@samsung.com> <20240313112620.1061463-2-s_min.jeong@samsung.com> In-Reply-To: <20240313112620.1061463-2-s_min.jeong@samsung.com> From: Daeho Jeong Date: Wed, 13 Mar 2024 08:46:12 -0700 Message-ID: Subject: Re: [f2fs-dev] [PATCH 2/2] f2fs: truncate page cache before clearing flags when aborting atomic write To: Sunmin Jeong Cc: jaegeuk@kernel.org, chao@kernel.org, daehojeong@google.com, linux-f2fs-devel@lists.sourceforge.net, stable@vger.kernel.org, linux-kernel@vger.kernel.org, Sungjong Seo Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Reviewed-by: Daeho Jeong On Wed, Mar 13, 2024 at 4:29=E2=80=AFAM Sunmin Jeong wrote: > > In f2fs_do_write_data_page, FI_ATOMIC_FILE flag selects the target inode > between the original inode and COW inode. When aborting atomic write and > writeback occur simultaneously, invalid data can be written to original > inode if the FI_ATOMIC_FILE flag is cleared meanwhile. > > To prevent the problem, let's truncate all pages before clearing the flag > > Atomic write thread Writeback thread > f2fs_abort_atomic_write > clear_inode_flag(inode, FI_ATOMIC_FILE) > __writeback_single_inode > do_writepages > f2fs_do_write_data_page > - use dn of original inode > truncate_inode_pages_final > > Fixes: 3db1de0e582c ("f2fs: change the current atomic write way") > Cc: stable@vger.kernel.org #v5.19+ > Reviewed-by: Sungjong Seo > Reviewed-by: Yeongjin Gil > Signed-off-by: Sunmin Jeong > --- > fs/f2fs/segment.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 7901ede58113..7e47b8054413 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -192,6 +192,9 @@ void f2fs_abort_atomic_write(struct inode *inode, boo= l clean) > if (!f2fs_is_atomic_file(inode)) > return; > > + if (clean) > + truncate_inode_pages_final(inode->i_mapping); > + > release_atomic_write_cnt(inode); > clear_inode_flag(inode, FI_ATOMIC_COMMITTED); > clear_inode_flag(inode, FI_ATOMIC_REPLACE); > @@ -201,7 +204,6 @@ void f2fs_abort_atomic_write(struct inode *inode, boo= l clean) > F2FS_I(inode)->atomic_write_task =3D NULL; > > if (clean) { > - truncate_inode_pages_final(inode->i_mapping); > f2fs_i_size_write(inode, fi->original_i_size); > fi->original_i_size =3D 0; > } > -- > 2.25.1 > > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel