f2fs: Add option to limit required GC for checkpoint=disable
This extends the checkpoint option to allow checkpoint=disable:%u[%] This allows you to specify what how much of the disk you are willing to lose access to while mounting with checkpoint=disable. If the amount lost would be higher, the mount will return -EAGAIN. This can be given as a percent of total space, or in blocks. Currently, we need to run garbage collection until the amount of holes is smaller than the OVP space. With the new option, f2fs can mark space as unusable up front instead of requiring garbage collection until the number of holes is small enough. Signed-off-by: Daniel Rosenberg <drosen@google.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:

committed by
Jaegeuk Kim

parent
a4c3ecaaad
commit
4d3aed7090
@@ -873,13 +873,14 @@ void f2fs_dirty_to_prefree(struct f2fs_sb_info *sbi)
|
||||
mutex_unlock(&dirty_i->seglist_lock);
|
||||
}
|
||||
|
||||
int f2fs_disable_cp_again(struct f2fs_sb_info *sbi)
|
||||
block_t f2fs_get_unusable_blocks(struct f2fs_sb_info *sbi)
|
||||
{
|
||||
struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
|
||||
int ovp_hole_segs =
|
||||
(overprovision_segments(sbi) - reserved_segments(sbi));
|
||||
block_t ovp_holes = ovp_hole_segs << sbi->log_blocks_per_seg;
|
||||
struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
|
||||
block_t holes[2] = {0, 0}; /* DATA and NODE */
|
||||
block_t unusable;
|
||||
struct seg_entry *se;
|
||||
unsigned int segno;
|
||||
|
||||
@@ -893,7 +894,17 @@ int f2fs_disable_cp_again(struct f2fs_sb_info *sbi)
|
||||
}
|
||||
mutex_unlock(&dirty_i->seglist_lock);
|
||||
|
||||
if (holes[DATA] > ovp_holes || holes[NODE] > ovp_holes)
|
||||
unusable = holes[DATA] > holes[NODE] ? holes[DATA] : holes[NODE];
|
||||
if (unusable > ovp_holes)
|
||||
return unusable - ovp_holes;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f2fs_disable_cp_again(struct f2fs_sb_info *sbi, block_t unusable)
|
||||
{
|
||||
int ovp_hole_segs =
|
||||
(overprovision_segments(sbi) - reserved_segments(sbi));
|
||||
if (unusable > F2FS_OPTION(sbi).unusable_cap)
|
||||
return -EAGAIN;
|
||||
if (is_sbi_flag_set(sbi, SBI_CP_DISABLED_QUICK) &&
|
||||
dirty_segments(sbi) > ovp_hole_segs)
|
||||
|
Reference in New Issue
Block a user