Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1629446rwr; Wed, 3 May 2023 19:14:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7I1ijZPnLx6X5e2i3tNGhg2PoL4LvIjwteMw7SQ1yiFBDc7aAKC6EQZFWEMKRF1+zXqpwR X-Received: by 2002:a05:6a20:a398:b0:f5:b78b:1a0e with SMTP id w24-20020a056a20a39800b000f5b78b1a0emr638905pzk.9.1683166440925; Wed, 03 May 2023 19:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683166440; cv=none; d=google.com; s=arc-20160816; b=BoWDQDYw2IZo0H1Wc7i6iwR/8wpWzKwMCQEGsq22QPWNxmFgbr3UsoEtI2tyyshVKz QUcCpKyeW7D9cI1ok5UckVT7EZ1G0+Hybe7abyaLJnQ6iDV3V0mQulCHXWsNgbBpvQmi Ih03pAByMAke8nqSw0eb/i6szy+FgruV1Vvxl+6fApxUjJyGtvMtzjiwxZ4DWfoxith9 2dKEkVAiZxjE/cZ4fk11XcsoC7ZSrBxMCq9C2hl9Ks2JiRUyacjBzWyfUp+8wD/S6UtV 9K00Runjs29VnmQIr1J0vpWB8XjvQSphhyiUjjfX+yYt0vM+upynMTewyEvyOuRZ/m+2 Soog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=DP/gh+Y3p/bDM5UF6k67cgSCrb9Lweuv/V5vt3XRftE=; b=E3M0zB0R6rvDHAhiYgciCm52nzF9hPuo1Wm/Gihh4ThukwasDfvxk+bZ1dDfnMffB1 3T52E9VnBnqdOxd6tyri9sii/ldSDEXl0nHkFAAZb8+tvSltfMLWvWHWvTQVBUQh8rXc Og+ZXQ/BijBf4lJ/KgnLyiJux7x8qLE+DD7GEolAIjebdlzmljMKxOIJRfMwK0tOYO2w KX17BuIn3TCUm/7VjdQctMU981kWvLdNz6t4mogeQB3fPa1DBbO61bL/sa06SY3MgXTh n+KhOQ/zSsMdUUF1WhYB6wP2s03lnVGixRCthMcyF3OHAFX8m6aloKcNOVfTGwT63s7z o7lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bd3Ks804; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a6566c5000000b0051b4140f6cbsi33945314pgw.149.2023.05.03.19.13.17; Wed, 03 May 2023 19:14:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bd3Ks804; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229642AbjEDBno (ORCPT + 99 others); Wed, 3 May 2023 21:43:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbjEDBnn (ORCPT ); Wed, 3 May 2023 21:43:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DC48C0; Wed, 3 May 2023 18:43:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A09DF61CD2; Thu, 4 May 2023 01:43:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1465DC433D2; Thu, 4 May 2023 01:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683164620; bh=rvpKaggMszfYip+0djm2qEsluKsxOtwAuEPdkTFMsMk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Bd3Ks804e8Dg3xIGkiux87A6xJhhYMXyiFSqE5jdNLdlQa28lotVHijpF+f+FLY90 JrMYvKKkzXjZZu1ijPd8sgcHK1p696lJQZRXJmjs+dW/dkpXMIhyVDT8EhRaTs+zUk lWVIBRF9IxbNkKKxq25oPqs5I3yw+QeY28d20fZsowvzYPAxXt33ZIJuPP7i8L19+H eF71fpWYVN6AM4xeSe9OHxqxpSe54RmVCTHau10eiEXAft5M+tZ4OzTgO2Oam6A4sQ fwCoqBYpmnMFyDGh3NS28M9TNblwalIE3T4iB/aqB0HDouHTr8Z14EAr6lk6Mcmd93 zxTBrpegkw7tA== Message-ID: <6596335b-2448-20f7-30ea-42ba40f1af72@kernel.org> Date: Thu, 4 May 2023 09:43:26 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v4] f2fs: add async reset zone command support Content-Language: en-US To: daejun7.park@samsung.com, "jaegeuk@kernel.org" , "rostedt@goodmis.org" , "mhiramat@kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , "linux-kernel@vger.kernel.org" , "linux-trace-kernel@vger.kernel.org" Cc: Seokhwan Kim , Yonggil Song , beomsu kim References: <20230502041628epcms2p7233a97389cebafb73fc525a47215e707@epcms2p7> From: Chao Yu In-Reply-To: <20230502041628epcms2p7233a97389cebafb73fc525a47215e707@epcms2p7> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/5/2 12:16, Daejun Park wrote: > Changelog: > > v3 -> v4 > Fixed build error caused by unused function. > > v2 -> v3 > Modified arguments to be correct for ftrace parameter. > Changed __submit_zone_reset_cmd to void return. > Refactored the f2fs_wait_discard_bio function. > Fixed code that was previously incorrectly merged. > > v1 -> v2 > Changed to apply the optional async reset write pointer by default. > > This patch enables submit reset zone command asynchornously. It helps > decrease average latency of write IOs in high utilization scenario by > faster checkpointing. > > Signed-off-by: Daejun Park > --- > fs/f2fs/segment.c | 83 +++++++++++++++++++++++++++++++++++-- > include/trace/events/f2fs.h | 18 +++++++- > 2 files changed, 96 insertions(+), 5 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 6db410f1bb8c..ec7a8de71198 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -1196,6 +1196,44 @@ static void __init_discard_policy(struct f2fs_sb_info *sbi, > static void __update_discard_tree_range(struct f2fs_sb_info *sbi, > struct block_device *bdev, block_t lstart, > block_t start, block_t len); > + > +#ifdef CONFIG_BLK_DEV_ZONED > +static void __submit_zone_reset_cmd(struct f2fs_sb_info *sbi, > + struct discard_cmd *dc, blk_opf_t flag, > + struct list_head *wait_list, > + unsigned int *issued) > +{ > + struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info; > + struct block_device *bdev = dc->bdev; > + struct bio *bio = bio_alloc(bdev, 0, REQ_OP_ZONE_RESET | flag, GFP_NOFS); > + unsigned long flags; > + > + trace_f2fs_issue_reset_zone(bdev, dc->di.start); > + > + spin_lock_irqsave(&dc->lock, flags); > + dc->state = D_SUBMIT; > + dc->bio_ref++; > + spin_unlock_irqrestore(&dc->lock, flags); > + > + if (issued) > + (*issued)++; > + > + atomic_inc(&dcc->queued_discard); > + dc->queued++; > + list_move_tail(&dc->list, wait_list); > + > + /* sanity check on discard range */ > + __check_sit_bitmap(sbi, dc->di.lstart, dc->di.lstart + dc->di.len); > + > + bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(dc->di.start); > + bio->bi_private = dc; > + bio->bi_end_io = f2fs_submit_discard_endio; > + submit_bio(bio); How about accounting iostat info for zone reset command? f2fs_update_iostat(sbi, NULL, FS_ZONE_RESET_IO, len * F2FS_BLKSIZE); > + > + atomic_inc(&dcc->issued_discard); > +} > +#endif > + > /* 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, > @@ -1217,6 +1255,13 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi, > if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) > return 0; > > +#ifdef CONFIG_BLK_DEV_ZONED > + if (f2fs_sb_has_blkzoned(sbi) && bdev_is_zoned(bdev)) { > + __submit_zone_reset_cmd(sbi, dc, flag, wait_list, issued); > + return 0; > + } > +#endif > + > trace_f2fs_issue_discard(bdev, dc->di.start, dc->di.len); > > lstart = dc->di.lstart; > @@ -1461,6 +1506,19 @@ static void __update_discard_tree_range(struct f2fs_sb_info *sbi, > } > } > > +#ifdef CONFIG_BLK_DEV_ZONED > +static void __queue_zone_reset_cmd(struct f2fs_sb_info *sbi, > + struct block_device *bdev, block_t blkstart, block_t lblkstart, > + block_t blklen) > +{ > + trace_f2fs_queue_reset_zone(bdev, blkstart); > + > + mutex_lock(&SM_I(sbi)->dcc_info->cmd_lock); > + __insert_discard_cmd(sbi, bdev, lblkstart, blkstart, blklen); > + mutex_unlock(&SM_I(sbi)->dcc_info->cmd_lock); > +} > +#endif > + > static void __queue_discard_cmd(struct f2fs_sb_info *sbi, > struct block_device *bdev, block_t blkstart, block_t blklen) > { > @@ -1724,6 +1782,19 @@ static void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr) > > mutex_lock(&dcc->cmd_lock); > dc = __lookup_discard_cmd(sbi, blkaddr); > +#ifdef CONFIG_BLK_DEV_ZONED > + if (dc && f2fs_sb_has_blkzoned(sbi) && bdev_is_zoned(dc->bdev)) { > + /* force submit zone reset */ > + if (dc->state == D_PREP) > + __submit_zone_reset_cmd(sbi, dc, REQ_SYNC, > + &dcc->wait_list, NULL); > + dc->ref++; IIUC, should be? else dc->ref++; Thanks, > + mutex_unlock(&dcc->cmd_lock); > + /* wait zone reset */ > + __wait_one_discard_bio(sbi, dc); > + return; > + } > +#endif > if (dc) { > if (dc->state == D_PREP) { > __punch_discard_cmd(sbi, dc, blkaddr); > @@ -1876,9 +1947,15 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi, > blkstart, blklen); > return -EIO; > } > - trace_f2fs_issue_reset_zone(bdev, blkstart); > - return blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET, > - sector, nr_sects, GFP_NOFS); > + > + if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING))) { > + trace_f2fs_issue_reset_zone(bdev, blkstart); > + return blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET, > + sector, nr_sects, GFP_NOFS); > + } > + > + __queue_zone_reset_cmd(sbi, bdev, blkstart, lblkstart, blklen); > + return 0; > } > > /* For conventional zones, use regular discard if supported */ > diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h > index 99cbc5949e3c..ee1477de8324 100644 > --- a/include/trace/events/f2fs.h > +++ b/include/trace/events/f2fs.h > @@ -1512,7 +1512,7 @@ DEFINE_EVENT(f2fs_discard, f2fs_remove_discard, > TP_ARGS(dev, blkstart, blklen) > ); > > -TRACE_EVENT(f2fs_issue_reset_zone, > +DECLARE_EVENT_CLASS(f2fs_reset_zone, > > TP_PROTO(struct block_device *dev, block_t blkstart), > > @@ -1528,11 +1528,25 @@ TRACE_EVENT(f2fs_issue_reset_zone, > __entry->blkstart = blkstart; > ), > > - TP_printk("dev = (%d,%d), reset zone at block = 0x%llx", > + TP_printk("dev = (%d,%d), zone at block = 0x%llx", > show_dev(__entry->dev), > (unsigned long long)__entry->blkstart) > ); > > +DEFINE_EVENT(f2fs_reset_zone, f2fs_queue_reset_zone, > + > + TP_PROTO(struct block_device *dev, block_t blkstart), > + > + TP_ARGS(dev, blkstart) > +); > + > +DEFINE_EVENT(f2fs_reset_zone, f2fs_issue_reset_zone, > + > + TP_PROTO(struct block_device *dev, block_t blkstart), > + > + TP_ARGS(dev, blkstart) > +); > + > TRACE_EVENT(f2fs_issue_flush, > > TP_PROTO(struct block_device *dev, unsigned int nobarrier,