Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c92b7c75 authored by Jaegeuk Kim's avatar Jaegeuk Kim
Browse files

f2fs: indicate shutdown f2fs to allow unmount successfully



Once we shutdown f2fs, we have to flush stale pages in order to unmount
the system. In order to make stable, we need to stop fault injection as well.

Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent d263b05d
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ struct kmem_cache *f2fs_inode_entry_slab;


void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
{
{
	f2fs_build_fault_attr(sbi, 0);
	set_ckpt_flags(sbi, CP_ERROR_FLAG);
	set_ckpt_flags(sbi, CP_ERROR_FLAG);
	if (!end_io)
	if (!end_io)
		f2fs_flush_merged_writes(sbi);
		f2fs_flush_merged_writes(sbi);
+7 −0
Original line number Original line Diff line number Diff line
@@ -1065,6 +1065,7 @@ enum {
	SBI_POR_DOING,				/* recovery is doing or not */
	SBI_POR_DOING,				/* recovery is doing or not */
	SBI_NEED_SB_WRITE,			/* need to recover superblock */
	SBI_NEED_SB_WRITE,			/* need to recover superblock */
	SBI_NEED_CP,				/* need to checkpoint */
	SBI_NEED_CP,				/* need to checkpoint */
	SBI_IS_SHUTDOWN,			/* shutdown by ioctl */
};
};


enum {
enum {
@@ -3398,4 +3399,10 @@ static inline bool f2fs_force_buffered_io(struct inode *inode, int rw)
			F2FS_I_SB(inode)->s_ndevs);
			F2FS_I_SB(inode)->s_ndevs);
}
}


#ifdef CONFIG_F2FS_FAULT_INJECTION
extern void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate);
#else
#define f2fs_build_fault_attr(sbi, rate)		do { } while (0)
#endif

#endif
#endif
+4 −0
Original line number Original line Diff line number Diff line
@@ -1885,6 +1885,7 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
		}
		}
		if (sb) {
		if (sb) {
			f2fs_stop_checkpoint(sbi, false);
			f2fs_stop_checkpoint(sbi, false);
			set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
			thaw_bdev(sb->s_bdev, sb);
			thaw_bdev(sb->s_bdev, sb);
		}
		}
		break;
		break;
@@ -1894,13 +1895,16 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
		if (ret)
		if (ret)
			goto out;
			goto out;
		f2fs_stop_checkpoint(sbi, false);
		f2fs_stop_checkpoint(sbi, false);
		set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
		break;
		break;
	case F2FS_GOING_DOWN_NOSYNC:
	case F2FS_GOING_DOWN_NOSYNC:
		f2fs_stop_checkpoint(sbi, false);
		f2fs_stop_checkpoint(sbi, false);
		set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
		break;
		break;
	case F2FS_GOING_DOWN_METAFLUSH:
	case F2FS_GOING_DOWN_METAFLUSH:
		f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_META_IO);
		f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_META_IO);
		f2fs_stop_checkpoint(sbi, false);
		f2fs_stop_checkpoint(sbi, false);
		set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
		break;
		break;
	default:
	default:
		ret = -EINVAL;
		ret = -EINVAL;
+3 −0
Original line number Original line Diff line number Diff line
@@ -159,6 +159,9 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page)
	struct f2fs_inode *ri;
	struct f2fs_inode *ri;
	__u32 provided, calculated;
	__u32 provided, calculated;


	if (unlikely(is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN)))
		return true;

	if (!f2fs_enable_inode_chksum(sbi, page) ||
	if (!f2fs_enable_inode_chksum(sbi, page) ||
			PageDirty(page) || PageWriteback(page))
			PageDirty(page) || PageWriteback(page))
		return true;
		return true;
+2 −1
Original line number Original line Diff line number Diff line
@@ -1146,7 +1146,8 @@ static int read_node_page(struct page *page, int op_flags)


	f2fs_get_node_info(sbi, page->index, &ni);
	f2fs_get_node_info(sbi, page->index, &ni);


	if (unlikely(ni.blk_addr == NULL_ADDR)) {
	if (unlikely(ni.blk_addr == NULL_ADDR) ||
			is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN)) {
		ClearPageUptodate(page);
		ClearPageUptodate(page);
		return -ENOENT;
		return -ENOENT;
	}
	}
Loading