Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1682448rdb; Sat, 3 Feb 2024 18:24:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWsU4ezyh1ymPi2/KkqzHKmDGLwR2B0VzMxlvNs4IfixXdTaghrPqFz2/9tDi0a/Un3bf8 X-Received: by 2002:a05:6808:1a8c:b0:3be:5d77:cfa7 with SMTP id bm12-20020a0568081a8c00b003be5d77cfa7mr12536317oib.1.1707013479831; Sat, 03 Feb 2024 18:24:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707013479; cv=pass; d=google.com; s=arc-20160816; b=juZK5oodt2G5DCKnG0WOTHwtjyHwYcUwfkjL5hr/LQ+Db+1jgVMj5rMml2yPEHq6NQ +qwcxe9wwRZwBlZrzcuuVlOI+zRl6Trk7rOzW0uHqfEncTDvi9tat3BAbfsIqf3ey2D8 NYexqXCpgZFAOZwm3CtbEjvQOUNEq0Fyl4eOODX3gcSR9X3QQee7I5FttBZBZicOwMV/ AOvDYn4bboK4vpollqDvIUa0KUKGhXN+nbvg2aRITNc/tREiMAj3SRn1Ueh1jXJxNTYs eRwNC9z5M2OEgpnFhLLPG6q3q9K5lfrt5GB/C/aFmZjE2dQkIkFkNeAG1dSfF3iqFQqk MqgA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=bYvZm/WpSJnLyEg2CJHkUadLZkjrNIMid0KBa/bNz/s=; fh=7vrhTBlZNr7Mvo498CrP2AL0dXUAQKdqNBdX5w4vvGU=; b=eVhR1bWGyoHnCgwLuWdbrFB0yYFbYPyqzyOLRK1MktZN3wnvez/DJBjKZvopmbZSsg xnDA7jl5L/PhMGK9kF/EK+Vq6WSMT2MDjjEiWB663zQeAy6HoCSNBZO5QPlacvvC38oc hjN4SbxILVW1xRdj1tfHILKMPENFKmKxcGCQxoCEnqiMxcvm3zj/eDKqQ+ejz9AH1bbD JcaoC0IdSYdS50ld9XLIRu+zbdgu7X9qBls3SxtWy8g0/J9mtKQtUOGYxOwd5k25FJHz kQv8G4omtcpyjuqKzqkua9Ll8gQOKtChYknKow7tBTqeOkoucDyWBiJCoF1/EUXqZwz3 vp1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NKPLco9j; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-51380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXXV/JLRHxGz/iKv8bGN4FlbwvJD5+RHyTEs//Ny8l9PtmQpmR+EE7paZ/Fq1N7TqTdNu0HQOOMA1rxYuexcasmUEJxq3YLfGU6DWPeCg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d15-20020a056a00198f00b006ddc6a4a5ddsi3977674pfl.94.2024.02.03.18.24.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 18:24:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NKPLco9j; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-51380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6B50728500D for ; Sun, 4 Feb 2024 02:24:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DD66138E; Sun, 4 Feb 2024 02:24:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NKPLco9j" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66F8810EB for ; Sun, 4 Feb 2024 02:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707013473; cv=none; b=uiUElE/fT0AsWWoT0+1Jz9UF+KWHD605txZx4SAZE/bHlPNzFpgbZmPQwiBD+vNO0XZb9Ji026a0DBhko0+ql/B/YbS/TvLM3dyX4jcl4fxRTb8LTUVLeggIfk0sJpuf7HKVS6jK4l5SHutMPBn3Cn34KjKnqUkGLnLgGw5wTOU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707013473; c=relaxed/simple; bh=w/HWrR+lQGWzJxB85ky3dmWebYzJu5r/BKHq8uRrEXA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VGMzjCtbHXH7VG+X7aw9mntwOva+B4uoqdC2BQbODeN26CIuLbrC6ce4Bwm8ZCIb959nB4ltG5+g/3mkybjoC+DNrTqpWCwVQvdPagq3PWOeG4+wtMPCJRVv1awHU+eSKrxz1RFkbBO2w9RbE8vrgfA+GgSou1QoYp+G9nNlApw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NKPLco9j; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D7C8C433F1; Sun, 4 Feb 2024 02:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707013472; bh=w/HWrR+lQGWzJxB85ky3dmWebYzJu5r/BKHq8uRrEXA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NKPLco9jJb9cP8o5a92KUMkiFYpFazPUfaqQtGVqbgSUT5dpcwoHB9O9A4o8amDD6 8EIGv4wlDzvIGfhZmOKwkugzpabWmi8dM7Fh7YxMgRGGKl15pyosbeGIWnUGI/wfLm 0I6icbSDsIakO/bqVci64zacXyRV1BqKzJk2G4e4zql1H8uX3Ez/0OQZorJL7IDD/F XCtd61ilA29P4RymD8j0fOcK9J3JpAZ3AalFl0IjqXFtFcnPgQHg0PBHC3jTgO/TB4 uuICc1ns/4M7uGEnhpIh4u1LYu42zCu73oyfXjDCs91IOc6HghP07+UQIeoBSNNDtC RRbrrv/V57jng== Message-ID: Date: Sun, 4 Feb 2024 10:24:28 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4] f2fs: fix zoned block device information initialization Content-Language: en-US To: Wenjie Qi Cc: jaegeuk@kernel.org, yangyongpeng1@oppo.com, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, hustqwj@hust.edu.cn References: <20240203152436.1352-1-qwjhust@gmail.com> <8eaf59a4-1aaa-460e-a3cc-b798ed5e0f63@kernel.org> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024/2/4 10:18, Wenjie Qi wrote: > Hi Chao, > > It seems to me that when mounting multiple zoned devices, > if their max_open_zones are all 0, then sbi->max_open_zones is 0. > This suggests that all of the mounted devices can open an unlimited > number of zones, > and that we don't need to compare sbi->max_open_zones with > F2FS_OPTION( sbi).active_logs. Yes, but I'm curious about how this case (sbi->max_open_zones is zero) works w/ following patch, do we need to initialized sbi->max_open_zones w/ UINT_MAX to indicate the unlimited open zone status of device if all zoned devices' max_open_zones is zero? > > Thanks, > > Chao Yu 于2024年2月4日周日 09:47写道: >> >> On 2024/2/3 23:24, Wenjie Qi wrote: >>> If the max open zones of zoned devices are less than >>> the active logs of F2FS, the device may error due to >>> insufficient zone resources when multiple active logs are >>> being written at the same time. If this value is 0, >>> there is no limit. >>> >>> Signed-off-by: Wenjie Qi >>> --- >>> fs/f2fs/f2fs.h | 1 + >>> fs/f2fs/super.c | 21 +++++++++++++++++++++ >>> 2 files changed, 22 insertions(+) >>> >>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h >>> index 543898482f8b..161107f2d3bd 100644 >>> --- a/fs/f2fs/f2fs.h >>> +++ b/fs/f2fs/f2fs.h >>> @@ -1558,6 +1558,7 @@ struct f2fs_sb_info { >>> >>> #ifdef CONFIG_BLK_DEV_ZONED >>> unsigned int blocks_per_blkz; /* F2FS blocks per zone */ >>> + unsigned int max_open_zones; /* max open zone resources of the zoned device */ >>> #endif >>> >>> /* for node-related operations */ >>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c >>> index 1b718bebfaa1..45e82d6016fc 100644 >>> --- a/fs/f2fs/super.c >>> +++ b/fs/f2fs/super.c >>> @@ -2388,6 +2388,16 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) >>> if (err) >>> goto restore_opts; >>> >>> +#ifdef CONFIG_BLK_DEV_ZONED >>> + if (sbi->max_open_zones && sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) { >>> + f2fs_err(sbi, >>> + "zoned: max open zones %u is too small, need at least %u open zones", >>> + sbi->max_open_zones, F2FS_OPTION(sbi).active_logs); >>> + err = -EINVAL; >>> + goto restore_opts; >>> + } >>> +#endif >>> + >>> /* flush outstanding errors before changing fs state */ >>> flush_work(&sbi->s_error_work); >>> >>> @@ -3930,11 +3940,22 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) >>> sector_t nr_sectors = bdev_nr_sectors(bdev); >>> struct f2fs_report_zones_args rep_zone_arg; >>> u64 zone_sectors; >>> + unsigned int max_open_zones; >>> int ret; >>> >>> if (!f2fs_sb_has_blkzoned(sbi)) >>> return 0; >>> >>> + max_open_zones = bdev_max_open_zones(bdev); >> >> Wenjie, >> >> max_open_zones can always be zero? then sbi->max_open_zones will be zero, >> is this a valid case? >> >> Thanks, >> >>> + if (max_open_zones && (max_open_zones < sbi->max_open_zones || !sbi->max_open_zones)) >>> + sbi->max_open_zones = max_open_zones; >>> + if (sbi->max_open_zones && sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) { >>> + f2fs_err(sbi, >>> + "zoned: max open zones %u is too small, need at least %u open zones", >>> + sbi->max_open_zones, F2FS_OPTION(sbi).active_logs); >>> + return -EINVAL; >>> + } >>> + >>> zone_sectors = bdev_zone_sectors(bdev); >>> if (!is_power_of_2(zone_sectors)) { >>> f2fs_err(sbi, "F2FS does not support non power of 2 zone sizes\n");