Linux-f2fs-devel Archive on
 help / color / Atom feed
* [f2fs-dev] [PATCH] f2fs: fix to drop meta/node pages during umount
@ 2019-07-18  8:39 Chao Yu
  0 siblings, 0 replies; only message in thread
From: Chao Yu @ 2019-07-18  8:39 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, drosen, linux-f2fs-devel

As reported in bugzilla:

A null pointer dereference bug is triggered in f2fs under kernel-5.1.3.


During umount, we will access NULL sbi->node_inode pointer in

	f2fs_bug_on(sbi, page->mapping == NODE_MAPPING(sbi) &&
				page->index != nid_of_node(page));

The reason is if disable_checkpoint mount option is on, meta dirty
pages can remain during umount, and then be flushed by iput() of
meta_inode, however node_inode has been iput()ed before
meta_inode's iput().

Since checkpoint is disabled, all meta/node datas are useless and
should be dropped in next mount, so in umount, let's adjust
drop_inode() to give a hint to iput_final() to drop all those dirty
datas correctly.

Signed-off-by: Chao Yu <>
 fs/f2fs/super.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 580fa3d837c7..e5cae67935f6 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -873,7 +873,21 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb)
 static int f2fs_drop_inode(struct inode *inode)
+	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 	int ret;
+	/*
+	 * during filesystem shutdown, if checkpoint is disabled,
+	 * drop useless meta/node dirty pages.
+	 */
+	if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) {
+		if (inode->i_ino == F2FS_NODE_INO(sbi) ||
+			inode->i_ino == F2FS_META_INO(sbi)) {
+			trace_f2fs_drop_inode(inode, 1);
+			return 1;
+		}
+	}
 	 * This is to avoid a deadlock condition like below.
 	 * writeback_single_inode(inode)

Linux-f2fs-devel mailing list

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-18  8:39 [f2fs-dev] [PATCH] f2fs: fix to drop meta/node pages during umount Chao Yu

Linux-f2fs-devel Archive on

Archives are clonable:
	git clone --mirror linux-f2fs-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-f2fs-devel linux-f2fs-devel/ \
	public-inbox-index linux-f2fs-devel

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone