From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <chao@kernel.org>
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Chao Yu <yuchao0@huawei.com>
Subject: Re: [PATCH] f2fs: split discard command in prior to block layer
Date: Fri, 6 Jul 2018 15:45:33 -0700 [thread overview]
Message-ID: <20180706224533.GC77984@jaegeuk-macbookpro.roam.corp.google.com> (raw)
In-Reply-To: <20180704153746.2510-1-chao@kernel.org>
On 07/04, Chao Yu wrote:
> From: Chao Yu <yuchao0@huawei.com>
>
> Some devices has small max_{hw,}discard_sectors, so that in
> __blkdev_issue_discard(), one big size discard bio can be split
> into multiple small size discard bios, result in heavy load in IO
> scheduler and device, which can hang other sync IO for long time.
>
> Now, f2fs is trying to control discard commands more elaboratively,
> in order to make less conflict in between discard IO and user IO
> to enhance application's performance, so in this patch, we will
> split discard bio in f2fs in prior to in block layer to reduce
> issuing multiple discard bios in a short time.
Hi Chao,
In terms of # of candidates, can we control this when actually issuing
the discard commands?
Thanks,
>
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
> fs/f2fs/f2fs.h | 13 ++++++-------
> fs/f2fs/segment.c | 25 ++++++++++++++++++++++---
> 2 files changed, 28 insertions(+), 10 deletions(-)
>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index a9da5a089cb4..a09d2b2d9520 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -178,7 +178,6 @@ enum {
>
> #define MAX_DISCARD_BLOCKS(sbi) BLKS_PER_SEC(sbi)
> #define DEF_MAX_DISCARD_REQUEST 8 /* issue 8 discards per round */
> -#define DEF_MAX_DISCARD_LEN 512 /* Max. 2MB per discard */
> #define DEF_MIN_DISCARD_ISSUE_TIME 50 /* 50 ms, if exists */
> #define DEF_MID_DISCARD_ISSUE_TIME 500 /* 500 ms, if device busy */
> #define DEF_MAX_DISCARD_ISSUE_TIME 60000 /* 60 s, if no candidates */
> @@ -701,22 +700,22 @@ static inline void set_extent_info(struct extent_info *ei, unsigned int fofs,
> }
>
> static inline bool __is_discard_mergeable(struct discard_info *back,
> - struct discard_info *front)
> + struct discard_info *front, unsigned int max_len)
> {
> return (back->lstart + back->len == front->lstart) &&
> - (back->len + front->len < DEF_MAX_DISCARD_LEN);
> + (back->len + front->len <= max_len);
> }
>
> static inline bool __is_discard_back_mergeable(struct discard_info *cur,
> - struct discard_info *back)
> + struct discard_info *back, unsigned int max_len)
> {
> - return __is_discard_mergeable(back, cur);
> + return __is_discard_mergeable(back, cur, max_len);
> }
>
> static inline bool __is_discard_front_mergeable(struct discard_info *cur,
> - struct discard_info *front)
> + struct discard_info *front, unsigned int max_len)
> {
> - return __is_discard_mergeable(cur, front);
> + return __is_discard_mergeable(cur, front, max_len);
> }
>
> static inline bool __is_extent_mergeable(struct extent_info *back,
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 4648561e2bfd..8e417a12684d 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1086,6 +1086,9 @@ static void __update_discard_tree_range(struct f2fs_sb_info *sbi,
> struct discard_cmd *dc;
> struct discard_info di = {0};
> struct rb_node **insert_p = NULL, *insert_parent = NULL;
> + struct request_queue *q = bdev_get_queue(bdev);
> + unsigned int max_discard_blocks =
> + SECTOR_TO_BLOCK(q->limits.max_discard_sectors);
> block_t end = lstart + len;
>
> mutex_lock(&dcc->cmd_lock);
> @@ -1129,7 +1132,8 @@ static void __update_discard_tree_range(struct f2fs_sb_info *sbi,
>
> if (prev_dc && prev_dc->state == D_PREP &&
> prev_dc->bdev == bdev &&
> - __is_discard_back_mergeable(&di, &prev_dc->di)) {
> + __is_discard_back_mergeable(&di, &prev_dc->di,
> + max_discard_blocks)) {
> prev_dc->di.len += di.len;
> dcc->undiscard_blks += di.len;
> __relocate_discard_cmd(dcc, prev_dc);
> @@ -1140,7 +1144,8 @@ static void __update_discard_tree_range(struct f2fs_sb_info *sbi,
>
> if (next_dc && next_dc->state == D_PREP &&
> next_dc->bdev == bdev &&
> - __is_discard_front_mergeable(&di, &next_dc->di)) {
> + __is_discard_front_mergeable(&di, &next_dc->di,
> + max_discard_blocks)) {
> next_dc->di.lstart = di.lstart;
> next_dc->di.len += di.len;
> next_dc->di.start = di.start;
> @@ -1170,7 +1175,11 @@ static void __update_discard_tree_range(struct f2fs_sb_info *sbi,
> static int __queue_discard_cmd(struct f2fs_sb_info *sbi,
> struct block_device *bdev, block_t blkstart, block_t blklen)
> {
> + struct request_queue *q = bdev_get_queue(bdev);
> + unsigned int max_discard_blocks =
> + SECTOR_TO_BLOCK(q->limits.max_discard_sectors);
> block_t lblkstart = blkstart;
> + block_t total_len = blklen;
>
> trace_f2fs_queue_discard(bdev, blkstart, blklen);
>
> @@ -1179,7 +1188,17 @@ static int __queue_discard_cmd(struct f2fs_sb_info *sbi,
>
> blkstart -= FDEV(devi).start_blk;
> }
> - __update_discard_tree_range(sbi, bdev, lblkstart, blkstart, blklen);
> +
> + while (total_len) {
> + if (blklen > max_discard_blocks)
> + blklen = max_discard_blocks;
> + __update_discard_tree_range(sbi, bdev, lblkstart,
> + blkstart, blklen);
> + lblkstart += blklen;
> + blkstart += blklen;
> + total_len -= blklen;
> + blklen = total_len;
> + }
> return 0;
> }
>
> --
> 2.16.2.17.g38e79b1fd
next prev parent reply other threads:[~2018-07-06 22:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 15:37 Chao Yu
2018-07-06 22:45 ` Jaegeuk Kim [this message]
2018-07-06 23:35 ` Chao Yu
2018-07-07 1:08 ` Jaegeuk Kim
2018-07-07 1:39 ` Chao Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180706224533.GC77984@jaegeuk-macbookpro.roam.corp.google.com \
--to=jaegeuk@kernel.org \
--cc=chao@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=yuchao0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®