Commit 041fae9c authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull f2fs updates from Jaegeuk Kim:
 "In this round, we've added two features: F2FS_IOC_START_ATOMIC_REPLACE
  and a per-block age-based extent cache.

  F2FS_IOC_START_ATOMIC_REPLACE is a variant of the previous atomic
  write feature which guarantees a per-file atomicity. It would be more
  efficient than AtomicFile implementation in Android framework.

  The per-block age-based extent cache implements another type of extent
  cache in memory which keeps the per-block age in a file, so that block
  allocator could split the hot and cold data blocks more accurately.

  Enhancements:
   - introduce F2FS_IOC_START_ATOMIC_REPLACE
   - refactor extent_cache to add a new per-block-age-based extent cache support
   - introduce discard_urgent_util, gc_mode, max_ordered_discard sysfs knobs
   - add proc entry to show discard_plist info
   - optimize iteration over sparse directories
   - add barrier mount option

  Bug fixes:
   - avoid victim selection from previous victim section
   - fix to enable compress for newly created file if extension matches
   - set zstd compress level correctly
   - initialize locks early in f2fs_fill_super() to fix bugs reported by syzbot
   - correct i_size change for atomic writes
   - allow to read node block after shutdown
   - allow to set compression for inlined file
   - fix gc mode when gc_urgent_high_remaining is 1
   - should put a page when checking the summary info

  Minor fixes and various clean-ups in GC, discard, debugfs, sysfs, and
  doc"

* tag 'f2fs-for-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (63 commits)
  f2fs: reset wait_ms to default if any of the victims have been selected
  f2fs: fix some format WARNING in debug.c and sysfs.c
  f2fs: don't call f2fs_issue_discard_timeout() when discard_cmd_cnt is 0 in f2fs_put_super()
  f2fs: fix iostat parameter for discard
  f2fs: Fix spelling mistake in label: free_bio_enrty_cache -> free_bio_entry_cache
  f2fs: add block_age-based extent cache
  f2fs: allocate the extent_cache by default
  f2fs: refactor extent_cache to support for read and more
  f2fs: remove unnecessary __init_extent_tree
  f2fs: move internal functions into extent_cache.c
  f2fs: specify extent cache for read explicitly
  f2fs: introduce f2fs_is_readonly() for readability
  f2fs: remove F2FS_SET_FEATURE() and F2FS_CLEAR_FEATURE() macro
  f2fs: do some cleanup for f2fs module init
  MAINTAINERS: Add f2fs bug tracker link
  f2fs: remove the unused flush argument to change_curseg
  f2fs: open code allocate_segment_by_default
  f2fs: remove struct segment_allocation default_salloc_ops
  f2fs: introduce discard_urgent_util sysfs node
  f2fs: define MIN_DISCARD_GRANULARITY macro
  ...
parents eb67d239 26a8057a
Loading
Loading
Loading
Loading
+41 −6
Original line number Diff line number Diff line
@@ -99,6 +99,12 @@ Description: Controls the issue rate of discard commands that consist of small
		checkpoint is triggered, and issued during the checkpoint.
		By default, it is disabled with 0.

What:		/sys/fs/f2fs/<disk>/max_ordered_discard
Date:		October 2022
Contact:	"Yangtao Li" <frank.li@vivo.com>
Description:	Controls the maximum ordered discard, the unit size is one block(4KB).
		Set it to 16 by default.

What:		/sys/fs/f2fs/<disk>/max_discard_request
Date:		December 2021
Contact:	"Konstantin Vyshetsky" <vkon@google.com>
@@ -132,7 +138,8 @@ Contact: "Chao Yu" <yuchao0@huawei.com>
Description:	Controls discard granularity of inner discard thread. Inner thread
		will not issue discards with size that is smaller than granularity.
		The unit size is one block(4KB), now only support configuring
		in range of [1, 512]. Default value is 4(=16KB).
		in range of [1, 512]. Default value is 16.
		For small devices, default value is 1.

What:		/sys/fs/f2fs/<disk>/umount_discard_timeout
Date:		January 2019
@@ -235,7 +242,7 @@ Description: Shows total written kbytes issued to disk.
What:		/sys/fs/f2fs/<disk>/features
Date:		July 2017
Contact:	"Jaegeuk Kim" <jaegeuk@kernel.org>
Description:	<deprecated: should use /sys/fs/f2fs/<disk>/feature_list/
Description:	<deprecated: should use /sys/fs/f2fs/<disk>/feature_list/>
		Shows all enabled features in current device.
		Supported features:
		encryption, blkzoned, extra_attr, projquota, inode_checksum,
@@ -592,10 +599,10 @@ Description: With "mode=fragment:block" mount options, we can scatter block allo
		in the length of 1..<max_fragment_hole> by turns. This value can be set
		between 1..512 and the default value is 4.

What:		/sys/fs/f2fs/<disk>/gc_urgent_high_remaining
Date:		December 2021
Contact:	"Daeho Jeong" <daehojeong@google.com>
Description:	You can set the trial count limit for GC urgent high mode with this value.
What:		/sys/fs/f2fs/<disk>/gc_remaining_trials
Date:		October 2022
Contact:	"Yangtao Li" <frank.li@vivo.com>
Description:	You can set the trial count limit for GC urgent and idle mode with this value.
		If GC thread gets to the limit, the mode will turn back to GC normal mode.
		By default, the value is zero, which means there is no limit like before.

@@ -634,3 +641,31 @@ Date: July 2022
Contact:	"Daeho Jeong" <daehojeong@google.com>
Description:	Show the accumulated total revoked atomic write block count after boot.
		If you write "0" here, you can initialize to "0".

What:		/sys/fs/f2fs/<disk>/gc_mode
Date:		October 2022
Contact:	"Yangtao Li" <frank.li@vivo.com>
Description:	Show the current gc_mode as a string.
		This is a read-only entry.

What:		/sys/fs/f2fs/<disk>/discard_urgent_util
Date:		November 2022
Contact:	"Yangtao Li" <frank.li@vivo.com>
Description:	When space utilization exceeds this, do background DISCARD aggressively.
		Does DISCARD forcibly in a period of given min_discard_issue_time when the number
		of discards is not 0 and set discard granularity to 1.
		Default: 80

What:		/sys/fs/f2fs/<disk>/hot_data_age_threshold
Date:		November 2022
Contact:	"Ping Xiong" <xiongping1@xiaomi.com>
Description:	When DATA SEPARATION is on, it controls the age threshold to indicate
		the data blocks as hot. By default it was initialized as 262144 blocks
		(equals to 1GB).

What:		/sys/fs/f2fs/<disk>/warm_data_age_threshold
Date:		November 2022
Contact:	"Ping Xiong" <xiongping1@xiaomi.com>
Description:	When DATA SEPARATION is on, it controls the age threshold to indicate
		the data blocks as warm. By default it was initialized as 2621440 blocks
		(equals to 10GB).
+12 −1
Original line number Diff line number Diff line
@@ -25,10 +25,14 @@ a consistency checking tool (fsck.f2fs), and a debugging tool (dump.f2fs).

- git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git

For reporting bugs and sending patches, please use the following mailing list:
For sending patches, please use the following mailing list:

- linux-f2fs-devel@lists.sourceforge.net

For reporting bugs, please use the following f2fs bug tracker link:

- https://bugzilla.kernel.org/enter_bug.cgi?product=File%20System&component=f2fs

Background and Design issues
============================

@@ -154,6 +158,8 @@ nobarrier This option can be used if underlying storage guarantees
			 If this option is set, no cache_flush commands are issued
			 but f2fs still guarantees the write ordering of all the
			 data writes.
barrier		 If this option is set, cache_flush commands are allowed to be
			 issued.
fastboot		 This option is used when a system wants to reduce mount
			 time as much as possible, even though normal performance
			 can be sacrificed.
@@ -199,6 +205,7 @@ fault_type=%d Support configuring fault injection type, should be
			 FAULT_SLAB_ALLOC	  0x000008000
			 FAULT_DQUOT_INIT	  0x000010000
			 FAULT_LOCK_OP		  0x000020000
			 FAULT_BLKADDR		  0x000040000
			 ===================	  ===========
mode=%s			 Control block allocation mode which supports "adaptive"
			 and "lfs". In "lfs" mode, there should be no random
@@ -340,6 +347,10 @@ memory=%s Control memory mode. This supports "normal" and "low" modes.
			 Because of the nature of low memory devices, in this mode, f2fs
			 will try to save memory sometimes by sacrificing performance.
			 "normal" mode is the default mode and same as before.
age_extent_cache	 Enable an age extent cache based on rb-tree. It records
			 data block update frequency of the extent per inode, in
			 order to provide better temperature hints for data block
			 allocation.
======================== ============================================================

Debugfs Entries
+1 −0
Original line number Diff line number Diff line
@@ -7889,6 +7889,7 @@ M: Chao Yu <chao@kernel.org>
L:	linux-f2fs-devel@lists.sourceforge.net
S:	Maintained
W:	https://f2fs.wiki.kernel.org/
B:	https://bugzilla.kernel.org/enter_bug.cgi?product=File%20System&component=f2fs
T:	git git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git
F:	Documentation/ABI/testing/sysfs-fs-f2fs
F:	Documentation/filesystems/f2fs.rst
+8 −1
Original line number Diff line number Diff line
@@ -171,6 +171,11 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
					block_t blkaddr, int type)
{
	if (time_to_inject(sbi, FAULT_BLKADDR)) {
		f2fs_show_injection_info(sbi, FAULT_BLKADDR);
		return false;
	}

	switch (type) {
	case META_NAT:
		break;
@@ -1897,8 +1902,10 @@ int f2fs_start_ckpt_thread(struct f2fs_sb_info *sbi)
	cprc->f2fs_issue_ckpt = kthread_run(issue_checkpoint_thread, sbi,
			"f2fs_ckpt-%u:%u", MAJOR(dev), MINOR(dev));
	if (IS_ERR(cprc->f2fs_issue_ckpt)) {
		int err = PTR_ERR(cprc->f2fs_issue_ckpt);

		cprc->f2fs_issue_ckpt = NULL;
		return -ENOMEM;
		return err;
	}

	set_task_ioprio(cprc->f2fs_issue_ckpt, cprc->ckpt_thread_ioprio);
+7 −41
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ static int zstd_init_compress_ctx(struct compress_ctx *cc)
	if (!level)
		level = F2FS_ZSTD_DEFAULT_CLEVEL;

	params = zstd_get_params(F2FS_ZSTD_DEFAULT_CLEVEL, cc->rlen);
	params = zstd_get_params(level, cc->rlen);
	workspace_size = zstd_cstream_workspace_bound(&params.cParams);

	workspace = f2fs_kvmalloc(F2FS_I_SB(cc->inode),
@@ -567,10 +567,7 @@ MODULE_PARM_DESC(num_compress_pages,
int f2fs_init_compress_mempool(void)
{
	compress_page_pool = mempool_create_page_pool(num_compress_pages, 0);
	if (!compress_page_pool)
		return -ENOMEM;

	return 0;
	return compress_page_pool ? 0 : -ENOMEM;
}

void f2fs_destroy_compress_mempool(void)
@@ -1981,9 +1978,7 @@ int f2fs_init_page_array_cache(struct f2fs_sb_info *sbi)

	sbi->page_array_slab = f2fs_kmem_cache_create(slab_name,
					sbi->page_array_slab_size);
	if (!sbi->page_array_slab)
		return -ENOMEM;
	return 0;
	return sbi->page_array_slab ? 0 : -ENOMEM;
}

void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi)
@@ -1991,53 +1986,24 @@ void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi)
	kmem_cache_destroy(sbi->page_array_slab);
}

static int __init f2fs_init_cic_cache(void)
int __init f2fs_init_compress_cache(void)
{
	cic_entry_slab = f2fs_kmem_cache_create("f2fs_cic_entry",
					sizeof(struct compress_io_ctx));
	if (!cic_entry_slab)
		return -ENOMEM;
	return 0;
}

static void f2fs_destroy_cic_cache(void)
{
	kmem_cache_destroy(cic_entry_slab);
}

static int __init f2fs_init_dic_cache(void)
{
	dic_entry_slab = f2fs_kmem_cache_create("f2fs_dic_entry",
					sizeof(struct decompress_io_ctx));
	if (!dic_entry_slab)
		return -ENOMEM;
	return 0;
}

static void f2fs_destroy_dic_cache(void)
{
	kmem_cache_destroy(dic_entry_slab);
}

int __init f2fs_init_compress_cache(void)
{
	int err;

	err = f2fs_init_cic_cache();
	if (err)
		goto out;
	err = f2fs_init_dic_cache();
	if (err)
		goto free_cic;
	return 0;
free_cic:
	f2fs_destroy_cic_cache();
out:
	kmem_cache_destroy(cic_entry_slab);
	return -ENOMEM;
}

void f2fs_destroy_compress_cache(void)
{
	f2fs_destroy_dic_cache();
	f2fs_destroy_cic_cache();
	kmem_cache_destroy(dic_entry_slab);
	kmem_cache_destroy(cic_entry_slab);
}
Loading