Skip to content

Commit f40f31c

Browse files
committed
Merge tag 'f2fs-for-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs updates from Jaegeuk Kim: "In this round, we've mainly focused on fixing bugs and addressing issues in recently introduced compression support. Enhancement: - add zstd support, and set LZ4 by default - add ioctl() to show # of compressed blocks - show mount time in debugfs - replace rwsem with spinlock - avoid lock contention in DIO reads Some major bug fixes wrt compression: - compressed block count - memory access and leak - remove obsolete fields - flag controls Other bug fixes and clean ups: - fix overflow when handling .flags in inode_info - fix SPO issue during resize FS flow - fix compression with fsverity enabled - potential deadlock when writing compressed pages - show missing mount options" * tag 'f2fs-for-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (66 commits) f2fs: keep inline_data when compression conversion f2fs: fix to disable compression on directory f2fs: add missing CONFIG_F2FS_FS_COMPRESSION f2fs: switch discard_policy.timeout to bool type f2fs: fix to verify tpage before releasing in f2fs_free_dic() f2fs: show compression in statx f2fs: clean up dic->tpages assignment f2fs: compress: support zstd compress algorithm f2fs: compress: add .{init,destroy}_decompress_ctx callback f2fs: compress: fix to call missing destroy_compress_ctx() f2fs: change default compression algorithm f2fs: clean up {cic,dic}.ref handling f2fs: fix to use f2fs_readpage_limit() in f2fs_read_multi_pages() f2fs: xattr.h: Make stub helpers inline f2fs: fix to avoid double unlock f2fs: fix potential .flags overflow on 32bit architecture f2fs: fix NULL pointer dereference in f2fs_verity_work() f2fs: fix to clear PG_error if fsverity failed f2fs: don't call fscrypt_get_encryption_info() explicitly in f2fs_tmpfile() f2fs: don't trigger data flush in foreground operation ...
2 parents 763dede + 531dfae commit f40f31c

File tree

24 files changed

+820
-428
lines changed

24 files changed

+820
-428
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,8 @@ Date: September 2019
318318
Contact: "Hridya Valsaraju" <[email protected]>
319319
Description: Average number of valid blocks.
320320
Available when CONFIG_F2FS_STAT_FS=y.
321+
322+
What: /sys/fs/f2fs/<disk>/mounted_time_sec
323+
Date: February 2020
324+
Contact: "Jaegeuk Kim" <[email protected]>
325+
Description: Show the mounted time in secs of this partition.

Documentation/filesystems/f2fs.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ checkpoint=%s[:%u[%]] Set to "disable" to turn off checkpointing. Set to "enabl
243243
hide up to all remaining free space. The actual space that
244244
would be unusable can be viewed at /sys/fs/f2fs/<disk>/unusable
245245
This space is reclaimed once checkpoint=enable.
246-
compress_algorithm=%s Control compress algorithm, currently f2fs supports "lzo"
247-
and "lz4" algorithm.
246+
compress_algorithm=%s Control compress algorithm, currently f2fs supports "lzo",
247+
"lz4" and "zstd" algorithm.
248248
compress_log_size=%u Support configuring compress cluster size, the size will
249249
be 4KB * (1 << %u), 16KB is minimum size, also it's
250250
default size.

fs/f2fs/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,12 @@ config F2FS_FS_LZ4
118118
default y
119119
help
120120
Support LZ4 compress algorithm, if unsure, say Y.
121+
122+
config F2FS_FS_ZSTD
123+
bool "ZSTD compression support"
124+
depends on F2FS_FS_COMPRESSION
125+
select ZSTD_COMPRESS
126+
select ZSTD_DECOMPRESS
127+
default y
128+
help
129+
Support ZSTD compress algorithm, if unsure, say Y.

fs/f2fs/checkpoint.c

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
5050
return page;
5151
}
5252

53-
/*
54-
* We guarantee no failure on the returned page.
55-
*/
5653
static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
5754
bool is_meta)
5855
{
@@ -206,7 +203,7 @@ bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
206203
}
207204

208205
/*
209-
* Readahead CP/NAT/SIT/SSA pages
206+
* Readahead CP/NAT/SIT/SSA/POR pages
210207
*/
211208
int f2fs_ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
212209
int type, bool sync)
@@ -898,7 +895,7 @@ int f2fs_get_valid_checkpoint(struct f2fs_sb_info *sbi)
898895
return -ENOMEM;
899896
/*
900897
* Finding out valid cp block involves read both
901-
* sets( cp pack1 and cp pack 2)
898+
* sets( cp pack 1 and cp pack 2)
902899
*/
903900
cp_start_blk_no = le32_to_cpu(fsb->cp_blkaddr);
904901
cp1 = validate_checkpoint(sbi, cp_start_blk_no, &cp1_version);
@@ -1250,20 +1247,20 @@ static void unblock_operations(struct f2fs_sb_info *sbi)
12501247
f2fs_unlock_all(sbi);
12511248
}
12521249

1253-
void f2fs_wait_on_all_pages_writeback(struct f2fs_sb_info *sbi)
1250+
void f2fs_wait_on_all_pages(struct f2fs_sb_info *sbi, int type)
12541251
{
12551252
DEFINE_WAIT(wait);
12561253

12571254
for (;;) {
12581255
prepare_to_wait(&sbi->cp_wait, &wait, TASK_UNINTERRUPTIBLE);
12591256

1260-
if (!get_pages(sbi, F2FS_WB_CP_DATA))
1257+
if (!get_pages(sbi, type))
12611258
break;
12621259

12631260
if (unlikely(f2fs_cp_error(sbi)))
12641261
break;
12651262

1266-
io_schedule_timeout(5*HZ);
1263+
io_schedule_timeout(DEFAULT_IO_TIMEOUT);
12671264
}
12681265
finish_wait(&sbi->cp_wait, &wait);
12691266
}
@@ -1301,10 +1298,14 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
13011298
else
13021299
__clear_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG);
13031300

1304-
if (is_sbi_flag_set(sbi, SBI_NEED_FSCK) ||
1305-
is_sbi_flag_set(sbi, SBI_IS_RESIZEFS))
1301+
if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
13061302
__set_ckpt_flags(ckpt, CP_FSCK_FLAG);
13071303

1304+
if (is_sbi_flag_set(sbi, SBI_IS_RESIZEFS))
1305+
__set_ckpt_flags(ckpt, CP_RESIZEFS_FLAG);
1306+
else
1307+
__clear_ckpt_flags(ckpt, CP_RESIZEFS_FLAG);
1308+
13081309
if (is_sbi_flag_set(sbi, SBI_CP_DISABLED))
13091310
__set_ckpt_flags(ckpt, CP_DISABLED_FLAG);
13101311
else
@@ -1384,13 +1385,8 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
13841385

13851386
/* Flush all the NAT/SIT pages */
13861387
f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
1387-
f2fs_bug_on(sbi, get_pages(sbi, F2FS_DIRTY_META) &&
1388-
!f2fs_cp_error(sbi));
13891388

1390-
/*
1391-
* modify checkpoint
1392-
* version number is already updated
1393-
*/
1389+
/* start to update checkpoint, cp ver is already updated previously */
13941390
ckpt->elapsed_time = cpu_to_le64(get_mtime(sbi, true));
13951391
ckpt->free_segment_count = cpu_to_le32(free_segments(sbi));
13961392
for (i = 0; i < NR_CURSEG_NODE_TYPE; i++) {
@@ -1493,11 +1489,11 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
14931489

14941490
/* Here, we have one bio having CP pack except cp pack 2 page */
14951491
f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
1496-
f2fs_bug_on(sbi, get_pages(sbi, F2FS_DIRTY_META) &&
1497-
!f2fs_cp_error(sbi));
1492+
/* Wait for all dirty meta pages to be submitted for IO */
1493+
f2fs_wait_on_all_pages(sbi, F2FS_DIRTY_META);
14981494

14991495
/* wait for previous submitted meta pages writeback */
1500-
f2fs_wait_on_all_pages_writeback(sbi);
1496+
f2fs_wait_on_all_pages(sbi, F2FS_WB_CP_DATA);
15011497

15021498
/* flush all device cache */
15031499
err = f2fs_flush_device_cache(sbi);
@@ -1506,7 +1502,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
15061502

15071503
/* barrier and flush checkpoint cp pack 2 page if it can */
15081504
commit_checkpoint(sbi, ckpt, start_blk);
1509-
f2fs_wait_on_all_pages_writeback(sbi);
1505+
f2fs_wait_on_all_pages(sbi, F2FS_WB_CP_DATA);
15101506

15111507
/*
15121508
* invalidate intermediate page cache borrowed from meta inode which are
@@ -1543,9 +1539,6 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
15431539
return unlikely(f2fs_cp_error(sbi)) ? -EIO : 0;
15441540
}
15451541

1546-
/*
1547-
* We guarantee that this checkpoint procedure will not fail.
1548-
*/
15491542
int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
15501543
{
15511544
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
@@ -1613,7 +1606,6 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
16131606

16141607
f2fs_flush_sit_entries(sbi, cpc);
16151608

1616-
/* unlock all the fs_lock[] in do_checkpoint() */
16171609
err = do_checkpoint(sbi, cpc);
16181610
if (err)
16191611
f2fs_release_discard_addrs(sbi);
@@ -1626,7 +1618,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
16261618
if (cpc->reason & CP_RECOVERY)
16271619
f2fs_notice(sbi, "checkpoint: version = %llx", ckpt_ver);
16281620

1629-
/* do checkpoint periodically */
1621+
/* update CP_TIME to trigger checkpoint periodically */
16301622
f2fs_update_time(sbi, CP_TIME);
16311623
trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint");
16321624
out:

0 commit comments

Comments
 (0)