Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1758452rdb; Sat, 3 Feb 2024 23:29:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEc4MEzvW7LFm9QGEy1Z/hP7zqndOb4D9p1AoUZ2YYd8Q/cM+7CEhKNssPlZ2y9PsjDbc+b X-Received: by 2002:a05:6a20:d80a:b0:19e:5e6c:9d61 with SMTP id iv10-20020a056a20d80a00b0019e5e6c9d61mr2625069pzb.28.1707031776353; Sat, 03 Feb 2024 23:29:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707031776; cv=pass; d=google.com; s=arc-20160816; b=rVwGFf38W+UKMrs1w00Cf7jdq8yu5kySy/S2nLcI9aNCcgXnjXnQbJYHJKkUaIxsRy dW4ZMJU0NmkPFD0JicvOGM9BTRHybblaYU46EVn1KEMW7hqMVnhhb38AWM79mga4fc3X vWM+8o5oIFwIQWeXjGxf82vNYhnLX7elznAFcEXDQ6Dx+6wjfHOoPDAu+2N1AqSUwjkA NFQs2H8sLkAWC9CH6ALOCyEcb9OyTpqiU+BEBN33YwSfHb999LLHKNInDlqM0j4WvJ21 yY2gY2TYJomBC2oAJGvrAQ5sSOlvfmxL7towiPLR0pskgsfjKJ++5GZeY2seVmtNds6N nJ/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=DVYWotuzszhb5Bt71MvuDcibA+w+/C5yZudwo/s/w7o=; fh=mXQds4cxPCS40TI3iRrT2POHqV7FH/xEZvxh5bgpQOc=; b=nek/cuIuh7K43UOeyCq/yu4qvGt6TfnOgsDBQgDfTsI5mSS25N76udCAsUjZnInhcu knmyTqo8rZ8JeakAeWf4RAg6vQkBU3cgwFjqnBh4mC+gGjC+Vwrp8fA0NEWWlgC2j1Gz Oe6iecFvVvD75/m2fuPnR0+xXn6R3Q037j/hu2mxKVFFVFtc44XDImUTtQy0w8s7DuqE VGxmdPSoY3lihlPxOPqJYkRSZBlElVEnCv3Q87fsSZj3j7+4rKnF4331wlnZ9VruLcN+ N9Rfa97PMX0rJw9EzHgFCsrgrWDwiR5SZ18b3nPxd+VwHOrrHBG3u31orNSD6Hc1nL9m 47+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KkQXPp+h; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-51491-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCUXKSXkoM8NHUKrzNBbwcOhAaQYUsfwFeNje9tryWrbGl+fCJTCamk/gBGduLfkit9CjzXNl54VK6L6I/XRFYVzOUPc7XUaMrmRyaXbsA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z1-20020a631901000000b005dbee5249fcsi4326319pgl.688.2024.02.03.23.29.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 23:29:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51491-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KkQXPp+h; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-51491-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 0818B2834DD for ; Sun, 4 Feb 2024 07:29:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D02EB651; Sun, 4 Feb 2024 07:29:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KkQXPp+h" Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09ABC6FC5 for ; Sun, 4 Feb 2024 07:29:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707031769; cv=none; b=U7W9i2W7urk8NmvJlvFpt/DPTLvLcb4fdh18ujdCvfykCrvWTXjEsI1xM8pS1BD1fsK3mrr43kj5Gaa90ZBfEi8oAz645Tig+GwmyZDR0vmXSZPbsQBDAtlCr93FCFiLsmX6is/TB6p55+24VMkzQgRssWihAmMyfGtB/PxyIAE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707031769; c=relaxed/simple; bh=8ob69iEUZbDr69aMdpqXAmN6AEUfbl4I1t5MkI+bc4E=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=PiD1zxlQwO0GiLW45648Xx7W3byMsfK1PMDJGKPXafQPWpLrzuVDZzmC3cPJT8b5EpVs0wYALTdXY7qxA0rGg2eXkAqjjEcWr/vgPMizdS1xAjbNCu+JCr/6Jadu2rqdado7D+iMjoJPUIO9Q1XbmfaQJSjWV9vcZcFgWf1j7E4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KkQXPp+h; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-42a9199cfd2so19859161cf.0 for ; Sat, 03 Feb 2024 23:29:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707031767; x=1707636567; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DVYWotuzszhb5Bt71MvuDcibA+w+/C5yZudwo/s/w7o=; b=KkQXPp+h3kBLOfYQM0Xmtdp2yIszf+UkoHt+L9eBKdflSdcn9y/OzqFtvBgw7Qr3L5 VxUxHnVk0gBt/+oqlmVzq1ePOWF5M1AiuGwJu2fP85pk6M3pOAt0SsuPcr93L5yb6ub/ TmXyrUKl6ZX1LD+6ml0ZXuQl+z6Tp1xopPQISeCxGCgIw37tmFNFJ6aC9i95dAV8fH0h Er+qoIkl18RX3JjKmuLUgevgMmGlNm+FGttgXCs0o3xPCgzh8XWDNDUN/xExCaVMTv01 9Y1LF/7r0At46OHT13LqrdiKK7a71I/R3HcMsT0sec3UfSNXaRtbAkz1nN4TXDKa5vXn 2vjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707031767; x=1707636567; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DVYWotuzszhb5Bt71MvuDcibA+w+/C5yZudwo/s/w7o=; b=KYMyFyCewYjrwXAAZ/Z1wSSXPaYPy7hAhRTiYJE/sqF60DnCobtDmLuYSdqYFkMXJW 5+1AuWdB6iUH+AEVZg7/QEEjo01D9CB63kFXYbsp/1RGhV1BSXKgOeT7Cdxg9ZUpLJ20 JKVrLS80wknE8bL8e7fRhDAOnkDYQC2iT2v5ILTaPVBthQmWnoqUaDfCFh0zTUyTU/lD OWmc6URcOJq6DHqMCsp/NbEUxiQAJ5LkSr936aQNCZLHdvLvbLHLK5i7imHoO+2jois7 bv4yoUrHHuONRII4N+puvUwUtIgcT4/FYoifkVodfhg+QDH5C1mlFivD5z5xYEWEjNru Sd4A== X-Gm-Message-State: AOJu0YyiOUYQLl3HFH0L9gre5typ1eEwp8DydyZigyNfrH9IvDgXdodf tCnoF2THpeq2FJXSx1A5QJ1zz+aYJi5/n/FnGdFvKbtOd3754YeNRWyLodAM7Biz/le5wqpPrao kJeBp5fco9mkVLfq/8M7WpyePXEo= X-Received: by 2002:ac8:46c6:0:b0:42b:eaa1:b28c with SMTP id h6-20020ac846c6000000b0042beaa1b28cmr2776685qto.43.1707031766715; Sat, 03 Feb 2024 23:29:26 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240204031022.1189-1-qwjhust@gmail.com> In-Reply-To: From: Wenjie Qi Date: Sun, 4 Feb 2024 15:29:16 +0800 Message-ID: Subject: Re: [PATCH v5] f2fs: fix zoned block device information initialization To: Yongpeng Yang Cc: jaegeuk@kernel.org, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, hustqwj@hust.edu.cn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Feb 4, 2024 at 12:53=E2=80=AFPM Yongpeng Yang wrote: > > 1. f2fs_scan_devices call init_blkz_info for each zoned device, is it > reasonable that every device need to have 6 open zones at least? Because it is possible for all active logs to write to the same zoned device at the same time, each zoned device must have at least the same number of open zone resources as active logs. > 2. we should add all open_zones of every zoned device to > sbi->max_open_zones, sbi->max_open_zones will be UINT_MAX or accumulated > open_zones. Is it more reasonable? I don't think that's right. sbi->max_open_zone is the number of resources that are the least of all zoned devices. Thanks. > > > On 2/4/2024 11:10 AM, 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. > > > > Signed-off-by: Wenjie Qi > > --- > > fs/f2fs/f2fs.h | 1 + > > fs/f2fs/super.c | 24 ++++++++++++++++++++++++ > > 2 files changed, 25 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 resource= s of the zoned device */ > > #endif > > > > /* for node-related operations */ > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > > index 1b718bebfaa1..c6709efbc294 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 < F2FS_OPTION(sbi).active_logs) { > > + f2fs_err(sbi, > > + "zoned: max open zones %u is too small, need at l= east %u open zones", > > + sbi->max_open_zones, F2FS_OPTION(sbi).ac= tive_logs); > > + err =3D -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 =3D 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 =3D bdev_max_open_zones(bdev); > > + if (max_open_zones && (max_open_zones < sbi->max_open_zones)) > > + sbi->max_open_zones =3D max_open_zones; > > + if (sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) { > > + f2fs_err(sbi, > > + "zoned: max open zones %u is too small, need at l= east %u open zones", > > + sbi->max_open_zones, F2FS_OPTION(sbi).ac= tive_logs); > > + return -EINVAL; > > + } > > + > > zone_sectors =3D 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"); > > @@ -4253,6 +4274,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info = *sbi) > > > > logical_blksize =3D bdev_logical_block_size(sbi->sb->s_