From patchwork Wed Sep 4 15:10:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daeho Jeong X-Patchwork-Id: 13791094 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D6C12CD4853 for ; Wed, 4 Sep 2024 15:11:18 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1slrfA-0001qo-LX; Wed, 04 Sep 2024 15:11:16 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1slrf5-0001qg-9r for linux-f2fs-devel@lists.sourceforge.net; Wed, 04 Sep 2024 15:11:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=43ydKagFmOiArusbTnepvZXequK3FKBWJc82HDWyEIw=; b=XbL8o/qf+B8tH7XqPsb5Ar0dUd tl9ZhtyRsNxWvhAjd7/pBVlJNsVh5rmFVvU/NPrNhKNfZGqpRn++9lTsR4MqZw+fwDbzsDpIROMyj WMBevfCGyKkaAe4j3/Z+C500bsURQunRP15/aCdxy4r2eAdKgx8cZg8E7UakzMdSEcOQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=43ydKagFmOiArusbTnepvZXequK3FKBWJc82HDWyEIw=; b=c QZcZCiRb+naHZIYqODgdr01ZmdRQOkVKb3KMeeNrLxdb1iZm6P2N9y1eEwGEMbM+45lWfcD1QmaM4 DPzyMobs18UOqSu8O1L8YKsHu0kGv6j/xfKAXPyVisGqtfcUnRICyUSpDuvic3RVI8iBkZ5mlOqrK oCjgauU8fVyoKyEM=; Received: from mail-pl1-f177.google.com ([209.85.214.177]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1slrf4-0000Pe-Ls for linux-f2fs-devel@lists.sourceforge.net; Wed, 04 Sep 2024 15:11:11 +0000 Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2053525bd90so36119815ad.0 for ; Wed, 04 Sep 2024 08:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725462660; x=1726067460; darn=lists.sourceforge.net; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=43ydKagFmOiArusbTnepvZXequK3FKBWJc82HDWyEIw=; b=fd5e7Gttl1hhLpedkCybInRJhcZ/r84VmIuipoY+YHcuQrbFivLGCsdJuP+L2Fg4Uf /vng1Nnm9sYmeV5GpuvX4+nsZ0Vq5ywXHioDounksy6PWgINoqbYE/Mh5o1nL/cCROJC OfUJZMV1rYDO/Wd12g3vfY1VTgfTZCjqN/ENrnW9fzJPVB2ll9aPMWlEdNXI9tDg47e5 DZW3feIdQD1F1bDTTqz89ELQAgeMaPg4Z/MB/aOwf6kw60d2dikE8UKUhtUofQ5e6sPI dbKdcDSQtkoq/D9pdY/7V4fQM3W+ijbekBucxkxGlacItIg0X9jMmnDV2VcC1BhrSh8E /59g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725462660; x=1726067460; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=43ydKagFmOiArusbTnepvZXequK3FKBWJc82HDWyEIw=; b=WQEE19SmSuPA3DSi1yBKrkNG3Q2JzyFiS0J4XmWGlG4bwRRFqZ+ua5hP4/G7Hl93ct NIJ04ceIqJCDEb4X2YoDKfCCiRKlR+U//ixfCJ5WDdlH+o4JiCgSGZUVZiLfIT68gRSn B+Iplccz7d5Gia50a2v0FPGCdwSyFtuTtZKhVKTO1B810voocvM3ghT1Xroo4McJLOSX 8+xaQ/UZjz4RC/WjTZYfqqNtOhZKOvQBXGOFTbNAdAc6meMbOqr7KuZVcrzX/JXwshkt dByhU+rAPS1UXYFFOW6aGYvG2JKGuOaOu7bbv8Bo+/hfLUzguGXRbUj2/NibrBaYK574 BMaQ== X-Forwarded-Encrypted: i=1; AJvYcCWvMY2MWS/reFLzqHdZw95UfuDJx2Kq+ENGCRNRkH7QrkXGMs4nAFEzyABDOJeIRwkVuPUmJ/AYiGVk4uavgh3V@lists.sourceforge.net X-Gm-Message-State: AOJu0YzQRrkFbhWDp1F8EhFd3fxvAZ9MB/tuR0PgYkFmYguQ6APFTAvR /gXVSv/B0fUvPm35zyTJ8r417S9ai2kqp9dKUCTwyYflQX5qDujj X-Google-Smtp-Source: AGHT+IGfo/94kB9afFvRPno+mvVQpzCAOhJq+Y9J3yrdPnGat19R1P1vOwtxLsIwUfwROlQ0n6sETw== X-Received: by 2002:a17:902:e74f:b0:205:7e3f:9e31 with SMTP id d9443c01a7336-2057e3fa1fcmr93168535ad.60.1725462659805; Wed, 04 Sep 2024 08:10:59 -0700 (PDT) Received: from daehojeong-desktop.mtv.corp.google.com ([2a00:79e0:2e14:7:85f3:1406:4b87:9708]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-206aea55d42sm14629905ad.204.2024.09.04.08.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 08:10:59 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Wed, 4 Sep 2024 08:10:54 -0700 Message-ID: <20240904151054.813444-1-daeho43@gmail.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog MIME-Version: 1.0 X-Headers-End: 1slrf4-0000Pe-Ls Subject: [f2fs-dev] [PATCH] f2fs: prevent atomic file from being dirtied before commit X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daeho Jeong Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Daeho Jeong Keep atomic file clean while updating and make it dirtied during commit in order to avoid unnecessary and excessive inode updates in the previous fix. Fixes: 4bf78322346f ("f2fs: mark inode dirty for FI_ATOMIC_COMMITTED flag") Signed-off-by: Daeho Jeong --- v2: take the original logic not to change inode size by inode dirtying from VFS layer --- fs/f2fs/f2fs.h | 2 +- fs/f2fs/inode.c | 5 +++++ fs/f2fs/segment.c | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index ac19c61f0c3e..4ef6d877aa36 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -802,6 +802,7 @@ enum { FI_ALIGNED_WRITE, /* enable aligned write */ FI_COW_FILE, /* indicate COW file */ FI_ATOMIC_COMMITTED, /* indicate atomic commit completed except disk sync */ + FI_ATOMIC_DIRTIED, /* indicate atomic file is dirtied */ FI_ATOMIC_REPLACE, /* indicate atomic replace */ FI_OPENED_FILE, /* indicate file has been opened */ FI_MAX, /* max flag, never be used */ @@ -3041,7 +3042,6 @@ static inline void __mark_inode_dirty_flag(struct inode *inode, case FI_INLINE_DOTS: case FI_PIN_FILE: case FI_COMPRESS_RELEASED: - case FI_ATOMIC_COMMITTED: f2fs_mark_inode_dirty_sync(inode, true); } } diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index aef57172014f..4729c49bf6d7 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -35,6 +35,11 @@ void f2fs_mark_inode_dirty_sync(struct inode *inode, bool sync) if (f2fs_inode_dirtied(inode, sync)) return; + if (f2fs_is_atomic_file(inode)) { + set_inode_flag(inode, FI_ATOMIC_DIRTIED); + return; + } + mark_inode_dirty_sync(inode); } diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 78c3198a6308..2f6ee9afd3ad 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -199,6 +199,10 @@ void f2fs_abort_atomic_write(struct inode *inode, bool clean) clear_inode_flag(inode, FI_ATOMIC_COMMITTED); clear_inode_flag(inode, FI_ATOMIC_REPLACE); clear_inode_flag(inode, FI_ATOMIC_FILE); + if (is_inode_flag_set(inode, FI_ATOMIC_DIRTIED)) { + clear_inode_flag(inode, FI_ATOMIC_DIRTIED); + f2fs_mark_inode_dirty_sync(inode, true); + } stat_dec_atomic_inode(inode); F2FS_I(inode)->atomic_write_task = NULL; @@ -366,6 +370,10 @@ static int __f2fs_commit_atomic_write(struct inode *inode) } else { sbi->committed_atomic_block += fi->atomic_write_cnt; set_inode_flag(inode, FI_ATOMIC_COMMITTED); + if (is_inode_flag_set(inode, FI_ATOMIC_DIRTIED)) { + clear_inode_flag(inode, FI_ATOMIC_DIRTIED); + f2fs_mark_inode_dirty_sync(inode, true); + } } __complete_revoke_list(inode, &revoke_list, ret ? true : false);