Skip to content

Commit d6edff7

Browse files
committed
Merge tag 'f2fs-for-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "In this round, we've added 1) superblock checksum feature, 2) implemented new mount option which we can disable/enable checkpoint to provide atomic updates of entire filesystem, 3) refactored quota operations to enhance its consistency along with checkpoint, 4) fixed subtle IO hang conditions and roll-forward recovery flow to resurrect any fsync'ed inode metadata. Enhancements: - add checksum to keep superblock contents more safe - add checkpoint=disable/enable to support A/B update of entire filesystem - use plug for readahead IO in readdir - add more IO counts to avoid block layer hacks Bug fixes: - prevent data corruption issue for hardware encryption - fix IO hang issues when GC is heavily triggered - add missing up_read in __write_node_page - recover inode metadata during roll-forward recovery flow - fix null pointer dereference issue in wrongly configured discard map There are some more sanity checks and minor bug fixes as well" * tag 'f2fs-for-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (62 commits) f2fs: fix to keep project quota consistent f2fs: guarantee journalled quota data by checkpoint f2fs: cleanup dirty pages if recover failed f2fs: fix data corruption issue with hardware encryption f2fs: fix to recover inode->i_flags of inode block during POR f2fs: spread f2fs_set_inode_flags() f2fs: fix to spread clear_cold_data() Revert "f2fs: fix to clear PG_checked flag in set_page_dirty()" f2fs: account read IOs and use IO counts for is_idle f2fs: fix to account IO correctly for cgroup writeback f2fs: fix to account IO correctly f2fs: remove request_list check in is_idle() f2fs: allow to mount, if quota is failed f2fs: update REQ_TIME in f2fs_cross_rename() f2fs: do not update REQ_TIME in case of error conditions f2fs: remove unneeded disable_nat_bits() f2fs: remove unused sbi->trigger_ssr_threshold f2fs: shrink sbi->sb_lock coverage in set_file_temperature() f2fs: use rb_*_cached friends f2fs: fix to recover cold bit of inode block during POR ...
2 parents fe0142d + 7813081 commit d6edff7

File tree

30 files changed

+1594
-568
lines changed

30 files changed

+1594
-568
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,22 @@ What: /sys/fs/f2fs/<disk>/idle_interval
121121
Date: January 2016
122122
Contact: "Jaegeuk Kim" <jaegeuk@kernel.org>
123123
Description:
124-
Controls the idle timing.
124+
Controls the idle timing for all paths other than
125+
discard and gc path.
126+
127+
What: /sys/fs/f2fs/<disk>/discard_idle_interval
128+
Date: September 2018
129+
Contact: "Chao Yu" <yuchao0@huawei.com>
130+
Contact: "Sahitya Tummala" <stummala@codeaurora.org>
131+
Description:
132+
Controls the idle timing for discard path.
133+
134+
What: /sys/fs/f2fs/<disk>/gc_idle_interval
135+
Date: September 2018
136+
Contact: "Chao Yu" <yuchao0@huawei.com>
137+
Contact: "Sahitya Tummala" <stummala@codeaurora.org>
138+
Description:
139+
Controls the idle timing for gc path.
125140

126141
What: /sys/fs/f2fs/<disk>/iostat_enable
127142
Date: August 2017

Documentation/filesystems/f2fs.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,10 @@ fault_type=%d Support configuring fault injection type, should be
172172
FAULT_DIR_DEPTH 0x000000100
173173
FAULT_EVICT_INODE 0x000000200
174174
FAULT_TRUNCATE 0x000000400
175-
FAULT_IO 0x000000800
175+
FAULT_READ_IO 0x000000800
176176
FAULT_CHECKPOINT 0x000001000
177177
FAULT_DISCARD 0x000002000
178+
FAULT_WRITE_IO 0x000004000
178179
mode=%s Control block allocation mode which supports "adaptive"
179180
and "lfs". In "lfs" mode, there should be no random
180181
writes towards main area.
@@ -211,6 +212,11 @@ fsync_mode=%s Control the policy of fsync. Currently supports "posix",
211212
non-atomic files likewise "nobarrier" mount option.
212213
test_dummy_encryption Enable dummy encryption, which provides a fake fscrypt
213214
context. The fake fscrypt context is used by xfstests.
215+
checkpoint=%s Set to "disable" to turn off checkpointing. Set to "enable"
216+
to reenable checkpointing. Is enabled by default. While
217+
disabled, any unmounting or unexpected shutdowns will cause
218+
the filesystem contents to appear as they did when the
219+
filesystem was mounted with that option.
214220

215221
================================================================================
216222
DEBUGFS ENTRIES

fs/f2fs/acl.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* fs/f2fs/acl.c
34
*
@@ -7,10 +8,6 @@
78
* Portions of this code from linux/fs/ext2/acl.c
89
*
910
* Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
10-
*
11-
* This program is free software; you can redistribute it and/or modify
12-
* it under the terms of the GNU General Public License version 2 as
13-
* published by the Free Software Foundation.
1411
*/
1512
#include <linux/f2fs_fs.h>
1613
#include "f2fs.h"
@@ -53,6 +50,9 @@ static struct posix_acl *f2fs_acl_from_disk(const char *value, size_t size)
5350
struct f2fs_acl_entry *entry = (struct f2fs_acl_entry *)(hdr + 1);
5451
const char *end = value + size;
5552

53+
if (size < sizeof(struct f2fs_acl_header))
54+
return ERR_PTR(-EINVAL);
55+
5656
if (hdr->a_version != cpu_to_le32(F2FS_ACL_VERSION))
5757
return ERR_PTR(-EINVAL);
5858

@@ -394,12 +394,16 @@ int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
394394
error = __f2fs_set_acl(inode, ACL_TYPE_DEFAULT, default_acl,
395395
ipage);
396396
posix_acl_release(default_acl);
397+
} else {
398+
inode->i_default_acl = NULL;
397399
}
398400
if (acl) {
399401
if (!error)
400402
error = __f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl,
401403
ipage);
402404
posix_acl_release(acl);
405+
} else {
406+
inode->i_acl = NULL;
403407
}
404408

405409
return error;

fs/f2fs/acl.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* fs/f2fs/acl.h
34
*
@@ -7,10 +8,6 @@
78
* Portions of this code from linux/fs/ext2/acl.h
89
*
910
* Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
10-
*
11-
* This program is free software; you can redistribute it and/or modify
12-
* it under the terms of the GNU General Public License version 2 as
13-
* published by the Free Software Foundation.
1411
*/
1512
#ifndef __F2FS_ACL_H__
1613
#define __F2FS_ACL_H__

fs/f2fs/checkpoint.c

Lines changed: 79 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* fs/f2fs/checkpoint.c
34
*
45
* Copyright (c) 2012 Samsung Electronics Co., Ltd.
56
* http://www.samsung.com/
6-
*
7-
* This program is free software; you can redistribute it and/or modify
8-
* it under the terms of the GNU General Public License version 2 as
9-
* published by the Free Software Foundation.
107
*/
118
#include <linux/fs.h>
129
#include <linux/bio.h>
@@ -122,11 +119,8 @@ struct page *f2fs_get_meta_page_nofail(struct f2fs_sb_info *sbi, pgoff_t index)
122119
if (PTR_ERR(page) == -EIO &&
123120
++count <= DEFAULT_RETRY_IO_COUNT)
124121
goto retry;
125-
126122
f2fs_stop_checkpoint(sbi, false);
127-
f2fs_bug_on(sbi, 1);
128123
}
129-
130124
return page;
131125
}
132126

@@ -282,8 +276,7 @@ static int __f2fs_write_meta_page(struct page *page,
282276
dec_page_count(sbi, F2FS_DIRTY_META);
283277

284278
if (wbc->for_reclaim)
285-
f2fs_submit_merged_write_cond(sbi, page->mapping->host,
286-
0, page->index, META);
279+
f2fs_submit_merged_write_cond(sbi, NULL, page, 0, META);
287280

288281
unlock_page(page);
289282

@@ -696,6 +689,8 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
696689
/* clear Orphan Flag */
697690
clear_ckpt_flags(sbi, CP_ORPHAN_PRESENT_FLAG);
698691
out:
692+
set_sbi_flag(sbi, SBI_IS_RECOVERED);
693+
699694
#ifdef CONFIG_QUOTA
700695
/* Turn quotas off */
701696
if (quota_enabled)
@@ -1084,6 +1079,21 @@ static void __prepare_cp_block(struct f2fs_sb_info *sbi)
10841079
ckpt->next_free_nid = cpu_to_le32(last_nid);
10851080
}
10861081

1082+
static bool __need_flush_quota(struct f2fs_sb_info *sbi)
1083+
{
1084+
if (!is_journalled_quota(sbi))
1085+
return false;
1086+
if (is_sbi_flag_set(sbi, SBI_QUOTA_SKIP_FLUSH))
1087+
return false;
1088+
if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_REPAIR))
1089+
return false;
1090+
if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_FLUSH))
1091+
return true;
1092+
if (get_pages(sbi, F2FS_DIRTY_QDATA))
1093+
return true;
1094+
return false;
1095+
}
1096+
10871097
/*
10881098
* Freeze all the FS-operations for checkpoint.
10891099
*/
@@ -1095,20 +1105,44 @@ static int block_operations(struct f2fs_sb_info *sbi)
10951105
.for_reclaim = 0,
10961106
};
10971107
struct blk_plug plug;
1098-
int err = 0;
1108+
int err = 0, cnt = 0;
10991109

11001110
blk_start_plug(&plug);
11011111

1102-
retry_flush_dents:
1112+
retry_flush_quotas:
1113+
if (__need_flush_quota(sbi)) {
1114+
int locked;
1115+
1116+
if (++cnt > DEFAULT_RETRY_QUOTA_FLUSH_COUNT) {
1117+
set_sbi_flag(sbi, SBI_QUOTA_SKIP_FLUSH);
1118+
f2fs_lock_all(sbi);
1119+
goto retry_flush_dents;
1120+
}
1121+
clear_sbi_flag(sbi, SBI_QUOTA_NEED_FLUSH);
1122+
1123+
/* only failed during mount/umount/freeze/quotactl */
1124+
locked = down_read_trylock(&sbi->sb->s_umount);
1125+
f2fs_quota_sync(sbi->sb, -1);
1126+
if (locked)
1127+
up_read(&sbi->sb->s_umount);
1128+
}
1129+
11031130
f2fs_lock_all(sbi);
1131+
if (__need_flush_quota(sbi)) {
1132+
f2fs_unlock_all(sbi);
1133+
cond_resched();
1134+
goto retry_flush_quotas;
1135+
}
1136+
1137+
retry_flush_dents:
11041138
/* write all the dirty dentry pages */
11051139
if (get_pages(sbi, F2FS_DIRTY_DENTS)) {
11061140
f2fs_unlock_all(sbi);
11071141
err = f2fs_sync_dirty_inodes(sbi, DIR_INODE);
11081142
if (err)
11091143
goto out;
11101144
cond_resched();
1111-
goto retry_flush_dents;
1145+
goto retry_flush_quotas;
11121146
}
11131147

11141148
/*
@@ -1117,14 +1151,20 @@ static int block_operations(struct f2fs_sb_info *sbi)
11171151
*/
11181152
down_write(&sbi->node_change);
11191153

1154+
if (__need_flush_quota(sbi)) {
1155+
up_write(&sbi->node_change);
1156+
f2fs_unlock_all(sbi);
1157+
goto retry_flush_quotas;
1158+
}
1159+
11201160
if (get_pages(sbi, F2FS_DIRTY_IMETA)) {
11211161
up_write(&sbi->node_change);
11221162
f2fs_unlock_all(sbi);
11231163
err = f2fs_sync_inode_meta(sbi);
11241164
if (err)
11251165
goto out;
11261166
cond_resched();
1127-
goto retry_flush_dents;
1167+
goto retry_flush_quotas;
11281168
}
11291169

11301170
retry_flush_nodes:
@@ -1215,6 +1255,19 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
12151255
if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
12161256
__set_ckpt_flags(ckpt, CP_FSCK_FLAG);
12171257

1258+
if (is_sbi_flag_set(sbi, SBI_CP_DISABLED))
1259+
__set_ckpt_flags(ckpt, CP_DISABLED_FLAG);
1260+
else
1261+
__clear_ckpt_flags(ckpt, CP_DISABLED_FLAG);
1262+
1263+
if (is_sbi_flag_set(sbi, SBI_QUOTA_SKIP_FLUSH))
1264+
__set_ckpt_flags(ckpt, CP_QUOTA_NEED_FSCK_FLAG);
1265+
else
1266+
__clear_ckpt_flags(ckpt, CP_QUOTA_NEED_FSCK_FLAG);
1267+
1268+
if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_REPAIR))
1269+
__set_ckpt_flags(ckpt, CP_QUOTA_NEED_FSCK_FLAG);
1270+
12181271
/* set this flag to activate crc|cp_ver for recovery */
12191272
__set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG);
12201273
__clear_ckpt_flags(ckpt, CP_NOCRC_RECOVERY_FLAG);
@@ -1422,6 +1475,8 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
14221475

14231476
clear_sbi_flag(sbi, SBI_IS_DIRTY);
14241477
clear_sbi_flag(sbi, SBI_NEED_CP);
1478+
clear_sbi_flag(sbi, SBI_QUOTA_SKIP_FLUSH);
1479+
sbi->unusable_block_count = 0;
14251480
__set_cp_next_pack(sbi);
14261481

14271482
/*
@@ -1446,6 +1501,12 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
14461501
unsigned long long ckpt_ver;
14471502
int err = 0;
14481503

1504+
if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) {
1505+
if (cpc->reason != CP_PAUSE)
1506+
return 0;
1507+
f2fs_msg(sbi->sb, KERN_WARNING,
1508+
"Start checkpoint disabled!");
1509+
}
14491510
mutex_lock(&sbi->cp_mutex);
14501511

14511512
if (!is_sbi_flag_set(sbi, SBI_IS_DIRTY) &&
@@ -1497,7 +1558,10 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
14971558
ckpt->checkpoint_ver = cpu_to_le64(++ckpt_ver);
14981559

14991560
/* write cached NAT/SIT entries to NAT/SIT area */
1500-
f2fs_flush_nat_entries(sbi, cpc);
1561+
err = f2fs_flush_nat_entries(sbi, cpc);
1562+
if (err)
1563+
goto stop;
1564+
15011565
f2fs_flush_sit_entries(sbi, cpc);
15021566

15031567
/* unlock all the fs_lock[] in do_checkpoint() */
@@ -1506,7 +1570,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
15061570
f2fs_release_discard_addrs(sbi);
15071571
else
15081572
f2fs_clear_prefree_segments(sbi, cpc);
1509-
1573+
stop:
15101574
unblock_operations(sbi);
15111575
stat_inc_cp_count(sbi->stat_info);
15121576

0 commit comments

Comments
 (0)