f2fs: support dynamic reserve/release for device aliasing
Subsystems (2)
PATCH v7 1/1 f2fs: support dynamic reserve/release for device aliasing
From: Daeho Jeong <[email protected]>
This patch adds a dynamic management feature to the existing device aliasing functionality. It allows users to dynamically reserve or release specific devices from the filesystem's free pool at runtime through new ioctls.
To support this, three new ioctls are introduced:
- F2FS_IOC_RESERVE_DEV_ALIAS: This reclaims the space occupied by a device aliasing file. It first performs a capacity check, resets GC victim information for the target range, marks the segments as in-use to prevent new allocations, and then triggers GC to migrate existing valid data out of the range. Finally, it reserves these blocks in the SIT to effectively exclude the device from the usable capacity.
- F2FS_IOC_RELEASE_DEV_ALIAS: This releases the reserved space of a previously reserved device aliasing file. It truncates the blocks associated with the file, which makes them available for general filesystem allocation again.
- F2FS_IOC_GET_DEV_ALIAS_STATUS: This retrieves the current aliasing status of a device aliasing file, returning whether the file is released (inactive alias) or reserved (active alias, with blocks fully allocated on the device).
---
v7: fixed extent alignment check to accomodate zoned storage alignment.
v6: fixed duplicated block reservations and racing w/ mmap.
added the extent alignment check for device aliasing areas.
v5: prevented new segment allocation on devices undergoing reservation
or with active aliases.
used in-memory struct to reserve blocks for device aliasing. cleared prefree (PRE) dirty segment bitmap.
v4: renamed interfaces.
fixed race conditions between checkpoint=disable mount and ioctls. refactored segment reservation part.
modified lock usage.
v3: add CAP_SYS_ADMIN and checkpoint=disabled check.
remove a f2fs specific flag exposed with getflags.
v2: prevent operations during checkpoint=disabled.
---
--- Documentation/filesystems/f2fs.rst | 35 ++++ fs/f2fs/data.c | 4 +- fs/f2fs/extent_cache.c | 9 + fs/f2fs/f2fs.h | 19 +- fs/f2fs/file.c | 273 ++++++++++++++++++++++++++++- fs/f2fs/gc.c | 30 ++-- fs/f2fs/namei.c | 14 ++ fs/f2fs/segment.c | 176 +++++++++++++------ fs/f2fs/segment.h | 22 +++ fs/f2fs/super.c | 36 ++++ include/uapi/linux/f2fs.h | 7 + 11 files changed, 557 insertions(+), 68 deletions(-)
Documentation/filesystems/f2fs.rst +35 -0
@@ -1045,6 +1045,41 @@ So, the key idea is, user can do any file operations on /dev/vdc, and reclaim the space after the use, while the space is counted as /data. That doesn't require modifying partition size and filesystem format. +Dynamic Device Aliasing Management +---------------------------------- + +In addition to static device aliasing by deleting the aliasing file, F2FS +supports dynamic management of device aliasing. This mechanism allows the system +to dynamically transition partition ownership between F2FS userdata and external +entities (e.g., zRAM, raw partition) based on system requirements without +deleting the master aliasing file or requiring unmount/remount. + +The master aliasing file is created during the initial format of the file system +and remains as a persistent control entity (ioctl gateway) in the root directory. + +- Partition Reservation (In-service to Aliased) + When a specific partition needs to be dedicated to external services (e.g., zRAM), + a user can reserve the device alias range via ioctl. The kernel resets GC victim + information for the target range, marks segments as in-use to prevent new + allocations, and triggers forced GC to migrate existing valid data out of the + range. Finally, it reserves these blocks in the SIT to effectively exclude the + device from the usable capacity. + +- Partition Release (Aliased to In-service) + When external usage concludes, the space is reclaimed not by deleting the file, + but through the release ioctl. The kernel truncates blocks associated with + the file, releasing them back to general filesystem allocation. + +.. code-block:: + + # f2fs_io dev_alias release /mnt/f2fs/vdc.file + # df -h + /dev/vdb 64G 753M 64G 2% /mnt/f2fs + + # f2fs_io dev_alias reserve /mnt/f2fs/vdc.file + # df -h + /dev/vdb 64G 33G 32G 52% /mnt/f2fs + Per-file Read-Only Large Folio Support --------------------------------------
fs/f2fs/data.c +2 -2
@@ -1270,7 +1270,7 @@ int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count)if (unlikely (is_inode_flag_set (dn->inode,FI_NO_ALLOC )))return -EPERM ; - err =inc_valid_block_count (sbi, dn->inode, &count, true); + err =inc_valid_block_count (sbi, dn->inode, &count, true, false);if (unlikely (err))return err;
@@ -1542,7 +1542,7 @@ static int __allocate_data_block(struct dnode_of_data *dn, int seg_type) dn->data_blkaddr =f2fs_data_blkaddr (dn);if (dn->data_blkaddr ==NULL_ADDR ) { - err =inc_valid_block_count (sbi, dn->inode, &count, true); + err =inc_valid_block_count (sbi, dn->inode, &count, true, false);if (unlikely (err))return err; }
fs/f2fs/extent_cache.c +9 -0
@@ -17,6 +17,7 @@#include "f2fs.h" #include "node.h" +#include "segment.h" #include <trace/events/f2fs.h> bool sanity_check_extent_cache (struct inode *inode,struct folio *ifolio)
@@ -62,6 +63,14 @@ bool sanity_check_extent_cache(struct inode *inode, struct folio *ifolio) __func__, inode->i_ino, ei.blk, ei.fofs, ei.len);return false; } + +if ((GET_SEGOFF_FROM_SEG0 (sbi, ei.blk) %BLKS_PER_SEC (sbi)) || + (ei.len %BLKS_PER_SEC (sbi))) { +f2fs_warn (sbi,"%s: device alias inode (ino=%llx)'s extent info [%u, %u, %u] is not aligned to section size %u" , + __func__, inode->i_ino, ei.blk, ei.fofs, ei.len, +BLKS_PER_SEC (sbi)); +return false; + }return true; }
fs/f2fs/f2fs.h +17 -2
@@ -1404,6 +1404,8 @@ struct f2fs_dev_info {unsigned int total_segments;block_t start_blk;block_t end_blk; +bool has_alias; +bool is_reserving;#ifdef CONFIG_BLK_DEV_ZONED unsigned int nr_blkz;/* Total number of zones */ unsigned long *blkz_seq;/* Bitmap indicating sequential zones */
@@ -1857,6 +1859,7 @@ struct f2fs_sb_info {block_t last_valid_block_count;/* for recovery */ block_t reserved_blocks;/* configurable reserved blocks */ block_t current_reserved_blocks;/* current reserved blocks */ +block_t alias_reserved_blocks;/* reserved blocks for device alias */ /* Additional tracking for no checkpoint mode */ block_t unusable_block_count;/* # of blocks saved by last cp */
@@ -2559,7 +2562,8 @@ static inline unsigned int get_available_block_count(struct f2fs_sb_info *sbi,block_t avail_user_block_count; avail_user_block_count = sbi->user_block_count - - sbi->current_reserved_blocks; + sbi->current_reserved_blocks - + sbi->alias_reserved_blocks;if (test_opt (sbi,RESERVE_ROOT ) && !__allow_reserved_root (sbi, inode, cap)) avail_user_block_count -=F2FS_OPTION (sbi).root_reserved_blocks;
@@ -2576,7 +2580,8 @@ static inline unsigned int get_available_block_count(struct f2fs_sb_info *sbi,static inline void f2fs_i_blocks_write (struct inode *,block_t ,bool ,bool );static inline int inc_valid_block_count (struct f2fs_sb_info *sbi, -struct inode *inode,blkcnt_t *count,bool partial) +struct inode *inode,blkcnt_t *count, +bool partial,bool alias_reserved) {long long diff =0 , release =0 ;block_t avail_user_block_count;
@@ -2599,10 +2604,16 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,spin_lock (&sbi->stat_lock); +if (alias_reserved) + sbi->alias_reserved_blocks -= *count; + avail_user_block_count =get_available_block_count (sbi, inode, true); diff = (long long )sbi->total_valid_block_count + *count - avail_user_block_count;if (unlikely (diff >0 )) { +if (alias_reserved) + sbi->alias_reserved_blocks += *count; +if (!partial) {spin_unlock (&sbi->stat_lock); release = *count;
@@ -4010,6 +4021,8 @@ int f2fs_flush_device_cache(struct f2fs_sb_info *sbi);void f2fs_destroy_flush_cmd_control (struct f2fs_sb_info *sbi,bool free);void f2fs_invalidate_blocks (struct f2fs_sb_info *sbi,block_t addr,unsigned int len); +void f2fs_reserve_device_alias (struct f2fs_sb_info *sbi,block_t addr, +unsigned int len);bool f2fs_is_checkpointed_data (struct f2fs_sb_info *sbi,block_t blkaddr);int f2fs_start_discard_thread (struct f2fs_sb_info *sbi);void f2fs_drop_discard_cmd (struct f2fs_sb_info *sbi);
@@ -4231,6 +4244,8 @@ void f2fs_build_gc_manager(struct f2fs_sb_info *sbi);int f2fs_gc_range (struct f2fs_sb_info *sbi,unsigned int start_seg,unsigned int end_seg,bool dry_run,unsigned int dry_run_sections); +void f2fs_reset_gc_victim_resource (struct f2fs_sb_info *sbi, +unsigned int start,unsigned int end);int f2fs_resize_fs (struct file *filp,__u64 block_count);int __init f2fs_create_garbage_collection_cache (void );void f2fs_destroy_garbage_collection_cache (void );
fs/f2fs/file.c +269 -4
330 lines not on this page · raw message
fs/f2fs/gc.c +19 -11
@@ -2197,29 +2197,37 @@ int f2fs_gc_range(struct f2fs_sb_info *sbi,return 0 ; } +void f2fs_reset_gc_victim_resource (struct f2fs_sb_info *sbi, +unsigned int start,unsigned int end) +{ +int i; + +mutex_lock (&DIRTY_I (sbi)->seglist_lock); +for (i =0 ; i <MAX_GC_POLICY ; i++) +if (SIT_I (sbi)->last_victim[i] >= start && +SIT_I (sbi)->last_victim[i] <= end) +SIT_I (sbi)->last_victim[i] =0 ; + +for (i =BG_GC ; i <=FG_GC ; i++) +if (sbi->next_victim_seg[i] >= start && + sbi->next_victim_seg[i] <= end) + sbi->next_victim_seg[i] =NULL_SEGNO ; +mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +} +static int free_segment_range (struct f2fs_sb_info *sbi,unsigned int secs,bool dry_run) {unsigned int next_inuse, start, end;struct cp_control cpc = {CP_RESIZE ,0 ,0 ,0 }; -int gc_mode, gc_type;int err =0 ;int type; -/* Force block allocation for GC */ MAIN_SECS (sbi) -= secs; start =MAIN_SECS (sbi) *SEGS_PER_SEC (sbi); end =MAIN_SEGS (sbi) -1 ; -mutex_lock (&DIRTY_I (sbi)->seglist_lock); -for (gc_mode =0 ; gc_mode <MAX_GC_POLICY ; gc_mode++) -if (SIT_I (sbi)->last_victim[gc_mode] >= start) -SIT_I (sbi)->last_victim[gc_mode] =0 ; - -for (gc_type =BG_GC ; gc_type <=FG_GC ; gc_type++) -if (sbi->next_victim_seg[gc_type] >= start) - sbi->next_victim_seg[gc_type] =NULL_SEGNO ; -mutex_unlock (&DIRTY_I (sbi)->seglist_lock); +f2fs_reset_gc_victim_resource (sbi, start, end);/* Move out cursegs from the target range */ for (type =CURSEG_HOT_DATA ; type <NR_CURSEG_PERSIST_TYPE ; type++) {
fs/f2fs/namei.c +14 -0
@@ -425,6 +425,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,if (!f2fs_is_checkpoint_ready (sbi))return -ENOSPC ; +if (IS_DEVICE_ALIASING (inode)) +return -EPERM ; + err =fscrypt_prepare_link (old_dentry, dir, dentry);if (err)return err;
@@ -568,6 +571,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)trace_f2fs_unlink_enter (dir, dentry); +if (IS_DEVICE_ALIASING (inode)) +return -EPERM ; +if (unlikely (f2fs_cp_error (sbi))) { err = -EIO ; goto out;
@@ -946,6 +952,9 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,bool old_is_dir =S_ISDIR (old_inode->i_mode);int err; +if (IS_DEVICE_ALIASING (old_inode)) +return -EPERM ; +if (unlikely (f2fs_cp_error (sbi)))return -EIO ;if (!f2fs_is_checkpoint_ready (sbi))
@@ -1016,6 +1025,8 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, }if (new_inode) { +if (IS_DEVICE_ALIASING (new_inode)) +return -EPERM ; err = -ENOTEMPTY ;if (old_is_dir && !f2fs_empty_dir (new_inode))
@@ -1143,6 +1154,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,int old_nlink =0 , new_nlink =0 ;int err; +if (IS_DEVICE_ALIASING (old_inode) ||IS_DEVICE_ALIASING (new_inode)) +return -EPERM ; +if (unlikely (f2fs_cp_error (sbi)))return -EIO ;if (!f2fs_is_checkpoint_ready (sbi))
fs/f2fs/segment.c +127 -49
240 lines not on this page · raw message
fs/f2fs/segment.h +22 -0
@@ -954,10 +954,32 @@ static inline block_t sum_blk_addr(struct f2fs_sb_info *sbi, int base, int type) - (base +1 ) + type; } +static inline bool f2fs_dev_is_reserving (struct f2fs_sb_info *sbi,int devi) +{ +if (!f2fs_sb_has_device_alias (sbi)) +return false; +return FDEV (devi).is_reserving; +} + +static inline bool f2fs_dev_is_alloc_blocked (struct f2fs_sb_info *sbi, +int devi,bool pinning) +{ +if (!f2fs_sb_has_device_alias (sbi)) +return false; +return (pinning &&FDEV (devi).has_alias) ||FDEV (devi).is_reserving; +} +static inline bool sec_usage_check (struct f2fs_sb_info *sbi,unsigned int secno) {if (is_cursec (sbi, secno) || (sbi->cur_victim_sec == secno))return true; +if (f2fs_sb_has_device_alias (sbi)) { +block_t start_blk =START_BLOCK (sbi,GET_SEG_FROM_SEC (sbi, secno)); +int devi =f2fs_target_device_index (sbi, start_blk); + +if (f2fs_dev_is_reserving (sbi, devi)) +return true; + }return false; }
fs/f2fs/super.c +36 -0
@@ -5001,6 +5001,39 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi) sbi->readdir_ra = true; } +static void f2fs_restore_device_alias (struct f2fs_sb_info *sbi) +{ +struct inode *root =d_inode (sbi->sb->s_root); +struct f2fs_dir_entry *de; +struct folio *folio; +int i; + +if (!f2fs_sb_has_device_alias (sbi)) +return ; + +for (i =1 ; i < sbi->s_ndevs; i++) { +char *name =strrchr (FDEV (i).path,'/' ); +struct inode *inode; +struct qstr qstr; + + name = name ? name +1 :FDEV (i).path; + qstr.name = name; + qstr.len =strlen (name); + + de =f2fs_find_entry (root, &qstr, &folio); +if (!de) +continue ; + + inode =f2fs_iget (sbi->sb,le32_to_cpu (de->ino)); +if (!IS_ERR (inode)) { +if (IS_DEVICE_ALIASING (inode)) +FDEV (i).has_alias = true; +iput (inode); + } +f2fs_folio_put (folio,0 ); + } +} +static int f2fs_fill_super (struct super_block *sb,struct fs_context *fc) {struct f2fs_fs_context *ctx = fc->fs_private;
@@ -5209,6 +5242,7 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc) sbi->last_valid_block_count = sbi->total_valid_block_count; sbi->reserved_blocks =0 ; sbi->current_reserved_blocks =0 ; + sbi->alias_reserved_blocks =0 ;limit_reserve_root (sbi);adjust_unusable_cap_perc (sbi);
@@ -5436,6 +5470,8 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc)f2fs_update_time (sbi,REQ_TIME );clear_sbi_flag (sbi,SBI_CP_DISABLED_QUICK ); +f2fs_restore_device_alias (sbi); + sbi->umount_lock_holder =NULL ;return 0 ;
include/uapi/linux/f2fs.h +7 -0
@@ -45,6 +45,9 @@#define F2FS_IOC_START_ATOMIC_REPLACE _IO(F2FS_IOCTL_MAGIC, 25)#define F2FS_IOC_GET_DEV_ALIAS_FILE _IOR(F2FS_IOCTL_MAGIC, 26, __u32)#define F2FS_IOC_IO_PRIO _IOW(F2FS_IOCTL_MAGIC, 27, __u32) +#define F2FS_IOC_RESERVE_DEV_ALIAS _IO(F2FS_IOCTL_MAGIC, 28) +#define F2FS_IOC_RELEASE_DEV_ALIAS _IO(F2FS_IOCTL_MAGIC, 29) +#define F2FS_IOC_GET_DEV_ALIAS_STATUS _IOR(F2FS_IOCTL_MAGIC, 30, __u32)/* * should be same as XFS_IOC_GOINGDOWN.
@@ -70,6 +73,10 @@ enum { F2FS_IOPRIO_MAX, }; +/* for F2FS_IOC_GET_DEV_ALIAS_STATUS */ +#define F2FS_DEV_ALIAS_STATUS_RELEASED 0 +#define F2FS_DEV_ALIAS_STATUS_RESERVED 1 +struct f2fs_gc_range {__u32 sync;__u64 start;
Signature · 1 line
2.55.0.629.g250fe7f194-goog
Quoted 20 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
This patch adds a dynamic management feature to the existing device aliasing functionality. It allows users to dynamically reserve or release specific devices from the filesystem's free pool at runtime through new ioctls.
To support this, three new ioctls are introduced:
-F2FS_IOC_RESERVE_DEV_ALIAS: This reclaims the space occupied by a device aliasing file. It first performs a capacity check, resets GC victim information for the target range, marks the segments as in-use to prevent new allocations, and then triggers GC to migrate existing valid data out of the range. Finally, it reserves these blocks in the SIT to effectively exclude the device from the usable capacity.-
F2FS_IOC_RELEASE_DEV_ALIAS: This releases the reserved space of a previously reserved device aliasing file. It truncates the blocks associated with the file, which makes them available for general filesystem allocation again.
Quoted 6 lines
-
F2FS_IOC_GET_DEV_ALIAS_STATUS: This retrieves the current aliasing status of a device aliasing file, returning whether the file is released (inactive alias) or reserved (active alias, with blocks fully allocated on the device).Signed-off-by Daeho Jeong <[email protected]>
Thanks,
This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <[email protected]>:
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:
Quoted 8 lines · On Wed, 5 Aug 2026 18:48:13 -0700 you wrote:
From: Daeho Jeong <[email protected]>
This patch adds a dynamic management feature to the existing device aliasing functionality. It allows users to dynamically reserve or release specific devices from the filesystem's free pool at runtime through new ioctls.
[...]
Here is the summary with links:
- [f2fs-dev,v7] f2fs: support dynamic reserve/release for device aliasing
https://git.kernel.org/jaegeuk/f2fs/c/eae3faf210bd
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Le 06/08/2026 à 03:48, Daeho Jeong a écrit :
Quoted 20 lines
From: Daeho Jeong <[email protected]>
This patch adds a dynamic management feature to the existing device aliasing functionality. It allows users to dynamically reserve or release specific devices from the filesystem's free pool at runtime through new ioctls.
To support this, three new ioctls are introduced:
-F2FS_IOC_RESERVE_DEV_ALIAS: This reclaims the space occupied by a device aliasing file. It first performs a capacity check, resets GC victim information for the target range, marks the segments as in-use to prevent new allocations, and then triggers GC to migrate existing valid data out of the range. Finally, it reserves these blocks in the SIT to effectively exclude the device from the usable capacity.-
F2FS_IOC_RELEASE_DEV_ALIAS: This releases the reserved space of a previously reserved device aliasing file. It truncates the blocks associated with the file, which makes them available for general filesystem allocation again.
Quoted 6 lines
-
F2FS_IOC_GET_DEV_ALIAS_STATUS: This retrieves the current aliasing status of a device aliasing file, returning whether the file is released (inactive alias) or reserved (active alias, with blocks fully allocated on the device).Signed-off-by Daeho Jeong <[email protected]>
Hi,
this patch has already reached -next, but 2 comments below, should they make any sense.
Quoted 15 lines
fs/f2fs/namei.c +3
-0@@ -425,6 +425,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,if (!f2fs_is_checkpoint_ready (sbi))return -ENOSPC ; +if (IS_DEVICE_ALIASING (inode)) +return -EPERM ; + err =fscrypt_prepare_link (old_dentry, dir, dentry);if (err)return err;
fs/f2fs/namei.c static int f2fs_unlink(struct inode *dir, struct dentry *dentry) · line 576
Quoted 6 lines
fs/f2fs/namei.c +3
-0@@ -568,6 +571,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)trace_f2fs_unlink_enter (dir, dentry); +if (IS_DEVICE_ALIASING (inode)) +return -EPERM ; +
Based on surrounding goto, should this one be:
err = -EPERM
goto out;
?
Quoted 14 lines
fs/f2fs/namei.c +3
-0if (unlikely (f2fs_cp_error (sbi))) { err = -EIO ; goto out;@@ -946,6 +952,9 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,bool old_is_dir =S_ISDIR (old_inode->i_mode);int err; +if (IS_DEVICE_ALIASING (old_inode)) +return -EPERM ; +if (unlikely (f2fs_cp_error (sbi)))return -EIO ;if (!f2fs_is_checkpoint_ready (sbi))
fs/f2fs/namei.c static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, · line 1029
Quoted 5 lines
fs/f2fs/namei.c +2
-0@@ -1016,6 +1025,8 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, }if (new_inode) { +if (IS_DEVICE_ALIASING (new_inode)) +return -EPERM ;
Based on surrounding goto, should this one be:
err = -EPERM
goto out_dir;
?
fs/f2fs/namei.c static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, · line 1162
Quoted 13 lines
fs/f2fs/namei.c +3
-0err = -ENOTEMPTY ;if (old_is_dir && !f2fs_empty_dir (new_inode))@@ -1143,6 +1154,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,int old_nlink =0 , new_nlink =0 ;int err; +if (IS_DEVICE_ALIASING (old_inode) ||IS_DEVICE_ALIASING (new_inode)) +return -EPERM ; +if (unlikely (f2fs_cp_error (sbi)))return -EIO ;if (!f2fs_is_checkpoint_ready (sbi))
[...]
CJ
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 77 lines · Christophe JAILLET
Quoted 20 lines · Daeho Jeong
From: Daeho Jeong <[email protected]>
This patch adds a dynamic management feature to the existing device aliasing functionality. It allows users to dynamically reserve or release specific devices from the filesystem's free pool at runtime through new ioctls.
To support this, three new ioctls are introduced:
-F2FS_IOC_RESERVE_DEV_ALIAS: This reclaims the space occupied by a device aliasing file. It first performs a capacity check, resets GC victim information for the target range, marks the segments as in-use to prevent new allocations, and then triggers GC to migrate existing valid data out of the range. Finally, it reserves these blocks in the SIT to effectively exclude the device from the usable capacity.-
F2FS_IOC_RELEASE_DEV_ALIAS: This releases the reserved space of a previously reserved device aliasing file. It truncates the blocks associated with the file, which makes them available for general filesystem allocation again.Quoted 6 lines
-
F2FS_IOC_GET_DEV_ALIAS_STATUS: This retrieves the current aliasing status of a device aliasing file, returning whether the file is released (inactive alias) or reserved (active alias, with blocks fully allocated on the device).Signed-off-by Daeho Jeong <[email protected]>Hi,
this patch has already reached -next, but 2 comments below, should they make any sense.
Quoted 15 lines
fs/f2fs/namei.c +3
-0@@ -425,6 +425,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,if (!f2fs_is_checkpoint_ready (sbi))return -ENOSPC ; +if (IS_DEVICE_ALIASING (inode)) +return -EPERM ; + err =fscrypt_prepare_link (old_dentry, dir, dentry);if (err)return err;fs/f2fs/namei.c static int f2fs_unlink(struct inode *dir, struct dentry *dentry) · line 576
Quoted 6 lines
fs/f2fs/namei.c +3
-0@@ -568,6 +571,9 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)trace_f2fs_unlink_enter (dir, dentry); +if (IS_DEVICE_ALIASING (inode)) +return -EPERM ; +Based on surrounding goto, should this one be:
err =-EPERM
goto out;
?Quoted 16 lines
fs/f2fs/namei.c +3
-0if (unlikely (f2fs_cp_error (sbi))) { err = -EIO ; goto out;@@ -946,6 +952,9 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,bool old_is_dir =S_ISDIR (old_inode->i_mode);int err; +if (IS_DEVICE_ALIASING (old_inode)) +return -EPERM ; +if (unlikely (f2fs_cp_error (sbi)))return -EIO ;if (!f2fs_is_checkpoint_ready (sbi))@@ -1016,6 +1025,8 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, }
Quoted 8 lines
fs/f2fs/namei.c static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir, · line 1029
Quoted 3 lines
fs/f2fs/namei.c +2
-0if (new_inode) { +if (IS_DEVICE_ALIASING (new_inode)) +return -EPERM ;Based on surrounding goto, should this one be:
err =-EPERM
gotoout_dir;
?
Oh, right. Thank you for letting me know this.
Quoted 17 lines
Quoted 5 lines
fs/f2fs/namei.c +0
-0err = -ENOTEMPTY ;if (old_is_dir && !f2fs_empty_dir (new_inode))fs/f2fs/namei.c static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, · line 1162
Quoted 9 lines
fs/f2fs/namei.c +3
-0@@ -1143,6 +1154,9 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,int old_nlink =0 , new_nlink =0 ;int err; +if (IS_DEVICE_ALIASING (old_inode) ||IS_DEVICE_ALIASING (new_inode)) +return -EPERM ; +if (unlikely (f2fs_cp_error (sbi)))return -EIO ;if (!f2fs_is_checkpoint_ready (sbi))[...]
CJ