diff options
author | Yuwei Guan <Yuwei.Guan@zeekrlife.com> | 2022-12-13 17:34:19 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2023-01-06 15:13:42 -0800 |
commit | 185a453bf1b5688f8c77f2646b0b6f3b1cbdddca (patch) | |
tree | fc76d80d488d6be34a592a50d243cb3942a4a0e8 /fs/f2fs/segment.c | |
parent | 8358014d6be8f3cb507d247d6a623e5961f848d0 (diff) | |
download | linux-stable-185a453bf1b5688f8c77f2646b0b6f3b1cbdddca.tar.gz linux-stable-185a453bf1b5688f8c77f2646b0b6f3b1cbdddca.tar.bz2 linux-stable-185a453bf1b5688f8c77f2646b0b6f3b1cbdddca.zip |
f2fs: deliver the accumulated 'issued' to __issue_discard_cmd_orderly()
Any of the following scenarios will send more than the number of
max_requests at a time, which will not meet the design of the
max_requests limit.
- Set max_ordered_discard larger than discard_granularity from userspace.
- It is a small size device, discard_granularity can be tuned to 1 in
f2fs_tuning_parameters().
We need to deliver the accumulated @issued to __issue_discard_cmd_orderly()
to meet the max_requests limit.
BTW, convert the parameter type of @issued in __submit_discard_cmd().
Signed-off-by: Yuwei Guan <Yuwei.Guan@zeekrlife.com>
Cc: Bagas Sanjaya <bagasdotme@gmail.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r-- | fs/f2fs/segment.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index a27ffc627264..e2f95f46d298 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1095,9 +1095,8 @@ static void __update_discard_tree_range(struct f2fs_sb_info *sbi, block_t start, block_t len); /* this function is copied from blkdev_issue_discard from block/blk-lib.c */ static int __submit_discard_cmd(struct f2fs_sb_info *sbi, - struct discard_policy *dpolicy, - struct discard_cmd *dc, - unsigned int *issued) + struct discard_policy *dpolicy, + struct discard_cmd *dc, int *issued) { struct block_device *bdev = dc->bdev; unsigned int max_discard_blocks = @@ -1378,8 +1377,8 @@ static void __queue_discard_cmd(struct f2fs_sb_info *sbi, mutex_unlock(&SM_I(sbi)->dcc_info->cmd_lock); } -static unsigned int __issue_discard_cmd_orderly(struct f2fs_sb_info *sbi, - struct discard_policy *dpolicy) +static void __issue_discard_cmd_orderly(struct f2fs_sb_info *sbi, + struct discard_policy *dpolicy, int *issued) { struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; struct discard_cmd *prev_dc = NULL, *next_dc = NULL; @@ -1387,7 +1386,6 @@ static unsigned int __issue_discard_cmd_orderly(struct f2fs_sb_info *sbi, struct discard_cmd *dc; struct blk_plug plug; unsigned int pos = dcc->next_pos; - unsigned int issued = 0; bool io_interrupted = false; mutex_lock(&dcc->cmd_lock); @@ -1414,9 +1412,9 @@ static unsigned int __issue_discard_cmd_orderly(struct f2fs_sb_info *sbi, } dcc->next_pos = dc->lstart + dc->len; - err = __submit_discard_cmd(sbi, dpolicy, dc, &issued); + err = __submit_discard_cmd(sbi, dpolicy, dc, issued); - if (issued >= dpolicy->max_requests) + if (*issued >= dpolicy->max_requests) break; next: node = rb_next(&dc->rb_node); @@ -1432,10 +1430,8 @@ next: mutex_unlock(&dcc->cmd_lock); - if (!issued && io_interrupted) - issued = -1; - - return issued; + if (!(*issued) && io_interrupted) + *issued = -1; } static unsigned int __wait_all_discard_cmd(struct f2fs_sb_info *sbi, struct discard_policy *dpolicy); @@ -1463,8 +1459,10 @@ retry: if (i + 1 < dpolicy->granularity) break; - if (i + 1 < dcc->max_ordered_discard && dpolicy->ordered) - return __issue_discard_cmd_orderly(sbi, dpolicy); + if (i + 1 < dcc->max_ordered_discard && dpolicy->ordered) { + __issue_discard_cmd_orderly(sbi, dpolicy, &issued); + return issued; + } pend_list = &dcc->pend_list[i]; |