the maximum size of a write bio that is completed in atomic
(atc) context. The default value for this attribute is UINT_MAX
which means that this functionality is disabled by default.
+
+What: /sys/fs/f2fs/<disk>/pinned_area_max_secno
+Date: August 2026
+Contact: "Daeho Jeong" <daehojeong@google.com>
+Description: This is a read-only entry to show the upper bound section number
+ for pinned files. Pinned files will only be allocated within
+ sections 0 to pinned_area_max_secno - 1.
auto F2FS determines the mode based on the
on-disk `SB_ENC_NO_COMPAT_FALLBACK_FL`
flag.
- ================== ========================================
+resizable_tail_secno=%u Control the number of sections at the tail of the
+ filesystem reserved for online resizing. Pinned files
+ will only be allocated within sections 0 to
+ (MAIN_SECS - resizable_tail_secno) - 1. If set to 0
+ (default), there is no tail restriction unless running
+ on a zoned block device where conventional zones are
+ used.
======================== ============================================================
Debugfs Entries
block_t unusable_cap; /* Amount of space allowed to be
* unusable when disabling checkpoint
*/
+ unsigned int resizable_tail_secno; /* number of resizable tail sections */
/* For compression */
unsigned char compress_algorithm; /* algorithm type */
spinlock_t dev_lock; /* protect dirty_device */
bool aligned_blksize; /* all devices has the same logical blksize */
unsigned int first_seq_zone_segno; /* first segno in sequential zone */
+ unsigned int pinned_area_max_secno; /* upper bound section for pinned files */
unsigned int bggc_io_aware; /* For adjust the BG_GC priority when pending IO */
unsigned int allocate_section_hint; /* the boundary position between devices */
unsigned int allocate_section_policy; /* determine the section writing priority */
unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg);
unsigned int alloc_policy = sbi->allocate_section_policy;
unsigned int alloc_hint = sbi->allocate_section_hint;
+ unsigned int max_secno = MAIN_SECS(sbi);
bool init = true;
bool looped = false;
int i, devi;
*/
if (f2fs_sb_has_blkzoned(sbi)) {
/* Prioritize writing to conventional zones */
- if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_PRIOR_CONV || pinning)
+ if (sbi->blkzone_alloc_policy == BLKZONE_ALLOC_PRIOR_CONV)
segno = 0;
else
segno = max(sbi->first_seq_zone_segno, *newseg);
alloc_hint > MAIN_SECS(sbi))
alloc_hint = MAIN_SECS(sbi);
- if (alloc_policy == ALLOCATE_FORWARD_FROM_HINT &&
- hint < alloc_hint)
+ if (pinning) {
+ max_secno = sbi->pinned_area_max_secno;
+ hint = 0;
+ } else if (alloc_policy == ALLOCATE_FORWARD_FROM_HINT &&
+ hint < alloc_hint) {
hint = alloc_hint;
- else if (alloc_policy == ALLOCATE_FORWARD_WITHIN_HINT &&
- hint >= alloc_hint)
+ } else if (alloc_policy == ALLOCATE_FORWARD_WITHIN_HINT &&
+ hint >= alloc_hint) {
hint = 0;
+ }
find_other_zone:
- secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
+ secno = find_next_zero_bit(free_i->free_secmap, max_secno, hint);
- if (secno >= MAIN_SECS(sbi)) {
+ if (secno >= max_secno) {
if (looped) {
- ret = -ENOSPC;
+ ret = (pinning && has_unpinned_area(sbi)) ?
+ -EAGAIN : -ENOSPC;
f2fs_bug_on(sbi, !pinning);
goto out_unlock;
}
goto out_unlock;
}
- /* no free section in conventional device or conventional zone */
- if (new_sec && pinning &&
- f2fs_is_sequential_zone_area(sbi, START_BLOCK(sbi, segno))) {
- ret = -EAGAIN;
- goto out_unlock;
- }
__set_inuse(sbi, segno);
*newseg = segno;
out_unlock:
err = f2fs_allocate_new_section(sbi, CURSEG_COLD_DATA_PINNED, false);
f2fs_unlock_op(sbi, &lc);
- if (f2fs_sb_has_blkzoned(sbi) && err == -EAGAIN && gc_required) {
- err = f2fs_gc_range(sbi, 0, sbi->first_seq_zone_segno - 1,
+ if (has_unpinned_area(sbi) && err == -EAGAIN && gc_required) {
+ err = f2fs_gc_range(sbi, 0,
+ sbi->pinned_area_max_secno * SEGS_PER_SEC(sbi) - 1,
true, ZONED_PIN_SEC_REQUIRED_COUNT, true);
if (err)
return err;
#define MAIN_SEGS(sbi) (SM_I(sbi)->main_segments)
#define MAIN_SECS(sbi) ((sbi)->total_sections)
+#define has_unpinned_area(sbi) ((sbi)->pinned_area_max_secno < MAIN_SECS(sbi))
#define TOTAL_SEGS(sbi) \
(SM_I(sbi) ? SM_I(sbi)->segment_count : \
Opt_jqfmt,
Opt_checkpoint,
Opt_lookup_mode,
+ Opt_resizable_tail_secno,
Opt_err,
};
fsparam_flag("age_extent_cache", Opt_age_extent_cache),
fsparam_enum("errors", Opt_errors, f2fs_param_errors),
fsparam_enum("lookup_mode", Opt_lookup_mode, f2fs_param_lookup_mode),
+ fsparam_u32("resizable_tail_secno", Opt_resizable_tail_secno),
{}
};
#define F2FS_SPEC_errors (1 << 23)
#define F2FS_SPEC_lookup_mode (1 << 24)
#define F2FS_SPEC_reserve_node (1 << 25)
+#define F2FS_SPEC_resizable_tail_secno (1 << 26)
struct f2fs_fs_context {
struct f2fs_mount_info info;
F2FS_OPTION(sbi).unusable_cap_perc);
}
+static inline void adjust_pinned_area_boundary(struct f2fs_sb_info *sbi)
+{
+ sbi->pinned_area_max_secno = MAIN_SECS(sbi);
+ if (f2fs_sb_has_blkzoned(sbi) && sbi->first_seq_zone_segno != NULL_SEGNO)
+ sbi->pinned_area_max_secno = min(sbi->pinned_area_max_secno,
+ GET_SEC_FROM_SEG(sbi, sbi->first_seq_zone_segno));
+ if (F2FS_OPTION(sbi).resizable_tail_secno)
+ sbi->pinned_area_max_secno = min(sbi->pinned_area_max_secno,
+ MAIN_SECS(sbi) - F2FS_OPTION(sbi).resizable_tail_secno);
+}
+
static void init_once(void *foo)
{
struct f2fs_inode_info *fi = (struct f2fs_inode_info *) foo;
F2FS_CTX_INFO(ctx).lookup_mode = result.uint_32;
ctx->spec_mask |= F2FS_SPEC_lookup_mode;
break;
+ case Opt_resizable_tail_secno:
+ F2FS_CTX_INFO(ctx).resizable_tail_secno = result.uint_32;
+ ctx->spec_mask |= F2FS_SPEC_resizable_tail_secno;
+ break;
}
return 0;
}
F2FS_OPTION(sbi).errors = F2FS_CTX_INFO(ctx).errors;
if (ctx->spec_mask & F2FS_SPEC_lookup_mode)
F2FS_OPTION(sbi).lookup_mode = F2FS_CTX_INFO(ctx).lookup_mode;
+ if (ctx->spec_mask & F2FS_SPEC_resizable_tail_secno)
+ F2FS_OPTION(sbi).resizable_tail_secno =
+ F2FS_CTX_INFO(ctx).resizable_tail_secno;
f2fs_apply_compression(fc, sb);
f2fs_apply_test_dummy_encryption(fc, sb);
static int f2fs_sanity_check_options(struct f2fs_sb_info *sbi, bool remount)
{
+ unsigned int total_sections = le32_to_cpu(sbi->raw_super->section_count);
+
+ if (F2FS_OPTION(sbi).resizable_tail_secno >= total_sections) {
+ f2fs_err(sbi, "Option resizable_tail_secno is larger than or equal to total sections (%u >= %u)",
+ F2FS_OPTION(sbi).resizable_tail_secno, total_sections);
+ return -EINVAL;
+ }
if (f2fs_sb_has_device_alias(sbi) &&
!test_opt(sbi, READ_EXTENT_CACHE)) {
f2fs_err(sbi, "device aliasing requires extent cache");
else if (F2FS_OPTION(sbi).lookup_mode == LOOKUP_AUTO)
seq_show_option(seq, "lookup_mode", "auto");
+ if (F2FS_OPTION(sbi).resizable_tail_secno)
+ seq_printf(seq, ",resizable_tail_secno=%u",
+ F2FS_OPTION(sbi).resizable_tail_secno);
+
return 0;
}
F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON;
F2FS_OPTION(sbi).memory_mode = MEMORY_MODE_NORMAL;
F2FS_OPTION(sbi).errors = MOUNT_ERRORS_CONTINUE;
+ F2FS_OPTION(sbi).resizable_tail_secno = 0;
set_opt(sbi, INLINE_XATTR);
set_opt(sbi, INLINE_DATA);
sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
(test_opt(sbi, POSIX_ACL) ? SB_POSIXACL : 0);
+ adjust_pinned_area_boundary(sbi);
limit_reserve_root(sbi);
fc->sb_flags = (flags & ~SB_LAZYTIME) | (sb->s_flags & SB_LAZYTIME);
/* get segno of first zoned block device */
sbi->first_seq_zone_segno = get_first_seq_zone_segno(sbi);
+ adjust_pinned_area_boundary(sbi);
+
sbi->reserved_pin_section = f2fs_sb_has_blkzoned(sbi) ?
ZONED_PIN_SEC_REQUIRED_COUNT :
GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi));
#endif
F2FS_SBI_GENERAL_RW_ATTR(carve_out);
F2FS_SBI_GENERAL_RW_ATTR(reserved_pin_section);
+F2FS_SBI_GENERAL_RO_ATTR(pinned_area_max_secno);
F2FS_SBI_GENERAL_RW_ATTR(bggc_io_aware);
F2FS_SBI_GENERAL_RW_ATTR(max_lock_elapsed_time);
F2FS_SBI_GENERAL_RW_ATTR(lock_duration_priority);
ATTR_LIST(max_read_extent_count),
ATTR_LIST(carve_out),
ATTR_LIST(reserved_pin_section),
+ ATTR_LIST(pinned_area_max_secno),
ATTR_LIST(allocate_section_hint),
ATTR_LIST(allocate_section_policy),
ATTR_LIST(max_lock_elapsed_time),