Skip to content

Commit 83a3bfd

Browse files
author
Jaegeuk Kim
committed
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: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent af697c0 commit 83a3bfd

6 files changed

Lines changed: 18 additions & 5 deletions

File tree

fs/f2fs/checkpoint.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct kmem_cache *f2fs_inode_entry_slab;
2828

2929
void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
3030
{
31+
f2fs_build_fault_attr(sbi, 0);
3132
set_ckpt_flags(sbi, CP_ERROR_FLAG);
3233
if (!end_io)
3334
f2fs_flush_merged_writes(sbi);

fs/f2fs/f2fs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,7 @@ enum {
10661066
SBI_POR_DOING, /* recovery is doing or not */
10671067
SBI_NEED_SB_WRITE, /* need to recover superblock */
10681068
SBI_NEED_CP, /* need to checkpoint */
1069+
SBI_IS_SHUTDOWN, /* shutdown by ioctl */
10691070
};
10701071

10711072
enum {
@@ -3373,4 +3374,10 @@ static inline bool f2fs_force_buffered_io(struct inode *inode, int rw)
33733374
F2FS_I_SB(inode)->s_ndevs);
33743375
}
33753376

3377+
#ifdef CONFIG_F2FS_FAULT_INJECTION
3378+
extern void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate);
3379+
#else
3380+
#define f2fs_build_fault_attr(sbi, rate) do { } while (0)
3381+
#endif
3382+
33763383
#endif

fs/f2fs/file.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,7 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
18891889
}
18901890
if (sb) {
18911891
f2fs_stop_checkpoint(sbi, false);
1892+
set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
18921893
thaw_bdev(sb->s_bdev, sb);
18931894
}
18941895
break;
@@ -1898,13 +1899,16 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
18981899
if (ret)
18991900
goto out;
19001901
f2fs_stop_checkpoint(sbi, false);
1902+
set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
19011903
break;
19021904
case F2FS_GOING_DOWN_NOSYNC:
19031905
f2fs_stop_checkpoint(sbi, false);
1906+
set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
19041907
break;
19051908
case F2FS_GOING_DOWN_METAFLUSH:
19061909
f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_META_IO);
19071910
f2fs_stop_checkpoint(sbi, false);
1911+
set_sbi_flag(sbi, SBI_IS_SHUTDOWN);
19081912
break;
19091913
default:
19101914
ret = -EINVAL;

fs/f2fs/inode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page)
159159
struct f2fs_inode *ri;
160160
__u32 provided, calculated;
161161

162+
if (unlikely(is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN)))
163+
return true;
164+
162165
if (!f2fs_enable_inode_chksum(sbi, page) ||
163166
PageDirty(page) || PageWriteback(page))
164167
return true;

fs/f2fs/node.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,8 @@ static int read_node_page(struct page *page, int op_flags)
11461146

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

1149-
if (unlikely(ni.blk_addr == NULL_ADDR)) {
1149+
if (unlikely(ni.blk_addr == NULL_ADDR) ||
1150+
is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN)) {
11501151
ClearPageUptodate(page);
11511152
return -ENOENT;
11521153
}

fs/f2fs/super.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ char *fault_name[FAULT_MAX] = {
5757
[FAULT_CHECKPOINT] = "checkpoint error",
5858
};
5959

60-
static void f2fs_build_fault_attr(struct f2fs_sb_info *sbi,
61-
unsigned int rate)
60+
void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate)
6261
{
6362
struct f2fs_fault_info *ffi = &F2FS_OPTION(sbi).fault_info;
6463

@@ -1379,9 +1378,7 @@ static void default_options(struct f2fs_sb_info *sbi)
13791378
set_opt(sbi, POSIX_ACL);
13801379
#endif
13811380

1382-
#ifdef CONFIG_F2FS_FAULT_INJECTION
13831381
f2fs_build_fault_attr(sbi, 0);
1384-
#endif
13851382
}
13861383

13871384
#ifdef CONFIG_QUOTA

0 commit comments

Comments
 (0)