From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 12E42331EAE for ; Tue, 23 Jun 2026 06:35:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782196526; cv=none; b=c3Rm0V01tNi7fy+xyOUlQgmtHEAQKdAy+mwRlZODA0kBvqm1bnNXTyBw9x7jSDz0ynbXg0Xr+TV4ibeSO1R85n06bFQun1fcqfk/6VDttqMSd5LbD9S4pRWmK0hSBuufw1mRYYjJhlT59zp6xij45hFLUPrSUJrYrTPWihppGg8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782196526; c=relaxed/simple; bh=nGze0EqFTry19kCZ46ib7RJRtq7QVUpGDz34NspoNQI=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=gk4uhJ3pAr09fu2lduDOIy18Snn1k6tZoBpsEg00hfWS2U6m+TIGjj5VlMqBExpswRfXc2lqoFlO65eSPhEmwwSpM12Zv7ggMMVUT+uwiBq2pcXYYiOcjnbNBCfb5JlvW5l7odf14fzTy2hlMRdkpO67iIIax/u4fwDnAnDm3HU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--joannechien.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pOKR63sq; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--joannechien.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pOKR63sq" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c89956023dbso2910613a12.0 for ; Mon, 22 Jun 2026 23:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782196524; x=1782801324; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=P7euHvllGVN2xR+H7CES7r8htrHKGHGiwc6X1lxzcng=; b=pOKR63sqWp7/rRXtkR/KLkYPkdFstrib6DNgvzgRyNVsa2bMxtulFZ5Og7GFM+Laf6 zlugRFB/MwS4MB5hRgMG3oNbfADtY0XYczGVZchQyP7Uq++MkSh5g/6jMA3Kr5pp5Mkt ZQaAeQbV2POgIURRE879eRSIdYe9k7fhnsLQtEMznYB3UpgosDnloqC4Zw7Nk7g7SLdx ee9zX119uPjm9Xrn0tzvTCBJktoZ4Ryrcljwy1Jh2z28rNl48ge27UH2sP7ufcppx+f8 rJif9fsaJQ/FgNV7/0iW67AKjRTxMItfrRiVz3isR+UKjzV1FwSsTayS4pZjH7YJr58j 0EgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782196524; x=1782801324; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=P7euHvllGVN2xR+H7CES7r8htrHKGHGiwc6X1lxzcng=; b=OsX0LCuMnQ5qCkTgxdVoY1kmSM5+g4woLjlO3rdDN1hqwm3GJouEQxZVxJeImWld7S F5pmH7QNBgGbt600vzYreMYqEITC/dPbfM4Z6XLmWsp5G1mN/z+FbYy2C1rRkuWs2Y/9 a1Er3xT8C+VQw7kPL1AZNcD2WX4QYEdOrZdUexejM0EN+dwXWZS9pEbqrJBBDJI52on3 T55kUFELrWM9lJLPdd/qKEu+Yovn8C/HUTXWJtj4z0+XjcXm/uYfWx95Ea1gcRWqBXHs FUYB/J1sFaOLiAHwUxGFPfHFLEYDAMczAGt3c7sbG5sYHm98DWQY5y+GfIt7WIE2zK8b c2vA== X-Forwarded-Encrypted: i=1; AFNElJ8UiUs/jZ/SZBC0mcWPQYHVmEjmONF/4W78lcQM+W2HfZ5DATouJD36R5SSfmJJJ/1zkRkhvVTC07by0+U=@vger.kernel.org X-Gm-Message-State: AOJu0YzDrVsng3puHwxrjUzLzQf/GrARfomMcolFlMU5CJFuloRcgvM4 cRcfPq4asUZjYnEyWT9hQ4t9jwCZkovG+EAJMDzhU96Rv3lpU5hhqc9Xf4wPm4UQsPsoyAI7DuA Cq3jdg3uFur5h+XCGzHVjbhwB4w== X-Received: from pfr9.prod.google.com ([2002:a05:6a00:94c9:b0:842:3697:8685]) (user=joannechien job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:b95:b0:842:4f20:5402 with SMTP id d2e1a72fcca58-8456253555amr14657406b3a.21.1782196524023; Mon, 22 Jun 2026 23:35:24 -0700 (PDT) Date: Tue, 23 Jun 2026 06:34:28 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.55.0.rc0.786.g65d90a0328-goog Message-ID: <20260623063428.222361-1-joannechien@google.com> Subject: [PATCH v2] f2fs: dirty directory inodes on mtime/ctime update From: Joanne Chang To: Jaegeuk Kim , Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Joanne Chang , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Xfstests generic/547 sometimes fail with mismatched directory metadata before and after a power failure. This happens because when a directory entry is added, renamed, or deleted, its mtime and ctime are updated and the inode is marked dirty via f2fs_mark_inode_dirty_sync(dir, sync=false). The sync=false flag means the dirty inode is not added to the global DIRTY_META list. Therefore, subsequent checkpoints skip flushing these updated directory blocks, causing directory timestamps to revert to stale values after a sudden power failure. Address this by changing the dirtying parameter to sync=true during directory entry mutations and renames. This forces F2FS to immediately queue the updated directory blocks on the global DIRTY_META list, ensuring timestamps are committed to checkpoints. Fixes: 7c45729a4d6d ("f2fs: keep dirty inodes selectively for checkpoint") Cc: stable@vger.kernel.org Signed-off-by: Joanne Chang --- v1 -> v2: - added Fixes and Cc tags fs/f2fs/dir.c | 6 +++--- fs/f2fs/inline.c | 2 +- fs/f2fs/namei.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index a9563f7fcd88..e1c42d2b5c15 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -460,7 +460,7 @@ void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de, folio_mark_dirty(folio); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - f2fs_mark_inode_dirty_sync(dir, false); + f2fs_mark_inode_dirty_sync(dir, true); f2fs_folio_put(folio, true); } @@ -615,7 +615,7 @@ void f2fs_update_parent_metadata(struct inode *dir, struct inode *inode, clear_inode_flag(inode, FI_NEW_INODE); } inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - f2fs_mark_inode_dirty_sync(dir, false); + f2fs_mark_inode_dirty_sync(dir, true); if (F2FS_I(dir)->i_current_depth != current_depth) f2fs_i_depth_write(dir, current_depth); @@ -927,7 +927,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct folio *folio, f2fs_folio_put(folio, true); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - f2fs_mark_inode_dirty_sync(dir, false); + f2fs_mark_inode_dirty_sync(dir, true); if (inode) f2fs_drop_nlink(dir, inode); diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index e2f7bedf1552..aec06fb4fd76 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -732,7 +732,7 @@ void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, f2fs_folio_put(folio, true); inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); - f2fs_mark_inode_dirty_sync(dir, false); + f2fs_mark_inode_dirty_sync(dir, true); if (inode) f2fs_drop_nlink(dir, inode); diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index cac03b8e91a1..7ffdf23cea5e 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -1076,7 +1076,7 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, f2fs_up_write(&F2FS_I(old_inode)->i_sem); inode_set_ctime_current(old_inode); - f2fs_mark_inode_dirty_sync(old_inode, false); + f2fs_mark_inode_dirty_sync(old_inode, true); f2fs_delete_entry(old_entry, old_folio, old_dir, NULL); old_folio = NULL; @@ -1246,7 +1246,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, f2fs_i_links_write(old_dir, old_nlink > 0); f2fs_up_write(&F2FS_I(old_dir)->i_sem); } - f2fs_mark_inode_dirty_sync(old_dir, false); + f2fs_mark_inode_dirty_sync(old_dir, true); /* update directory entry info of new dir inode */ f2fs_set_link(new_dir, new_entry, new_folio, old_inode); @@ -1265,7 +1265,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, f2fs_i_links_write(new_dir, new_nlink > 0); f2fs_up_write(&F2FS_I(new_dir)->i_sem); } - f2fs_mark_inode_dirty_sync(new_dir, false); + f2fs_mark_inode_dirty_sync(new_dir, true); if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT) { f2fs_add_ino_entry(sbi, old_dir->i_ino, TRANS_DIR_INO); -- 2.55.0.rc0.786.g65d90a0328-goog