From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 90E3B31F9BD for ; Mon, 15 Jun 2026 08:04:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781510642; cv=none; b=ShNQF5wY75UnI1Tq9lldQTlv4j+KFZPlPvyOCh4VIKAM/JF4A5rEo86xo2u6815Vw4nYcl8po6PkIosqns/9cnb8jIqUC/4yN2qvf52Ok6kdKuPfRBD9e125DovxgTyDoXMAdVmmhRtAO9fFrv+IaKbR4XSXTs8HjDUKW7rEZ8s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781510642; c=relaxed/simple; bh=MfZP7Q0aYe/hXtmWJstUBTyuREJqoUdchuVdMiyQhYE=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=IKeUqpGZO9/ErTVxKqVVQYASEbefpiEJQjbxckuO0JXVEgzbUQHKlc/YPhJehn4xaN0T2SFGh6G7tghw5hrixiig1umYZ4NEADFAQ93e15rpsoSdPddZrKKzGPlyTkwmDyKB4fdrUwUGMi7sUmLPvmUnqSGS56C1VDpcBQRxxpo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CtINnXxT; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CtINnXxT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 455DD1F000E9; Mon, 15 Jun 2026 08:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781510641; bh=A/7HaUKF285OiVVqEwwEggqwl8EHC2WWLW18/9e0IEQ=; h=Date:Cc:Subject:To:References:From:In-Reply-To; b=CtINnXxTnZlixysPxZSfDYAjvxrBhKeoikkJ9lzdGRq3QfKgz+527hLVpn1WdTuIr GOM3/Z8bCde3Zn9F/6sGYbbDmtyeWPEEA09Bf90FskgJc6uHBIxV5EH0FuX5UV/qsL 6eJqRgOU4Z0IS3E8sKYp1w+xLhOwxnZPdKOHtLiXQB+KD0IAs+DmsNYdPj9b3lMal0 ytTIefLPzVqplzIIl/YroxPjxzXZJaDYtbAOSgEtyz2EPWdBtsaulNbPyWC7Z1P7Ib jbNi8QlFVeesgsKcDOazoy3WOh1VGIh4vprOEZM8NVyssWP8FN/Y3H9Te8/YqA4Z24 VOlf7w8DQdaEA== Message-ID: <7a1d2390-8416-4e1d-859e-b4ac73c0894a@kernel.org> Date: Mon, 15 Jun 2026 16:03:58 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, qiwenjie@xiaomi.com Subject: Re: [PATCH] f2fs: skip clean inode update during fsync To: Wenjie Qi , jaegeuk@kernel.org References: <20260528140954.3205736-1-qiwenjie@xiaomi.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20260528140954.3205736-1-qiwenjie@xiaomi.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/28/26 22:09, Wenjie Qi wrote: > f2fs_do_sync_file() calls f2fs_skip_inode_update() before deciding > whether it has to write an inode block and continue into the recovery > info/flush path. > > For a full fsync, f2fs_skip_inode_update() currently returns false when > FI_AUTO_RECOVER is not set. That makes fsync on an already clean file > call f2fs_write_inode(). f2fs_write_inode() then returns immediately if > the in-memory timestamps match the inode block and FI_DIRTY_INODE is not > set, but f2fs_do_sync_file() still continues through go_write and may end > at f2fs_issue_flush(). > > Avoid that unnecessary path for clean, time-consistent inodes without > FI_AUTO_RECOVER. Keep the existing conservative checks for keep-size > files and non-block-aligned i_size before allowing the skip, and leave the > FI_AUTO_RECOVER path unchanged. > > On a QEMU/KASAN test VM, repeated fsync() on an existing clean F2FS file > improved from about 35.7 us/fsync to about 1.13 us/fsync. The baseline > issued one flush per fsync, while the patched kernel kept the F2FS flush > count unchanged over 140000 clean fsync calls. > > Signed-off-by: Wenjie Qi > --- > fs/f2fs/f2fs.h | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index 9f24287de4c3..ebd485abecb4 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -3668,11 +3668,13 @@ static inline bool f2fs_skip_inode_update(struct inode *inode, int dsync) > spin_unlock(&sbi->inode_lock[DIRTY_META]); > return ret; > } > - if (!is_inode_flag_set(inode, FI_AUTO_RECOVER) || > - file_keep_isize(inode) || > - i_size_read(inode) & ~PAGE_MASK) > + if (file_keep_isize(inode) || i_size_read(inode) & ~PAGE_MASK) > return false; > > + if (!is_inode_flag_set(inode, FI_AUTO_RECOVER)) > + return f2fs_is_time_consistent(inode) && > + !is_inode_flag_set(inode, FI_DIRTY_INODE); IIUC, without this additional check condition, f2fs_write_inode() will skip to update inode page as well according to the same check condition, so, do you know why will we have so many benefits on fsync? int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) { ... /* * atime could be updated without dirtying f2fs inode in lazytime mode */ if (f2fs_is_time_consistent(inode) && !is_inode_flag_set(inode, FI_DIRTY_INODE)) return 0; Thanks, > + > if (!f2fs_is_time_consistent(inode)) > return false; >