Message ID | 20240203152436.1352-1-qwjhust@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-51147-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp1070391dyc; Sat, 3 Feb 2024 07:25:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IELp9yJxK+eyyK+KCFggSXKzN668Omzh/vxRC9JIisinSNpiukHMiCs3Gix9ZRFQyQE7TWH X-Received: by 2002:a05:6512:2209:b0:511:4a1f:ea74 with SMTP id h9-20020a056512220900b005114a1fea74mr132149lfu.0.1706973937581; Sat, 03 Feb 2024 07:25:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706973937; cv=pass; d=google.com; s=arc-20160816; b=qNT7H0FCbXsx/i/tMj0jUyld+xf32mrMeNVwSZLaNQR0ivKXJ0mqI9us0DmnCXvbeq W9ZVj3npSo1P7zMQBJKoEEQUPbJ/DNKeh/zZIAkLH3OR3IWGW/nshs3mHBO9CLRxZJec UqwWl+yla5iPzKyi0FWe2bBmlaTZoX++hp2Mt9GT/3uQB3h7AjN0hqa2uSPKWfYVTzDz y4xtJgvm2+BxUmLY18JkPgaWu52FM2TsEWgfB0AjiOhpwxCgtbPertD75SSjcPCENxOo eLbVXFKDbNnL+5l4pifvpZgVvvcuRaKyFmpwOkRU1B/IJSgixnu7vK4tyedY56WJAFxu wc/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=c88lqSxqRhgcdBuXBMm8xLbio2cc1M+G+N4XYcCvLJA=; fh=cdvuHfQmzw4pTFnI7QTH38AdoHcga+YA+Bqpdgf0rtM=; b=K6FRVLgmRPRIZyqF2ANBIuqyj1/uthcof0GlnHEYCj37N13/ugnsApGFkU9z0btgQY GorjYIsComNHF9I2QSSOhIVP3vmX0Ovft4J+Si2RNQDUkgKMImoszOpXYThU0VHhph0C v8Pu76Hr9n5rh6F/qbWxTvMLI0AutVUPfZbZ1ozml4I3Qvr8UiZa5rtFWQUe1XBl1YG/ 8qzs7TVPgFnUCDoDyiwIL1OsfR8brN1PjDrCiyZfMD61j65GGlb3mlz3UiiCsTXtA6S7 iK16PTZsZ2O+AqGYbpGAWuIsIOJwJEk14njO41O29dI21ur6tkDlBKK8mCWB+fn6Jjj2 1ndg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cTe+wfru; 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-51147-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51147-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCWtlLVF/3GFhpr//vPmqHM6KxaoBNCoWslid02oOOxrvauSyZIkHtDku8atmFZF2XFYyEflACRXET/7Dd1kDGbtscc1wQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id uz17-20020a170907119100b00a371db6ea69si1376001ejb.598.2024.02.03.07.25.37 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 07:25:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51147-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cTe+wfru; 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-51147-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51147-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1DF3C1F228F8 for <ouuuleilei@gmail.com>; Sat, 3 Feb 2024 15:25:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC16D5F569; Sat, 3 Feb 2024 15:25:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cTe+wfru" Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 6A21A5F54A for <linux-kernel@vger.kernel.org>; Sat, 3 Feb 2024 15:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706973917; cv=none; b=occrMhtY1+zuo2GGxTayU7vIo2QKruZSlkmiIY5xU6W2zarmvn5lLQ53uGMoZPU5LqfGjNd4M7xHZZR9umc5z5MgCNO8nT737XHFm2FprKM/syqH0w3Ita6Vioh/8X4iGUn8nQGKwmuqRTCWFqaq4/pbhloEdRZji0N2AZWuYPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706973917; c=relaxed/simple; bh=RtPXT9uJnRvUvzMIpDyqdjM8D8hOXa06jLXqA6g599Q=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kWXkJvik8h4l6KCvDo6AyQ6SiJiuUfrXOWwhWENSmBlGN7EKgDd/epd5gCo6k71cr5uJXe3XSGv1Od7NIYBLGVzemIQ2y0dOJneEpMY4jp8mJZNGM66g/oFSGmQjDPJin0Gl3vC3G9JtTG/26mLC+8APF/Kz50PKj92U4rMx3o4= 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=cTe+wfru; arc=none smtp.client-ip=209.85.214.180 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-pl1-f180.google.com with SMTP id d9443c01a7336-1d731314e67so22269155ad.1 for <linux-kernel@vger.kernel.org>; Sat, 03 Feb 2024 07:25:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706973914; x=1707578714; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=c88lqSxqRhgcdBuXBMm8xLbio2cc1M+G+N4XYcCvLJA=; b=cTe+wfruQLdKJbG6YOQ+7xocjo9XFeQcdGZ7TrMkJHKMevUuJvAMj6lo8jLfzXhX7m rcd1eyLuvgM5c7GZCvbcZlB++TgmvLDu+uZd0mPM79xKG0+3s+Fwij5R38nyY7/nm6kQ 2Cyf2s/YRQjVAdgbkNzeHXQdmxyJMHnYJpu/eBQcJia4U2XebUAHsAyysaVUIfLxOvtI 831tYbz/oNZ0mO5zc6tfzbeXIsizICmYmEOesdcz/dUTen1zNecWzDYQRsKloZwEv6kY 8aoM5uohQA9UdvxS+991A0YozN0moGBgbttna7FOYm9z+sgm2gNsh918gFoIu7WwNvMi 6XNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706973914; x=1707578714; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=c88lqSxqRhgcdBuXBMm8xLbio2cc1M+G+N4XYcCvLJA=; b=n8txYki2oPjYnjhYPIkjSO1GGvpgkNOoDMtGwqlai42ZnsDlsRCfx86SR/2q6+Wib8 Fv61xP9zxoZPWDSNWVIZ9jh1wyy8piP07uIFKoAkI80UwsvDy7/TOZR6IfkuymNXLt4W vUJXQmMNolJJuvnjmsZ4iMP0yxBedrZphfLHlkW6qh9kr4samxC+WRTF99nZ05hzrhJ/ lH/XeOdcgObqiDj/07TB26egqS9s+uXcusesRmTi//LPP2cmmeYto92zbNe68hQG/56H 02vbuVbd2eqXjB5NK8cmVHmcI67RTvmXzTJzeNRIIsvaFrxtCAchP4ciLz27/H8Zw5kc yIxQ== X-Gm-Message-State: AOJu0YyXs4Web3nAEJKW/2X1/AhrnnB+Clz/8xuUMVtUDkmvnR/gLP1s 5yvOpXvhe8qyvPoOY9DtqjJZrqhynRxACvRoeh/2Z/GjXgIYfldb X-Received: by 2002:a17:902:f545:b0:1d9:5d65:c1b with SMTP id h5-20020a170902f54500b001d95d650c1bmr7436906plf.41.1706973914367; Sat, 03 Feb 2024 07:25:14 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUnaJiN3/oUVmOaXrf8A7R+Oc/J9rdZuq2hqa3OkuWuLiIUbcBwBO2NnGovu7VXgDk8iR2QXDi+ypeB0NGiZSA3yIp4tXmywVL5r/ZL7AeQPPOF9AAP5sZ3daQly/5/NcFpotuBCFavYnKgvhVGHiZxt96+cjL75gHi0HVp3fH+jb9RNNEBWut2/bo7ZxjWxr9QW2kqKsCCiiTSEZ8IHtZO9XnAb8VoAa6rZrEMfcF3Qg== Received: from localhost.localdomain ([112.38.163.83]) by smtp.gmail.com with ESMTPSA id ku12-20020a170903288c00b001d7284b9461sm3370081plb.128.2024.02.03.07.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 07:25:14 -0800 (PST) From: Wenjie Qi <qwjhust@gmail.com> To: jaegeuk@kernel.org, chao@kernel.org, yangyongpeng1@oppo.com, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: hustqwj@hust.edu.cn, Wenjie Qi <qwjhust@gmail.com> Subject: [PATCH v4] f2fs: fix zoned block device information initialization Date: Sat, 3 Feb 2024 23:24:36 +0800 Message-ID: <20240203152436.1352-1-qwjhust@gmail.com> X-Mailer: git-send-email 2.43.0.windows.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789891903425943377 X-GMAIL-MSGID: 1789891903425943377 |
Series |
[v4] f2fs: fix zoned block device information initialization
|
|
Commit Message
Wenjie Qi
Feb. 3, 2024, 3:24 p.m. UTC
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 <qwjhust@gmail.com>
---
fs/f2fs/f2fs.h | 1 +
fs/f2fs/super.c | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
Comments
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 <qwjhust@gmail.com> > --- > 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");
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. Thanks, Chao Yu <chao@kernel.org> 于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 <qwjhust@gmail.com> > > --- > > 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");
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 <chao@kernel.org> 于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 <qwjhust@gmail.com> >>> --- >>> 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");
I agree with you, it looks a bit more intuitive that way. I'll submit a new version of the patch as soon as I can. Thanks, On Sun, Feb 4, 2024 at 10:24 AM Chao Yu <chao@kernel.org> wrote: > > 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 <chao@kernel.org> 于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 <qwjhust@gmail.com> > >>> --- > >>> 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");
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); + 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");