+
+ ==================
=============================================
+ value description
+ bggc_block_io = 0 Prioritize background GC
+ bggc_block_io = 1 Stop background GC only when issuing read
I/O
+ bggc_block_io = 2 Stop background GC when issuing I/O
+ ==================
=============================================
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 46be7560548c..fe41b733fbc2 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -155,6 +155,12 @@ enum blkzone_allocation_policy {
BLKZONE_ALLOC_PRIOR_CONV, /* Prioritize writing to conventional
zones */
};
+enum bggc_block_io_policy {
+ BGGC_PRIOR,
+ READ_IO_PRIOR,
+ ALL_IO_PRIOR,
+};
+
/*
* An implementation of an rwsem that is explicitly unfair to readers. This
* prevents priority inversion when a low-priority reader acquires the read
lock
@@ -1804,6 +1810,7 @@ struct f2fs_sb_info {
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 bggc_block_io; /* For adjust the BG_GC
priority when issuing IO */
/* For write statistics */
u64 sectors_written_start;
@@ -2998,13 +3005,10 @@ static inline bool is_idle(struct f2fs_sb_info *sbi,
int type)
if (sbi->gc_mode == GC_URGENT_HIGH)
return true;
- if (zoned_gc) {
- if (is_inflight_read_io(sbi))
- return false;
- } else {
- if (is_inflight_io(sbi, type))
- return false;
- }
+ if (sbi->bggc_block_io == READ_IO_PRIOR && is_inflight_read_io(sbi))
+ return false;
+ if (sbi->bggc_block_io == ALL_IO_PRIOR && is_inflight_io(sbi, type))
+ return false;
if (sbi->gc_mode == GC_URGENT_MID)
return true;
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index e16c4e2830c2..a21cecc5424e 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -4629,9 +4629,11 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
logical_blksize = bdev_logical_block_size(sbi->sb->s_bdev);
sbi->aligned_blksize = true;
+ sbi->bggc_block_io = ALL_IO_PRIOR;
#ifdef CONFIG_BLK_DEV_ZONED
sbi->max_open_zones = UINT_MAX;
sbi->blkzone_alloc_policy = BLKZONE_ALLOC_PRIOR_SEQ;
+ sbi->bggc_block_io = READ_IO_PRIOR;
#endif
for (i = 0; i < max_devices; i++) {
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index f736052dea50..efea15209788 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -674,6 +674,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
sbi->blkzone_alloc_policy = t;
return count;
}
+
+ if (!strcmp(a->attr.name, "bggc_block_io")) {
+ if (t < BGGC_PRIOR || t > ALL_IO_PRIOR)
+ return -EINVAL;
+ sbi->bggc_block_io = t;
+ return count;
+ }
#endif
#ifdef CONFIG_F2FS_FS_COMPRESSION
@@ -1172,6 +1179,7 @@ F2FS_SBI_GENERAL_RW_ATTR(max_read_extent_count);
#ifdef CONFIG_BLK_DEV_ZONED
F2FS_SBI_GENERAL_RO_ATTR(unusable_blocks_per_sec);
F2FS_SBI_GENERAL_RW_ATTR(blkzone_alloc_policy);
+F2FS_SBI_GENERAL_RW_ATTR(bggc_block_io);
#endif
F2FS_SBI_GENERAL_RW_ATTR(carve_out);
F2FS_SBI_GENERAL_RW_ATTR(reserved_pin_section);
@@ -1342,6 +1350,7 @@ static struct attribute *f2fs_attrs[] = {
#ifdef CONFIG_BLK_DEV_ZONED
ATTR_LIST(unusable_blocks_per_sec),
ATTR_LIST(blkzone_alloc_policy),
+ ATTR_LIST(bggc_block_io),
#endif
#ifdef CONFIG_F2FS_FS_COMPRESSION
ATTR_LIST(compr_written_block),